[PATCH 0/2] Command for entering mask rom USB download mode
samuel at sholland.org
Mon Jul 4 01:26:22 CEST 2022
On 7/3/22 2:20 PM, Michal Suchanek wrote:
> many ARM SoCs have a mask rom feature that provides interface for
> downloading firmware over USB.
> Downstream rockchip u-boot has 'brom' or 'rbrom' command for this
> purpose, and downstream sunxi u-boot provides 'efex' command. p-boot has
> code for entering FEL on A64 SoC.
> With this patch I am able to activate the USB downloader on a rk3399 but
> the rkflashtool fails to communicate with the device. On a H2+ I can get
> into the FEL mode and get flash parameters. YMMV
> I don't have any great idea how to structure this so that the command
> does not need platform-specific code. Is there an example of a command
> that has platform-specific implementations?
Generally you would do this by having the driver interact with some DM uclass.
Platforms may or may not provide a driver implementing that uclass; the details
are hidden behind the uclass's interface. All the command has to do is search
for a DM device by uclass, and if one is found, call some operation on it.
In this case, UCLASS_REBOOT_MODE already exists. It sounds like what we need is
the inverse of dm_reboot_mode_update() -- a function that takes a string and
programs the device with the corresponding mode value.
To be generic, you could call this function from do_reset() if some positional
argument is provided, allowing usage like "reset bootloader" or "reset fel".
Rockchip platforms already have syscon-reboot-mode hooked up in their
devicetrees. The driver for this should be trivial.
Allwinner platforms would need to add a nvmem-reboot-mode node, and a bit more
driver infrastructure. U-Boot does not have NVMEM uclass, so you would need to
add one or reuse UCLASS_MISC.
More information about the U-Boot