MMC_BOOT in `reform-flash-uboot`

I was looking into reform-flash-uboot and I don’t believe it currently works as written:

$ sudo reform-flash-uboot
Usage: 
  reform-flash-uboot [--offline] [device...]

/usr/sbin/reform-flash-uboot: 59: MMC_BOOT: parameter not set

I believe the intent is that this parameter be set by sourcing from /usr/share/reform-tools/machines/, but none of the definitions there define MMC_BOOT. I’d make a pull request but I’m not sure what the intent of this parameter is.

Additionally, it’s easy to make parted hang indefinitely in this script by providing an argument that doesn’t exist in /dev, since in that case it prompts for instruction:

$ sudo parted --machine asdf unit B print
Error: Could not stat device asdf - No such file or directory.
Retry/Cancel? 

I’d suggest a change like:

diff --git a/sbin/reform-flash-uboot b/sbin/reform-flash-uboot
index bab7019..5ccb662 100755
--- a/sbin/reform-flash-uboot
+++ b/sbin/reform-flash-uboot
@@ -134,7 +134,7 @@ for dev in "$@"; do
        fi
 
        # no further tests for disks without a partition table
-       if [ "$(parted --machine "$dev" unit B print 2>/dev/null | grep "^$dev:" | cut -d: -f 6)" = unknown ]; then
+       if [ "$(parted --script --machine "$dev" unit B print 2>/dev/null | grep "^$dev:" | cut -d: -f 6)" = unknown ]; then
                continue
        fi

Thank you! Fixed here: reform-tools 1.50 (!81) · Merge requests · Reform / MNT Reform Tools · GitLab

Thank you! Fixed here: reform-tools 1.50 (!81) · Merge requests · Reform / MNT Reform Tools · GitLab

2 Likes

thank you for the quick fixes!

This raises a question for me, though: is reform-flash-uboot (either with no arguments or with emmc) supposed to do anything on Pocket Reform? Since EMMC_BOOT and SD_BOOT are both false:

~/source/reform-tools$ sudo ./sbin/reform-flash-uboot 
Usage: 
  reform-flash-uboot [--offline] [device...]

Download and write recent uboot to chosen device.
Without arguments only /boot/flash.bin will be updated unless --offline is given.
Otherwise, the arguments are the devices onto which to install uboot.
~/source/reform-tools$ sudo ./sbin/reform-flash-uboot emmc
E: writing uboot to eMMC not supported on MNT Pocket Reform with i.MX8MP Module

The behaviour is correct. On the pocket, reform-flash-uboot is supposed to do nothing because

  • flashing to sd-card would be pointless as imx8mplus will load u-boot from emmc
  • flashing to emmc has not yet been performed successfully other than by Lukas themselves

According to @minute:

josch: yeah, maybe for imx8mplus it should be done only by people who really want to do that and know what they’re doing

source: 2024-08-04.log

Unfortunately, the factory u-boot on the pocket reform does not set the ${fdtfile} variable which prevents booting generic system images or Debian installer images. I was working on fixing that here: pocket reform u-boot fixes for `$fdtfile` (!1) · Merge requests · Reform / MNT Reform i.MX8MPlus U-Boot Build · GitLab

@andypiper already tried out my patched u-boot on their pocket reform (thank you!) but without success, sadly. :frowning:

So maybe in the future we want to allow flashing a newer u-boot version onto emmc on the imx8mplus but right now, this would likely soft-brick your device. If you want to help, there is definitely enough stuff to do to make this all work better. :slightly_smiling_face:

3 Likes

Thanks for explaining! I didn’t realize there wasn’t a way to update u-boot as is; I have a handful of other things to look into on my list but I may be able to look into it eventually