On Thu, Jan 22, 2026 at 02:17:28PM +0100, Rasmus Villemoes wrote:

> The am335x knows nothing about eMMC boot partitions, so in order to
> implement an update procedure of the bootloader which is robust
> against power failure or other interruptions, one must make use of the
> fact that ROM code on the am335x looks for a valid first stage
> bootloader at several different offsets. Updating that can then be
> implemented by (assume we put MLO at offsets 128K and 256K):
> 
> (1) At least one of the two slots must contain a valid header, since
> we successfully booted. Pick the other one.
> 
> (2) Overwrite the first sector of the slot chosen in step (a) with all
> zeroes.
> 
> (3) Write everything but the first sector to the chosen slot.
> 
> (4) Write the first sector (containing the magic signature that the
> boot ROM uses to identify a valid image) to the chosen slot.
> 
> (5) Repeat steps (2)-(4) for the other slot.
> 
> It's not possible to simply write the whole MLO in one go, especially
> not when updating the 128K slot, because an interruption after the
> first sector is written would make the ROM code believe the image is
> valid.
> 
> But this only caters for SPL itself; regardless of where SPL was
> loaded from, it would go on to load U-Boot proper from
> SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR. So in order to update the whole
> bootloader, we need to teach SPL to use a
> different offset for U-Boot proper depending on where SPL itself was
> loaded from (*). With that, the update procedure is just amended by a step
> 
> (3a) Write U-Boot proper to the offset corresponding to the SPL slot
> being updated.
> 
> We can know (*) because the ROM code sets a new bit in a certain
> "trace vector" before each successive attempt.
> 
> Signed-off-by: Rasmus Villemoes <[email protected]>
> ---
>  arch/arm/mach-omap2/Kconfig       | 37 +++++++++++++++++++++++++++++++
>  arch/arm/mach-omap2/boot-common.c | 31 ++++++++++++++++++++++++++
>  2 files changed, 68 insertions(+)

Very interesting. I think the only thing really missing is that this
needs to be covered under doc/ as well.

-- 
Tom

Attachment: signature.asc
Description: PGP signature

Reply via email to