Re: Unable to boot Pi 3b+ [crashes during bcm_sdhci_attach for Broadcom 2708 SDHCI controller for modern RPi* firmware]

From: Mark Millard <marklmi_at_yahoo.com>
Date: Sun, 20 Aug 2023 02:05:05 UTC
[The issue is https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268835
which is already fixed in stable/13 and main but no release has the
fix yet.]

On Aug 19, 2023, at 12:41, Mark Millard <marklmi@yahoo.com> wrote:

> On Aug 19, 2023, at 12:12, Mark Millard <marklmi@yahoo.com> wrote:
> 
>> On Aug 19, 2023, at 11:59, Peter G <list-freebsd-arm@box559.com> wrote:
>> 
>>> Mark Millard wrote on 2023-08-19 02:14:
>>> [...]
>>>> The thing to log would probably be a boot attempt of a fresh
>>>> 13.2-RELEASE that has had the RPi* firmware ( including
>>>> bcm271*.dtb files and overlays/ ) from 14.0-ALPHA2 (or ALPHA1)
>>>> substituted, probably also having had u-boot.bin substituted.
>>>> In other words, avoiding having any old vintages of those
>>>> materials. I'd suggest leaving EFI/ and dtb/ alone. Those have
>>>> files built as part of FreeBSD.
>>>> If nothing else, this could help with identifying analogous
>>>> contexts in the future if others have problems.
>>>> ===
>>>> Mark Millard
>>>> marklmi at yahoo.com
>>> 
>>> I copied these files
>>> start*.elf
>>> fixup*.dat
>>> bcm*
>>> overlays/*
>>> u-boot.bin
>>> from
>>> FreeBSD-14.0-ALPHA2-arm64-aarch64-RPI-20230818-77013f29d048-264841.img
>>> to
>>> FreeBSD-13.2-RELEASE-arm64-aarch64-RPI.img
>>> and booted the modified image.
>>> 
>>> The crash is back. The console log is at:
>>> https://box559.com/console-13.2-RELEASE-mod4.txt
>>> 
>> 
>> Thanks.
>> 
>> To publicly/broadly publish the crash material part of that log file:
>> 
>> . . .
>> sdhci_bcm0: <Broadcom 2708 SDHCI controller> mem 0x7e300000-0x7e3000ff irq 17 on simplebus0
>> Fatal data abort:
>> x0:         ffffffff
>> x1:                0
>> x2: ffff0000008d6ebe
>> x3:               6e
>> x4: ffff000000f4060c
>> x5:               6e
>> x6: ffff0000001927a8
>> x7: 6d63625f69636864
>> x8: ffff000000e34700
>> x9:               20
>> x10:                0
>> x11:                1
>> x12:  300000000006e65
>> x13:   fefefefeff0100
>> x14:              69b
>> x15:               1a
>> x16:                0
>> x17:                0
>> x18: ffff000000f407e0
>> x19:         ffffffff
>> x20:                0
>> x21: ffff000000be6000
>> x22: ffff000000be6000
>> x23: ffffa00000ddec38
>> x24: ffff000000938016
>> x25: ffff000000961e00
>> x26: ffff0000008f9bfb
>> x27: ffffa00000dced60
>> x28:         31e00000
>> x29: ffff000000f407e0
>> sp: ffff000000f407e0
>> lr: ffff000000880e04
>> elr: ffff00000087aefc
>> spsr:         a00000c5
>> far:               20
>> esr:         96000004
>> panic: vm_fault failed: ffff00000087aefc
>> cpuid = 0
>> time = 1
>> KDB: stack backtrace:
>> #0 0xffff0000004fd02c at kdb_backtrace+0x60
>> #1 0xffff0000004a8328 at vpanic+0x13c
>> #2 0xffff0000004a81e8 at panic+0x44
>> #3 0xffff0000007f42e0 at data_abort+0x200
>> #4 0xffff0000007d3010 at handle_el1h_sync+0x10
>> #5 0xffff000000880e00 at bcm_sdhci_attach+0x318
>> #6 0xffff000000880e00 at bcm_sdhci_attach+0x318
>> #7 0xffff0000004e8f94 at device_attach+0x3fc
>> #8 0xffff0000004eb134 at bus_generic_new_pass+0x120
>> #9 0xffff0000004eb0c4 at bus_generic_new_pass+0xb0
>> #10 0xffff0000004eb0c4 at bus_generic_new_pass+0xb0
>> #11 0xffff0000004eb0c4 at bus_generic_new_pass+0xb0
>> #12 0xffff0000004ed200 at root_bus_configure+0x40
>> #13 0xffff00000041e5e8 at mi_startup+0x11c
>> #14 0xffff0000000008b4 at virtdone+0x78
>> Uptime: 1s
> 
> Adding some obviously sdhci related *.dtb file differences
> (leading whitespace need not have been preserved here):
> 
> # diff -u999999 ~/RPi3B+-dtb-file-olderFBSD.dts ~/RPi3B+-dtb-file.dts | less
> . . .
>                mmc@7e300000 {
> 
>                        brcm,overclock-50 = <0x0>;
>                        bus-width = <0x4>;
> -                       clocks = <0x7 0x1c>;
> +                       clocks = <0x8 0x1c>;
>                        compatible = "brcm,bcm2835-mmc", "brcm,bcm2835-sdhci";
>                        dma-names = "rx-tx";
> -                       dmas = <0xb 0xb>;
> +                       dmas = <0xc 0xb>;
>                        interrupts = <0x2 0x1e>;
>                        phandle = <0x2f>;
> -                       pinctrl-0 = <0x1c>;
> +                       pinctrl-0 = <0x14>;
>                        pinctrl-names = "default";
>                        reg = <0x7e300000 0x100>;
>                        status = "disabled";
>                };
>                mmcnr@7e300000 {
> 
> +                       #address-cells = <0x1>;
> +                       #size-cells = <0x0>;
>                        brcm,overclock-50 = <0x0>;
>                        bus-width = <0x4>;
> -                       clocks = <0x7 0x1c>;
> +                       clocks = <0x8 0x1c>;
>                        compatible = "brcm,bcm2835-mmc", "brcm,bcm2835-sdhci";
>                        dma-names = "rx-tx";
> -                       dmas = <0xb 0xb>;
> +                       dmas = <0xc 0xb>;
>                        interrupts = <0x2 0x1e>;
>                        non-removable;
>                        phandle = <0x30>;
> -                       pinctrl-0 = <0x1d>;
> +                       pinctrl-0 = <0x1b>;
>                        pinctrl-names = "default";
>                        reg = <0x7e300000 0x100>;
>                        status = "okay";
> +                       wifi@1 {
> +
> +                               compatible = "brcm,bcm4329-fmac";
> +                               phandle = <0x82>;
> +                               reg = <0x1>;
> +                       };
>                };
> 
> where, for reference:
> 
>                dma@7e007000 {
> 
>                        #dma-cells = <0x1>;
>                        brcm,dma-channel-mask = <0x7f35>;
>                        compatible = "brcm,bcm2835-dma";
>                        interrupt-names = "dma0", "dma1", "dma2", "dma3", "dma4", "dma5", "dma6", "dma7", "dma8", "dma9", "dma10", "dma11", "dma12", "dma13", "dma14", "dma-shared-all";
>                        interrupts = <0x1 0x10 0x1 0x11 0x1 0x12 0x1 0x13 0x1 0x14 0x1 0x15 0x1 0x16 0x1 0x17 0x1 0x18 0x1 0x19 0x1 0x1a 0x1 0x1b 0x1 0x1b 0x1 0x1b 0x1 0x1b 0x1 0x1c>;
> -                       phandle = <0xb>;
> +                       phandle = <0xc>;
>                        reg = <0x7e007000 0xf00>;
>                };
> 
> 
> The ordering in the .dts comparisons is sorted to allow the
> differences to be seen. I've not looked at the overall
> original-ordering differences related to sdhci (yet?).
> 

Turns out this is a known kernel-error fixed in main and
stable/13 already. See:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268835

There is no release yet which can use the modern RPi*
*.dtb files (at least some of them) .firmware.

I'll note the modern RPi* *.dtb files are not wrong. It is
the kernel that does not handle all the conditions it is
supposed to.

For the modern RPi3+ both of the following apply

A) The modern RPi3+ can not use the older RPi*
    firmware ( start*.elf and fixup*.dat files ).

B) The FreeBSD kernel in 12.* and 13.2-RELEASE and
    before can not use the newer RPi* *.dtb's but
    can use the modern RPi* start*.elf/fixup*.dat
    files.

C) You have shown that, for at least the modern
    RPi3B+ , the newer start*.elf and fixup*.dat
    files are useful with the older *.dtb files.

Those wishing to use releng/* at or before 13.2
are stuck with adjusting the msdosfs file system
content based on the above. releng/13.3 and
releng/14.0 should not end up with this problem.

===
Mark Millard
marklmi at yahoo.com