[U-Boot] [PATCH v2 0/2] sunxi: add spi flash bootcmd

Patches enable booting FIT image from SPI flash device.
Changes since v1: - Move bootcmd to config_distro_bootcmd - Add Kconfig options to enable and configure it
Oskari Lemmela (2): distro_bootcmd: add spi flash boot command sunxi: enable distro spi boot command
Kconfig | 29 +++++++++++++++++++++++++++++ include/config_distro_bootcmd.h | 16 ++++++++++++++++ include/configs/sunxi-common.h | 1 + 3 files changed, 46 insertions(+)

Add a boot command to distro boot to support load FIT image from SPI flash.
Signed-off-by: Oskari Lemmela oskari@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

On Thu, Jan 31, 2019 at 12:51 AM Oskari Lemmela oskari@lemmela.net wrote:
Add a boot command to distro boot to support load FIT image from SPI flash.
Add some info about why default offsets being used below.

Hi,
On 9.2.2019 17.50, Jagan Teki wrote:
On Thu, Jan 31, 2019 at 12:51 AM Oskari Lemmela oskari@lemmela.net wrote:
Add a boot command to distro boot to support load FIT image from SPI flash.
Add some info about why default offsets being used below.
Or is it just better not to define default values?
Oskari

On Tue, Feb 19, 2019 at 9:57 PM Oskari Lemmelä oskari@lemmela.net wrote:
Hi,
On 9.2.2019 17.50, Jagan Teki wrote:
On Thu, Jan 31, 2019 at 12:51 AM Oskari Lemmela oskari@lemmela.net wrote:
Add a boot command to distro boot to support load FIT image from SPI flash.
Add some info about why default offsets being used below.
Or is it just better not to define default values?
Adding offsets fine, for verification. please add comments on offsets along with which platform it's been tested.

Signed-off-by: Oskari Lemmela oskari@lemmela.net --- include/configs/sunxi-common.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index ed0cfc24f5..967f3e1f08 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -415,6 +415,7 @@ extern int soft_i2c_gpio_scl; BOOT_TARGET_DEVICES_MMC(func) \ BOOT_TARGET_DEVICES_SCSI(func) \ BOOT_TARGET_DEVICES_USB(func) \ + BOOT_TARGET_DEVICES_SPI(func) \ func(PXE, pxe, na) \ func(DHCP, dhcp, na)
participants (3)
-
Jagan Teki
-
Oskari Lemmela
-
Oskari Lemmelä