spl: Lightweight UBI and UBI fastmap support
Subsystems (3)
v3 cover spl: Lightweight UBI and UBI fastmap support
This is yet another update of Thomas's patchset:
https://patchwork.ozlabs.org/patch/367305/
https://patchwork.ozlabs.org/patch/367306/
First patch is just sorting Makefile mtd entries aplhabeticaly and can be applied any time, fourth is an example how to make it work with a real board and leaves some yet unresolved issues.
ladis
PATCH v3 1/4 mtd: Sort subsystem directories aplhabeticaly in Makefile
--- drivers/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/Makefile +2 -2
@@ -18,14 +18,14 @@ obj-$(CONFIG_SYS_MVEBU_DDR_A38X) += ddr/marvell/a38x/ obj-$(CONFIG_SYS_MVEBU_DDR_AXP) += ddr/marvell/axp/ obj-$(CONFIG_ALTERA_SDRAM) += ddr/altera/ obj-$(CONFIG_SPL_SERIAL_SUPPORT) += serial/ -obj-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += mtd/spi/ obj-$(CONFIG_SPL_SPI_SUPPORT) += spi/ obj-$(CONFIG_SPL_POWER_SUPPORT) += power/ power/pmic/ obj-$(CONFIG_SPL_POWER_SUPPORT) += power/regulator/ +obj-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += misc/ obj-$(CONFIG_SPL_MTD_SUPPORT) += mtd/ obj-$(CONFIG_SPL_NAND_SUPPORT) += mtd/nand/ -obj-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += misc/ obj-$(CONFIG_SPL_ONENAND_SUPPORT) += mtd/onenand/ +obj-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += mtd/spi/ obj-$(CONFIG_SPL_DMA_SUPPORT) += dma/ obj-$(CONFIG_SPL_ETH_SUPPORT) += net/ obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
Signature · 1 line
2.1.4
PATCH v3 1/4 mtd: Sort subsystem directories aplhabeticaly in Makefile
Quoted 1 line · Ladislav Michl
Signed-off-by Ladislav Michl <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160112/5467f334/attachment-0001.sig>
PATCH v3 2/4 nand_spl_simple: Add a simple NAND read function
In reply to Ladislav MichlFrom: Thomas Gleixner <[email protected]>
To support UBI in SPL we need a simple NAND read function. Add one to nand_spl_simple and keep it as simple as it goes.
---
Changes in v3:
- Rename nand_spl_read_flash to nand_spl_read_block and optimize it.
drivers/mtd/nand/nand_spl_simple.c | 62 ++++++++++++++++++++++++++++++++++++++ include/nand.h | 1 + 2 files changed, 63 insertions(+)
drivers/mtd/nand/nand_spl_simple.c +62 -0
@@ -209,6 +209,68 @@ static int nand_read_page(int block, int page, void *dst) }#endif +#ifdef CONFIG_SPL_UBI +/* +* Temporary storage for non NAND page aligned and non NAND page sized +* reads. Note: This does not support runtime detected FLASH yet, but +* that should be reasonably easy to fix by making the buffer large +* enough :) +*/ +static u8 scratch_buf[CONFIG_SYS_NAND_PAGE_SIZE ]; + +/** +* nand_spl_read_block - Read data from physical eraseblock into a buffer +* @block: Number of the physical eraseblock +* @offset: Data offset from the start of @peb +* @len: Data size to read +* @dst: Address of the destination buffer +* +* This could be further optimized if we'd have a subpage read +* function in the simple code. On NAND which allows subpage reads +* this would spare quite some time to readout e.g. the VID header of +* UBI. +* +* Notes: +* @offset + @len are not allowed to be larger than a physical +* erase block. No sanity check done for simplicity reasons. +* +* To support runtime detected flash this needs to be extended by +* information about the actual flash geometry, but thats beyond the +* scope of this effort and for most applications where fast boot is +* required it is not an issue anyway. +*/ +int nand_spl_read_block (int block,int offset,int len,void *dst) +{ +int page, read; + +/* Calculate the page number */ + page = offset /CONFIG_SYS_NAND_PAGE_SIZE ; + +/* Offset to the start of a flash page */ + offset = offset %CONFIG_SYS_NAND_PAGE_SIZE ; + +while (len) { +/* +* Non page aligned reads go to the scratch buffer. +* Page aligned reads go directly to the destination. +*/ +if (offset || len <CONFIG_SYS_NAND_PAGE_SIZE ) { +nand_read_page (block, page, scratch_buf); + read =min (len,CONFIG_SYS_NAND_PAGE_SIZE - offset); +memcpy (dst, scratch_buf + offset, read); + offset =0 ; + }else { +nand_read_page (block, page, dst); + read =CONFIG_SYS_NAND_PAGE_SIZE ; + } + page++; + len -= read; + dst += read; + } +return 0 ; +} +#endif +int nand_spl_load_image (uint32_t offs,unsigned int size,void *dst) {unsigned int block, lastblock;
include/nand.h +1 -0
@@ -124,6 +124,7 @@ int nand_unlock(nand_info_t *meminfo, loff_t start, size_t length,int nand_get_lock_status (nand_info_t *meminfo,loff_t offset);int nand_spl_load_image (uint32_t offs,unsigned int size,void *dst); +int nand_spl_read_block (int block,int offset,int len,void *dst);void nand_deselect (void );#ifdef CONFIG_SYS_NAND_SELECT_DEVICE
Signature · 1 line
2.1.4
PATCH v3 2/4 nand_spl_simple: Add a simple NAND read function
Quoted 8 lines · Ladislav Michl
From: Thomas Gleixner <[email protected]>
To support UBI in SPL we need a simple NAND read function. Add one to
nand_spl_simpleand keep it as simple as it goes.Signed-off-by Thomas Gleixner <[email protected]>Signed-off-by Ladislav Michl <[email protected]>Acked-by Scott Wood <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160112/c38b2524/attachment.sig>
PATCH v3 3/4 spl: Lightweight UBI and UBI fastmap support
In reply to Ladislav MichlFrom: Thomas Gleixner <[email protected]>
Booting a payload out of NAND FLASH from the SPL is a crux today, as it requires hard partioned FLASH. Not a brilliant idea with the reliability of todays NAND FLASH chips.
The upstream UBI + UBI fastmap implementation which is about to brought to u-boot is too heavy weight for SPLs as it provides way more functionality than needed for a SPL and does not even fit into the restricted SPL areas which are loaded from the SoC boot ROM.
So this provides a fast and lightweight implementation of UBI scanning and UBI fastmap attach. The scan and logical to physical block mapping code is developed from scratch, while the fastmap implementation is lifted from the linux kernel source and stripped down to fit the SPL needs.
The text foot print on the board which I used for development is:
6854 0 0 6854 1abddrivers/mtd/ubispl/built-in.o
Attaching a NAND chip with 4096 physical eraseblocks (4 blocks are reserved for the SPL) takes:
In full scan mode: 1172ms In fastmap mode: 95ms
The code requires quite some storage. The largest and unknown part of it is the number of fastmap blocks to read. Therefor the data structure is not put into the BSS. The code requires a pointer to free memory handed in which is initialized by the UBI attach code itself.
See doc/README.ubispl for further information on how to use it.
This shares the ubi-media.h and crc32 implementation of drivers/mtd/ubi There is no way to share the fastmap code, as UBISPL only utilizes the slightly modified functions ubi_attach_fastmap() and ubi_scan_fastmap() from the original kernel ubi fastmap implementation.
---
Changes in v2:
- fixes ubi_calc_fm_size to include also sizeof(struct ubi_fm_sb)
- dropped private copy of ubi-media.h
- ubi-wrapper.h now contains only needed definitions from ubi.h and ubi-user.h
- used return values from errno.h
Changes in v3:
- move vol_id check to ubi_scan_vid_hdr to verify it has meaningfull value
before testing ubi->toload
- fixed checkpatch errors except those present also in linux code
README | 4 + doc/README.ubispl | 143 ++++++ drivers/Makefile | 1 + drivers/mtd/ubispl/Makefile | 1 + drivers/mtd/ubispl/ubi-wrapper.h | 106 +++++ drivers/mtd/ubispl/ubispl.c | 926 +++++++++++++++++++++++++++++++++++++++ drivers/mtd/ubispl/ubispl.h | 136 ++++++ include/ubispl.h | 92 ++++ 8 files changed, 1409 insertions(+) create mode 100644 doc/README.ubispl create mode 100644 drivers/mtd/ubispl/Makefile create mode 100644 drivers/mtd/ubispl/ubi-wrapper.h create mode 100644 drivers/mtd/ubispl/ubispl.c create mode 100644 drivers/mtd/ubispl/ubispl.h create mode 100644 include/ubispl.h
README +4 -0
@@ -3654,6 +3654,10 @@ FIT uImage format: Support for NAND boot using simple NAND drivers that expose the cmd_ctrl() interface. + CONFIG_SPL_UBI + Support for a lightweight UBI (fastmap) scanner and + loader + CONFIG_SPL_MTD_SUPPORT Support for the MTD subsystem within SPL. Useful for environment on NAND support within SPL.
doc/README.ubispl new file +143 -0
143 lines not on this page · raw message
drivers/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_SPL_MTD_SUPPORT) += mtd/ obj-$(CONFIG_SPL_NAND_SUPPORT) += mtd/nand/ obj-$(CONFIG_SPL_ONENAND_SUPPORT) += mtd/onenand/ obj-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += mtd/spi/ +obj-$(CONFIG_SPL_UBI) += mtd/ubispl/ obj-$(CONFIG_SPL_DMA_SUPPORT) += dma/ obj-$(CONFIG_SPL_ETH_SUPPORT) += net/ obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
drivers/mtd/ubispl/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += ubispl.o ../ubi/crc32.o
drivers/mtd/ubispl/ubi-wrapper.h new file +106 -0
106 lines not on this page · raw message
drivers/mtd/ubispl/ubispl.c new file +926 -0
926 lines not on this page · raw message
drivers/mtd/ubispl/ubispl.h new file +136 -0
136 lines not on this page · raw message
include/ubispl.h new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v3 3/4 spl: Lightweight UBI and UBI fastmap support
Hello Ladislav,
Am 11.01.2016 um 00:17 schrieb Ladislav Michl:
Quoted 51 lines
From: Thomas Gleixner <[email protected]>
Booting a payload out of NAND FLASH from the SPL is a crux today, as it requires hard partioned FLASH. Not a brilliant idea with the reliability of todays NAND FLASH chips.
The upstream UBI + UBI fastmap implementation which is about to brought to u-boot is too heavy weight for SPLs as it provides way more functionality than needed for a SPL and does not even fit into the restricted SPL areas which are loaded from the SoC boot ROM.
So this provides a fast and lightweight implementation of UBI scanning and UBI fastmap attach. The scan and logical to physical block mapping code is developed from scratch, while the fastmap implementation is lifted from the linux kernel source and stripped down to fit the SPL needs.
The text foot print on the board which I used for development is:
6854 0 0 6854 1abd
drivers/mtd/ubispl/built-in.oAttaching a NAND chip with 4096 physical eraseblocks (4 blocks are reserved for the SPL) takes:
In full scan mode: 1172ms In fastmap mode: 95msThe code requires quite some storage. The largest and unknown part of it is the number of fastmap blocks to read. Therefor the data structure is not put into the BSS. The code requires a pointer to free memory handed in which is initialized by the UBI attach code itself.
See doc/README.ubispl for further information on how to use it.
This shares the
ubi-media.hand crc32 implementation ofdrivers/mtd/ubiThere is no way to share the fastmap code, as UBISPL only utilizes the slightly modified functionsubi_attach_fastmap()andubi_scan_fastmap()from the original kernel ubi fastmap implementation.Signed-off-by Thomas Gleixner <[email protected]>Signed-off-by Ladislav Michl <[email protected]>---
Changes in v2:
- fixesubi_calc_fm_sizeto include alsosizeof(struct ubi_fm_sb)
- dropped private copy ofubi-media.h
-ubi-wrapper.hnow contains only needed definitions fromubi.handubi-user.h
- used return values fromerrno.h
Quoted 4 lines
Changes in v3:
- movevol_idcheck toubi_scan_vid_hdrto verify it has meaningfull valuebefore testing ubi->toload- fixed checkpatch errors except those present also in linux code
Thanks! Patch applies now ;-)
Quoted 10 lines
README | 4 + doc/README.ubispl | 143 ++++++ drivers/Makefile | 1 + drivers/mtd/ubispl/Makefile | 1 + drivers/mtd/ubispl/ubi-wrapper.h | 106 +++++ drivers/mtd/ubispl/ubispl.c | 926 +++++++++++++++++++++++++++++++++++++++ drivers/mtd/ubispl/ubispl.h | 136 ++++++ include/ubispl.h | 92 ++++ 8 files changed, 1409 insertions(+)
Quoted 6 lines
create mode 100644 doc/README.ubispl
create mode 100644drivers/mtd/ubispl/Makefilecreate mode 100644drivers/mtd/ubispl/ubi-wrapper.hcreate mode 100644drivers/mtd/ubispl/ubispl.ccreate mode 100644drivers/mtd/ubispl/ubispl.hcreate mode 100644include/ubispl.h
Only 2 nitpicks
[...]
Quoted 6 lines
drivers/mtd/ubispl/ubispl.c new file +0
-0@@ -0,0 +1,926 @@
[...]
Quoted 181 lines
drivers/mtd/ubispl/ubispl.c new file +181
-0+static int ubi_attach_fastmap (struct ubi_scan_info *ubi, +struct ubi_attach_info *ai, +struct ubi_fastmap_layout *fm) +{ +struct ubi_fm_hdr *fmhdr; +struct ubi_fm_scan_pool *fmpl1, *fmpl2; +struct ubi_fm_ec *fmec; +struct ubi_fm_volhdr *fmvhdr; +struct ubi_fm_eba *fm_eba; +int ret, i, j, pool_size, wl_pool_size; +size_t fm_pos =0 , fm_size = ubi->fm_size; +void *fm_raw = ubi->fm_buf; + +memset (ubi->fm_used,0 ,sizeof (ubi->fm_used)); + + fm_pos +=sizeof (struct ubi_fm_sb ); +if (fm_pos >= fm_size) + goto fail_bad; + + fmhdr = (struct ubi_fm_hdr *)(fm_raw + fm_pos); + fm_pos +=sizeof (*fmhdr); +if (fm_pos >= fm_size) + goto fail_bad; + +if (be32_to_cpu (fmhdr->magic) !=UBI_FM_HDR_MAGIC ) { +ubi_err ("bad fastmap header magic: 0x%x, expected: 0x%x" , +be32_to_cpu (fmhdr->magic),UBI_FM_HDR_MAGIC ); + goto fail_bad; + } + + fmpl1 = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos); + fm_pos +=sizeof (*fmpl1); +if (fm_pos >= fm_size) + goto fail_bad; +if (be32_to_cpu (fmpl1->magic) !=UBI_FM_POOL_MAGIC ) { +ubi_err ("bad fastmap pool magic: 0x%x, expected: 0x%x" , +be32_to_cpu (fmpl1->magic),UBI_FM_POOL_MAGIC ); + goto fail_bad; + } + + fmpl2 = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos); + fm_pos +=sizeof (*fmpl2); +if (fm_pos >= fm_size) + goto fail_bad; +if (be32_to_cpu (fmpl2->magic) !=UBI_FM_POOL_MAGIC ) { +ubi_err ("bad fastmap pool magic: 0x%x, expected: 0x%x" , +be32_to_cpu (fmpl2->magic),UBI_FM_POOL_MAGIC ); + goto fail_bad; + } + + pool_size =be16_to_cpu (fmpl1->size); + wl_pool_size =be16_to_cpu (fmpl2->size); + fm->max_pool_size =be16_to_cpu (fmpl1->max_size); + fm->max_wl_pool_size =be16_to_cpu (fmpl2->max_size); + +if (pool_size >UBI_FM_MAX_POOL_SIZE || pool_size <0 ) { +ubi_err ("bad pool size: %i" , pool_size); + goto fail_bad; + } + +if (wl_pool_size >UBI_FM_MAX_POOL_SIZE || wl_pool_size <0 ) { +ubi_err ("bad WL pool size: %i" , wl_pool_size); + goto fail_bad; + } + +if (fm->max_pool_size >UBI_FM_MAX_POOL_SIZE || + fm->max_pool_size <0 ) { +ubi_err ("bad maximal pool size: %i" , fm->max_pool_size); + goto fail_bad; + } + +if (fm->max_wl_pool_size >UBI_FM_MAX_POOL_SIZE || + fm->max_wl_pool_size <0 ) { +ubi_err ("bad maximal WL pool size: %i" , fm->max_wl_pool_size); + goto fail_bad; + } + +/* read EC values from free list */ +for (i =0 ; i <be32_to_cpu (fmhdr->free_peb_count); i++) { + fmec = (struct ubi_fm_ec *)(fm_raw + fm_pos); + fm_pos +=sizeof (*fmec); +if (fm_pos >= fm_size) + goto fail_bad; + } + +/* read EC values from used list */ +for (i =0 ; i <be32_to_cpu (fmhdr->used_peb_count); i++) { + fmec = (struct ubi_fm_ec *)(fm_raw + fm_pos); + fm_pos +=sizeof (*fmec); +if (fm_pos >= fm_size) + goto fail_bad; + +generic_set_bit (be32_to_cpu (fmec->pnum), ubi->fm_used); + } + +/* read EC values from scrub list */ +for (i =0 ; i <be32_to_cpu (fmhdr->scrub_peb_count); i++) { + fmec = (struct ubi_fm_ec *)(fm_raw + fm_pos); + fm_pos +=sizeof (*fmec); +if (fm_pos >= fm_size) + goto fail_bad; + } + +/* read EC values from erase list */ +for (i =0 ; i <be32_to_cpu (fmhdr->erase_peb_count); i++) { + fmec = (struct ubi_fm_ec *)(fm_raw + fm_pos); + fm_pos +=sizeof (*fmec); +if (fm_pos >= fm_size) + goto fail_bad; + } + +/* Iterate over all volumes and read their EBA table */ +for (i =0 ; i <be32_to_cpu (fmhdr->vol_count); i++) { +u32 vol_id, vol_type, used, reserved; + + fmvhdr = (struct ubi_fm_volhdr *)(fm_raw + fm_pos); + fm_pos +=sizeof (*fmvhdr); +if (fm_pos >= fm_size) + goto fail_bad; + +if (be32_to_cpu (fmvhdr->magic) !=UBI_FM_VHDR_MAGIC ) { +ubi_err ("bad fastmap vol header magic: 0x%x, " \ +"expected: 0x%x" , +be32_to_cpu (fmvhdr->magic),UBI_FM_VHDR_MAGIC ); + goto fail_bad; + } + + vol_id =be32_to_cpu (fmvhdr->vol_id); + vol_type = fmvhdr->vol_type; + used =be32_to_cpu (fmvhdr->used_ebs); + + fm_eba = (struct ubi_fm_eba *)(fm_raw + fm_pos); + fm_pos +=sizeof (*fm_eba); + fm_pos += (sizeof (__be32) *be32_to_cpu (fm_eba->reserved_pebs)); +if (fm_pos >= fm_size) + goto fail_bad; + +if (be32_to_cpu (fm_eba->magic) !=UBI_FM_EBA_MAGIC ) { +ubi_err ("bad fastmap EBA header magic: 0x%x, " \ +"expected: 0x%x" , +be32_to_cpu (fm_eba->magic),UBI_FM_EBA_MAGIC ); + goto fail_bad; + } + + reserved =be32_to_cpu (fm_eba->reserved_pebs); +ubi_dbg ("FA: vol %u used %u res: %u" , vol_id, used, reserved); +for (j =0 ; j < reserved; j++) { +int pnum =be32_to_cpu (fm_eba->pnum[j]); + +if ((int )be32_to_cpu (fm_eba->pnum[j]) <0 ) +continue ; + +if (!__test_and_clear_bit (pnum, ubi->fm_used)) +continue ; + +/* +* We only handle static volumes so used_ebs +* needs to be handed in. And we do not assign +* the reserved blocks +*/ +if (j >= used) +continue ; + + ret =assign_aeb_to_av (ubi, pnum, j, vol_id, + vol_type, used); +if (!ret) +continue ; + +/* +* Nasty: The fastmap claims that the volume +* has one block more than it, but that block +* is always empty and the other blocks have +* the correct number of total LEBs in the +* headers. Deal with it. +*/ +if (ret !=UBI_IO_FF && j != used -1 ) + goto fail_bad; +ubi_dbg ("FA: Vol: %u Ignoring empty LEB %d of %d" , + vol_id, j, used); + } + }
drivers/mtd/ubispl/ubispl.c line 472
Quoted 10 lines
drivers/mtd/ubispl/ubispl.c new file +10
-0+ + ret =scan_pool (ubi, fmpl1->pebs, pool_size); +if (ret) + goto fail; + + ret =scan_pool (ubi, fmpl2->pebs, wl_pool_size); +if (ret) + goto fail; + +#ifdef CHECKME
What means this?
Quoted 70 lines
drivers/mtd/ubispl/ubispl.c new file +70
-0+/* +* If fastmap is leaking PEBs (must not happen), raise a +* fat warning and fall back to scanning mode. +* We do this here because in ubi_wl_init() it's too late +* and we cannot fall back to scanning. +*/ +if (WARN_ON (count_fastmap_pebs (ai) != ubi->peb_count - + ai->bad_peb_count - fm->used_blocks)) + goto fail_bad; +#endif + +return 0 ; + +fail_bad: + ret =UBI_BAD_FASTMAP ; +fail: +return ret; +} + +static int ubi_scan_fastmap (struct ubi_scan_info *ubi, +struct ubi_attach_info *ai, +int fm_anchor) +{ +struct ubi_fm_sb *fmsb, *fmsb2; +struct ubi_vid_hdr *vh; +struct ubi_fastmap_layout *fm; +int i, used_blocks, pnum, ret =0 ; +size_t fm_size; +__be32 crc, tmp_crc; +unsigned long long sqnum =0 ; + + fmsb = &ubi->fm_sb; + fm = &ubi->fm_layout; + + ret =ubi_io_read (ubi, fmsb, fm_anchor, ubi->leb_start,sizeof (*fmsb)); +if (ret && ret !=UBI_IO_BITFLIPS ) + goto free_fm_sb; +else if (ret ==UBI_IO_BITFLIPS ) + fm->to_be_tortured[0 ] =1 ; + +if (be32_to_cpu (fmsb->magic) !=UBI_FM_SB_MAGIC ) { +ubi_err ("bad super block magic: 0x%x, expected: 0x%x" , +be32_to_cpu (fmsb->magic),UBI_FM_SB_MAGIC ); + ret =UBI_BAD_FASTMAP ; + goto free_fm_sb; + } + +if (fmsb->version !=UBI_FM_FMT_VERSION ) { +ubi_err ("bad fastmap version: %i, expected: %i" , + fmsb->version,UBI_FM_FMT_VERSION ); + ret =UBI_BAD_FASTMAP ; + goto free_fm_sb; + } + + used_blocks =be32_to_cpu (fmsb->used_blocks); +if (used_blocks >UBI_FM_MAX_BLOCKS || used_blocks <1 ) { +ubi_err ("number of fastmap blocks is invalid: %i" , used_blocks); + ret =UBI_BAD_FASTMAP ; + goto free_fm_sb; + } + + fm_size = ubi->leb_size * used_blocks; +if (fm_size != ubi->fm_size) { +ubi_err ("bad fastmap size: %zi, expected: %zi" , fm_size, + ubi->fm_size); + ret =UBI_BAD_FASTMAP ; + goto free_fm_sb; + } + + vh = &ubi->fm_vh;
drivers/mtd/ubispl/ubispl.c line 552
Quoted 10 lines
drivers/mtd/ubispl/ubispl.c new file +10
-0+ +for (i =0 ; i < used_blocks; i++) { + pnum =be32_to_cpu (fmsb->block_loc[i]); + +if (ubi_io_is_bad (ubi, pnum)) { + ret =UBI_BAD_FASTMAP ; + goto free_hdr; + } + +#ifdef LATER
Here to ... what means this?
Quoted 15 lines
drivers/mtd/ubispl/ubispl.c new file +15
-0+int image_seq; + ret =ubi_io_read_ec_hdr (ubi, pnum, ech,0 ); +if (ret && ret !=UBI_IO_BITFLIPS ) { +ubi_err ("unable to read fastmap block# %i EC (PEB: %i)" , + i, pnum); +if (ret >0 ) + ret =UBI_BAD_FASTMAP ; + goto free_hdr; + }else if (ret ==UBI_IO_BITFLIPS ) + fm->to_be_tortured[i] =1 ; + + image_seq =be32_to_cpu (ech->image_seq); +if (!ubi->image_seq) + ubi->image_seq = image_seq; +/*
drivers/mtd/ubispl/ubispl.c line 577
Quoted 10 lines
drivers/mtd/ubispl/ubispl.c new file +10
-0+* Older UBI implementations have image_seq set to zero, so +* we shouldn't fail if image_seq == 0. +*/ +if (image_seq && (image_seq != ubi->image_seq)) { +ubi_err ("wrong image seq:%d instead of %d" , +be32_to_cpu (ech->image_seq), ubi->image_seq); + ret =UBI_BAD_FASTMAP ; + goto free_hdr; + } +#endif
Beside of this:
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v3 3/4 spl: Lightweight UBI and UBI fastmap support
In reply to Ladislav MichlQuoted 35 lines · Ladislav Michl
From: Thomas Gleixner <[email protected]>
Booting a payload out of NAND FLASH from the SPL is a crux today, as it requires hard partioned FLASH. Not a brilliant idea with the reliability of todays NAND FLASH chips.
The upstream UBI + UBI fastmap implementation which is about to brought to u-boot is too heavy weight for SPLs as it provides way more functionality than needed for a SPL and does not even fit into the restricted SPL areas which are loaded from the SoC boot ROM.
So this provides a fast and lightweight implementation of UBI scanning and UBI fastmap attach. The scan and logical to physical block mapping code is developed from scratch, while the fastmap implementation is lifted from the linux kernel source and stripped down to fit the SPL needs.
The text foot print on the board which I used for development is:
6854 0 0 6854 1abd
drivers/mtd/ubispl/built-in.oAttaching a NAND chip with 4096 physical eraseblocks (4 blocks are reserved for the SPL) takes:
In full scan mode: 1172ms In fastmap mode: 95msThe code requires quite some storage. The largest and unknown part of it is the number of fastmap blocks to read. Therefor the data structure is not put into the BSS. The code requires a pointer to free memory handed in which is initialized by the UBI attach code itself.
See doc/README.ubispl for further information on how to use it.
Quoted 7 lines
This shares the
ubi-media.hand crc32 implementation ofdrivers/mtd/ubiThere is no way to share the fastmap code, as UBISPL only utilizes the slightly modified functionsubi_attach_fastmap()andubi_scan_fastmap()from the original kernel ubi fastmap implementation.Signed-off-by Thomas Gleixner <[email protected]>Signed-off-by Ladislav Michl <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160112/39a9a5d7/attachment.sig>
PATCH v3 4/4 igep00x0: UBIize
In reply to Ladislav MichlThis patch converts IGEP board to use UBI volumes for environment, u-boot, kernel... With exception of first four sectors read by SoC boot ROM whole NAND is UBI managed. Code is too big, so I dropped CONFIG_SPL_EXT_SUPPORT to make it fit. It is meant more likely as a test of Thomas' patch, so more people can play with that.
--- board/isee/igep00x0/igep00x0.c | 76 +++++++++++++++++++++++++++++++++++++++ common/spl/Makefile | 5 ++- common/spl/spl.c | 13 +++++++ common/spl/spl_ubi.c | 36 +++++++++++++++++++ include/configs/omap3_igep00x0.h | 64 +++++++++++++++------------------ include/configs/ti_armv7_common.h | 1 - include/spl.h | 4 +++ 7 files changed, 162 insertions(+), 37 deletions(-) create mode 100644 common/spl/spl_ubi.c
board/isee/igep00x0/igep00x0.c +76 -0
@@ -10,6 +10,9 @@#include <ns16550.h> #include <twl4030.h> #include <netdev.h> +#include <nand.h> +#include <ubispl.h> +#include <spl.h> #include <asm/gpio.h> #include <asm/io.h> #include <asm/arch/mem.h>
@@ -212,3 +215,76 @@ int board_eth_init(bd_t *bis)#endif }#endif + +#undef CONFIG_SPL_OS_BOOT + +#ifdef CONFIG_SPL_BUILD +#ifdef CONFIG_SPL_OS_BOOT +int spl_start_uboot (void ) +{ +/* break into full u-boot on 'c' */ +if (serial_tstc () &&serial_getc () =='c' ) +return 1 ; + +return 0 ; +} + +static void spl_set_header_linux (void ) +{ + spl_image.size =3 *1024 *1024 ; + spl_image.entry_point =0x82000000 ; + spl_image.load_addr =0x82000000 ; + spl_image.os =IH_OS_LINUX ; + spl_image.name ="Linux" ; +} +#endif + +int spl_board_ubi_load_image (u32 boot_device) +{ +int ret; +struct image_header *header; +struct ubispl_info info; +struct ubispl_load volumes[2 ]; + + info.ubi = (struct ubi_scan_info *) + (CONFIG_SYS_SPL_MALLOC_START +CONFIG_SYS_SPL_MALLOC_SIZE ); + info.fastmap =1 ; + info.read = nand_spl_read_block; + + info.peb_offset =4 ; + info.peb_size =CONFIG_SYS_NAND_BLOCK_SIZE ; + info.vid_offset =512 ; + info.leb_start =2048 ; + info.peb_count =4096 - info.peb_offset; + +#ifdef CONFIG_SPL_OS_BOOT +if (!spl_start_uboot ()) { + volumes[0 ].name ="kernel" ; + volumes[0 ].vol_id =3 ; + volumes[0 ].load_addr = (void *)0x82000000 ; + volumes[1 ].name ="dtb" ; + volumes[1 ].vol_id =4 ; + volumes[1 ].load_addr = (void *)0x88000000 ; + + ret =ubispl_load_volumes (&info, volumes,2 ); +if (!ret) { +puts ("Linux loaded.\n" ); +spl_set_header_linux (); +return 0 ; + } +puts ("Loading Linux failed, falling back to U-Boot.\n" ); + } +#endif + header = (struct image_header *) + (CONFIG_SYS_TEXT_BASE -sizeof (struct image_header )); + volumes[0 ].name ="loader" ; + volumes[0 ].vol_id =0 ; + volumes[0 ].load_addr = (void *)header; + + ret =ubispl_load_volumes (&info, volumes,1 ); +if (!ret) +spl_parse_image_header (header); + +return ret; +} +#endif
common/spl/Makefile +4 -1
@@ -10,10 +10,13 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_FRAMEWORK) += spl.o -obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o +ifndef CONFIG_SPL_UBI +obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o obj-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o +endif +obj-$(CONFIG_SPL_UBI) += spl_ubi.o obj-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o obj-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o
common/spl/spl.c +13 -0
@@ -286,6 +286,18 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_MMC2_2 :return spl_mmc_load_image (boot_device);#endif +#ifdef CONFIG_SPL_UBI +#ifdef CONFIG_SPL_NAND_SUPPORT +case BOOT_DEVICE_NAND : +#endif +#ifdef CONFIG_SPL_ONENAND_SUPPORT +case BOOT_DEVICE_ONENAND : +#endif +#ifdef CONFIG_SPL_NOR_SUPPORT +case BOOT_DEVICE_NOR : +#endif +return spl_ubi_load_image (boot_device); +#else #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND :return spl_nand_load_image ();
@@ -298,6 +310,7 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_NOR :return spl_nor_load_image ();#endif +#endif /* CONFIG_SPL_UBI */ #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART :return spl_ymodem_load_image ();
common/spl/spl_ubi.c new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright (C) 2016 +* Ladislav Michl <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +#include <common.h> +#include <config.h> +#include <spl.h> +#include <asm/io.h> +#include <nand.h> + +__weak int spl_board_ubi_load_image (u32 boot_device) +{ +return -EINVAL ; +} + +int spl_ubi_load_image (u32 boot_device) +{ +int ret; + +#ifdef CONFIG_SPL_NAND_SUPPORT +if (boot_device ==BOOT_DEVICE_NAND ) +nand_init (); +#endif + + ret =spl_board_ubi_load_image (boot_device); + +#ifdef CONFIG_SPL_NAND_SUPPORT +if (boot_device ==BOOT_DEVICE_NAND ) +nand_deselect (); +#endif + +return ret; +} +
include/configs/omap3_igep00x0.h +29 -35
110 lines not on this page · raw message
include/configs/ti_armv7_common.h +0 -1
@@ -232,7 +232,6 @@#define CONFIG_SPL_LIBDISK_SUPPORT #define CONFIG_SPL_MMC_SUPPORT #define CONFIG_SPL_FAT_SUPPORT -#define CONFIG_SPL_EXT_SUPPORT #endif #define CONFIG_SYS_THUMB_BUILD
include/spl.h +4 -0
@@ -40,6 +40,7 @@ u32 spl_boot_mode(void);void spl_set_header_raw_uboot (void );void spl_parse_image_header (const struct image_header *header);void spl_board_prepare_for_linux (void ); +int spl_board_ubi_load_image (u32 boot_device);void __noreturn jump_to_image_linux (void *arg);int spl_start_uboot (void );void spl_display_print (void );
@@ -53,6 +54,9 @@ int spl_onenand_load_image(void);/* NOR SPL functions */ int spl_nor_load_image (void ); +/* UBI SPL functions */ +int spl_ubi_load_image (u32 boot_device); +/* MMC SPL functions */ int spl_mmc_load_image (u32 boot_device);
Signature · 1 line
2.1.4
PATCH v3 4/4 igep00x0: UBIize
Hello Ladislav,
Am 11.01.2016 um 00:18 schrieb Ladislav Michl:
Quoted 16 lines
This patch converts IGEP board to use UBI volumes for environment, u-boot, kernel... With exception of first four sectors read by SoC boot ROM whole NAND is UBI managed. Code is too big, so I dropped
CONFIG_SPL_EXT_SUPPORTto make it fit. It is meant more likely as a test of Thomas' patch, so more people can play with that.Signed-off-by Ladislav Michl <[email protected]>--- board/isee/igep00x0/igep00x0.c | 76 +++++++++++++++++++++++++++++++++++++++ common/spl/Makefile | 5 ++- common/spl/spl.c | 13 +++++++ common/spl/spl_ubi.c | 36 +++++++++++++++++++ include/configs/omap3_igep00x0.h | 64 +++++++++++++++------------------ include/configs/ti_armv7_common.h | 1 - include/spl.h | 4 +++ 7 files changed, 162 insertions(+), 37 deletions(-)
Quoted 1 line
create mode 100644
common/spl/spl_ubi.c
Could you seperate common changes in "common/*" and your special board changes?
Beside of that, this patch does not apply ...
pollux:u-boot-smartweb hs [master] $ git am mbox
Wende an: igep00x0: UBIize
error: Anwendung des Patches fehlgeschlagen: board/isee/igep00x0/igep00x0.c:212
error: board/isee/igep00x0/igep00x0.c: Patch konnte nicht angewendet werden /work/hs/tbot/u-boot-smartweb/.git/rebase-apply/patch:194: new blank line at EOF. +
error: Anwendung des Patches fehlgeschlagen: include/configs/omap3_igep00x0.h:77
error: include/configs/omap3_igep00x0.h: Patch konnte nicht angewendet werden Anwendung des Patches fehlgeschlagen bei 0001 igep00x0: UBIize
Die Kopie des fehlgeschlagenen Patches befindet sich in:
/work/hs/tbot/u-boot-smartweb/.git/rebase-apply/patch
Wenn Sie das Problem gel?st haben, f?hren Sie "git am --continue" aus. Falls Sie diesen Patch auslassen m?chten, f?hren Sie stattdessen "git am --skip" aus.
Um den urspr?nglichen Branch wiederherzustellen und die Anwendung der Patches abzubrechen, f?hren Sie "git am --abort" aus. pollux:u-boot-smartweb hs [master] $ git am --abort
"git am -3 mbox" fails also ...
I used as base:
commit e6c516a973dff2718488d065d859bcfe64fb05aa
Merge: d77a092 b5e7c1e
Author: Tom Rini <[email protected]>
Date: Sun Jan 10 09:17:52 2016 -0500
Merge branch 'master' of git://www.denx.de/git/u-boot-imx
With the "patch" command it works:
pollux:u-boot-smartweb hs [master] $ patch -p1 < mbox patching file board/isee/igep00x0/igep00x0.c Hunk #2 succeeded at 210 with fuzz 1 (offset -5 lines). patching file common/spl/Makefile
patching file common/spl/spl.c
patching file common/spl/spl_ubi.c
patching file include/configs/omap3_igep00x0.h Hunk #1 succeeded at 80 with fuzz 2 (offset 3 lines). Hunk #2 succeeded at 94 (offset 7 lines).
Hunk #3 succeeded at 108 (offset 7 lines). Hunk #4 succeeded at 125 with fuzz 1 (offset 7 lines). Hunk #5 succeeded@175 (offset 7 lines). patching file include/configs/ti_armv7_common.h patching file include/spl.h pollux:u-boot-smartweb hs [master] $
Do you have local changes in "include/configs/omap3_igep00x0.h" ?
Quoted 58 lines
board/isee/igep00x0/igep00x0.c +43
-0@@ -10,6 +10,9 @@#include <ns16550.h> #include <twl4030.h> #include <netdev.h> +#include <nand.h> +#include <ubispl.h> +#include <spl.h> #include <asm/gpio.h> #include <asm/io.h> #include <asm/arch/mem.h> @@ -212,3 +215,76 @@ int board_eth_init(bd_t *bis)#endif }#endif + +#undef CONFIG_SPL_OS_BOOT + +#ifdef CONFIG_SPL_BUILD +#ifdef CONFIG_SPL_OS_BOOT +int spl_start_uboot (void ) +{ +/* break into full u-boot on 'c' */ +if (serial_tstc () &&serial_getc () =='c' ) +return 1 ; + +return 0 ; +} + +static void spl_set_header_linux (void ) +{ + spl_image.size =3 *1024 *1024 ; + spl_image.entry_point =0x82000000 ; + spl_image.load_addr =0x82000000 ; + spl_image.os =IH_OS_LINUX ; + spl_image.name ="Linux" ; +} +#endif + +int spl_board_ubi_load_image (u32 boot_device) +{ +int ret; +struct image_header *header; +struct ubispl_info info; +struct ubispl_load volumes[2 ]; + + info.ubi = (struct ubi_scan_info *) + (CONFIG_SYS_SPL_MALLOC_START +CONFIG_SYS_SPL_MALLOC_SIZE ); + info.fastmap =1 ; + info.read = nand_spl_read_block; + + info.peb_offset =4 ; + info.peb_size =CONFIG_SYS_NAND_BLOCK_SIZE ; + info.vid_offset =512 ; + info.leb_start =2048 ;
board/isee/igep00x0/igep00x0.c int board_eth_init(bd_t *bis) · line 267
Quoted 10 lines
board/isee/igep00x0/igep00x0.c +10
-0+ info.peb_count =4096 - info.peb_offset; + +#ifdef CONFIG_SPL_OS_BOOT +if (!spl_start_uboot ()) { + volumes[0 ].name ="kernel" ; + volumes[0 ].vol_id =3 ; + volumes[0 ].load_addr = (void *)0x82000000 ; + volumes[1 ].name ="dtb" ; + volumes[1 ].vol_id =4 ; + volumes[1 ].load_addr = (void *)0x88000000 ;
Maybe you would use defines here instead hardcoded numbers?
Quoted 51 lines
board/isee/igep00x0/igep00x0.c +23
-0+ + ret =ubispl_load_volumes (&info, volumes,2 ); +if (!ret) { +puts ("Linux loaded.\n" ); +spl_set_header_linux (); +return 0 ; + } +puts ("Loading Linux failed, falling back to U-Boot.\n" ); + } +#endif + header = (struct image_header *) + (CONFIG_SYS_TEXT_BASE -sizeof (struct image_header )); + volumes[0 ].name ="loader" ; + volumes[0 ].vol_id =0 ; + volumes[0 ].load_addr = (void *)header; + + ret =ubispl_load_volumes (&info, volumes,1 ); +if (!ret) +spl_parse_image_header (header); + +return ret; +} +#endif common/spl/Makefile +4
-1@@ -10,10 +10,13 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_FRAMEWORK) += spl.o -obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o +ifndef CONFIG_SPL_UBI +obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o obj-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o +endif +obj-$(CONFIG_SPL_UBI) += spl_ubi.o obj-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o obj-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.ocommon/spl/spl.c +1
-0@@ -286,6 +286,18 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_MMC2_2 :return spl_mmc_load_image (boot_device);#endif +#ifdef CONFIG_SPL_UBI
common/spl/spl.c static int spl_load_image(u32 boot_device) · line 299
Quoted 10 lines
common/spl/spl.c +10
-0+#ifdef CONFIG_SPL_NAND_SUPPORT +case BOOT_DEVICE_NAND : +#endif +#ifdef CONFIG_SPL_ONENAND_SUPPORT +case BOOT_DEVICE_ONENAND : +#endif +#ifdef CONFIG_SPL_NOR_SUPPORT +case BOOT_DEVICE_NOR : +#endif +return spl_ubi_load_image (boot_device);
I am unsure here if we should disable raw nor read complete when enabling UBISPL, but this is maybe a theoretical case, so this is OK for me. If someone needs it we can change this here later.
Quoted 199 lines
common/spl/spl.c +2
-0+#else #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND :return spl_nand_load_image ();@@ -298,6 +310,7 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_NOR :return spl_nor_load_image ();#endif +#endif /* CONFIG_SPL_UBI */ #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART :return spl_ymodem_load_image ();common/spl/spl_ubi.c new file +36
-0@@ -0,0 +1,36 @@ +/* +* Copyright (C) 2016 +* Ladislav Michl <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +#include <common.h> +#include <config.h> +#include <spl.h> +#include <asm/io.h> +#include <nand.h> + +__weak int spl_board_ubi_load_image (u32 boot_device) +{ +return -EINVAL ; +} + +int spl_ubi_load_image (u32 boot_device) +{ +int ret; + +#ifdef CONFIG_SPL_NAND_SUPPORT +if (boot_device ==BOOT_DEVICE_NAND ) +nand_init (); +#endif + + ret =spl_board_ubi_load_image (boot_device); + +#ifdef CONFIG_SPL_NAND_SUPPORT +if (boot_device ==BOOT_DEVICE_NAND ) +nand_deselect (); +#endif + +return ret; +} +include/configs/omap3_igep00x0.h +29
-35@@ -77,6 +77,7 @@#endif #define CONFIG_CMD_DHCP #define CONFIG_CMD_PING +#define CONFIG_CMD_UBI #ifndef CONFIG_SPL_BUILD @@ -86,6 +87,10 @@"stdout=serial\0" \ "stderr=serial\0" +#define ENV_MTD_SETTINGS \ + "mtdids=nand0=gpmc-nand.0\0" \ + "mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0" +#define MEM_LAYOUT_SETTINGS \ DEFAULT_LINUX_BOOT_ENV \ "scriptaddr=0x87E00000\0" \@@ -96,36 +101,15 @@#include <config_distro_bootcmd.h> -#define CONFIG_EXTRA_ENV_SETTINGS \ ENV_DEVICE_SETTINGS \ + ENV_MTD_SETTINGS \ MEM_LAYOUT_SETTINGS \ BOOTENV#endif /* -* FLASH and environment organization -*/ - -#ifdef CONFIG_BOOT_ONENAND -#define CONFIG_SYS_ONENAND_BASE ONENAND_MAP - -#define ONENAND_ENV_OFFSET 0x260000/* environment starts here */ - -#define CONFIG_ENV_IS_IN_ONENAND 1 -#define CONFIG_ENV_SIZE (512 << 10)/* Total Size Environment */ -#define CONFIG_ENV_ADDR ONENAND_ENV_OFFSET -#endif - -#ifdef CONFIG_NAND -#define CONFIG_ENV_OFFSET 0x260000/* environment starts here */ -#define CONFIG_ENV_IS_IN_NAND 1 -#define CONFIG_ENV_SIZE (512 << 10)/* Total Size Environment */ -#define CONFIG_ENV_ADDR NAND_ENV_OFFSET -#endif - -/* * SMSC911x Ethernet */ #if defined(CONFIG_CMD_NET )@@ -134,19 +118,37 @@#define CONFIG_SMC911X_BASE 0x2C000000#endif /* (CONFIG_CMD_NET) */ +/* +* FLASH and environment organization +*/ +#define CONFIG_SPL_UBI 1 +#define CONFIG_SPL_UBI_MAX_VOL_LEBS 256 +#define CONFIG_SPL_UBI_MAX_PEB_SIZE (256*1024) +#define CONFIG_SPL_UBI_MAX_PEBS 4096 +#define CONFIG_SPL_UBI_VOL_IDS 8 + +#define CONFIG_ENV_IS_IN_UBI 1 +#define CONFIG_ENV_UBI_PART "UBI" +#define CONFIG_ENV_UBI_VOLUME "config" +#define CONFIG_ENV_UBI_VOLUME_REDUND "config_r" +#define CONFIG_UBI_SILENCE_MSG 1 +#define CONFIG_UBIFS_SILENCE_MSG 1 +#define CONFIG_ENV_SIZE (32*1024) + +#define CONFIG_RBTREE +#define CONFIG_MTD_PARTITIONS +#define MTDIDS_DEFAULT "nand0=gpmc-nand.0" +#define MTDPARTS_DEFAULT "mtdparts=gpmc-nand.0:512k(SPL),-(UBI)" +/* OneNAND boot config */ #ifdef CONFIG_BOOT_ONENAND #define CONFIG_SPL_ONENAND_SUPPORT -#define CONFIG_SYS_ONENAND_U_BOOT_OFFS 0x80000#define CONFIG_SYS_ONENAND_PAGE_SIZE 2048 -#define CONFIG_SPL_ONENAND_LOAD_ADDR 0x80000 -#define CONFIG_SPL_ONENAND_LOAD_SIZE \ - (512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR) -#endif /* NAND boot config */ #ifdef CONFIG_NAND +#define CONFIG_SPL_NAND_SUPPORT #define CONFIG_SYS_NAND_BUSWIDTH_16BIT #define CONFIG_SYS_NAND_5_ADDR_CYCLE #define CONFIG_SYS_NAND_PAGE_COUNT 64@@ -166,14 +168,6 @@#define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW_DETECTION_SW#define CONFIG_NAND_OMAP_GPMC #define CONFIG_BCH - -#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000 -/* NAND: SPL falcon mode configs */ -#ifdef CONFIG_SPL_OS_BOOT -#define CONFIG_CMD_SPL_NAND_OFS 0x240000 -#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS 0x280000 -#define CONFIG_CMD_SPL_WRITE_SIZE 0x2000 -#endif #endif #endif /* __IGEP00X0_H */ include/configs/ti_armv7_common.h +0
-1@@ -232,7 +232,6 @@#define CONFIG_SPL_LIBDISK_SUPPORT #define CONFIG_SPL_MMC_SUPPORT #define CONFIG_SPL_FAT_SUPPORT -#define CONFIG_SPL_EXT_SUPPORT #endif #define CONFIG_SYS_THUMB_BUILD include/spl.h +1
-0@@ -40,6 +40,7 @@ u32 spl_boot_mode(void);void spl_set_header_raw_uboot (void );void spl_parse_image_header (const struct image_header *header);void spl_board_prepare_for_linux (void ); +int spl_board_ubi_load_image (u32 boot_device);void __noreturn jump_to_image_linux (void *arg);int spl_start_uboot (void );void spl_display_print (void );
include/spl.h int spl_onenand_load_image(void); · line 62
Quoted 9 lines
include/spl.h +3
-0@@ -53,6 +54,9 @@ int spl_onenand_load_image(void);/* NOR SPL functions */ int spl_nor_load_image (void ); +/* UBI SPL functions */ +int spl_ubi_load_image (u32 boot_device); +/* MMC SPL functions */ int spl_mmc_load_image (u32 boot_device);
Looks good to me, please seperate the common changes into a seperate patch, and I think we can add the patchserie to mainline, if merge window opens.
Thanks for your work!
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v3 4/4 igep00x0: UBIize
Hi Heiko,
On Mon, Jan 11, 2016 at 07:20:06AM +0100, Heiko Schocher wrote:
[...]
Quoted 2 lines
Could you seperate common changes in "common/*" and your special board changes?
It is done bellow, just common/* part to start discussion...
Quoted 1 line
Beside of that, this patch does not apply ...
Ah, igep00x0 part is based on top of this:
http://lists.denx.de/pipermail/u-boot/2016-January/240013.html
I silently hoped to be applied for 2016.01 release, but never mind :)
Now assumption is that once board switches to UBI, loading u-boot or kernel from bare flash does not make a sense anymore, so with CONFIG_SPL_UBI all that code in spl_nor.c (reevaluate?!), spl_nand.c and spl_onenand.c is not used in favour of spl_ubi.c. As ubispl can load volumes by volume id and not by name, it is bringing some inconsistencies with for example ubi environment code, which is using volume names. Is it worth fixing? All that ubispl_info structure is board specific and there is not much left besides initializing it. Also volumes can differ per board basis, so providing common function is somewhat questionable. However here it is, just to show how does it look like. Suggestions are very welcome as silence around this part of patch is a bit suspicious ;-)
commit f68d017a4d35bfac3cccd7c7f19ab1c2fe76d908
Author: Ladislav Michl <[email protected]> Date: Mon Jan 11 13:08:10 2016 +0100
spl: support loading from UBI volumes
Add simple support for loading from UBI volumes. This is just a test and needs to be made configurable
common/spl/Makefile +4 -1
@@ -10,10 +10,13 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_FRAMEWORK) += spl.o -obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o +ifndef CONFIG_SPL_UBI +obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o obj-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o +endif +obj-$(CONFIG_SPL_UBI) += spl_ubi.o obj-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o obj-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o
common/spl/spl.c +13 -0
@@ -286,6 +286,18 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_MMC2_2 :return spl_mmc_load_image (boot_device);#endif +#ifdef CONFIG_SPL_UBI +#ifdef CONFIG_SPL_NAND_SUPPORT +case BOOT_DEVICE_NAND : +#endif +#ifdef CONFIG_SPL_ONENAND_SUPPORT +case BOOT_DEVICE_ONENAND : +#endif +#ifdef CONFIG_SPL_NOR_SUPPORT +case BOOT_DEVICE_NOR : +#endif +return spl_ubi_load_image (boot_device); +#else #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND :return spl_nand_load_image ();
@@ -298,6 +310,7 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_NOR :return spl_nor_load_image ();#endif +#endif /* CONFIG_SPL_UBI */ #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART :return spl_ymodem_load_image ();
common/spl/spl_ubi.c new file +73 -0
73 lines not on this page · raw message
include/spl.h +4 -0
@@ -40,6 +40,7 @@ u32 spl_boot_mode(void);void spl_set_header_raw_uboot (void );void spl_parse_image_header (const struct image_header *header);void spl_board_prepare_for_linux (void ); +int spl_board_ubi_load_image (u32 boot_device);void __noreturn jump_to_image_linux (void *arg);int spl_start_uboot (void );void spl_display_print (void );
@@ -53,6 +54,9 @@ int spl_onenand_load_image(void);/* NOR SPL functions */ int spl_nor_load_image (void ); +/* UBI SPL functions */ +int spl_ubi_load_image (u32 boot_device); +/* MMC SPL functions */ int spl_mmc_load_image (u32 boot_device);
PATCH v3 4/4 igep00x0: UBIize
Hello Ladislav,
Am 11.01.2016 um 13:58 schrieb Ladislav Michl:
Quoted 8 lines
Hi Heiko,
On Mon, Jan 11, 2016 at 07:20:06AM +0100, Heiko Schocher wrote:
[...]Quoted 2 lines
Could you seperate common changes in "common/*" and your special board changes?
It is done bellow, just common/* part to start discussion...
;-)
Quoted 5 lines
Quoted 1 line
Beside of that, this patch does not apply ...
Ah, igep00x0 part is based on top of this:
http://lists.denx.de/pipermail/u-boot/2016-January/240013.html
I silently hoped to be applied for 2016.01 release, but never mind :)
;-)
Ah, I added them to my automated build, and now it works again :-D
BTW: patch "[U-Boot,PATCHv2,2/5] igep00x0: Cleanup ethernet support" has a checkpatch warning, search in
http://xeidos.ddns.net/buildbot/builders/smartweb_dfu/builds/43/steps/shell/logs/tbotlog
for "2016-01-12 07:47:08,369"
Quoted 4 lines
Now assumption is that once board switches to UBI, loading u-boot or kernel from bare flash does not make a sense anymore, so with
CONFIG_SPL_UBIall that code inspl_nor.c(reevaluate?!),spl_nand.candspl_onenand.cis not used in favour ofspl_ubi.c. As ubispl can load volumes by volume id
I thought about this change too, and I think your assumption is OK here. Let us bring in this change, and if someone has other needs, we have to look again at this place .. but I think, if switching to use UBI, than it makes no sense to read in raw mode ...
Other opinions?
Quoted 2 lines
and not by name, it is bringing some inconsistencies with for example ubi environment code, which is using volume names. Is it worth fixing?
It would be nice to have ... yes, if it is easy to do? Also we must have a look at the codesize.
Quoted 5 lines
All that
ubispl_infostructure is board specific and there is not much left besides initializing it. Also volumes can differ per board basis, so providing common function is somewhat questionable. However here it is, just to show how does it look like. Suggestions are very welcome as silence around this part of patch is a bit suspicious ;-)
Questions are coming if there are users ;-)
I vote for bringing this in, and we will see, where we have to make things more configurable ... some nitpicks below ...
Quoted 92 lines
commit
f68d017a4d35bfac3cccd7c7f19ab1c2fe76d908Author: Ladislav Michl <[email protected]> Date: Mon Jan 11 13:08:10 2016 +0100spl: support loading from UBI volumes
Add simple support for loading from UBI volumes. This is just a test and needs to be made configurable
Signed-off-by Ladislav Michl <[email protected]>common/spl/Makefile +4
-1@@ -10,10 +10,13 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_FRAMEWORK) += spl.o -obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o +ifndef CONFIG_SPL_UBI +obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o obj-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o +endif +obj-$(CONFIG_SPL_UBI) += spl_ubi.o obj-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o obj-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.ocommon/spl/spl.c +13
-0@@ -286,6 +286,18 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_MMC2_2 :return spl_mmc_load_image (boot_device);#endif +#ifdef CONFIG_SPL_UBI +#ifdef CONFIG_SPL_NAND_SUPPORT +case BOOT_DEVICE_NAND : +#endif +#ifdef CONFIG_SPL_ONENAND_SUPPORT +case BOOT_DEVICE_ONENAND : +#endif +#ifdef CONFIG_SPL_NOR_SUPPORT +case BOOT_DEVICE_NOR : +#endif +return spl_ubi_load_image (boot_device); +#else #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND :return spl_nand_load_image ();@@ -298,6 +310,7 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_NOR :return spl_nor_load_image ();#endif +#endif /* CONFIG_SPL_UBI */ #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART :return spl_ymodem_load_image ();common/spl/spl_ubi.c new file +25
-0@@ -0,0 +1,73 @@ +/* +* Copyright (C) 2016 +* Ladislav Michl <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <config.h> +#include <nand.h> +#include <ubispl.h> +#include <spl.h> + +int spl_ubi_load_image (u32 boot_device) +{ +int ret; +struct image_header *header; +struct ubispl_info info; +struct ubispl_load volumes[2 ]; + +#ifdef CONFIG_SPL_NAND_SUPPORT +if (boot_device ==BOOT_DEVICE_NAND ) +nand_init (); +#endif +
common/spl/spl_ubi.c line 35
Quoted 10 lines
common/spl/spl_ubi.c new file +10
-0+/* TODO: Make it decently configurable */ + info.ubi = (struct ubi_scan_info *) + (CONFIG_SYS_SPL_MALLOC_START +CONFIG_SYS_SPL_MALLOC_SIZE ); + info.fastmap =1 ; + info.read = nand_spl_read_block; + + info.peb_offset =4 ; + info.peb_size =CONFIG_SYS_NAND_BLOCK_SIZE ; + info.vid_offset =512 ; + info.leb_start =2048 ;
this three values should be configurable!
common/spl/spl_ubi.c line 40
Quoted 5 lines
common/spl/spl_ubi.c new file +5
-0+ info.peb_count =CONFIG_SPL_UBI_MAX_PEBS - info.peb_offset; + +#ifdef CONFIG_SPL_OS_BOOT +if (!spl_start_uboot ()) { + volumes[0 ].name ="kernel" ;
Also we should have the names configurable ... not for all boards the kernel is stored in "kernel" ...
common/spl/spl_ubi.c line 43
Quoted 3 lines
common/spl/spl_ubi.c new file +3
-0+ volumes[0 ].vol_id =CONFIG_SPL_UBI_LOAD_KERNEL_ID ; + volumes[0 ].load_addr = (void *)CONFIG_SYS_LOAD_ADDR ; + volumes[1 ].name ="args" ;
Same here.
Quoted 44 lines
common/spl/spl_ubi.c new file +30
-0+ volumes[1 ].vol_id =CONFIG_SPL_UBI_LOAD_ARGS_ID ; + volumes[1 ].load_addr = (void *)CONFIG_SYS_SPL_ARGS_ADDR ; + + ret =ubispl_load_volumes (&info, volumes,2 ); +if (!ret) { + header = (struct image_header *) volumes[0 ].load_addr; +spl_parse_image_header (header); +puts ("Linux loaded.\n" ); +return 0 ; + } + puts("Loading Linux failed, falling back to U-Boot.\n"); + } +#endif + header = (struct image_header *) + (CONFIG_SYS_TEXT_BASE -sizeof (struct image_header )); + volumes[0 ].name ="monitor" ; + volumes[0 ].vol_id =CONFIG_SPL_UBI_LOAD_MONITOR_ID ; + volumes[0 ].load_addr = (void *)header; + + ret =ubispl_load_volumes (&info, volumes,1 ); +if (!ret) +spl_parse_image_header (header); + +#ifdef CONFIG_SPL_NAND_SUPPORT +if (boot_device ==BOOT_DEVICE_NAND ) +nand_deselect (); +#endif + +return ret; +}include/spl.h +1
-0@@ -40,6 +40,7 @@ u32 spl_boot_mode(void);void spl_set_header_raw_uboot (void );void spl_parse_image_header (const struct image_header *header);void spl_board_prepare_for_linux (void ); +int spl_board_ubi_load_image (u32 boot_device);void __noreturn jump_to_image_linux (void *arg);int spl_start_uboot (void );void spl_display_print (void );
include/spl.h int spl_onenand_load_image(void); · line 62
Quoted 9 lines
include/spl.h +3
-0@@ -53,6 +54,9 @@ int spl_onenand_load_image(void);/* NOR SPL functions */ int spl_nor_load_image (void ); +/* UBI SPL functions */ +int spl_ubi_load_image (u32 boot_device); +/* MMC SPL functions */ int spl_mmc_load_image (u32 boot_device);
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v3 4/4 igep00x0: UBIize
Hi Heiko,
Quoted 10 lines · Heiko Schocher
Am 11.01.2016 um 13:58 schrieb Ladislav Michl:
Quoted 6 lines · Heiko Schocher
Quoted 1 line
Beside of that, this patch does not apply ...
Ah, igep00x0 part is based on top of this:
http://lists.denx.de/pipermail/u-boot/2016-January/240013.html
I silently hoped to be applied for 2016.01 release, but never mind :);-)
Quoted 8 lines
Ah, I added them to my automated build, and now it works again :-D
BTW: patch "[U-Boot,PATCHv2,2/5] igep00x0: Cleanup ethernet support" has a checkpatch warning, search in
http://xeidos.ddns.net/buildbot/builders/smartweb_dfu/builds/43/steps/shell/logs/tbotlog
for "2016-01-12 07:47:08,369"
Hmm, I do not agree with warning as I consider code pretty readable :) Anyway, there is similar "unaligned case" few lines bellow. Perhaps send additional patch to fix them both?
Quoted 10 lines
Quoted 4 lines
Now assumption is that once board switches to UBI, loading u-boot or kernel from bare flash does not make a sense anymore, so with
CONFIG_SPL_UBIall that code inspl_nor.c(reevaluate?!),spl_nand.candspl_onenand.cis not used in favour ofspl_ubi.c. As ubispl can load volumes by volume idI thought about this change too, and I think your assumption is OK here. Let us bring in this change, and if someone has other needs, we have to look again at this place .. but I think, if switching to use UBI, than it makes no sense to read in raw mode ...
Quoted 7 lines
Other opinions?
Quoted 2 lines
and not by name, it is bringing some inconsistencies with for example ubi environment code, which is using volume names. Is it worth fixing?
It would be nice to have ... yes, if it is easy to do? Also we must have a look at the codesize.
It seems Thomas had a good reason to use volume ids, see ubi_scan_vid_hdr called from ipl_scan.
Quoted 10 lines
Quoted 5 lines
All that
ubispl_infostructure is board specific and there is not much left besides initializing it. Also volumes can differ per board basis, so providing common function is somewhat questionable. However here it is, just to show how does it look like. Suggestions are very welcome as silence around this part of patch is a bit suspicious ;-)Questions are coming if there are users ;-)
I vote for bringing this in, and we will see, where we have to make things more configurable ... some nitpicks below ...
Okay, I need to be able to load also bare zImage. This change is independent and possibly controversial, so I'll put it here for disscusion :)
commit c092b3c0627dd8d4b3f3d756c58b53fcf205587f
Author: Ladislav Michl <[email protected]> Date: Tue Jan 12 16:37:04 2016 +0100
spl: zImage support in Falcon mode
Other payload than uImage is currently considered to be raw U-Boot image. Check also for zImage in Falcon mode.
arch/arm/lib/Makefile +2 -0
@@ -26,11 +26,13 @@ endif obj-$(CONFIG_CPU_V7M) += cmd_boot.o obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o obj-$(CONFIG_CMD_BOOTM) += bootm.o +obj-$(CONFIG_CMD_BOOTM) += zimage.o obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o obj-$(CONFIG_USE_ARCH_MEMSET) += memset.o obj-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o else obj-$(CONFIG_SPL_FRAMEWORK) += spl.o +obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o endif obj-$(CONFIG_SEMIHOSTING) += semihosting.o
arch/arm/lib/bootm.c +0 -32
@@ -348,38 +348,6 @@ int do_bootm_linux(int flag, int argc, char * const argv[],return 0 ; } -#ifdef CONFIG_CMD_BOOTZ - -struct zimage_header { -uint32_t code[9 ]; -uint32_t zi_magic; -uint32_t zi_start; -uint32_t zi_end; -}; - -#define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818 - -int bootz_setup (ulong image,ulong *start,ulong *end) -{ -struct zimage_header *zi; - - zi = (struct zimage_header *)map_sysmem (image,0 ); -if (zi->zi_magic !=LINUX_ARM_ZIMAGE_MAGIC ) { -puts ("Bad Linux ARM zImage magic!\n" ); -return 1 ; - } - - *start = zi->zi_start; - *end = zi->zi_end; - -printf ("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n" , image, *start, - *end); - -return 0 ; -} - -#endif /* CONFIG_CMD_BOOTZ */ -#if defined(CONFIG_BOOTM_VXWORKS )void boot_prep_vxworks (bootm_headers_t *images) {
arch/arm/lib/zimage.c new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Copyright (C) 2016 +* Ladislav Michl <[email protected]> +* +* bootz code: +* Copyright (C) 2012 Marek Vasut <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +#include <common.h> + +#define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818 + +struct arm_z_header { +uint32_t code[9 ]; +uint32_t zi_magic; +uint32_t zi_start; +uint32_t zi_end; +} __attribute__ ((__packed__ )); + +int bootz_setup (ulong image,ulong *start,ulong *end) +{ +struct arm_z_header *zi = (struct arm_z_header *) image; + +if (zi->zi_magic !=LINUX_ARM_ZIMAGE_MAGIC ) { +#ifndef CONFIG_SPL_FRAMEWORK +puts ("Bad Linux ARM zImage magic!\n" ); +#endif +return 1 ; + } + + *start = zi->zi_start; + *end = zi->zi_end; +#ifndef CONFIG_SPL_FRAMEWORK +printf ("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n" , image, *start, + *end); +#endif + +return 0 ; +}
common/spl/spl.c +23 -0
@@ -52,6 +52,15 @@ __weak int spl_start_uboot(void)puts ("SPL: Direct Linux boot not active!\n" ); return 1; } + +/* +* Weak default function for arch specific zImage check. Return zero +* and fill start and end address if image is recognized. +*/ +int __weak bootz_setup (ulong image,ulong *start,ulong *end) +{ +return 1 ; +}#endif /*
@@ -112,6 +121,20 @@ void spl_parse_image_header(const struct image_header *header)*/ panic ("** no mkimage signature but raw image not supported" );#else +#ifdef CONFIG_SPL_OS_BOOT +ulong start, end; + +if (!bootz_setup ((ulong )header, &start, &end)) { + spl_image.name ="Linux" ; + spl_image.os =IH_OS_LINUX ; + spl_image.load_addr = (u32 )header; + spl_image.entry_point = (u32 )header; + spl_image.size = end - start; +debug ("spl: payload zImage, load addr: 0x%x size: %d\n" , + spl_image.load_addr, spl_image.size); +return ; + } +#endif /* Signature not found - assume u-boot.bin */ debug ("mkimage signature not found - ih_magic = %x\n" , header->ih_magic);
Quoted 96 lines
Quoted 96 lines
commit
f68d017a4d35bfac3cccd7c7f19ab1c2fe76d908Author: Ladislav Michl <[email protected]> Date: Mon Jan 11 13:08:10 2016 +0100spl: support loading from UBI volumes
Add simple support for loading from UBI volumes. This is just a test and needs to be made configurable
Signed-off-by Ladislav Michl <[email protected]>common/spl/Makefile +4
-1@@ -10,10 +10,13 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_FRAMEWORK) += spl.o -obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o +ifndef CONFIG_SPL_UBI +obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o obj-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o +endif +obj-$(CONFIG_SPL_UBI) += spl_ubi.o obj-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o obj-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.ocommon/spl/spl.c +13
-0@@ -286,6 +286,18 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_MMC2_2 :return spl_mmc_load_image (boot_device);#endif +#ifdef CONFIG_SPL_UBI +#ifdef CONFIG_SPL_NAND_SUPPORT +case BOOT_DEVICE_NAND : +#endif +#ifdef CONFIG_SPL_ONENAND_SUPPORT +case BOOT_DEVICE_ONENAND : +#endif +#ifdef CONFIG_SPL_NOR_SUPPORT +case BOOT_DEVICE_NOR : +#endif +return spl_ubi_load_image (boot_device); +#else #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND :return spl_nand_load_image ();@@ -298,6 +310,7 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_NOR :return spl_nor_load_image ();#endif +#endif /* CONFIG_SPL_UBI */ #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART :return spl_ymodem_load_image ();common/spl/spl_ubi.c new file +29
-0@@ -0,0 +1,73 @@ +/* +* Copyright (C) 2016 +* Ladislav Michl <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <config.h> +#include <nand.h> +#include <ubispl.h> +#include <spl.h> + +int spl_ubi_load_image (u32 boot_device) +{ +int ret; +struct image_header *header; +struct ubispl_info info; +struct ubispl_load volumes[2 ]; + +#ifdef CONFIG_SPL_NAND_SUPPORT +if (boot_device ==BOOT_DEVICE_NAND ) +nand_init (); +#endif + +/* TODO: Make it decently configurable */ + info.ubi = (struct ubi_scan_info *) + (CONFIG_SYS_SPL_MALLOC_START +CONFIG_SYS_SPL_MALLOC_SIZE ); + info.fastmap =1 ;
Quoted 8 lines
common/spl/spl_ubi.c line 35
Quoted 6 lines
common/spl/spl_ubi.c new file +6
-0+ info.read = nand_spl_read_block; + + info.peb_offset =4 ; + info.peb_size =CONFIG_SYS_NAND_BLOCK_SIZE ; + info.vid_offset =512 ; + info.leb_start =2048 ;this three values should be configurable!
Sure and it is done in next version.
Quoted 8 lines
common/spl/spl_ubi.c line 40
Quoted 5 lines
common/spl/spl_ubi.c new file +5
-0+ info.peb_count =CONFIG_SPL_UBI_MAX_PEBS - info.peb_offset; + +#ifdef CONFIG_SPL_OS_BOOT +if (!spl_start_uboot ()) { + volumes[0 ].name ="kernel" ;Also we should have the names configurable ... not for all boards the kernel is stored in "kernel" ...
It is not needed here to make them configurable, because current code loads volumes by id not by name. Current code loads volumes by id for a sake of simplicity. Perhaps we could drop name field as it is used only for pretty print?
[...]
Best regards,
ladis
PATCH v3 4/4 igep00x0: UBIize
Hello Ladislav,
Am 12.01.2016 um 23:17 schrieb Ladislav Michl:
Quoted 15 lines
Hi Heiko,
Quoted 12 lines · Heiko Schocher
Am 11.01.2016 um 13:58 schrieb Ladislav Michl:
Quoted 6 lines · Heiko Schocher
Quoted 1 line
Beside of that, this patch does not apply ...
Ah, igep00x0 part is based on top of this:
http://lists.denx.de/pipermail/u-boot/2016-January/240013.html
I silently hoped to be applied for 2016.01 release, but never mind :);-)
Ah, I added them to my automated build, and now it works again :-D
Quoted 8 lines
Quoted 6 lines
BTW: patch "[U-Boot,PATCHv2,2/5] igep00x0: Cleanup ethernet support" has a checkpatch warning, search in
http://xeidos.ddns.net/buildbot/builders/smartweb_dfu/builds/43/steps/shell/logs/tbotlog
for "2016-01-12 07:47:08,369"
Hmm, I do not agree with warning as I consider code pretty readable :)
Its a warning only ...
Yes, I am also unhappy to adding blanks in such cases ... maybe this should be discussed in a seperate thread?
Quoted 2 lines
Anyway, there is similar "unaligned case" few lines bellow. Perhaps send additional patch to fix them both?
If you fix it, then please in a v4 patch, thanks!
Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
Now assumption is that once board switches to UBI, loading u-boot or kernel from bare flash does not make a sense anymore, so with
CONFIG_SPL_UBIall that code inspl_nor.c(reevaluate?!),spl_nand.candspl_onenand.cis not used in favour ofspl_ubi.c. As ubispl can load volumes by volume idI thought about this change too, and I think your assumption is OK here. Let us bring in this change, and if someone has other needs, we have to look again at this place .. but I think, if switching to use UBI, than it makes no sense to read in raw mode ...
Other opinions?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
and not by name, it is bringing some inconsistencies with for example ubi environment code, which is using volume names. Is it worth fixing?
It would be nice to have ... yes, if it is easy to do? Also we must have a look at the codesize.
It seems Thomas had a good reason to use volume ids, see
ubi_scan_vid_hdrcalled fromipl_scan.
Yes indeed ... so let it as it is.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
All that
ubispl_infostructure is board specific and there is not much left besides initializing it. Also volumes can differ per board basis, so providing common function is somewhat questionable. However here it is, just to show how does it look like. Suggestions are very welcome as silence around this part of patch is a bit suspicious ;-)
Quoted 7 lines
Quoted 4 lines
Questions are coming if there are users ;-)
I vote for bringing this in, and we will see, where we have to make things more configurable ... some nitpicks below ...
Okay, I need to be able to load also bare zImage. This change is independent and possibly controversial, so I'll put it here for disscusion :)
Please post it as a RFC patch seperate, with for example Marek in Cc, so he can speak up here too.
Quoted 266 lines
commit
c092b3c0627dd8d4b3f3d756c58b53fcf205587fAuthor: Ladislav Michl <[email protected]> Date: Tue Jan 12 16:37:04 2016 +0100spl: zImage support in Falcon mode
Other payload than uImage is currently considered to be raw U-Boot image. Check also for zImage in Falcon mode.
Signed-off-by Ladislav Michl <[email protected]>arch/arm/lib/Makefile +2
-0@@ -26,11 +26,13 @@ endif obj-$(CONFIG_CPU_V7M) += cmd_boot.o obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o obj-$(CONFIG_CMD_BOOTM) += bootm.o +obj-$(CONFIG_CMD_BOOTM) += zimage.o obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o obj-$(CONFIG_USE_ARCH_MEMSET) += memset.o obj-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o else obj-$(CONFIG_SPL_FRAMEWORK) += spl.o +obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o endif obj-$(CONFIG_SEMIHOSTING) += semihosting.oarch/arm/lib/bootm.c +0
-32@@ -348,38 +348,6 @@ int do_bootm_linux(int flag, int argc, char * const argv[],return 0 ; } -#ifdef CONFIG_CMD_BOOTZ - -struct zimage_header { -uint32_t code[9 ]; -uint32_t zi_magic; -uint32_t zi_start; -uint32_t zi_end; -}; - -#define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818 - -int bootz_setup (ulong image,ulong *start,ulong *end) -{ -struct zimage_header *zi; - - zi = (struct zimage_header *)map_sysmem (image,0 ); -if (zi->zi_magic !=LINUX_ARM_ZIMAGE_MAGIC ) { -puts ("Bad Linux ARM zImage magic!\n" ); -return 1 ; - } - - *start = zi->zi_start; - *end = zi->zi_end; - -printf ("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n" , image, *start, - *end); - -return 0 ; -} - -#endif /* CONFIG_CMD_BOOTZ */ -#if defined(CONFIG_BOOTM_VXWORKS )void boot_prep_vxworks (bootm_headers_t *images) {arch/arm/lib/zimage.c new file +40
-0@@ -0,0 +1,40 @@ +/* +* Copyright (C) 2016 +* Ladislav Michl <[email protected]> +* +* bootz code: +* Copyright (C) 2012 Marek Vasut <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +#include <common.h> + +#define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818 + +struct arm_z_header { +uint32_t code[9 ]; +uint32_t zi_magic; +uint32_t zi_start; +uint32_t zi_end; +} __attribute__ ((__packed__ )); + +int bootz_setup (ulong image,ulong *start,ulong *end) +{ +struct arm_z_header *zi = (struct arm_z_header *) image; + +if (zi->zi_magic !=LINUX_ARM_ZIMAGE_MAGIC ) { +#ifndef CONFIG_SPL_FRAMEWORK +puts ("Bad Linux ARM zImage magic!\n" ); +#endif +return 1 ; + } + + *start = zi->zi_start; + *end = zi->zi_end; +#ifndef CONFIG_SPL_FRAMEWORK +printf ("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n" , image, *start, + *end); +#endif + +return 0 ; +}common/spl/spl.c +23
-0@@ -52,6 +52,15 @@ __weak int spl_start_uboot(void)puts ("SPL: Direct Linux boot not active!\n" ); return 1; } + +/* +* Weak default function for arch specific zImage check. Return zero +* and fill start and end address if image is recognized. +*/ +int __weak bootz_setup (ulong image,ulong *start,ulong *end) +{ +return 1 ; +}#endif /* @@ -112,6 +121,20 @@ void spl_parse_image_header(const struct image_header *header)*/ panic ("** no mkimage signature but raw image not supported" );#else +#ifdef CONFIG_SPL_OS_BOOT +ulong start, end; + +if (!bootz_setup ((ulong )header, &start, &end)) { + spl_image.name ="Linux" ; + spl_image.os =IH_OS_LINUX ; + spl_image.load_addr = (u32 )header; + spl_image.entry_point = (u32 )header; + spl_image.size = end - start; +debug ("spl: payload zImage, load addr: 0x%x size: %d\n" , + spl_image.load_addr, spl_image.size); +return ; + } +#endif /* Signature not found - assume u-boot.bin */ debug ("mkimage signature not found - ih_magic = %x\n" , header->ih_magic);Quoted 97 lines
Quoted 97 lines
commit
f68d017a4d35bfac3cccd7c7f19ab1c2fe76d908Author: Ladislav Michl <[email protected]> Date: Mon Jan 11 13:08:10 2016 +0100spl: support loading from UBI volumes
Add simple support for loading from UBI volumes. This is just a test and needs to be made configurable
Signed-off-by Ladislav Michl <[email protected]>common/spl/Makefile +4
-1@@ -10,10 +10,13 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_FRAMEWORK) += spl.o -obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o +ifndef CONFIG_SPL_UBI +obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o obj-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o +endif +obj-$(CONFIG_SPL_UBI) += spl_ubi.o obj-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o obj-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.ocommon/spl/spl.c +13
-0@@ -286,6 +286,18 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_MMC2_2 :return spl_mmc_load_image (boot_device);#endif +#ifdef CONFIG_SPL_UBI +#ifdef CONFIG_SPL_NAND_SUPPORT +case BOOT_DEVICE_NAND : +#endif +#ifdef CONFIG_SPL_ONENAND_SUPPORT +case BOOT_DEVICE_ONENAND : +#endif +#ifdef CONFIG_SPL_NOR_SUPPORT +case BOOT_DEVICE_NOR : +#endif +return spl_ubi_load_image (boot_device); +#else #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND :return spl_nand_load_image ();@@ -298,6 +310,7 @@ static int spl_load_image(u32 boot_device)case BOOT_DEVICE_NOR :return spl_nor_load_image ();#endif +#endif /* CONFIG_SPL_UBI */ #ifdef CONFIG_SPL_YMODEM_SUPPORT case BOOT_DEVICE_UART :return spl_ymodem_load_image ();common/spl/spl_ubi.c new file +29
-0@@ -0,0 +1,73 @@ +/* +* Copyright (C) 2016 +* Ladislav Michl <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <config.h> +#include <nand.h> +#include <ubispl.h> +#include <spl.h> + +int spl_ubi_load_image (u32 boot_device) +{ +int ret; +struct image_header *header; +struct ubispl_info info; +struct ubispl_load volumes[2 ]; + +#ifdef CONFIG_SPL_NAND_SUPPORT +if (boot_device ==BOOT_DEVICE_NAND ) +nand_init (); +#endif + +/* TODO: Make it decently configurable */ + info.ubi = (struct ubi_scan_info *) + (CONFIG_SYS_SPL_MALLOC_START +CONFIG_SYS_SPL_MALLOC_SIZE ); + info.fastmap =1 ;Quoted 8 lines
common/spl/spl_ubi.c line 35
Quoted 6 lines
common/spl/spl_ubi.c new file +6
-0+ info.read = nand_spl_read_block; + + info.peb_offset =4 ; + info.peb_size =CONFIG_SYS_NAND_BLOCK_SIZE ; + info.vid_offset =512 ; + info.leb_start =2048 ;this three values should be configurable!
Quoted 1 line
Sure and it is done in next version.
Thanks!
Quoted 9 lines
Quoted 8 lines
common/spl/spl_ubi.c line 40
Quoted 5 lines
common/spl/spl_ubi.c new file +5
-0+ info.peb_count =CONFIG_SPL_UBI_MAX_PEBS - info.peb_offset; + +#ifdef CONFIG_SPL_OS_BOOT +if (!spl_start_uboot ()) { + volumes[0 ].name ="kernel" ;Also we should have the names configurable ... not for all boards the kernel is stored in "kernel" ...
Quoted 4 lines
It is not needed here to make them configurable, because current code loads volumes by id not by name. Current code loads volumes by id for a sake of simplicity. Perhaps we could drop name field as it is used only for pretty print?
Ah, correct ... I should try your patches on a board ... also it is in board specific code, so Ok for me. Just if it is only for pretty print .. drop it and save some bytes?
So I wait for your v4 round, thanks for your work!
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH v3 4/4 igep00x0: UBIize
In reply to Heiko SchocherHi Heiko,
just one more thing I forgot to mention...
Quoted 1 line · Heiko Schocher
Am 11.01.2016 um 13:58 schrieb Ladislav Michl:
[...]
Quoted 10 lines
Quoted 5 lines
All that
ubispl_infostructure is board specific and there is not much left besides initializing it. Also volumes can differ per board basis, so providing common function is somewhat questionable. However here it is, just to show how does it look like. Suggestions are very welcome as silence around this part of patch is a bit suspicious ;-)Questions are coming if there are users ;-)
I vote for bringing this in, and we will see, where we have to make things more configurable ... some nitpicks below ...
I wouldn't make payload loading function completely board specific as we would face danger of copying similar pattern over and over for every board wanting to support ubispl without anyone even considering consolidation. History of U-Boot proves that happens :) So lets's make payload loading function decently generic which will force users to improve it and eventuelly provide their own as a last option. Also let's not pretend code works on anything but NAND, so patch would boil down to something like this:
commit 9fd0671cb68e14d3238867173a8ecdaf0f4695af
Author: Ladislav Michl <[email protected]> Date: Mon Jan 11 13:08:10 2016 +0100
spl: support loading from UBI volumes
Add support for loading from UBI volumes on the top of NAND.
common/spl/Makefile +3 -0
@@ -12,8 +12,11 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_FRAMEWORK) += spl.o obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o +ifndef CONFIG_SPL_UBI obj-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o +endif obj-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o +obj-$(CONFIG_SPL_UBI) += spl_ubi.o obj-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o obj-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o
common/spl/spl.c +4 -0
@@ -288,8 +288,12 @@ static int spl_load_image(u32 boot_device)#endif #ifdef CONFIG_SPL_NAND_SUPPORT case BOOT_DEVICE_NAND : +#ifdef CONFIG_SPL_UBI +return spl_ubi_load_image (boot_device); +#else return spl_nand_load_image ();#endif +#endif #ifdef CONFIG_SPL_ONENAND_SUPPORT case BOOT_DEVICE_ONENAND :return spl_onenand_load_image ();
common/spl/spl_ubi.c new file +71 -0
71 lines not on this page · raw message
include/spl.h +4 -0
@@ -40,6 +40,7 @@ u32 spl_boot_mode(void);void spl_set_header_raw_uboot (void );void spl_parse_image_header (const struct image_header *header);void spl_board_prepare_for_linux (void ); +int spl_board_ubi_load_image (u32 boot_device);void __noreturn jump_to_image_linux (void *arg);int spl_start_uboot (void );void spl_display_print (void );
@@ -53,6 +54,9 @@ int spl_onenand_load_image(void);/* NOR SPL functions */ int spl_nor_load_image (void ); +/* UBI SPL functions */ +int spl_ubi_load_image (u32 boot_device); +/* MMC SPL functions */ int spl_mmc_load_image (u32 boot_device);