[PATCH] driver: nand: skip BBT scan during SPL to reduce size and complexity
Michael Nazzareno Trimarchi
michael at amarulasolutions.com
Tue Nov 25 14:45:45 CET 2025
Hi Dinesh
On Thu, Nov 13, 2025 at 4:04 AM <dinesh.maniyam at altera.com> wrote:
>
> From: Dinesh Maniyam <dinesh.maniyam at altera.com>
>
> Guard the Bad Block Table (BBT) scanning with `#ifndef CONFIG_SPL_BUILD`
> to prevent running `chip->scan_bbt()` in SPL builds.
>
> The SPL only requires basic NAND read functionality to load the next
> stage and does not need full BBT management. Running the BBT scan in
> SPL unnecessarily increases code size, memory usage, and boot time.
>
> This change ensures the BBT is scanned only in U-Boot proper, where the
> full NAND subsystem and dynamic memory are available.
>
> Signed-off-by: Dinesh Maniyam <dinesh.maniyam at altera.com>
> ---
> drivers/mtd/nand/raw/nand_base.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index 48e3685d995..4dc2a19b8f6 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -532,7 +532,9 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int allowbbt)
> if (!(chip->options & NAND_SKIP_BBTSCAN) &&
> !(chip->options & NAND_BBT_SCANNED)) {
> chip->options |= NAND_BBT_SCANNED;
> +#ifndef CONFIG_XPL_BUILD
> chip->scan_bbt(mtd);
> +#endif
> }
>
Look at the file there are other points where this ifdef is used for
exactly the same reason and please check this commit
commit fa87360b3ae28639f72e1c665b0631436693f60f
Author: Roger Quadros <rogerq at kernel.org>
Date: Tue Dec 20 12:21:57 2022 +0200
mtd: rawnand: nand_base: Allow base driver to be used in SPL
without nand_bbt
nand_bbt.c is not being built with the nand_base driver during SPL
build. This results in build failures if we try to access any nand_bbt
related functions.
Don't use any nand_bbt functions for SPL build.
Signed-off-by: Roger Quadros <rogerq at kernel.org>
Signed-off-by: Michael Trimarchi <michael at amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi at amarulasolutions.com>
Link: https://lore.kernel.org/all/20221220102203.52398-3-rogerq@kernel.org
Michael
> if (!chip->bbt)
> --
> 2.43.7
>
--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael at amarulasolutions.com
__________________________________
Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info at amarulasolutions.com
www.amarulasolutions.com
More information about the U-Boot
mailing list