Diff for /wikisrc/ports/evbarm/raspberry_pi.mdwn between versions 1.132 and 1.141

version 1.132, 2020/10/15 19:44:53 version 1.141, 2021/02/24 08:05:57
Line 1 Line 1
 [[!meta title="NetBSD/evbarm on Raspberry Pi"]]  [[!meta title="NetBSD/evbarm on Raspberry Pi"]]
   
 This page describes the NetBSD/evbarm port on [Raspberry Pi](http://www.raspberrypi.org) hardware.  All [board variants](https://en.wikipedia.org/wiki/Raspberry_Pi#Specifications) earlier than the RPI4 are believed supported, and specific boards known to work are listed.  We use e.g. "RPI2" to refer to "Raspberry Pi 2" to save precious bytes on this page.  This web page is still 32-bit (aarch32) centric, even though as of mid-2020 aarch64 is also a normal approach.  This page describes the NetBSD/evbarm port on [Raspberry Pi](http://www.raspberrypi.org) hardware.  All [board variants](https://en.wikipedia.org/wiki/Raspberry_Pi#Specifications) earlier than the RPI4 are believed supported, and specific boards known to work are listed.  We use e.g. "RPI2" to refer to "Raspberry Pi 2" to save precious bytes on this page.
   
 Initial, limited, Raspberry Pi support was introduced in NetBSD 6.0.  NetBSD 7.0 added complete support for the board, along with introducing support for the quad-core Raspberry Pi 2 board.  Raspberry Pi 3 support was added for NetBSD 8.  NetBSD 9 supports aarch64, meaning using the newer processors in 64-bit mode (via -current in mid 2018).  Initial Raspberry Pi support was introduced in NetBSD 6.0.  NetBSD 7.0 added complete support for the board, along with introducing support for the quad-core Raspberry Pi 2 board.  Raspberry Pi 3 support was added for NetBSD 8.  NetBSD 9 supports aarch64, meaning using the newer processors in 64-bit mode.
   
 Overall, this page takes the view that NetBSD 7 and earlier are obsolete; aside from history, it is written as if those versions don't exist.  
   
 The HOWTO is written for what works on formal releases, release branches (e.g. netbsd-9) and NetBSD-current.  It purposefully does not contain instructions about how to get things to work by installing code that is still being tested and not yet in -current.  
   
 [[images/raspberrypi.jpg]]  [[images/raspberrypi.jpg]]
   
Line 44  The HOWTO is written for what works on f Line 40  The HOWTO is written for what works on f
   
 ## NetBSD current  ## NetBSD current
   
    - RPI3/RPI4 audio with aarch64 kernels
           - Previously the driver was only included with 32-bit (ARMv7/ARMv6)
             kernels and images due to the Broadcom code having 64-bit cleanliness
             issues.
  - RPI3 builtin bluetooth   - RPI3 builtin bluetooth
   
 ## (maybe) NetBSD current, with manual steps  
   
    These items do not work in the sense that they simply function after a standard install.  Being listed here implies only that there has been list traffic that implies that after taking a bunch of steps (e.g. new firmware, new dtbs, enabling drivers, applying patches), one can end up with the feature working.  The HOWTO explicitly refrains from describing these steps because they are ephemeral.  However, the fact that list traffic indicates success is possible is a clue that proper support is on the horizon, and that is notable.  
   
  - RPI3 and RPI0W builtin WiFi   - RPI3 and RPI0W builtin WiFi
    - RPI4 (using EDK2 UEFI firmware)
           - RPI4 Ethernet (Broadcom GENETv5, genet(4))
   
 ## What needs documenting if it works  ## What needs documenting if it works
   
    - (Everything listed in the previous section.)
  - CM1   - CM1
  - CM3   - CM3
  - CM3lite   - CM3lite
   
 ## What needs work  ## What needs work
   
  - RPI4 (as of 2020-01, still does not work in current)  
  - USB (host); isochronous transfers.   - USB (host); isochronous transfers.
  - RPI0W Bluetooth Low Energy (probably)   - RPI0W Bluetooth Low Energy (probably)
    - DRM/KMS
   
 # CPU types  # CPU types
   
Line 72  The HOWTO is written for what works on f Line 70  The HOWTO is written for what works on f
  - RPI2 uses "earmv7hf".   - RPI2 uses "earmv7hf".
  - RPI2-1.2 uses "earmv7hf" or "aarch64" (armv8 CPU hardware)   - RPI2-1.2 uses "earmv7hf" or "aarch64" (armv8 CPU hardware)
  - RPI3 uses "earmv7hf" or "aarch64" (armv8 CPU hardware)   - RPI3 uses "earmv7hf" or "aarch64" (armv8 CPU hardware)
  - RPI4 \todo   - RPI4 uses "aarch64" (armv8 CPU hardware)
   
 Note that one can run a build of earmv6hf on the 2 and 3.  There will still be a kernel7, built to use the 2/3 hardware, but with the armv6 instruction set.  Note that one can run a build of earmv6hf on the 2 and 3.  There will still be a kernel7, built to use the 2/3 hardware, but with the armv6 instruction set.
   
 In theory the code compiled for earmv7hf will be faster, but anecdotal experience is that it doesn't matter that much.  \todo Post a link to a quality benchmark.  In theory the code compiled for earmv7hf will be faster, but anecdotal experience is that it doesn't matter that much.
   
 While the evbarm port has "eb" variants (for big-endian mode), the RPI systems do not support eb and these variants will not work.  Systems built for older CPU architectures (earm, earmv4, earmv5) are not expected to work on RPI.  While the evbarm port has "eb" variants (for big-endian mode), the RPI systems do not support eb and these variants will not work.  Systems built for older CPU architectures (earm, earmv4, earmv5) are not expected to work on RPI.
   
 The RPI2-1.2 and RPI3 have an armv8 CPU that supports aarch64 (64-bit  
 mode) in addition to aarch32 (regular 32-bit ARM).  This is supported,  
 from 9 onwards, by the "aarch64" MACHINE_ARCH of evbarm, also  
 available in build.sh via the alias evbarm64.  This is also  
 referred to as [[NetBSD/aarch64|aarch64]].  
   
 # Installation  # Installation
   
 ## SD card structure  The simplest way is to download the appropriate SD card image from the NetBSD mirrors:
   
 The Raspberry Pi looks for firmware and kernel.img on the first FAT32 MBR partition of the uSD card.  A separate kernel (kernel7.img) is used on RPI2 and RPI3.  - The Raspberry Pi 1 requires the ARMv6 [rpi.img.gz](http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-9/latest/evbarm-earmv6hf/binary/gzimg/rpi.img.gz).
 The NetBSD kernel will then find NetBSD MBR partition and within that the root disklabel partition, and use that FFS partition as the root filesystem.  - The Raspberry Pi 2-3 can use the standard ARMv7 [armv7.img.gz](https://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-9/latest/evbarm-earmv7hf/binary/gzimg/armv7.img.gz) image.
   - The Raspberry Pi 3 can also use [https://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-9/latest/evbarm-aarch64/binary/gzimg/arm64.img.gz](arm64.img.gz).
   
 A 2 GB card is the smallest workable size that the installation image will fit on.  After the first boot, the system resizes the NetBSD root partition to fill the card.  Note that swap is after /boot and before /, and not contained in the NetBSD fdisk partition.  However, if you don't try to change the partition structure, this should not cause you any trouble.  Decompress it and write it to the SD card:
   
 Note that SD cards generally have limited write tolerance, so you may wish to disable atime updates via the noatime option, as is done by the default installation.          $ gunzip armv7.img.gz
           $ dd if=armv7.img of=/dev/rld0d conv=sync bs=1m progress=1
   
   If you're not using NetBSD, your operating system's dd command's arguments may vary. On Windows, try [Rawrite32](https://www.netbsd.org/~martin/rawrite32/).
   
   The Raspberry Pi 4 requires the [UEFI firmware](https://github.com/pftf/RPi4/releases). Write the UEFI firmware to the SD card, and then insert an USB drive with the standard NetBSD `arm64.img` written to it. The Pi will then boot from USB.
   
 ## Choosing a version  The Raspberry Pi 3 can also [boot NetBSD from UEFI firmware](https://washbear.neocities.org/rpi3-netbsd-uefi.html), but the installation process is currently more complicated. However, there are some advantages, so you might want to try anyway.
   
 First, decide if you want to install a formal release (8.0 or 9.0), a stable branch build (netbsd-8, netbsd-9), or NetBSD-current.  For people who don't know how to choose among those, a recent build of netbsd-9 is probably best, with 9.0 the choice for those who value being at exactly a formal release.  ## SD card structure
   
 See also "ebijun's image", below, which is NetBSD-current and includes packages.  The Raspberry Pi looks for firmware and kernel.img on the first FAT32 MBR partition of the uSD card.  A separate kernel (kernel7.img) is used on RPI2 and RPI3.
   The NetBSD kernel will then find NetBSD MBR partition and within that the root disklabel partition, and use that FFS partition as the root filesystem.
   
 ## Getting bits to install  A 2 GB card is the smallest workable size that the installation image will fit on.  After the first boot, the system resizes the NetBSD root partition to fill the card.  Note that swap is after /boot and before /, and not contained in the NetBSD fdisk partition.  However, if you don't try to change the partition structure, this should not cause you any trouble.
   
 You can either build a release yourself with build.sh, or get a release from the NetBSD HTTPS/FTP servers.  The bits from both sources should match, except for things like  timestamps, or because the sources are from slightly different points along branches.  Note that SD cards generally have limited write tolerance, so you may wish to disable atime updates via the noatime option, as is done by the default installation.
   
 ### Building yourself  ## Building yourself
   
 Getting sources and building a release with build.sh is not special for evbarm.  However, the evbarm port has a very large number of CPU types, compared to i386 and amd64 which have one each.  The standard approach is to use -m to define MACHINE and -a to define MACHINE_ARCH.  build.sh supports aliases that can be passed as a MACHINE value, but denote both MACHINE and a MACHINE_ARCH.   The third line uses an alias and is equal to the second, for RPI2/3.  Note that the aliases start with "evb" while the MACHINE_ARCH values do not, and that aliases have "-el" or "-eb", while the MACHINE_ARCH values have no suffix or "eb".  Getting sources and building a release with build.sh is not special for evbarm.  However, the evbarm port has a very large number of CPU types, compared to i386 and amd64 which have one each.  The standard approach is to use -m to define MACHINE and -a to define MACHINE_ARCH.  build.sh supports aliases that can be passed as a MACHINE value, but denote both MACHINE and a MACHINE_ARCH.   The third line uses an alias and is equal to the second, for RPI2/3.  Note that the aliases start with "evb" while the MACHINE_ARCH values do not, and that aliases have "-el" or "-eb", while the MACHINE_ARCH values have no suffix or "eb".
   
Line 117  Getting sources and building a release w Line 116  Getting sources and building a release w
   
 Consider setting RELEASEMACHINEDIR if you wish to build multiple MACHINE_ARCH values for a MACHINE; see build.sh.  Use something like "evbarm-earmv7hf", so that 1) earvm6 and earmv7 don't collide and 2) anita will recognize it as a type of evbarm.  Consider setting RELEASEMACHINEDIR if you wish to build multiple MACHINE_ARCH values for a MACHINE; see build.sh.  Use something like "evbarm-earmv7hf", so that 1) earvm6 and earmv7 don't collide and 2) anita will recognize it as a type of evbarm.
   
 ### NetBSD autobuild HTTPS/FTP servers  
   
 NetBSD provides nightly builds on [nycdn.netbsd.org](https://nycdn.netbsd.org/pub/NetBSD-daily/).  The next directory level is the branch being built (netbsd-8, netbsd-9, HEAD, and more), plus optionally things like compiler type.  It is followed by date/time, e.g. "HEAD/201811051650Z"; once a build is complete the symlink "latest" is adjusted to point to it.  The next level is "${MACHINE}-${MACHINE_ARCH}", e.g. "evbarm-earmv7hf", and multiple combinations are provided.  
   
 An example URL, arguably the standard approach for first-time NetBSD/RPI users, is <https://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-8/latest/evbarm-earmv7hf/binary/gzimg/>  
   
 ### release layout  
   
 Once you get to the releasedir, self-built and autobuild releases have the same structure.  
   
  - The 'evbarm-earmv6hf/binary/gzimg/' directory contains an rpi.img file that will run on any of the RPI boards.  
  - The 'evbarm-earmv7hf/binary/gzimg/' directory contains an armv7.img file that uses the armv7 instruction set, and thus can run only on the RPI2 and RPI3 (and perhaps the CM3).  It also supports systems other than the RPI family.  
   
 \todo Explain why there is no armv7_inst.gz.  
   
 ## Preparing a uSD card  
   
 Once you have rpi.img.gz (or rpi_inst for earmv6 boards), put it on a uSD card using gunzip and dd, for example:  
   
  - gunzip rpi.img.gz  
  - dd if=rpi.img of=/dev/disk1  
   
 ## Console approaches  ## Console approaches
   
 The standard approach is to use a USB keyboard and an HDMI monitor for installation.  The standard approach is to use a USB keyboard and an HDMI monitor for installation.
Line 177  every few weeks. Line 154  every few weeks.
   
  - <https://github.com/ebijun/NetBSD/blob/master/RPI/RPIimage/Image/README>   - <https://github.com/ebijun/NetBSD/blob/master/RPI/RPIimage/Image/README>
   
   ## Boot Process
   
   https://www.raspberrypi.org/documentation/configuration/config-txt/boot.md
   
   ### DTBs
   
   Note that generally, a single dtb is loaded.  On NetBSD 9, the dtb
   file for the system is loaded by the bootloader (in flash).
   
   The RPI bootloader looks for a magic string in a trailer after the kernel to determine if it should use DTB support (the new normal) or something called ATAG (apparently the old way).  See [upstream commit introducing DTB trailer](https://github.com/raspberrypi/linux/commit/2367d8a42e2717d8d15a39a9085cc2909fae033a#diff-8f088aca645d10d79b594d58db4136f3e09caee077fe373bb08f02f2040900a9) for more information.
   
   ### Kernel format variants
   
   In netbsd-8, only the ELF and bin variants of RPI2 are built.  The bin version is used.
   
   In netbsd-9 releasedir/binary/kernels, the following 4 versions of GENERIC are produced.  (This might be the same in current.)
   
   #### netbsd-GENERIC.gz
   
   This is regular ELF and not used on RPI.
   
   #### netbsd-GENERIC.bin.gz
   
   It is unclear why this file exists on 9.  It seems to be like img, but without the trailer for DTB; this makes sense for 8.
   
   #### netbsd-GENERIC.img.gz
   
   On NetBSD >=9, the kernel with the .img suffix has the trailer to cause the bootloader to load DTB files.
   
   #### netbsd-GENERIC.ub.gz
   
   This is for u-boot and not used on RPI.
   
 ## Configuring 802.11  ## Configuring 802.11
   
 After installation, the Ethernet will function as on any other NetBSD system; simply enable dhcpcd or configure a static address.  USB WiFi devices will also function as on any other NetBSD system; in addition to dhcpcd or static, configure and enable wpa_supplicant.  After installation, the Ethernet will function as on any other NetBSD system; simply enable dhcpcd or configure a static address.  USB WiFi devices will also function as on any other NetBSD system; in addition to dhcpcd or static, configure and enable wpa_supplicant.
Line 221  The program vcgencmd, referenced in the  Line 231  The program vcgencmd, referenced in the 
   
 ## Updating dtb files  ## Updating dtb files
   
 (This is harder than it should be.)  ### NetBSD 8
 Build a release.  gunzip the armv7.img, vnconfig it, and mount the MSDOS partition (e) e.g. on /mnt.  Copy the dtb files from /mnt/*.dtb to /boot, and from /mnt/dtb/*.dtb to /mnt/dtb.  
   On NetBSD 8, dtb files are not used.
   
 It seems that some systems, including RPI, require dtb files in /boot, and some expect  them in /boot/dtb.  ### NetBSD 9
   
 \todo Explain how one is supposed to be able to update these from the dtb files in releasedir/binary/kernel, or fix it to have the same structure.  Build a release.  gunzip the armv7.img, vnconfig it, and mount the MSDOS partition (e) e.g. on /mnt.  Copy the dtb files from /mnt/foo.dtb to /boot, and from /mnt/dtb/foo.dtb to /boot/dtb.
   
   It seems that some systems, including RPI, require dtb files in /boot, and some expect them in /boot/dtb.
   
   ### NetBSD current
   
   When updating, ensure that /boot is mounted and that you unpack the dtb set.
   
 ## Updating the firmware  ## Updating the firmware
   
 It is highly likely that running NetBSD from a given branch X with firmware from a branch Y < X will not go well.  It is unclear if firmware from a branch Y > X will work.   It is standard practice to use firmware from the right branch.  It is highly likely that running NetBSD from a given branch X with firmware from a branch Y < X will not go well.  It is unclear if firmware from a branch Y > X will work.  It is standard practice to use firmware from the right branch.
   
 A section below describes the process of updating NetBSD's copy of the firmware from upstream, with testing, by NetBSD developers.  This section is about updating a system's firmware from the firmware in a version of NetBSD.  A section below describes the process of updating NetBSD's copy of the firmware from upstream, with testing, by NetBSD developers.  This section is about updating a system's firmware from the firmware in a version of NetBSD.
   
Line 268  The aarch64 kernel can run aarch32 binar Line 285  The aarch64 kernel can run aarch32 binar
   
 # X11 and GPU  # X11 and GPU
   
   Video acceleration currently only works with 32-bit (ARMv7 and ARMv6) kernels due to the Broadcom code not being 64-bit clean.
   
   Since applications require specialized support for the GPU, only a few applications are normally accelerated.  NetBSD/aarch64 normally uses `llvmpipe` to provide fast parallel CPU-driven support for OpenGL, so should be faster when running normal applications.
   
   The situation should be improved, ideally by writing a DRM/KMS driver.
   
 ## Video playback  ## Video playback
   
 Accelerated video playback is supported with the [OMXPlayer](http://pkgsrc.se/multimedia/omxplayer) application and through GStreamer with the [omx](http://pkgsrc.se/multimedia/gst-plugins1-omx) plugin.  Accelerated video playback is supported with the [OMXPlayer](http://pkgsrc.se/multimedia/omxplayer) application and through GStreamer with the [omx](http://pkgsrc.se/multimedia/gst-plugins1-omx) plugin.

Removed from v.1.132  
changed lines
  Added in v.1.141


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb