U-boot can't boot from eMMC when SD card is inserted

Started by filo, January 16, 2023, 09:00:07 PM

Previous topic - Next topic

filo

I have an A20 LIME2 with eMMC. I ran olinuxino-sd-to-emmc. Everything went fine. I formated the SD card with an empty filesystem. Now the Olinuxino boots fine from eMMC only when SD card is absent. With the SD card present U-Boot get into some strange loop trying to boot from Ethernet.

I would like to keep the SD card in for data logging and storage but the device must obviously boot reliably with the card present.

I used A20-OLinuXino-bullseye-minimal-20220928-143706 image.

Good boot from eMMC (SD card absent):
U-Boot SPL 2021.04+olimex-1-20220927.105322 (Sep 27 2022 - 10:54:20 +0000)
DRAM: 1024 MiB
CPU: 912000000Hz, AXI/AHB/APB: 3/2/2
Loading configuration from EEPROM: OK
Verifying data: OK
Trying to boot from MMC2


U-Boot 2021.04+olimex-1-20220927.105322 (Sep 27 2022 - 10:54:20 +0000) Allwinner Technology

CPU:   Allwinner A20 (SUN7I)
ID:    A20-OLinuXino-LIME2-e16Gs16M Rev.L1
SN:    000279A9
MAC:   30:1F:9A:D1:46:24
I2C:   ready
DRAM:  1 GiB
SF: Detected w25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC:   mmc@1c0f000: 0, mmc@1c11000: 1
Loading Environment from EXT4... *** Warning - bad CRC, using default environment

Loading Environment from FAT... ** No device specified **
In:    serial
Out:   serial
Err:   serial
Allwinner mUSB OTG (Peripheral)
Net:   eth0: ethernet@1c50000, eth1: usb_ether
starting USB...
Bus usb@1c14000: USB EHCI 1.00
Bus usb@1c14400: USB OHCI 1.0
Bus usb@1c1c000: USB EHCI 1.00
Bus usb@1c1c400: USB OHCI 1.0
scanning bus usb@1c14000 for devices... 2 USB Device(s) found
scanning bus usb@1c14400 for devices... 1 USB Device(s) found
scanning bus usb@1c1c000 for devices... 1 USB Device(s) found
scanning bus usb@1c1c400 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc1(part 0) is current device
Scanning mmc 1:1...
Found U-Boot script /boot/boot.scr
2274 bytes read in 1 ms (2.2 MiB/s)
## Executing script at 43100000
Boot script loaded from mmc
Checking for /uEnv.txt...
Checking for /boot/uEnv.txt...
1156 bytes read in 1 ms (1.1 MiB/s)
Loaded environment from /boot/uEnv.txt
Loading FIT image...
16195639 bytes read in 885 ms (17.5 MiB/s)
## Loading kernel from FIT Image at 58000000 ...
   Using 'config-9604' configuration
   Trying 'kernel-1' kernel subimage
     Description:  Linux kernel 5.10.105-olimex
     Type:         Kernel Image
     Compression:  uncompressed
     Data Start:   0x580000d4
     Data Size:    6533568 Bytes = 6.2 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x40080000
     Entry Point:  0x40080000
     Hash algo:    crc32
     Hash value:   07bbff0b
     Hash algo:    sha1
     Hash value:   61e0951c1f96b692559776eea6464ee2d09fb02c
   Verifying Hash Integrity ... crc32+ sha1+ OK
## Loading ramdisk from FIT Image at 58000000 ...
   Using 'config-9604' configuration
   Trying 'ramdisk-1' ramdisk subimage
     Description:  Ramdisk for kernel 5.10.105-olimex
     Type:         RAMDisk Image
     Compression:  Unknown Compression
     Data Start:   0x5863b3c8
     Data Size:    9207270 Bytes = 8.8 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x4fe00000
     Entry Point:  0x4fe00000
     Hash algo:    crc32
     Hash value:   8f40935d
     Hash algo:    sha1
     Hash value:   0b60449019557afb130dcef5be3444d9acd1d98d
   Verifying Hash Integrity ... crc32+ sha1+ OK
   Loading ramdisk from 0x5863b3c8 to 0x4fe00000
WARNING: 'compression' nodes for ramdisks are deprecated, please fix your .its file!
## Loading fdt from FIT Image at 58000000 ...
   Using 'config-9604' configuration
   Trying 'fdt-4' fdt subimage
     Description:  unavailable
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x58f22f68
     Data Size:    43643 Bytes = 42.6 KiB
     Architecture: ARM
     Load Address: 0x4fa00000
     Hash algo:    crc32
     Hash value:   36a64574
     Hash algo:    sha1
     Hash value:   16c904b58520be6ecf47b5482c59376f4aba068f
   Verifying Hash Integrity ... crc32+ sha1+ OK
   Loading fdt from 0x58f22f68 to 0x4fa00000
