A20 Lime2 eMMC - booting from eMMC with inserted SD card

Started by miiihi, October 16, 2017, 11:45:37 AM

Previous topic - Next topic

miiihi

Hi,

I've installed the official Debian Jessie image to the eMMC, using emmc.sh script. System works fine and boots from eMMC as it should, but only if there is no SD card inserted. If there is a SD card inserted during boot, it becomes /dev/mmcblk0 and the boot fails, because it wants to mount root device from /dev/mmcblk0p2, where it doesn't exist.

I think, that the correct solution would be, to switch the order of mmc devices. The eMMC should be first and the SD should be second. I tried to achieve this with switching the parameters for [card0_boot_para]/[card2_boot_para] and [mmc0_para]/[mmc2_para]. After compiling script.bin, boot fails to initialize emmc/sd devices, failing with '[mmc-err] update clock timeout, fatal error'.

So the question is, what am I doing wrong with switching the emmc/sd devices (I'm quite a newbie here...) or is there another option to achieve the same - to boot from eMMC with SD card inserted?

Thanks

SR-Digitronic

I use the MICRO, but they should be the same in this regard.

eMMC is always /dev/mmcblk0

Are you sure that you boot from eMMC?
Since SD card has higher priority than eMMC, therefore you boot from SD card when it's inserted.
If /dev/mmcblk0 were the SD card, then /dev/mmcblk0p2 should exist. The second partition is the root partition of the SD card.

You can always change U-Boot's boot behavior and linux parameters with /boot/boot.scr:

https://github.com/OLIMEX/OLINUXINO/blob/master/SOFTWARE/A20/A20-build-3.4.103-release-2/boot.cmd

mkimage -C none -A arm -T script -d /mnt/sdboot/boot.cmd /mnt/sdboot/boot.scr

What you asked for, would be root=/dev/mmcblk1p2

miiihi

To answer my own question...

The current Olimex image can't handle booting from eMMC if there is a SD card inserted, because when the SD card is present, it becomes mmcblk0 and eMMC is mmcblk1. If there is no SD card, eMMC is mmcblk0.
See https://github.com/linux-sunxi/linux-sunxi/issues/242

The solution is to boot from root by PARTUUID, but I couldn get that working...

In the end I used Armbian distro, which can handle this flawlessy

LubOlimex

Hey,

Did you try editing the fex file and more specifically changing the card detect mode, sdc_detmode to sdc_detmode = 1 ? When you boot from the eMMC do the following:

cd /boot/
bin2fex script.bin script.fex
nano script.fex

press CTRL+W to search and search for "mmc0", under [mmc0_para] edit sdc_detmode and make it sdc_detmode = 1

press CTRL+X to exit and press Enter to apply the changes.

Convert the edited script.fex to bin again with the opposite tool

fex2bin script.fex script.bin

reboot

Let me know how it goes.

Best regards,
Lub/OLIMEX
Technical support and documentation manager at Olimex

miiihi

Hi Lub, thanks for the anwser...

However, I've already moved on from your image to the Armbian image, so I can't test your suggestion.

But the issue is really simple to reproduce:
- boot from SD with the image https://www.olimex.com/wiki/images/2/21/A20-lime2_mainline_uboot_sunxi_kernel_3.4.103_jessie_eMMC_rel_15.torrent
- run ./emmc.sh script to install to eMMC
- shutdown and replace the SD card with any nonbootable SD card
- boot fails....

best m

JohnS

That's because the BROM (boot rom) inside the CPU does that isn't it?  Would need AW to change their chips.  Not looking likely without a huge payment - if then.

Easily worked around.

John

LubOlimex

@miiihi Yes, I reproduced it. And changing the card detect mode as I suggested fixes it.
Technical support and documentation manager at Olimex