Steps for Moving OS from SD Card to eMMC on A311D

Hi everyone,

Could someone guide me through the exact steps required to transfer the operating system from the SD card to the eMMC on the A311D? Additionally, I’d like to know how to configure the device to boot from the eMMC without the need for the SD card.

Thanks in advance for your help!

I think the official position of MNT is still that it is not recommended to flash u-boot to eMMC on A311D because should that u-boot image be faulty or something go wrong during the flashing procedure, your board will be soft-bricked and require some extra hardware to restore again.

That being said, I can certainly tell you how to do it anyways but performing these steps will come with the risk of making your device unbootable. I don’t know whether you feel like you can recover from such a situation by yourself or not.

What do you think?

2 Likes

Thank you for the response.

If u-boot remains on the SD card, would it be sufficient to run only the reform-migrate command to complete the process?

Yes, you’d run something like this:

sudo reform-migrate --emmc /dev/mmcblk2p2

That would put /boot onto the first partition and the rootfs onto the second partition of your eMMC. If you do not have the correct partition setup, here is how to start from scratch:

One thing to consider: At least in my testing, u-boot often (sometimes?) fails to load the kernel from the eMMC on A311D, even if u-boot itself always loads fine from eMMC. The technical reasons are still unknown (I have reported these issues to people working on the drivers). If this should get annoying, to work around this, one can migrate to an SSD NVMe, which is natively supported in u-boot for A311D.

@minute oh? That would be news for me. I have my /boot on eMMC with A311D and cannot remember a single time where u-boot failed to load the kernel from it. What could be the difference between my system and yours? My u-boot is the latest version that reform-flash-uboot knows about.

1 Like

Hmm, interesting. Maybe I just had a bad board on the table then.

I can second whjat josch said. I have both, u-boot and my /boot partition in eMMC, and never had troubles loading the kernel.

1 Like

Hey @josch

I decided to move on with this and:

  • Install SSD and move rootfs to that
  • Move /boot to eMMC
  • Install u-boot on eMMC

I assume this will include the following steps:

  • Prepare SSD (from reform-migrate comment)
    sudo parted /dev/nvme0n1 mklabel msdos
    sudo parted /dev/nvme0n1 mkpart primary ext4 4MiB -1
    sudo mkfs.ext4 /dev/nvme0n1p1

  • Move rootfs to SSD and /boot to eMMC
    sudo reform-migrate --emmc /dev/nvme0n1p1

  • Install u-boot on eMMC
    reform-flash-uboot emmc

Is this the correct approach? Thanks.

1 Like

Since you are on A311D, the most critical step is the one involving flashing u-boot to your eMMC. The existing tools like reform-flash-uboot or reform-boot-config (as it’s called by reform-migrate) will prevent you from writing to your eMMC. You have to either modify these tools ore modify /usr/share/reform-tools/machines/MNT Reform 2 with BPI-CM4 Module.conf and set EMMC_USE=true and EMMC_BOOT=true. The values for UBOOT_OFFSET and FLASHBIN_OFFSET might need to both be set to zero.

I would do do the u-boot flashing step first instead of last because there is no point in going through the whole process that comes before in your list if you happen to mis-flash u-boot.

Other than that, yes, I guess the list is correct.

Okay, how would I know if the u-boot step goes well?

How to know if UBOOT_OFFSET and FLASHBIN_OFFSET needs to be set to zero?

What determines whether u-boot is triggered from the SD card or eMMC?

You have a USB UART adapter connected to see the serial output, correct? If it worked, then you will be able to see the early boot messages without an SD-card inserted. The output you get should look similar to this: u boot · Wiki · Reform / reform-debian-packages · GitLab

I don’t really know. It might work without changing them in the first place because right now both offsets in /usr/share/reform-tools/machines/MNT Reform 2 with BPI-CM4 Module.conf are 512 bytes, so the u-boot binary is shifted by the same amount as is stripped off from its beginning, thus effectively doing the same as havinf both offsets as zero except that in the mmcblk0boot0 special devices there is no MBR to screw up, so the 512 byte “shift” is not really needed.

In contrast to imx8mq there is no DIP switch that lets you decide where to load it from. If the SoM finds a working u-boot on eMMC it will use that one in preference of u-boot on the SD-card. That’s why you can soft-brick the thing if something goes wrong.

To my knowledge, @minute and @soulsource are the only ones who have did all of this and they may need to correct what i’ve said.

1 Like

I did not need to change the offsets to flash uboot to the a311d emmc on Pocket Reform.

2 Likes

Success! I’m now officially running without an SD card. Thanks, everyone!

Notes:

I needed to run reform-flash-rescue first to be able to run reform-boot-config (from the reform-migrate) (to make the needed partitions).
Additionally, I had to remove the section involving bmaptool from the script to get it to run.

3 Likes

Can you show an error message so that i can fix the bug?

Hi – I am booting up my mnt reform a311d after a time and am noticing that (1) I performed these steps successfully, but (2) I must have misconfigured debian because I can only only access the login from the serial console – my display remains off through the boot sequence! This remains true even if I have a rescue image accessible on an SD card. To make matters worse I forgot my login information :sob:.

@josch would you be able to help explain how to change the boot order in this scenario? I saw that there were DIP switches for a different compute module, but the A311D doesn’t seem to have them. Alternatively, it would probably be good to know how to wipe the MMC and revert to an SD-card-style boot.

Thank you so much!

I don’t believe you’ve “soft-bricked” your system in a way that would require the dip switches or the hdmi i2c device. I believe if uboot is working (and especially if you can boot from sd card) you’re fine.

I’m not sure what would cause the error you’re describing. Do you know what kernel version you’re using?

If you can get the login prompt from the recovery image (and log in with root and no password) you should be able to mount the disks (or wipe nvme if you don’t know the disk password), chroot into the mount point, and make any changes you like to the system.

If you can get a login prompt at all, you should be able to get into the system (over serial) if you

  • interrupt uboot when the prompt appears over serial by pressing any key
  • using editenv bootargs to add init=/bin/bash to the end of list of arguments
  • continue booting with run bootcmd

Once you get a root prompt on the system this way you should be able to troubleshoot further or reinstall etc. It may be possible to wipe the first mmc partition if your goal is to get back to booting from sd, but I don’t know that that would solve your problem.

1 Like

I don’t believe you’ve “soft-bricked” your system in a way that would require the dip switches or the hdmi i2c device. I believe if uboot is working (and especially if you can boot from sd card) you’re fine.

ah! root login with no password did the trick! Also yes, it seems like it is booting from the SD card (I guess I got confused). The I guess the problem is that the internal display doesn’t turn on and I only have access to the login via serial console on a second laptop.

I’m not sure what would cause the error you’re describing. Do you know what kernel version you’re using?

I’m using a recent image from Jobs · Reform / reform-system-image · GitLab – I think build #5988, commit 7b322388.

$ uname -a
Linux reform 6.10.9-mnt-reform-arm64 #1 SMP Debian 6.10.9-1+reform20240916T143123Z (2024-09-16) aarch64 GNU/Linux
1 Like

Okay, nevermind all of this – it seems like there is just an issue with the system image. I used the one I found at reform.debian.net which seems to work (which uses the 6.10.6 kernel). Thank you, @deianara !

3 Likes

Neat. I might also try upgrading the system with apt-get and seeing if that solves your problem (or if there are any errors). I’m not sure what else would cause a system to fail to use the display, maybe the initramfs creation process failing somehow?

1 Like