How to armv7 boot both RPi2B v1.1 (bcm2709 --real armv7) and RPi3B (bcm2710 aarch64), but not RPI4B (bcm2711 aarch64)

From: Mark Millard <marklmi_at_yahoo.com>
Date: Wed, 12 Oct 2022 23:15:01 UTC
On 2022-Oct-11, at 16:33, bob prohaska <fbsd@www.zefox.net> wrote:

> On Tue, Oct 11, 2022 at 11:37:25AM -0700, Mark Millard wrote:
> [snip] 
>> Actually the below is confusing. /boot/msdos
>> is supposed to be a mount point (empty directory)
>> at which the msdosfs can be mounted to make those
>> files show up there, despite being from a different
>> file system. 
> 
> Apologies for the ambiguity!
> 
> /dev/da0s1 on /boot/msdos (msdosfs, local, noatime)
> is the normal dos filesystem on the root USB device.
> Normally it is mounted, IME.
> 
> /dev/mmcsd0s1 on /mnt (msdosfs, local)
> was where I mounted the microSD DOS partition
> so the contents could be listed. This is a Pi2 
> so a DOS microSD card is required to boot from USB.
> Normally /dev/mmcsd0s1 is not mounted when root
> is booted from USB.
> 
> Mostly I wondered if files placed in an "unused" DOS
> subdirectory could be hidden from the boot software.
> It was a poor way to pose the question.
> 
> At the moment the armv7 PATA disk is updating. If it boots
> the Pi2 successfully I'll try it on Pi3 and Pi4. If
> that works I'll set up a SATA armv7 disk and test the
> troublesome disk enclosures. 
> 

Here is how I got armv7 going for booting both a
RPi2B v1.1 (so: Cortex-A7) and a RPi3B (so:
Cortex-A53). This will not get a RPi4B going.
Because of the EFI/BOOT/bootarm.efi issues with
main [so: 14], I used a 13.1-STABLE snapshot as
the basis for this.

FYI: the msdosfs snapshot content in:

FreeBSD-13.1-STABLE-arm-armv7-GENERICSD-20221007-d497b97e902-252653.img

looks like:

# mount -onoatime -tmsdosfs /dev/da0s1 /mnt
# ls -Tld /mnt/*
drwxr-xr-x  1 root  wheel     4096 Oct  7 05:22:48 2022 /mnt/EFI
-rwxr-xr-x  1 root  wheel   103876 Oct  7 03:29:26 2022 /mnt/MLO
-rwxr-xr-x  1 root  wheel    26745 Mar  3 13:29:56 2021 /mnt/bcm2709-rpi-2-b.dtb
-rwxr-xr-x  1 root  wheel    52456 Mar  3 13:29:56 2021 /mnt/bootcode.bin
-rwxr-xr-x  1 root  wheel       89 Oct  7 03:37:56 2022 /mnt/config.txt
drwxr-xr-x  1 root  wheel     8192 Oct  7 05:22:48 2022 /mnt/dtb
-rwxr-xr-x  1 root  wheel     7314 Mar  3 13:29:56 2021 /mnt/fixup.dat
-rwxr-xr-x  1 root  wheel     3187 Mar  3 13:29:56 2021 /mnt/fixup_cd.dat
-rwxr-xr-x  1 root  wheel    10298 Mar  3 13:29:56 2021 /mnt/fixup_db.dat
-rwxr-xr-x  1 root  wheel    10298 Mar  3 13:29:56 2021 /mnt/fixup_x.dat
drwxr-xr-x  1 root  wheel     4096 Oct  7 05:22:54 2022 /mnt/overlays
-rwxr-xr-x  1 root  wheel  2952960 Mar  3 13:29:56 2021 /mnt/start.elf
-rwxr-xr-x  1 root  wheel   793116 Mar  3 13:29:56 2021 /mnt/start_cd.elf
-rwxr-xr-x  1 root  wheel  4794472 Mar  3 13:29:56 2021 /mnt/start_db.elf
-rwxr-xr-x  1 root  wheel  3704808 Mar  3 13:29:56 2021 /mnt/start_x.elf
-rwxr-xr-x  1 root  wheel   504892 Oct  7 03:37:20 2022 /mnt/u-boot.bin
-rwxr-xr-x  1 root  wheel  1163404 Oct  7 03:29:26 2022 /mnt/u-boot.img
-r-xr-xr-x  1 root  wheel   462032 Oct  7 05:20:00 2022 /mnt/ubldr.bin

It does not have the timeout file that allows more time
for USB devices in particular contexts. But timeout
is only directly useful on microsd cards, in order to
allow binding to a wider range of USB boot devices.

It also does not have any of:

bcm2710-rpi-2-b.dtb
bcm2710-rpi-3-b-plus.dtb
bcm2710-rpi-3-b.dtb
bcm2710-rpi-cm3.dtb

Such would be needed for armv7 style booting of any of:

RPi2 v1.2
RPi3B+
RPi3B
Compute Module 3

(Again, the armv7 u-boot.bin does not handle the bcm2711*.dtb
related USB hardware, last I checked a RPi4B example anyway.
So I ignore that context here.)

It also has only:

# ls -Tld /mnt/overlays/*
-rwxr-xr-x  1 root  wheel  1221 Mar  3 13:29:56 2021 /mnt/overlays/mmc.dtbo

so it does not have:

disable-bt.dtbo
miniuart-bt.dtbo

for controlling which UART handles the serial console
on the likes of a RPi3B.

The u-boot.bin does not have an adjusted usb_pgood_delay .
(For some of the USB media that I have access to the
adjustment is important to booting. So my adjsutment will
be involved here.)

The following is being shown after booting an RPi2 v1.1
(so: a cortex-A7 form of armv7) based on what I adjusted
and used:

. . .
FreeBSD 13.1-STABLE #0 stable/13-n252653-d497b97e902: Fri Oct  7 05:01:41 UTC 2022
    root@releng3.nyi.freebsd.org:/usr/obj/usr/src/arm.armv7/sys/GENERIC arm
FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)
VT: init without driver.
No PSCI/SMCCC call function found
CPU: ARM Cortex-A7 r0p5 (ECO: 0x00000000)
. . .
# uname -apKU
FreeBSD generic 13.1-STABLE FreeBSD 13.1-STABLE #0 stable/13-n252653-d497b97e902: Fri Oct  7 05:01:41 UTC 2022     root@releng3.nyi.freebsd.org:/usr/obj/usr/src/arm.armv7/sys/GENERIC arm armv7 1301507 1301507

# gpart show -p
=>      63  62333889    mmcsd0  MBR  (30G)
        63      2016            - free -  (1.0M)
      2079    102312  mmcsd0s1  fat32lba  [active]  (50M)
    104391  62229561            - free -  (30G)

=>       63  468862065    da0  MBR  (224G)
         63       1985         - free -  (993K)
       2048     102400  da0s1  fat32lba  [active]  (50M)
     104448  468757680  da0s2  freebsd  (224G)

=>        0  468757680   da0s2  BSD  (224G)
          0        128          - free -  (64K)
        128  468757552  da0s2a  freebsd-ufs  (224G)

# more /etc/fstab
# Custom /etc/fstab for FreeBSD embedded images
/dev/ufs/rootfs         /               ufs     rw              1       1
/dev/msdosfs/MSDOSBOOT  /boot/msdos     msdosfs rw,noatime      0       0
tmpfs                   /tmp            tmpfs   rw,mode=1777    0       0

NOTE: /dev/msdosfs/MSDOSBOOT is in mmcsd0s1 in my context.
(So the USB msdosfs does not have the MSDOSBOOT label. Avoid
duplicate labels. Which you want mounts as /boot/msdos or
/boot/efi is up to you. Do not take the choices from this
example as important for such.)

# find /boot/msdos/ -print
/boot/msdos/
/boot/msdos/bootcode.bin
/boot/msdos/timeout

Note that I do include timeout in the microsd card's
msdosfs. I've USB media that will not boot otherwise
(necessary, but not sufficient by itself overall).

As for the USB media . . .

# mount -onoatime -tmsdosfs /dev/da0s1 /mnt
# ls -Tld /mnt/*
drwxr-xr-x  1 root  wheel     4096 Oct  7 05:22:48 2022 /mnt/EFI
-rwxr-xr-x  1 root  wheel   103876 Oct  7 03:29:26 2022 /mnt/MLO
-rwxr-xr-x  1 root  wheel    26745 Mar  3 13:29:56 2021 /mnt/bcm2709-rpi-2-b.dtb
-rwxr-xr-x  1 root  wheel    26894 Mar  3 13:29:56 2021 /mnt/bcm2710-rpi-2-b.dtb
-rwxr-xr-x  1 root  wheel    29011 Mar  3 13:29:56 2021 /mnt/bcm2710-rpi-3-b-plus.dtb
-rwxr-xr-x  1 root  wheel    28392 Mar  3 13:29:56 2021 /mnt/bcm2710-rpi-3-b.dtb
-rwxr-xr-x  1 root  wheel    26890 Mar  3 13:29:56 2021 /mnt/bcm2710-rpi-cm3.dtb
-rwxr-xr-x  1 root  wheel    52456 Mar  3 13:29:56 2021 /mnt/bootcode.bin
-rwxr-xr-x  1 root  wheel      207 Oct 10 06:05:20 2022 /mnt/config.txt
-rwxr-xr-x  1 root  wheel       89 Oct  7 03:37:56 2022 /mnt/config.txt.orig
drwxr-xr-x  1 root  wheel     8192 Oct  7 05:22:48 2022 /mnt/dtb
-rwxr-xr-x  1 root  wheel     7314 Mar  3 13:29:56 2021 /mnt/fixup.dat
-rwxr-xr-x  1 root  wheel     3187 Mar  3 13:29:56 2021 /mnt/fixup_cd.dat
-rwxr-xr-x  1 root  wheel    10298 Mar  3 13:29:56 2021 /mnt/fixup_db.dat
-rwxr-xr-x  1 root  wheel    10298 Mar  3 13:29:56 2021 /mnt/fixup_x.dat
drwxr-xr-x  1 root  wheel     4096 Oct  7 05:22:54 2022 /mnt/overlays
-rwxr-xr-x  1 root  wheel  2952960 Mar  3 13:29:56 2021 /mnt/start.elf
-rwxr-xr-x  1 root  wheel   793116 Mar  3 13:29:56 2021 /mnt/start_cd.elf
-rwxr-xr-x  1 root  wheel  4794472 Mar  3 13:29:56 2021 /mnt/start_db.elf
-rwxr-xr-x  1 root  wheel  3704808 Mar  3 13:29:56 2021 /mnt/start_x.elf
-rwxr-xr-x  1 root  wheel        0 Apr 24 10:58:58 2022 /mnt/timeout
-rwxr-xr-x  1 root  wheel   504932 Oct 10 05:17:40 2022 /mnt/u-boot.bin
-rwxr-xr-x  1 root  wheel   504892 Oct  7 03:37:20 2022 /mnt/u-boot.bin.orig
-rwxr-xr-x  1 root  wheel  1163404 Oct  7 03:29:26 2022 /mnt/u-boot.img
-r-xr-xr-x  1 root  wheel   462032 Oct  7 05:20:00 2022 /mnt/ubldr.bin

So I had added:

bcm2710-rpi-2-b.dtb
bcm2710-rpi-3-b-plus.dtb
bcm2710-rpi-3-b.dtb
bcm2710-rpi-cm3.dtb

and (not important on USB media but added anyway):

timeout

I used an updated config.txt:

# diff -u /mnt/config.txt.orig /mnt/config.txt
--- /mnt/config.txt.orig        2022-10-07 03:37:56.000000000 +0000
+++ /mnt/config.txt     2022-10-10 06:05:20.000000000 +0000
@@ -1,5 +1,13 @@
-init_uart_clock=3000000
+#init_uart_clock=3000000
 enable_uart=1
 kernel=u-boot.bin
 kernel7=u-boot.bin
 dtoverlay=mmc
+#
+# Local additions:
+dtoverlay=disable-bt
+initial_turbo=60
+#uart_2ndstage=1
+#dtdebug=1
+gpu_mem_1024=32
+force_turbo=1

(Having config.txt on the microsd card's msdosfs will prevent
booting from USB media.)

I used a u-boot.bin that has my patch, including the
usb_pgood_delay adjustment.

I also added the 2 *-bt.dtbo files:

# ls -Tld /mnt/overlays/*
-rwxr-xr-x  1 root  wheel  1073 Mar  3 13:29:56 2021 /mnt/overlays/disable-bt.dtbo
-rwxr-xr-x  1 root  wheel  1819 Mar  3 13:29:56 2021 /mnt/overlays/miniuart-bt.dtbo
-rwxr-xr-x  1 root  wheel  1221 Mar  3 13:29:56 2021 /mnt/overlays/mmc.dtbo

I will note that, in this configuration, u-boot.bin
output is the first output to show up on the serial
console. This can take a bit to get that far so it
looks initially like nothing is happening but it is.
Be willing to wait a bit.

Moving the microsd card and USB media to the RPi3B and
attempting to boot worked just fine (but required
some of my changes reported above).

. . .
FreeBSD 13.1-STABLE #0 stable/13-n252653-d497b97e902: Fri Oct  7 05:01:41 UTC 2022
    root@releng3.nyi.freebsd.org:/usr/obj/usr/src/arm.armv7/sys/GENERIC arm
FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)
VT: init without driver.
No PSCI/SMCCC call function found
CPU: ARM Cortex-A53 r0p4 (ECO: 0x00000080)
. . .
# uname -apKU
FreeBSD generic 13.1-STABLE FreeBSD 13.1-STABLE #0 stable/13-n252653-d497b97e902: Fri Oct  7 05:01:41 UTC 2022     root@releng3.nyi.freebsd.org:/usr/obj/usr/src/arm.armv7/sys/GENERIC arm armv7 1301507 1301507

===
Mark Millard
marklmi at yahoo.com