Hi,
Default only SD boot mode is supported for the early boot use-case, so can I know the changes to add the QSPI early boot ?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
Default only SD boot mode is supported for the early boot use-case, so can I know the changes to add the QSPI early boot ?
Hi,
Add the below changes to the u-boot source code for the QSPI early boot support.
diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c old mode 100644 new mode 100755 index c826df2591..e73e53fcda --- a/common/spl/spl_spi.c +++ b/common/spl/spl_spi.c @@ -13,9 +13,50 @@ #include <spi_flash.h> #include <errno.h> #include <spl.h> +#include <remoteproc.h> DECLARE_GLOBAL_DATA_PTR; +u32 spl_spi_load_core(struct rproc *cfg_arg) +{ + struct spi_flash *flash; + struct rproc *cfg = cfg_arg; + struct image_header *header; + u32 temp_load_addr, temp_load_size; + + debug("spl: loading remote core image %s\n", cfg->firmware_name); + + flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS, + CONFIG_SF_DEFAULT_CS, + CONFIG_SF_DEFAULT_SPEED, + CONFIG_SF_DEFAULT_MODE); + if (!flash) { + puts("SPI probe failed.\n"); + hang(); + } + + if (cfg->spi_offset == 0) + return 1; + + header = (struct image_header *)(CONFIG_SYS_TEXT_BASE); + + spi_flash_read(flash, cfg->spi_offset, + 128, (void *)header); + if (image_get_magic(header) != IH_MAGIC) { + printf("mkimage signature not found\n"); + return 1; + } + + temp_load_addr = (u32)(cfg->load_addr) - sizeof(struct image_header); + + temp_load_size = image_get_data_size(header) + + sizeof(struct image_header); + spi_flash_read(flash, cfg->spi_offset, + temp_load_size, (void *)temp_load_addr); + + return 0; +} + #ifdef CONFIG_SPL_OS_BOOT /* * Load the kernel, check for a valid header we can parse, and if found load diff --git a/drivers/remoteproc/dsp_rproc.c b/drivers/remoteproc/dsp_rproc.c old mode 100644 new mode 100755 index 9e15724371..5a87caa480 --- a/drivers/remoteproc/dsp_rproc.c +++ b/drivers/remoteproc/dsp_rproc.c @@ -562,7 +562,8 @@ struct rproc dsp1_config = { .start_core = dsp_start_core, .config_mmu = dsp_config_mmu, .config_peripherals = dsp1_config_peripherals, - .intmem_to_l3_mapping = &dsp1_intmem_to_l3_mapping + .intmem_to_l3_mapping = &dsp1_intmem_to_l3_mapping, + .spi_offset = CONFIGS_SYS_SPI_DSP1_OFFS }; struct rproc dsp2_config = { @@ -578,7 +579,8 @@ struct rproc dsp2_config = { .start_core = dsp_start_core, .config_mmu = dsp_config_mmu, .config_peripherals = dsp2_config_peripherals, - .intmem_to_l3_mapping = &dsp2_intmem_to_l3_mapping + .intmem_to_l3_mapping = &dsp2_intmem_to_l3_mapping, + .spi_offset = CONFIGS_SYS_SPI_DSP2_OFFS }; struct rproc *dsp_rproc_cfg_arr[RPROC_END_ENUMS] = { @@ -708,6 +710,24 @@ static int dsp_probe(struct udevice *dev) cfg = dsp_rproc_cfg_arr[dsp->id]; loadaddr = cfg->load_addr; + +#ifdef CONFIG_SPL_BUILD + if(BOOT_DEVICE_SPI == spl_boot_device()) + { + ret = spl_spi_load_core(cfg); + if(ret) { + dev_err(dev, "Firmware %s loading is failed\n", cfg->firmware_name); + } + else + { + INIT_LIST_HEAD(&dsp->mappings); + ret = spl_pre_boot_dsp_core(dev, dsp->id); + } + return ret; + } + +#endif + size = load_firmware(cfg->firmware_name, &loadaddr); if (!size) { dev_err(dev, "Firmware loading failed\n"); diff --git a/drivers/remoteproc/ipu_rproc.c b/drivers/remoteproc/ipu_rproc.c index 963897018b..8a174447e4 100644 --- a/drivers/remoteproc/ipu_rproc.c +++ b/drivers/remoteproc/ipu_rproc.c @@ -525,7 +525,8 @@ struct rproc ipu1_config = { .firmware_name = "dra7-ipu1-fw.lzop", .config_mmu = ipu_config_mmu, .config_peripherals = ipu1_config_peripherals, - .intmem_to_l3_mapping = &ipu1_intmem_to_l3_mapping + .intmem_to_l3_mapping = &ipu1_intmem_to_l3_mapping, + .spi_offset = CONFIGS_SYS_SPI_IPU1_OFFS }; struct rproc ipu2_config = { @@ -539,7 +540,8 @@ struct rproc ipu2_config = { .firmware_name = "dra7-ipu2-fw.lzop", .config_mmu = ipu_config_mmu, .config_peripherals = ipu2_config_peripherals, - .intmem_to_l3_mapping = &ipu2_intmem_to_l3_mapping + .intmem_to_l3_mapping = &ipu2_intmem_to_l3_mapping, + .spi_offset = CONFIGS_SYS_SPI_IPU2_OFFS }; struct rproc *rproc_cfg_arr[2] = { @@ -699,12 +701,29 @@ static int ipu_probe(struct udevice *dev) cfg = rproc_cfg_arr[priv->id]; loadaddr = cfg->load_addr; + +#ifdef CONFIG_SPL_BUILD + if(BOOT_DEVICE_SPI == spl_boot_device()) + { + ret = spl_spi_load_core(cfg); + if(ret) { + dev_err(dev, "Firmware %s loading is failed\n", cfg->firmware_name); + } + else + { + INIT_LIST_HEAD(&priv->mappings); + ret = spl_pre_boot_core(dev, priv->id); + } + return ret; + } + +#endif + size = load_firmware(cfg->firmware_name, &loadaddr); if (!size) { dev_err(dev, "Firmware loading failed\n"); return -EINVAL; } - INIT_LIST_HEAD(&priv->mappings); ret = spl_pre_boot_core(dev, priv->id); diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h index 51dcae3d29..8ac8b312b9 100644 --- a/include/configs/dra7xx_evm.h +++ b/include/configs/dra7xx_evm.h @@ -85,6 +85,28 @@ #define CONFIG_SYS_SPI_KERNEL_OFFS 0x1E0000 #define CONFIG_SYS_SPI_ARGS_OFFS 0x140000 #define CONFIG_SYS_SPI_ARGS_SIZE 0x80000 + +#define CONFIGS_SYS_SPI_KERNEL_SIZE 0x800000 +#define CONFIGS_SYS_SPI_LOGO_OFFS (CONFIGS_SYS_SPI_KERNEL_SIZE +\ + (0x1E0000)) +#define CONFIGS_SYS_SPI_LOGO_SIZE 0x80000 +#define CONFIGS_SYS_SPI_RPROC_BIN_OFFS (CONFIGS_SYS_SPI_LOGO_OFFS +\ + CONFIGS_SYS_SPI_LOGO_SIZE) + +#define CONFIGS_SYS_SPI_RPROC_BIN_SIZE 0x1000000 +#define CONFIGS_SYS_SPI_IPU1_BIN_SIZE 0x400000 +#define CONFIGS_SYS_SPI_IPU2_BIN_SIZE 0x400000 +#define CONFIGS_SYS_SPI_DSP1_BIN_SIZE 0x400000 +#define CONFIGS_SYS_SPI_DSP2_BIN_SIZE 0x400000 +#define CONFIGS_SYS_SPI_IPU1_OFFS (CONFIGS_SYS_SPI_RPROC_BIN_OFFS) +#define CONFIGS_SYS_SPI_IPU2_OFFS (CONFIGS_SYS_SPI_IPU1_OFFS +\ + CONFIGS_SYS_SPI_IPU1_BIN_SIZE) +#define CONFIGS_SYS_SPI_DSP1_OFFS (CONFIGS_SYS_SPI_IPU2_OFFS +\ + CONFIGS_SYS_SPI_IPU2_BIN_SIZE) +#define CONFIGS_SYS_SPI_DSP2_OFFS (CONFIGS_SYS_SPI_DSP1_OFFS +\ + CONFIGS_SYS_SPI_DSP1_BIN_SIZE) + + #if defined(CONFIG_QSPI_BOOT) #define CONFIG_SYS_REDUNDAND_ENVIRONMENT #define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED diff --git a/include/remoteproc.h b/include/remoteproc.h old mode 100644 new mode 100755 index 4193618d5f..d7a7649c86 --- a/include/remoteproc.h +++ b/include/remoteproc.h @@ -415,6 +415,7 @@ struct rproc { struct rproc_intmem_to_l3_mapping *intmem_to_l3_mapping; u32 trace_pa; u32 trace_len; + u32 spi_offset; }; extern struct rproc *rproc_cfg_arr[2]; diff --git a/include/spl.h b/include/spl.h index fcbb6035fe..faaef30fdf 100644 --- a/include/spl.h +++ b/include/spl.h @@ -12,6 +12,7 @@ #include <linux/compiler.h> #include <asm/spl.h> #include <handoff.h> +#include <remoteproc.h> /* Value in r0 indicates we booted from U-Boot */ #define UBOOT_NOT_LOADED_FROM_SPL 0x13578642 @@ -399,6 +400,8 @@ int spl_spi_load(struct spl_image_info *spl_image, unsigned int offs_override, void *buffer); +u32 spl_spi_load_core(struct rproc *cfg_arg); + /** * spl_invoke_atf - boot using an ARM trusted firmware image */
Refer the below thread as a reference for flashing the images to the QSPI memory.
Thanks
Gaviraju