spl: Support loading FIT from various boot media
Subsystems (2)
v6 cover spl: Support loading FIT from various boot media
This series supports loading FIT from FS, nand, spi, uart.
It consolidates all the previously post FIT support patches and rebased on top of mainline. Patch [1] and [2] got merged.
[1] http://patchwork.ozlabs.org/patch/618403/
[2] http://patchwork.ozlabs.org/patch/623919/
Verified all these boot modes on TI platforms.
Lokesh Vutla (8):
spl: fit: Fix the number of bytes read when reading fdt from fit
spl: Allow to load a FIT containing U-Boot from FS
spl: Support loading a FIT from FAT FS
spl: Support loading a FIT from SPI
mtd: nand: am335x: spl: Fix copying of image
spl: Support loading a FIT from NAND
spl: fit: Do not print selected dtb during fit load
spl: Add an option to load a FIT containing U-Boot from UART
common/spl/spl_fat.c | 36 ++++++++++++-- common/spl/spl_fit.c | 79 ++++++++++++++++++++++++------- common/spl/spl_mmc.c | 1 + common/spl/spl_nand.c | 37 +++++++++++++-- common/spl/spl_ymodem.c | 98 +++++++++++++++++++++++++++++++++------ drivers/mtd/nand/am335x_spl_bch.c | 15 +++++- drivers/mtd/spi/spi_spl_load.c | 37 +++++++++++++-- include/spl.h | 12 +++++ 8 files changed, 269 insertions(+), 46 deletions(-)
Signature · 1 line
2.8.2
PATCH v6 1/8 spl: fit: Fix the number of bytes read when reading fdt from fit
sectors field is not being updated when reading fdt from fit image. Because of this size_of(u-boot.bin) is being read when reading fdt. Fixing it by updating the sectors field properly.
--- common/spl/spl_fit.c | 1 + 1 file changed, 1 insertion(+)
common/spl/spl_fit.c +1 -0
@@ -181,6 +181,7 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)*/ dst = load_ptr + data_size; fdt_offset += base_offset; + sectors = (fdt_len + info->bl_len -1 ) / info->bl_len; count = info->read (info, sector + fdt_offset / info->bl_len, sectors, dst); debug("fit read %x sectors to %x, dst %p, data_offset %x\n",
Signature · 1 line
2.8.2
PATCH v6 1/8 spl: fit: Fix the number of bytes read when reading fdt from fit
Quoted 8 lines · Lokesh Vutla
sectors field is not being updated when reading fdt from fit image. Because of this
size_of(u-boot.bin)is being read when reading fdt. Fixing it by updating the sectors field properly.Tested-by Michal Simek <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>Signed-off-by Lokesh Vutla <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160530/ce2f290d/attachment.sig>
PATCH v6 2/8 spl: Allow to load a FIT containing U-Boot from FS
In reply to Lokesh VutlaThis provides a way to load a FIT containing U-Boot and a selection of device tree files from a File system. Making sure that all the reads and writes are aligned to their respective needs.
--- common/spl/spl_fit.c | 76 +++++++++++++++++++++++++++++++++++++++++----------- common/spl/spl_mmc.c | 1 + include/spl.h | 12 +++++++++ 3 files changed, 74 insertions(+), 15 deletions(-)
common/spl/spl_fit.c +61 -15
@@ -87,6 +87,42 @@ static int spl_fit_select_fdt(const void *fdt, int images, int *fdt_offsetp)return -ENOENT ; } +static int get_aligned_image_offset (struct spl_load_info *info,int offset) +{ +/* +* If it is a FS read, get the first address before offset which is +* aligned to ARCH_DMA_MINALIGN. If it is raw read return the +* block number to which offset belongs. +*/ +if (info->filename) +return offset & ~(ARCH_DMA_MINALIGN -1 ); + +return offset / info->bl_len; +} + +static int get_aligned_image_overhead (struct spl_load_info *info,int offset) +{ +/* +* If it is a FS read, get the difference between the offset and +* the first address before offset which is aligned to +* ARCH_DMA_MINALIGN. If it is raw read return the offset within the +* block. +*/ +if (info->filename) +return offset & (ARCH_DMA_MINALIGN -1 ); + +return offset % info->bl_len; +} + +static int get_aligned_image_size (struct spl_load_info *info,int data_size, +int offset) +{ +if (info->filename) +return data_size +get_aligned_image_overhead (info, offset); + +return (data_size + info->bl_len -1 ) / info->bl_len; +} +int spl_load_simple_fit (struct spl_load_info *info,ulong sector,void *fit) {int sectors;
@@ -96,7 +132,7 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)void *load_ptr;int fdt_offset, fdt_len;int data_offset, data_size; -int base_offset; +int base_offset, align_len;int src_sector;void *dst;
@@ -122,8 +158,10 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)* In fact the FIT has its own load address, but we assume it cannot * be before CONFIG_SYS_TEXT_BASE. */ - fit = (void *)(CONFIG_SYS_TEXT_BASE - size - info->bl_len); - sectors = (size + info->bl_len -1 ) / info->bl_len; + align_len =ARCH_DMA_MINALIGN -1 ; + fit = (void *)((CONFIG_SYS_TEXT_BASE - size - info->bl_len - + align_len) & ~align_len); + sectors =get_aligned_image_size (info, size,0 ); count = info->read (info, sector, sectors, fit);debug ("fit read sector %lx, sectors=%d, dst=%p, count=%lu\n" , sector, sectors, fit, count);
@@ -156,19 +194,23 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)* byte will be at 'load'. This may mean we need to load it starting * before then, since we can only read whole blocks. */ - sectors = (data_size + info->bl_len -1 ) / info->bl_len; data_offset += base_offset; + sectors =get_aligned_image_size (info, data_size, data_offset); load_ptr = (void *)load;debug ("U-Boot size %x, data %p\n" , data_size, load_ptr); - dst = load_ptr - (data_offset % info->bl_len); + dst = load_ptr;/* Read the image */ - src_sector = sector + data_offset / info->bl_len; -debug ("image: data_offset=%x, dst=%p, src_sector=%x, sectors=%x\n" , - data_offset, dst, src_sector, sectors); + src_sector = sector +get_aligned_image_offset (info, data_offset); +debug ("Aligned image read: dst=%p, src_sector=%x, sectors=%x\n" , + dst, src_sector, sectors); count = info->read (info, src_sector, sectors, dst);if (count != sectors)return -EIO ; +debug ("image: dst=%p, data_offset=%x, size=%x\n" , dst, data_offset, + data_size); +memcpy (dst, dst +get_aligned_image_overhead (info, data_offset), + data_size);/* Figure out which device tree the board wants to use */ fdt_len =spl_fit_select_fdt (fit, images, &fdt_offset);
@@ -178,14 +220,15 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)/* * Read the device tree and place it after the image. There may be * some extra data before it since we can only read entire blocks. +* And also align the destination address to ARCH_DMA_MINALIGN. */ - dst = load_ptr + data_size; + dst = (void *)((load + data_size + align_len) & ~align_len); fdt_offset += base_offset; - sectors = (fdt_len + info->bl_len -1 ) / info->bl_len; - count = info->read (info, sector + fdt_offset / info->bl_len, sectors, - dst); -debug ("fit read %x sectors to %x, dst %p, data_offset %x\n" , - sectors, spl_image.load_addr, dst, fdt_offset); + sectors =get_aligned_image_size (info, fdt_len, fdt_offset); + src_sector = sector +get_aligned_image_offset (info, fdt_offset); + count = info->read (info, src_sector, sectors, dst); +debug ("Aligned fdt read: dst %p, src_sector = %x, sectors %x\n" , + dst, src_sector, sectors);if (count != sectors)return -EIO ;
@@ -194,7 +237,10 @@ int spl_load_simple_fit(struct spl_load_info *info, ulong sector, void *fit)* After this we will have the U-Boot image and its device tree ready * for us to start. */ -memcpy (dst, dst + fdt_offset % info->bl_len, fdt_len); +debug ("fdt: dst=%p, data_offset=%x, size=%x\n" , dst, fdt_offset, + fdt_len); +memcpy (load_ptr + data_size, + dst +get_aligned_image_overhead (info, fdt_offset), fdt_len);return 0 ; }
common/spl/spl_mmc.c +1 -0
@@ -77,6 +77,7 @@ static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector)debug ("Found FIT\n" ); load.dev = mmc; load.priv =NULL ; + load.filename =NULL ; load.bl_len = mmc->read_bl_len; load.read = h_spl_load_read; ret =spl_load_simple_fit (&load, sector, header);
include/spl.h +12 -0
@@ -35,16 +35,28 @@ struct spl_image_info {* @dev: Pointer to the device, e.g. struct mmc * * @priv: Private data for the device * @bl_len: Block length for reading in bytes +* @filename: Name of the fit image file. * @read: Function to call to read from the device */ struct spl_load_info {void *dev;void *priv;int bl_len; +const char *filename;ulong (*read)(struct spl_load_info *load,ulong sector,ulong count,void *buf); }; +/** +* spl_load_simple_fit() - Loads a fit image from a device. +* @info: Structure containing the information required to load data. +* @sector: Sector number where FIT image is located in the device +* @fdt: Pointer to the copied FIT header. +* +* Reads the FIT image @sector in the device. Loads u-boot image to +* specified load address and copies the dtb to end of u-boot image. +* Returns 0 on success. +*/ int spl_load_simple_fit (struct spl_load_info *info,ulong sector,void *fdt);#define SPL_COPY_PAYLOAD_ONLY 1
Signature · 1 line
2.8.2
PATCH v6 2/8 spl: Allow to load a FIT containing U-Boot from FS
Quoted 8 lines · Lokesh Vutla
This provides a way to load a FIT containing U-Boot and a selection of device tree files from a File system. Making sure that all the reads and writes are aligned to their respective needs.
Tested-by Michal Simek <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>Signed-off-by Lokesh Vutla <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160530/01a4686c/attachment.sig>
PATCH v6 3/8 spl: Support loading a FIT from FAT FS
In reply to Lokesh VutlaDetect a FIT when loading from a FAT File system and handle it using the new FIT SPL support.
--- common/spl/spl_fat.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)
common/spl/spl_fat.c +32 -4
@@ -15,6 +15,7 @@#include <fat.h> #include <errno.h> #include <image.h> +#include <libfdt.h> static int fat_registered;
@@ -39,6 +40,20 @@ static int spl_register_fat_device(struct blk_desc *block_dev, int partition)return err; } +static ulong spl_fit_read (struct spl_load_info *load,ulong file_offset, +ulong size,void *buf) +{ +loff_t actread; +int ret; +char *filename = (char *)load->filename; + + ret =fat_read_file (filename, buf, file_offset, size, &actread); +if (ret) +return ret; + +return actread; +} +int spl_load_image_fat (struct blk_desc *block_dev,int partition,const char *filename)
@@ -57,11 +72,24 @@ int spl_load_image_fat(struct blk_desc *block_dev,if (err <=0 ) goto end; - err =spl_parse_image_header (header); -if (err) - goto end; +if (IS_ENABLED (CONFIG_SPL_LOAD_FIT ) && +image_get_magic (header) ==FDT_MAGIC ) { +struct spl_load_info load; + +debug ("Found FIT\n" ); + load.read = spl_fit_read; + load.bl_len =1 ; + load.filename = (void *)filename; + load.priv =NULL ; - err =file_fat_read (filename, (u8 *)spl_image.load_addr,0 ); +return spl_load_simple_fit (&load,0 , header); + }else { + err =spl_parse_image_header (header); +if (err) + goto end; + + err =file_fat_read (filename, (u8 *)spl_image.load_addr,0 ); + } end: #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
Signature · 1 line
2.8.2
PATCH v6 3/8 spl: Support loading a FIT from FAT FS
Quoted 7 lines · Lokesh Vutla
Detect a FIT when loading from a FAT File system and handle it using the new FIT SPL support.
Tested-by Michal Simek <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>Signed-off-by Lokesh Vutla <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160530/a63e3e2f/attachment.sig>
PATCH v6 4/8 spl: Support loading a FIT from SPI
In reply to Lokesh VutlaDetect a FIT when loading from SPI and handle it using the new FIT SPL support.
--- drivers/mtd/spi/spi_spl_load.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-)
drivers/mtd/spi/spi_spl_load.c +32 -5
@@ -48,6 +48,18 @@ static int spi_load_image_os(struct spi_flash *flash, }#endif +static ulong spl_spi_fit_read (struct spl_load_info *load,ulong sector, +ulong count,void *buf) +{ +struct spi_flash *flash = load->dev; +ulong ret; + + ret =spi_flash_read (flash, sector, count, buf); +if (!ret) +return count; +else +return 0 ; +}/* * The main entry for SPI booting. It's necessary that SDRAM is already * configured and available since this code loads the main U-Boot image
@@ -85,11 +97,26 @@ int spl_spi_load_image(void)if (err)return err; - err =spl_parse_image_header (header); -if (err) -return err; - err =spi_flash_read (flash,CONFIG_SYS_SPI_U_BOOT_OFFS , - spl_image.size, (void *)spl_image.load_addr); +if (IS_ENABLED (CONFIG_SPL_LOAD_FIT )) { +struct spl_load_info load; + +debug ("Found FIT\n" ); + load.dev = flash; + load.priv =NULL ; + load.filename =NULL ; + load.bl_len =1 ; + load.read = spl_spi_fit_read; + err =spl_load_simple_fit (&load, +CONFIG_SYS_SPI_U_BOOT_OFFS , + header); + }else { + err =spl_parse_image_header (header); +if (err) +return err; + err =spi_flash_read (flash,CONFIG_SYS_SPI_U_BOOT_OFFS , + spl_image.size, + (void *)spl_image.load_addr); + } }return err;
Signature · 1 line
2.8.2
PATCH v6 4/8 spl: Support loading a FIT from SPI
Quoted 5 lines · Lokesh Vutla
Detect a FIT when loading from SPI and handle it using the new FIT SPL support.
Reviewed-by Tom Rini <[email protected]>Signed-off-by Lokesh Vutla <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160530/e65bbc87/attachment.sig>
PATCH v6 5/8 mtd: nand: am335x: spl: Fix copying of image
In reply to Lokesh VutlaWhen offset is not aligned to page address, it is possible that extra offset will be read from nand. Adjust the image such that first byte of the image is at load address after the first page is read.
--- drivers/mtd/nand/am335x_spl_bch.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/mtd/nand/am335x_spl_bch.c +14 -1
@@ -173,7 +173,7 @@ static int nand_read_page(int block, int page, void *dst)int nand_spl_load_image (uint32_t offs,unsigned int size,void *dst) {unsigned int block, lastblock; -unsigned int page; +unsigned int page, page_offset;/* * offs has to be aligned to a page address!
@@ -181,6 +181,7 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst) block = offs /CONFIG_SYS_NAND_BLOCK_SIZE ; lastblock = (offs + size -1 ) /CONFIG_SYS_NAND_BLOCK_SIZE ; page = (offs %CONFIG_SYS_NAND_BLOCK_SIZE ) /CONFIG_SYS_NAND_PAGE_SIZE ; + page_offset = offs %CONFIG_SYS_NAND_PAGE_SIZE ;while (block <= lastblock) {if (!nand_is_bad_block (block)) {
@@ -189,6 +190,18 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)*/ while (page <CONFIG_SYS_NAND_PAGE_COUNT ) {nand_read_page (block, page, dst); +/* +* When offs is not aligned to page address the +* extra offset is copied to dst as well. Copy +* the image such that its first byte will be +*@the dst. +*/ +if (unlikely (page_offset)) { +memmove (dst, dst + page_offset, +CONFIG_SYS_NAND_PAGE_SIZE ); + dst = (void *)((int )dst - page_offset); + page_offset =0 ; + } dst +=CONFIG_SYS_NAND_PAGE_SIZE ; page++; }
Signature · 1 line
2.8.2
PATCH v6 5/8 mtd: nand: am335x: spl: Fix copying of image
Quoted 6 lines · Lokesh Vutla
When offset is not aligned to page address, it is possible that extra offset will be read from nand. Adjust the image such that first byte of the image is at load address after the first page is read.
Reviewed-by Tom Rini <[email protected]>Signed-off-by Lokesh Vutla <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160530/d2b0e00a/attachment.sig>
PATCH v6 6/8 spl: Support loading a FIT from NAND
In reply to Lokesh VutlaDetect a FIT when loading from NAND and handle it using the new FIT SPL support.
--- common/spl/spl_nand.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-)
common/spl/spl_nand.c +32 -5
@@ -9,6 +9,8 @@#include <spl.h> #include <asm/io.h> #include <nand.h> +#include <libfdt_env.h> +#include <fdt.h> #if defined(CONFIG_SPL_NAND_RAW_ONLY )int spl_nand_load_image (void )
@@ -24,6 +26,19 @@ int spl_nand_load_image(void) return 0; }#else + +static ulong spl_nand_fit_read (struct spl_load_info *load,ulong offs, +ulong size,void *dst) +{ +int ret; + + ret =nand_spl_load_image (offs, size, dst); +if (!ret) +return size; +else +return 0 ; +} +static int spl_nand_load_element (int offset,struct image_header *header) {int err;
@@ -32,12 +47,24 @@ static int spl_nand_load_element(int offset, struct image_header *header)if (err)return err; - err =spl_parse_image_header (header); -if (err) -return err; +if (IS_ENABLED (CONFIG_SPL_LOAD_FIT ) && +image_get_magic (header) ==FDT_MAGIC ) { +struct spl_load_info load; -return nand_spl_load_image (offset, spl_image.size, - (void *)(unsigned long )spl_image.load_addr); +debug ("Found FIT\n" ); + load.dev =NULL ; + load.priv =NULL ; + load.filename =NULL ; + load.bl_len =1 ; + load.read = spl_nand_fit_read; +return spl_load_simple_fit (&load, offset, header); + }else { + err =spl_parse_image_header (header); +if (err) +return err; +return nand_spl_load_image (offset, spl_image.size, + (void *)spl_image.load_addr); + } }int spl_nand_load_image (void )
Signature · 1 line
2.8.2
PATCH v6 6/8 spl: Support loading a FIT from NAND
Quoted 5 lines · Lokesh Vutla
Detect a FIT when loading from NAND and handle it using the new FIT SPL support.
Reviewed-by Tom Rini <[email protected]>Signed-off-by Lokesh Vutla <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160530/2225d6cf/attachment.sig>
PATCH v6 7/8 spl: fit: Do not print selected dtb during fit load
In reply to Lokesh VutlaNo prints should be allowed during UART load.
--- common/spl/spl_fit.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
common/spl/spl_fit.c +1 -3
@@ -67,9 +67,7 @@ static int spl_fit_select_fdt(const void *fdt, int images, int *fdt_offsetp) *fdt_offsetp =fdt_getprop_u32 (fdt, fdt_node,"data-offset" ); len =fdt_getprop_u32 (fdt, fdt_node,"data-size" ); -#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT -printf ("FIT: Selected '%s'\n" , name); -#endif +debug ("FIT: Selected '%s'\n" , name);return len; }
Signature · 1 line
2.8.2
PATCH v6 7/8 spl: fit: Do not print selected dtb during fit load
Quoted 4 lines · Lokesh Vutla
No prints should be allowed during UART load.
Reviewed-by Tom Rini <[email protected]>Signed-off-by Lokesh Vutla <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160530/fa8cc351/attachment.sig>
PATCH v6 8/8 spl: Add an option to load a FIT containing U-Boot from UART
In reply to Lokesh VutlaThis provides a way to load a FIT containing U-Boot and a selection of device tree files from UART.
--- common/spl/spl_ymodem.c | 98 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 84 insertions(+), 14 deletions(-)
common/spl/spl_ymodem.c +84 -14
@@ -14,15 +14,60 @@#include <xyzModem.h> #include <asm/u-boot.h> #include <asm/utils.h> +#include <libfdt.h> #define BUF_SIZE 1024 +/* +* Information required to load image using ymodem. +* +* @image_read: Now of bytes read from the image. +* @buf: pointer to the previous read block. +*/ +struct ymodem_fit_info { +int image_read; +char *buf; +}; +static int getcymodem (void ) {if (tstc ())return (getc ());return -1 ; } +static ulong ymodem_read_fit (struct spl_load_info *load,ulong offset, +ulong size,void *addr) +{ +int res, err; +struct ymodem_fit_info *info = load->priv; +char *buf = info->buf; + +while (info->image_read < offset) { + res =xyzModem_stream_read (buf,BUF_SIZE , &err); +if (res <=0 ) +return res; + info->image_read += res; + } + +if (info->image_read > offset) { + res = info->image_read - offset; +memcpy (addr, &buf[BUF_SIZE - res], res); + addr = addr + res; + } + +while (info->image_read < offset + size) { + res =xyzModem_stream_read (buf,BUF_SIZE , &err); +if (res <=0 ) +return res; + +memcpy (addr, buf, res); + info->image_read += res; + addr += res; + } + +return size; +} +int spl_ymodem_load_image (void ) {int size =0 ;
@@ -31,30 +76,55 @@ int spl_ymodem_load_image(void)int ret;connection_info_t info;char buf[BUF_SIZE ]; -ulong store_addr = ~0 ;ulong addr =0 ; info.mode = xyzModem_ymodem; ret =xyzModem_stream_open (&info, &err); +if (ret) { +printf ("spl: ymodem err - %s\n" ,xyzModem_error (err)); +return ret; + } + + res =xyzModem_stream_read (buf,BUF_SIZE , &err); +if (res <=0 ) + goto end_stream; + +if (IS_ENABLED (CONFIG_SPL_LOAD_FIT ) && +image_get_magic ((struct image_header *)buf) ==FDT_MAGIC ) { +struct spl_load_info load; +struct ymodem_fit_info info; + +debug ("Found FIT\n" ); + load.dev =NULL ; + load.priv = (void *)&info; + load.filename =NULL ; + load.bl_len =1 ; + info.buf = buf; + info.image_read =BUF_SIZE ; + load.read = ymodem_read_fit; + ret =spl_load_simple_fit (&load,0 , (void *)buf); + size = info.image_read; -if (!ret) { -while ((res = -xyzModem_stream_read (buf,BUF_SIZE , &err)) >0 ) { -if (addr ==0 ) { - ret =spl_parse_image_header ((struct image_header *)buf); -if (ret) -return ret; - } - store_addr = addr + spl_image.load_addr; +while ((res =xyzModem_stream_read (buf,BUF_SIZE , &err)) >0 ) + size += res; + }else { +spl_parse_image_header ((struct image_header *)buf); + ret =spl_parse_image_header ((struct image_header *)buf); +if (ret) +return ret; + addr = spl_image.load_addr; +memcpy ((void *)addr, buf, res); + size += res; + addr += res; + +while ((res =xyzModem_stream_read (buf,BUF_SIZE , &err)) >0 ) { +memcpy ((void *)addr, buf, res); size += res; addr += res; -memcpy ((char *)(store_addr), buf, res); } - }else { -printf ("spl: ymodem err - %s\n" ,xyzModem_error (err)); -return ret; } +end_stream:xyzModem_stream_close (&err);xyzModem_stream_terminate (false, &getcymodem);
Signature · 1 line
2.8.2
PATCH v6 8/8 spl: Add an option to load a FIT containing U-Boot from UART
Quoted 5 lines · Lokesh Vutla
This provides a way to load a FIT containing U-Boot and a selection of device tree files from UART.
Reviewed-by Tom Rini <[email protected]>Signed-off-by Lokesh Vutla <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160530/49961919/attachment.sig>