Skip to content

Load the M4 code from the same eMMC partition the SPL booted from

This merge request enables the U-boot SPL to load the M4 firmware from the eMMC hardware partition the SoC booted from.

It makes possible to store all the bootloader images on the eMMC boot partitions (/dev/mmcblk0boot{0,1}), which are isolated from the eMMC user area, and are write-protected (in software) by default in Linux. This makes it more difficult for users to accidentally brick their phone by messing with the partition layout or attempting to switch between Linux distros.

It also paves the way for being able to move away from MBR and use GPT instead: librem5-devkit-tools#7

If the SPL was booted from boot1, the M4 binary will be loaded from boot1; if it was booted from the user area, m4.bin will be loaded from the user area. I tested both configurations and they were all booting correctly, so it should not break anything.

If you want to test this patch by yourself, you can use this UUU script:

FB: ucmd setenv fastboot_buffer 0x43000000
FB: download -f flash.bin
FB: ucmd mmc partconf 0 0 1 1
FB: ucmd mmc write 0x43000000 0x42 0x800
FB: download -f m4.bin
FB: ucmd mmc partconf 0 0 1 1
FB: ucmd mmc write 0x43000000 0x4 0x3e
FB: Done

This will set your eMMC to boot from the boot1 partition, and flash the binaries there.

To configure the eMMC to boot from the user area again:

FB: ucmd mmc partconf 0 0 7 0
FB: Done

Merge request reports