## Loading fdt from FIT Image at 58000000 ...
   Trying 'overlay-1' fdt subimage
     Description:  unavailable
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x58f6e9b4
     Data Size:    1001 Bytes = 1001 Bytes
     Architecture: ARM
     Load Address: 0x4fa10000
     Hash algo:    crc32
     Hash value:   d1d51f29
     Hash algo:    sha1
     Hash value:   fa0c14efb55dbe4bdf8aa7241a3e600b486e3ef6
   Verifying Hash Integrity ... crc32+ sha1+ OK
   Loading fdt from 0x58f6e9b4 to 0x4fa10000
## Loading fdt from FIT Image at 58000000 ...
   Trying 'overlay-2' fdt subimage
     Description:  unavailable
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x58f6ee80
     Data Size:    436 Bytes = 436 Bytes
     Architecture: ARM
     Load Address: 0x4fa20000
     Hash algo:    crc32
     Hash value:   00f3a93c
     Hash algo:    sha1
     Hash value:   efa518e1ffcc7c09a7d8010de6a7b363f1345b30
   Verifying Hash Integrity ... crc32+ sha1+ OK
   Loading fdt from 0x58f6ee80 to 0x4fa20000
   Booting using the fdt blob at 0x4fa00000
EHCI failed to shut down host controller.
   Loading Kernel Image
   Loading Ramdisk to 49738000, end 49fffde6 ... OK
   Loading Device Tree to 4972a000, end 49737c59 ... OK
Applying overlay: '/usr/lib/olinuxino-overlays/sun7i-a20/spi1-spidev.dtbo'...
408 bytes read in 3 ms (132.8 KiB/s)
Applying overlay: '/usr/lib/olinuxino-overlays/sun7i-a20/spi2-spidev.dtbo'...
408 bytes read in 4 ms (99.6 KiB/s)
Applying overlay: '/usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-i2c2.dtbo'...
726 bytes read in 4 ms (176.8 KiB/s)
Applying overlay: '/usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-spi1.dtbo'...
1005 bytes read in 3 ms (327.1 KiB/s)
Applying overlay: '/usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-spi2.dtbo'...
1005 bytes read in 4 ms (245.1 KiB/s)
Applying overlay: '/usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-uart3.dtbo'...
863 bytes read in 4 ms (210 KiB/s)
Applying overlay: '/usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-uart4.dtbo'...
867 bytes read in 4 ms (210.9 KiB/s)
Applying overlay: '/usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-uart5.dtbo'...
867 bytes read in 3 ms (282.2 KiB/s)
Applying overlay: '/usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-uart6.dtbo'...
867 bytes read in 4 ms (210.9 KiB/s)
Applying overlay: '/usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-uart7.dtbo'...
867 bytes read in 4 ms (210.9 KiB/s)
Applying overlay: '/usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-spi0.dtbo'...
1001 bytes read in 3 ms (325.2 KiB/s)
Applying overlay: '/usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-can.dtbo'...
732 bytes read in 4 ms (178.7 KiB/s)
Applying overlay: '/usr/lib/olinuxino-overlays/sun7i-a20/lime2-lcd-olinuxino.dtbo'...
2225 bytes read in 3 ms (723.6 KiB/s)

Starting kernel ...

[    0.004196] /cpus/cpu@0 missing clock-frequency property
[    0.004244] /cpus/cpu@1 missing clock-frequency property
[    0.991211] sun4i-usb-phy 1c13400.phy: Couldn't request ID GPIO
Loading, please wait...
Starting version 247.3-7+deb11u1
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
Begin: Will now check root file system ... fsck from util-linux 2.36.1
[/sbin/fsck.ext4 (1) -- /dev/mmcblk1p1] fsck.ext4 -a -C0 /dev/mmcblk1p1
/dev/mmcblk1p1: clean, 28420/954720 files, 253726/3814400 blocks
done.
done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... done.

Welcome to Debian GNU/Linux 11 (bullseye)!

Bad boot (SD card inserted):
U-Boot SPL 2021.04+olimex-1-20220927.105322 (Sep 27 2022 - 10:54:20 +0000)
DRAM: 1024 MiB
CPU: 912000000Hz, AXI/AHB/APB: 3/2/2
Loading configuration from EEPROM: OK
Verifying data: OK
Trying to boot from MMC1


