Add sf SPI flash support to distro boot
cover Add sf SPI flash support to distro boot
This patchset adds support for booting from SPI flash via the SPI flash subsystem commands to distro boot.
This addition is useful for allowing small embedded devices that support booting from various storage media (USB thumb drives, SD cards, eMMC) to boot from SPI flash, too using a common framework.
I'll use this feature for supporting the Pine64 Pinebook Pro, an 14" RK3399 ARM based laptop. I'll send a patchset for that device, soon.
Cc-ing some of the latest commit signers since there does not seem to be a dedicated maintainer for distro boot.
Tobias
Tobias Schramm (2):
distro_bootcmd: make BOOTENV_DEV_NAME and BOOTENV_DEV macro variadic
distro_bootcmd: add sf SPI flash boot support
include/config_distro_bootcmd.h | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
Signature · 1 line
2.26.0
PATCH 1/2 distro_bootcmd: make BOOTENV_DEV_NAME and BOOTENV_DEV macro variadic
Using a variadic macro allows boot device macros to take additional arguments
--- include/config_distro_bootcmd.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/config_distro_bootcmd.h +4 -4
@@ -398,13 +398,13 @@ BOOT_TARGET_DEVICES_references_PXE_without_CONFIG_CMD_DHCP_or_PXE#endif -#define BOOTENV_DEV_NAME (devtypeu, devtypel, instance) \ - BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance) +#define BOOTENV_DEV_NAME (devtypeu, devtypel, instance, ...) \ + BOOTENV_DEV_NAME_##devtypeu(devtypeu, devtypel, instance, ##__VA_ARGS__)#define BOOTENV_BOOT_TARGETS \ "boot_targets=" BOOT_TARGET_DEVICES(BOOTENV_DEV_NAME) "\0" -#define BOOTENV_DEV (devtypeu, devtypel, instance) \ - BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance) +#define BOOTENV_DEV (devtypeu, devtypel, instance, ...) \ + BOOTENV_DEV_##devtypeu(devtypeu, devtypel, instance, ##__VA_ARGS__)#define BOOTENV \ BOOTENV_SHARED_HOST \ BOOTENV_SHARED_MMC \
Signature · 1 line
2.26.0
PATCH 2/2 distro_bootcmd: add sf SPI flash boot support
In reply to Tobias SchrammThis commit adds generic boot support for SPI flash. Adding SPI flash support to a device can be achieved by adding following declaration to the BOOT_TARGET_DEVICES
func(SF, sf, <spibus>[:<cs>], <mtd partition>)
--- include/config_distro_bootcmd.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
include/config_distro_bootcmd.h +22 -0
@@ -67,6 +67,27 @@ BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC#endif +#ifdef CONFIG_CMD_SF +#define BOOTENV_SHARED_SF \ + "sf_boot=if sf probe ${devnum}; then " \ + "sf read ${scriptaddr} ${distro_bootpart} && "\ + "source ${scriptaddr}; " \ + "fi\0" +#define BOOTENV_DEV_SF (devtypeu, devtypel, instance, bootpart) \ + "bootcmd_" #devtypel #instance "=" \ + "devnum=" #instance "; " \ + "distro_bootpart=" #bootpart "; " \ + "run " #devtypel "_boot\0" +#define BOOTENV_DEV_NAME_SF (devtypeu, devtypel, instance, bootpart) \ + #devtypel #instance " " +#else +#define BOOTENV_SHARED_MMC +#define BOOTENV_DEV_SF \ + BOOT_TARGET_DEVICES_references_SF_without_CONFIG_CMD_SF +#define BOOTENV_DEV_NAME_SF \ + BOOT_TARGET_DEVICES_references_SF_without_CONFIG_CMD_SF +#endif +#ifdef CONFIG_CMD_UBIFS #define BOOTENV_SHARED_UBIFS \ "ubifs_boot=" \
@@ -408,6 +429,7 @@#define BOOTENV \ BOOTENV_SHARED_HOST \ BOOTENV_SHARED_MMC \ + BOOTENV_SHARED_SF \ BOOTENV_SHARED_PCI \ BOOTENV_SHARED_USB \ BOOTENV_SHARED_SATA \
Signature · 1 line
2.26.0
PATCH 2/2 distro_bootcmd: add sf SPI flash boot support
Quoted 46 lines · Tobias Schramm
This commit adds generic boot support for SPI flash. Adding SPI flash support to a device can be achieved by adding following declaration to the
BOOT_TARGET_DEVICESfunc(SF, sf, <spibus>[:<cs>], <mtd partition>)Signed-off-by Tobias Schramm <[email protected]>Cc Patrick Wildt <[email protected]>Cc AKASHI Takahiro <[email protected]>--- include/config_distro_bootcmd.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)include/config_distro_bootcmd.h +21
-0@@ -67,6 +67,27 @@ BOOT_TARGET_DEVICES_references_MMC_without_CONFIG_CMD_MMC#endif +#ifdef CONFIG_CMD_SF +#define BOOTENV_SHARED_SF \ + "sf_boot=if sf probe ${devnum}; then " \ + "sf read ${scriptaddr} ${distro_bootpart} && "\ + "source ${scriptaddr}; " \ + "fi\0" +#define BOOTENV_DEV_SF (devtypeu, devtypel, instance, bootpart) \ + "bootcmd_" #devtypel #instance "=" \ + "devnum=" #instance "; " \ + "distro_bootpart=" #bootpart "; " \ + "run " #devtypel "_boot\0" +#define BOOTENV_DEV_NAME_SF (devtypeu, devtypel, instance, bootpart) \ + #devtypel #instance " " +#else +#define BOOTENV_SHARED_MMC +#define BOOTENV_DEV_SF \ + BOOT_TARGET_DEVICES_references_SF_without_CONFIG_CMD_SF +#define BOOTENV_DEV_NAME_SF \ + BOOT_TARGET_DEVICES_references_SF_without_CONFIG_CMD_SF +#endif +#ifdef CONFIG_CMD_UBIFS #define BOOTENV_SHARED_UBIFS \ "ubifs_boot=" \
include/config_distro_bootcmd.h line 435
Quoted 7 lines
include/config_distro_bootcmd.h +1
-0@@ -408,6 +429,7 @@#define BOOTENV \ BOOTENV_SHARED_HOST \ BOOTENV_SHARED_MMC \ + BOOTENV_SHARED_SF \ BOOTENV_SHARED_PCI \ BOOTENV_SHARED_USB \ BOOTENV_SHARED_SATA \
I'm adding Jagan here as he's been working on something similar and includes moving the new logic to a new include file. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200424/bf3b55af/attachment.sig>