I need my board to only try and boot from emmc, fails if SD card is in the slot

My Rock Pi4 boots just fine from eMMC, but I want to use my SD cards for storage.
However if a newly formatted SD card is in the SD card slot, the board will no longer boot (I dont have any output at that stage though.) But remove the SD card and it boots from the emmc just fine again.

I I am making a small cluster project, and have 6 of these Rock Pi 4A Ver 1.4 boards to boot from eMMC Plan is to use the SD cards in the SD slots for storage using GlusterFS)
(I am using the latest dietpi image)

Does anyone know how I can change the sbc to only try to boot from eMMC?

Hi @LucidScrubJay,

From what I have been able to find, the boot order is present in the boot loader (u-boot). So to change boot order from SD to eMMC, one will need to update u-boot.

A workaround (not tested yet) is to partition the SD card in such a way that there is empty space in the beginning, and then the storage partition starts. The empty space in the beginning can be upto 16Mb (as found on Slarm64), and can be zeroed out as suggested here:

Will test and confirm.

Thanks aaditya :slight_smile:

In the meantime I have just tested that the SD was not set as bootable, or something like that.
The eMMc shows up as mmcblk2 and the SD card as mmcblk1 (so it stands to reason that it tries the SD card first).

I tried deleting all partitions in fdisk and create a new, confirm that boot flag was not set but no luck so far.

Same. The workaround did not work here. What I did:

  1. Partitioned SD card leaving 4Mb at the beginning (used gparted).

  2. Zeroed out 1Mb near the beginning (adapted from setup.sh from Slarm64):

    dd if=/dev/zero of=/dev/mmcblk0 seek=64 bs=1k count=1024

/dev/mmcblk0 is my sd card device (device, not partition).

When SD card was inserted, it tried to boot from it and failed.

oh bummer :frowning:
well thank you for trying anyway, I appreciate it.

Happy holidays aaditya

Happy to help @LucidScrubJay :slightly_smiling_face:

I have one more workaround to try, will test and report.

1 Like

Hey @LucidScrubJay which OS image you are using?

A clumsy workaround I found for Armbian:

  • write same OS image to eMMC and SD card.
  • Before booting, partition SD card such that around 1Gb unformatted space is left for it to expand, and create data partition in the rest.
  • System boots from SD card. After boot and setting up username etc, edit /boot/armbianEnv.txt and set rootdevice=UUID={uuid-of-your-emmc}.

Hopefully someone can provide a better solution which does not involve booting from SD card at all.

A question: If all else fails, would it be possible to use USB device for storage? Something like an external hardisk. Those would provide faster storage besides getting rid of this issue.

hi, well I bought about 8 x 64GB Pro extreme A2 mSD storage cards, so I will stick with that if I can. I want to fast IO more than the throughput for when I add GlusterFS on top of it all.
Think that until a u-boot solution is available I will stick with just booting without SD cards in.
Using Python fabric I should be able to mount and init stuff once all is booted in one go. (just a little bothersome but hopefully I will not be booting too often.)

adding OS to both emmc and SD seems prone to issue, so will avoid that option for now, but thank you for helping out on a solution and the feedback, really great of you to help.

Thank you

1 Like


Found a way to make it work. Need to modify u-boot bootloader to boot from eMMC.

For Armbian, it means rebuilding the image with this patch removed:

After rebuilding whole image or only bootloader can be flashed. :slightly_smiling_face:

Found here: https://forum.armbian.com/topic/12992-armbian-images-do-not-boot-on-rockpi4a-with-workaround/?do=findComment&comment=95454

It’s wrong. Head of idbloader isn’t erased. Idbloader begining at 64 sectors (=512), not 1k bs. Uboot and trust modules was don’t erased all.
I have no problem with SDcard. If I remove boot flag from all partition on SD, then boot first parttition with boot flag from emmc.

boot libreelec from emmc now
LibreELEC:~ # parted /dev/mmcblk1 p
Model: SD SL16G (sd/mmc)
Disk /dev/mmcblk1: 15.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name          Flags
 1      32.8kB  4129kB  4096kB
 2      8389kB  12.6MB  4194kB
 3      12.6MB  16.8MB  4194kB
 4      16.8MB  134MB   117MB   fat16        none          msftdata
 5      134MB   252MB   117MB   fat16        xubuntu       msftdata
 6      252MB   789MB   537MB   fat16        libre         msftdata
 7      789MB   1325MB  537MB   fat16        slax          msftdata
 8      1325MB  1862MB  537MB   fat16        ARMB54        msftdata
 9      1862MB  2399MB  537MB   fat16        nne           msftdata
10      2399MB  13.1GB  10.7GB  ext4         ubuntu
11      13.1GB  13.4GB  268MB   fat16        bootmint      msftdata
12      13.4GB  13.5GB  117MB   fat16        BootMain      msftdata
13      13.5GB  15.9GB  2409MB  ext4         librestorage  msftdata

LibreELEC:~ # parted /dev/mmcblk2 p
Model: MMC SOD16G (sd/mmc)
Disk /dev/mmcblk2: 15.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name         Flags
 1      32.8kB  8389kB  8356kB               idbloader
 2      8389kB  12.6MB  4194kB               uboot
 3      12.6MB  16.8MB  4194kB               trust
 4      16.8MB  21.0MB  4194kB               misc
 5      21.0MB  25.2MB  4194kB               dtb
 6      25.2MB  29.4MB  4194kB               dtbo
 7      29.4MB  30.4MB  1049kB               vbmeta
 8      30.4MB  64.0MB  33.6MB               boot
 9      64.0MB  131MB   67.1MB               recovery
10      131MB   249MB   117MB                backup
11      249MB   253MB   4194kB               security
12      253MB   790MB   537MB   ext4         cache
13      790MB   2937MB  2147MB  ext2         system
14      2937MB  2954MB  16.8MB  ext4         metadata
15      2954MB  3491MB  537MB   ext2         vendor
16      3491MB  4028MB  537MB   ext2         oem
17      4028MB  4028MB  524kB                frp
18      4028MB  4030MB  2098kB               userdata
20      14.6GB  15.1GB  537MB   fat16        libre2       boot, esp
19      15.1GB  15.7GB  536MB   ext4         storageEMMC

LibreELEC:~ # 
1 Like

Kindly let us know the correct command too. :slightly_smiling_face:

if SDcard was formated as boot image and first boot partition locate at 32768 sector then
dd if=/dev/zero of=/dev/mmcblk0 seek=64 count=$((32768-64))

p.s. with 5.x kernels SD - /dev/mmcblk1 EMMC - /dev/mmcblk2

1 Like

It worked.

Thanks! :pray: