[U-Boot] [PATCH v2 1/2] distro_bootcmd: add spi flash boot command

Oskari Lemmela oskari at lemmela.net
Wed Jan 30 19:21:28 UTC 2019


Add a boot command to distro boot to support load FIT image
from SPI flash.

Signed-off-by: Oskari Lemmela <oskari at lemmela.net>
---
 Kconfig                         | 29 +++++++++++++++++++++++++++++
 include/config_distro_bootcmd.h | 16 ++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/Kconfig b/Kconfig
index a078f7b1b6..f28fbf4fc0 100644
--- a/Kconfig
+++ b/Kconfig
@@ -342,6 +342,35 @@ config FIT_IMAGE_POST_PROCESS
 	  injected into the FIT creation (i.e. the blobs would have been pre-
 	  processed before being added to the FIT image).
 
+config FIT_SPI_FLASH_BOOT
+	bool "Distro bootcmd from SPI Flash"
+	depends on DM_SPI_FLASH
+	imply CMD_SF
+	help
+	  Enable SPI bootcmd to load FIT image from SPI flash. Command
+	  probes for the SPI flash device. If device is found command
+	  will try to load FIT image to memory and boot it.
+
+config FIT_FLASH_IMAGE_ADDR
+	hex "FIT image memory address"
+	depends on FIT_SPI_FLASH_BOOT
+	help
+	  Memory address where to load FIT image.
+
+config FIT_FLASH_IMAGE_OFFSET
+	hex "FIT image flash offset"
+	depends on FIT_SPI_FLASH_BOOT
+	default 0x100000
+	help
+	  Flash offset of FIT image.
+
+config FIT_FLASH_IMAGE_SIZE
+	hex "FIT image size"
+	depends on FIT_SPI_FLASH_BOOT
+	default 0x700000
+	help
+	  Max size of the FIT image.
+
 if SPL
 
 config SPL_FIT
diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 555efb7433..75bc76c139 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -242,6 +242,22 @@
 	BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB
 #endif
 
+#ifdef CONFIG_FIT_SPI_FLASH_BOOT
+#define BOOT_TARGET_DEVICES_SPI(func) func(SPI, spi, 0)
+#define BOOTENV_DEV_SPI(devtypeu, devtypel, instance) \
+	"image_addr_r=" __stringify(CONFIG_FIT_FLASH_IMAGE_ADDR) "\0" \
+	"image_addr=" __stringify(CONFIG_FIT_FLASH_IMAGE_OFFSET) "\0" \
+	"image_size=" __stringify(CONFIG_FIT_FLASH_IMAGE_SIZE) "\0" \
+	"bootcmd_" #devtypel #instance "=" \
+		"if sf probe " #instance "; then " \
+			"sf read ${image_addr_r} ${image_addr} ${image_size}; " \
+			"bootm ${image_addr_r}; " \
+	"fi\0"
+#define BOOTENV_DEV_NAME_SPI	BOOTENV_DEV_NAME_BLKDEV
+#else
+#define BOOT_TARGET_DEVICES_SPI(func)
+#endif
+
 #ifdef CONFIG_CMD_VIRTIO
 #define BOOTENV_SHARED_VIRTIO	BOOTENV_SHARED_BLKDEV(virtio)
 #define BOOTENV_DEV_VIRTIO	BOOTENV_DEV_BLKDEV
-- 
2.17.1



More information about the U-Boot mailing list