U-Boot 2021.04+olimex-1-20220927.105322 (Sep 27 2022 - 10:54:20 +0000) Allwinner Technology

CPU:   Allwinner A20 (SUN7I)
ID:    A20-OLinuXino-LIME2-e16Gs16M Rev.L1
SN:    000279A9
MAC:   30:1F:9A:D1:46:24
I2C:   ready
DRAM:  1 GiB
SF: Detected w25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
MMC:   mmc@1c0f000: 0, mmc@1c11000: 1
Loading Environment from EXT4...
** Unable to use mmc 0:auto for loading the env **
Loading Environment from FAT... ** No device specified **
In:    serial
Out:   serial
Err:   serial
Allwinner mUSB OTG (Peripheral)
Net:   eth0: ethernet@1c50000, eth1: usb_ether
starting USB...
Bus usb@1c14000: USB EHCI 1.00
Bus usb@1c14400: USB OHCI 1.0
Bus usb@1c1c000: USB EHCI 1.00
Bus usb@1c1c400: USB OHCI 1.0
scanning bus usb@1c14000 for devices... 2 USB Device(s) found
scanning bus usb@1c14400 for devices... 1 USB Device(s) found
scanning bus usb@1c1c000 for devices... 1 USB Device(s) found
scanning bus usb@1c1c400 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
** Unrecognized filesystem type **
switch to partitions #0, OK
mmc1(part 0) is current device
Scanning mmc 1:1...
Found U-Boot script /boot/boot.scr
2274 bytes read in 1 ms (2.2 MiB/s)
## Executing script at 43100000
Boot script loaded from mmc
Checking for /uEnv.txt...
** Unrecognized filesystem type **
Checking for /boot/uEnv.txt...
** Unrecognized filesystem type **
Loading FIT image...
** Unrecognized filesystem type **
** Unrecognized filesystem type **
SCRIPT FAILED: continuing...
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
Scanning disk [email protected]...
** Unrecognized filesystem type **
Scanning disk [email protected]...
Found 4 disks
No EFI system partition
BootOrder not defined
EFI boot manager: Cannot load any image
scanning bus for devices...
SATA link 0 timeout.
AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
flags: ncq stag pm led clo only pmp pio slum part ccc apst

Device 0: unknown device

Device 0: unknown device
ethernet@1c50000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Could not initialize PHY ethernet@1c50000
using musb-hdrc, OUT ep1out IN ep1in STATUS ep2in
MAC de:ad:be:ef:00:01
HOST MAC de:ad:be:ef:00:00
RNDIS ready
The remote end did not respond in time.missing environment variable: pxeuuid
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/01-30-1f-9a-d1-46-24
ethernet@1c50000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Could not initialize PHY ethernet@1c50000
using musb-hdrc, OUT ep1out IN ep1in STATUS ep2in
MAC de:ad:be:ef:00:01
HOST MAC de:ad:be:ef:00:00
RNDIS ready
The remote end did not respond in time.missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000000
ethernet@1c50000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Could not initialize PHY ethernet@1c50000
using musb-hdrc, OUT ep1out IN ep1in STATUS ep2in
MAC de:ad:be:ef:00:01
HOST MAC de:ad:be:ef:00:00
RNDIS ready
The remote end did not respond in time.missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000000
ethernet@1c50000 Waiting for PHY auto negotiation to complete......... TIMEOUT !
Could not initialize PHY ethernet@1c50000
using musb-hdrc, OUT ep1out IN ep1in STATUS ep2in
MAC de:ad:be:ef:00:01
HOST MAC de:ad:be:ef:00:00
RNDIS ready
The remote end did not respond in time.missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000000
ethernet@1c50000 Waiting for PHY auto negotiation to complete....

LubOlimex

Make sure to wipe the card good before attempting to boot with it inserted. The reason is that there is strict boot priority and SD card has higher priority than SPI/eMMC memory.

This means that it is ok to have SD card inserted but only if it is not bootable (aka only used as storage).

Alternatively, it might be possible to insert the SD card after the boot process from the eMMC had already started. However, this is improper practice that might damage the SD card's contents.

You can find about the boot priority ranking here in the "eGON Boot" section:

https://linux-sunxi.org/BROM

Technical support and documentation manager at Olimex

filo

Yes, this was it. :) I wiped the first 16 MB of the SD card with dd and now the boot proceeds correctly. Some leftovers must have been there even after repartitioninig at the beginning of the SD card that made the SPL pick MMC1 over MMC2.

LubOlimex

Nice! Yes, it is usually at the start and it is possible to have leftovers.
Technical support and documentation manager at Olimex