mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-30 08:31:03 +00:00
6f4e7d3c75
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.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. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Acked-by: Heiko Schocher <hs@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
90 lines
2.7 KiB
C
90 lines
2.7 KiB
C
/*
|
|
* Copyright (c) Thomas Gleixner <tglx@linutronix.de>
|
|
*
|
|
* SPDX-License-Identifier: GPL 2.0+ BSD-3-Clause
|
|
*/
|
|
#ifndef __UBOOT_UBISPL_H
|
|
#define __UBOOT_UBISPL_H
|
|
|
|
/*
|
|
* The following CONFIG options are relevant for UBISPL
|
|
*
|
|
* #define CONFIG_SPL_UBI_MAX_VOL_LEBS 256
|
|
*
|
|
* Defines the maximum number of logical erase blocks per loadable
|
|
* (static) volume to size the ubispl internal arrays.
|
|
*
|
|
* #define CONFIG_SPL_UBI_MAX_PEB_SIZE (256*1024)
|
|
*
|
|
* Defines the maximum physical erase block size to size the fastmap
|
|
* buffer for ubispl.
|
|
*
|
|
* #define CONFIG_SPL_UBI_MAX_PEBS 4096
|
|
*
|
|
* Define the maximum number of physical erase blocks to size the
|
|
* ubispl internal arrays.
|
|
*
|
|
* #define CONFIG_SPL_UBI_VOL_IDS 8
|
|
*
|
|
* Defines the maximum number of volumes in which UBISPL is
|
|
* interested. Limits the amount of memory for the scan data and
|
|
* speeds up the scan process as we simply ignore stuff which we dont
|
|
* want to load from the SPL anyway. So the volumes which can be
|
|
* loaded in the above example are ids 0 - 7
|
|
*/
|
|
|
|
/*
|
|
* The struct definition is in drivers/mtd/ubispl/ubispl.h. It does
|
|
* not fit into the BSS due to the large buffer requirement of the
|
|
* upstream fastmap code. So the caller of ubispl_load_volumes needs
|
|
* to hand in a pointer to a free memory area where ubispl will place
|
|
* its data. The area is not required to be initialized.
|
|
*/
|
|
struct ubi_scan_info;
|
|
|
|
typedef int (*ubispl_read_flash)(int pnum, int offset, int len, void *dst);
|
|
|
|
/**
|
|
* struct ubispl_info - description structure for fast ubi scan
|
|
* @ubi: Pointer to memory space for ubi scan info structure
|
|
* @peb_size: Physical erase block size
|
|
* @vid_offset: Offset of the VID header
|
|
* @leb_start: Start of the logical erase block, i.e. offset of data
|
|
* @peb_count: Number of physical erase blocks in the UBI FLASH area
|
|
* aka MTD partition.
|
|
* @peb_offset: Offset of PEB0 in the UBI FLASH area (aka MTD partition)
|
|
* to the real start of the FLASH in erase blocks.
|
|
* @fastmap: Enable fastmap attachment
|
|
* @read: Read function to access the flash
|
|
*/
|
|
struct ubispl_info {
|
|
struct ubi_scan_info *ubi;
|
|
u32 peb_size;
|
|
u32 vid_offset;
|
|
u32 leb_start;
|
|
u32 peb_count;
|
|
u32 peb_offset;
|
|
int fastmap;
|
|
ubispl_read_flash read;
|
|
};
|
|
|
|
/**
|
|
* struct ubispl_load - structure to describe a volume to load
|
|
* @vol_id: Volume id
|
|
* @load_addr: Load address of the volume
|
|
*/
|
|
struct ubispl_load {
|
|
int vol_id;
|
|
void *load_addr;
|
|
};
|
|
|
|
/**
|
|
* ubispl_load_volumes - Scan flash and load volumes
|
|
* @info: Pointer to the ubi scan info structure
|
|
* @lovls: Pointer to array of volumes to load
|
|
* @nrvols: Array size of @lovls
|
|
*/
|
|
int ubispl_load_volumes(struct ubispl_info *info,
|
|
struct ubispl_load *lvols, int nrvols);
|
|
|
|
#endif
|