collected fallout of porting an ATSAMA5D27 based board
Subsystems (5)
cover collected fallout of porting an ATSAMA5D27 based board
Hi,
while porting an ATSAMA5D2 based board (booting from NAND flash with UBI) I stumbled over generic, NAND- and UBI related asperity:
1. tiny-printf does not handle NULL arguments to '%s' in a proper way
2. vtbl_check() has an useless debug output due to a typo
3. NAND: An informative output fails badly, if the NAND vendor is unknown
4. the nand_atmel driver lacks a vital initialisation
OK, you might say the nand_atmel NAND driver is obsolete, but it was the only solution to get booting from NAND running. The new DM based NAND driver refused to do anything usefull, so I dropped it after spending a couple of days debugging it:
<RANT>brilliant!</RANT>
regards
Benedikt Spranger
Benedikt Spranger (5):
tiny-printf: Handle NULL pointer argument to %s drivers/mtd/ubispl/ubispl.c: Fix error message
mtd: nand: raw: Fix potential NULL pointer dereference
mtd: nand: Update NAND manufacturer Ids
mtd: nand: raw: atmel_nand: Add missing nand_scan_ident()
drivers/mtd/nand/raw/atmel_nand.c | 4 ++++ drivers/mtd/nand/raw/nand_base.c | 8 ++++---- drivers/mtd/nand/raw/nand_ids.c | 22 ++++++++++++---------- drivers/mtd/ubispl/ubispl.c | 2 +- include/linux/mtd/rawnand.h | 23 +++++++++++++---------- lib/tiny-printf.c | 2 +- 6 files changed, 35 insertions(+), 26 deletions(-)
Signature · 1 line
2.45.2
cover collected fallout of porting an ATSAMA5D2 based board
Hi,
while porting an ATSAMA5D2 based board (booting from NAND flash with UBI) I stumbled over generic, NAND- and UBI related asperity:
1. tiny-printf does not handle NULL arguments to '%s' in a proper way
2. vtbl_check() has an useless debug output due to a typo
3. NAND: An informative output fails badly, if the NAND vendor is unknown
4. the nand_atmel driver lacks a vital initialisation
OK, you might say the nand_atmel NAND driver is obsolete, but it was the only solution to get booting from NAND running. The new DM based NAND driver refused to do anything usefull, so I dropped it after spending a couple of days debugging it:
<RANT>brilliant!</RANT>
regards
Benedikt Spranger
Benedikt Spranger (5):
tiny-printf: Handle NULL pointer argument to %s drivers/mtd/ubispl/ubispl.c: Fix error message
mtd: nand: raw: Fix potential NULL pointer dereference
mtd: nand: Update NAND manufacturer Ids
mtd: nand: raw: atmel_nand: Add missing nand_scan_ident()
drivers/mtd/nand/raw/atmel_nand.c | 4 ++++ drivers/mtd/nand/raw/nand_base.c | 8 ++++---- drivers/mtd/nand/raw/nand_ids.c | 22 ++++++++++++---------- drivers/mtd/ubispl/ubispl.c | 2 +- include/linux/mtd/rawnand.h | 23 +++++++++++++---------- lib/tiny-printf.c | 2 +- 6 files changed, 35 insertions(+), 26 deletions(-)
Signature · 1 line
2.45.2
Re: [PATCH 0/5] collected fallout of porting an ATSAMA5D2 based board
Quoted 27 lines · Benedikt Spranger
Hi,
while porting an ATSAMA5D2 based board (booting from NAND flash with UBI) I stumbled over generic, NAND- and UBI related asperity:
1. tiny-printf does not handle NULL arguments to '%s' in a proper way
2.vtbl_check()has an useless debug output due to a typo
3. NAND: An informative output fails badly, if the NAND vendor is unknown
4. thenand_atmeldriver lacks a vital initialisationOK, you might say the
nand_atmelNAND driver is obsolete, but it was the only solution to get booting from NAND running. The new DM based NAND driver refused to do anything usefull, so I dropped it after spending a couple of days debugging it:<RANT>brilliant!</RANT>
regards
Benedikt SprangerBenedikt Spranger (5):
tiny-printf: Handle NULL pointer argument to %sdrivers/mtd/ubispl/ubispl.c: Fix error message
mtd: nand: raw: Fix potential NULL pointer dereference
mtd: nand: Update NAND manufacturer Ids
mtd: nand: raw:atmel_nand: Add missingnand_scan_ident()
Quoted 8 lines
drivers/mtd/nand/raw/atmel_nand.c | 4 ++++ drivers/mtd/nand/raw/nand_base.c | 8 ++++---- drivers/mtd/nand/raw/nand_ids.c | 22 ++++++++++++---------- drivers/mtd/ubispl/ubispl.c | 2 +- include/linux/mtd/rawnand.h | 23 +++++++++++++---------- lib/tiny-printf.c | 2 +- 6 files changed, 35 insertions(+), 26 deletions(-)
Coming back to these patches I had a look and except a typo , it looks good. I can take these through at91 tree or maybe Michael you want to have a look as they touch the MTD/NAND drivers ?
Thanks,
Eugen
Re: [PATCH 0/5] collected fallout of porting an ATSAMA5D2 based board
Quoted 39 lines · Eugen Hristev
Quoted 27 lines · Benedikt Spranger
Hi,
while porting an ATSAMA5D2 based board (booting from NAND flash with UBI) I stumbled over generic, NAND- and UBI related asperity:
1. tiny-printf does not handle NULL arguments to '%s' in a proper way
2.vtbl_check()has an useless debug output due to a typo
3. NAND: An informative output fails badly, if the NAND vendor is unknown
4. thenand_atmeldriver lacks a vital initialisationOK, you might say the
nand_atmelNAND driver is obsolete, but it was the only solution to get booting from NAND running. The new DM based NAND driver refused to do anything usefull, so I dropped it after spending a couple of days debugging it:<RANT>brilliant!</RANT>
regards
Benedikt SprangerBenedikt Spranger (5):
tiny-printf: Handle NULL pointer argument to %sdrivers/mtd/ubispl/ubispl.c: Fix error message
mtd: nand: raw: Fix potential NULL pointer dereference
mtd: nand: Update NAND manufacturer Ids
mtd: nand: raw:atmel_nand: Add missingnand_scan_ident()Quoted 8 lines
drivers/mtd/nand/raw/atmel_nand.c | 4 ++++ drivers/mtd/nand/raw/nand_base.c | 8 ++++---- drivers/mtd/nand/raw/nand_ids.c | 22 ++++++++++++---------- drivers/mtd/ubispl/ubispl.c | 2 +- include/linux/mtd/rawnand.h | 23 +++++++++++++---------- lib/tiny-printf.c | 2 +- 6 files changed, 35 insertions(+), 26 deletions(-)
Quoted 6 lines
Coming back to these patches I had a look and except a typo , it looks good. I can take these through at91 tree or maybe Michael you want to have a look as they touch the MTD/NAND drivers ?
Thanks,
Eugen
I have applied patches 1 and 2 to u-boot-at91/next . The other three would need a resubmit .
Eugen
Re: [PATCH 0/5] collected fallout of porting an ATSAMA5D2 based board
HI all
Quoted 17 lines · Eugen Hristev
Quoted 13 lines · Eugen Hristev
Quoted 10 lines · Benedikt Spranger
Hi,
while porting an ATSAMA5D2 based board (booting from NAND flash with UBI) I stumbled over generic, NAND- and UBI related asperity:
1. tiny-printf does not handle NULL arguments to '%s' in a proper way
2.vtbl_check()has an useless debug output due to a typo
3. NAND: An informative output fails badly, if the NAND vendor is unknown
4. thenand_atmeldriver lacks a vital initialisation
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
OK, you might say the
nand_atmelNAND driver is obsolete, but it was the only solution to get booting from NAND running. The new DM based NAND driver refused to do anything usefull, so I dropped it after spending a couple of days debugging it:<RANT>brilliant!</RANT>
I totally missed those patches. I'm really concerned about it. I will review the respin
Michael
Quoted 31 lines
Quoted 19 lines
Quoted 10 lines
regards
Benedikt SprangerBenedikt Spranger (5):
tiny-printf: Handle NULL pointer argument to %sdrivers/mtd/ubispl/ubispl.c: Fix error message
mtd: nand: raw: Fix potential NULL pointer dereference
mtd: nand: Update NAND manufacturer Ids
mtd: nand: raw:atmel_nand: Add missingnand_scan_ident()Quoted 8 lines
drivers/mtd/nand/raw/atmel_nand.c | 4 ++++ drivers/mtd/nand/raw/nand_base.c | 8 ++++---- drivers/mtd/nand/raw/nand_ids.c | 22 ++++++++++++---------- drivers/mtd/ubispl/ubispl.c | 2 +- include/linux/mtd/rawnand.h | 23 +++++++++++++---------- lib/tiny-printf.c | 2 +- 6 files changed, 35 insertions(+), 26 deletions(-)Quoted 6 lines
Coming back to these patches I had a look and except a typo , it looks good. I can take these through at91 tree or maybe Michael you want to have a look as they touch the MTD/NAND drivers ?
Thanks,
EugenI have applied patches 1 and 2 to u-boot-at91/next . The other three would need a resubmit .
Eugen
Signature · 11 lines
Michael Nazzareno Trimarchi Co-Founder & Chief Executive Officer M. +39 347 913 2170 [email protected] __________________________________ Amarula Solutions BV Joop Geesinkweg 125, 1114 AB, Amsterdam, NL T. +31 (0)85 111 9172 [email protected] www.amarulasolutions.com
PATCH 1/5 tiny-printf: Handle NULL pointer argument to %s
In reply to Benedikt SprangerA NULL pointer argument to %s causes a NULL pointer dereference in the fixed width numerical printout code, since p is overwritten with NULL. In case of %s width is 0. Check width before dereferencing the pointer.
--- lib/tiny-printf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/tiny-printf.c +1 -1
@@ -311,7 +311,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va) *info->bf =0 ; info->bf = p; -while (*info->bf++ && width >0 ) +while (width >0 && info->bf && *info->bf++) width--;while (width-- >0 ) info->putc (info, lz ?'0' :' ' );
Signature · 1 line
2.45.2
PATCH 2/5 drivers/mtd/ubispl/ubispl.c: Fix error message
In reply to Benedikt SprangerThe bad CRC error message has transposed characters, which render the output useless:
"bad CRC at record 213: #08x, not #08x" instead of "bad CRC at record 213: #00000000, not #4be31f4d"
Fix the error message.
--- drivers/mtd/ubispl/ubispl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ubispl/ubispl.c +1 -1
@@ -113,7 +113,7 @@ static int vtbl_check(struct ubi_scan_info *ubi, crc =crc32 (UBI_CRC32_INIT , &vtbl[i],UBI_VTBL_RECORD_SIZE_CRC );if (be32_to_cpu (vtbl[i].crc) != crc) { -ubi_err ("bad CRC at record %u: %#08x, not %#08x" , +ubi_err ("bad CRC at record %u: #%08x, not #%08x" , i, crc,be32_to_cpu (vtbl[i].crc));ubi_dump_vtbl_record (&vtbl[i], i);return 1 ;
Signature · 1 line
2.45.2
PATCH 3/5 mtd: nand: raw: Fix potential NULL pointer dereference
In reply to Benedikt SprangerA NAND manufacture ID may not be found in nand_manuf_ids[] database. In case of an ONFI or JEDEC NAND a crutial NULL pointer check is missing and printing out the manufacture name result in a NULL pointer dereference. Instead of adding additional NULL pointer checks ensure a valid nand_menufacture_desc and remove the checks entirely.
--- drivers/mtd/nand/raw/nand_base.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/nand_base.c +4 -4
@@ -4241,7 +4241,7 @@ static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip,* @id: manufacturer ID * * Returns a nand_manufacturer_desc object if the manufacturer is defined -* in the NAND manufacturers database, NULL otherwise. +* in the NAND manufacturers database, "Unknown" entry otherwise. */ static const struct nand_manufacturer *nand_get_manufacturer_desc (u8 id) {
@@ -4252,7 +4252,7 @@ static const struct nand_manufacturer *nand_get_manufacturer_desc(u8 id)return &nand_manuf_ids[i]; } -return NULL ; +return &nand_manuf_ids[i]; }/*
@@ -4425,13 +4425,13 @@ ident_done: else if (chip->jedec_version) pr_info("%s %s\n", manufacturer_desc->name, chip->jedec_params.model); - else if (manufacturer_desc) + else pr_info("%s %s\n", manufacturer_desc->name, type->name);#else if (chip->jedec_version)pr_info ("%s %s\n" , manufacturer_desc->name, chip->jedec_params.model); -else if (manufacturer_desc) +else pr_info ("%s %s\n" , manufacturer_desc->name, type->name);#endif
Signature · 1 line
2.45.2
PATCH 4/5 mtd: nand: Update NAND manufacturer Ids
In reply to Benedikt SprangerAlign manufacturer Ids with the Id list from Linux kernel v6.11. While at it, sort the entries in alphabetical order.
--- drivers/mtd/nand/raw/nand_ids.c | 22 ++++++++++++---------- include/linux/mtd/rawnand.h | 23 +++++++++++++---------- 2 files changed, 25 insertions(+), 20 deletions(-)
drivers/mtd/nand/raw/nand_ids.c +12 -10
@@ -180,20 +180,22 @@ struct nand_flash_dev nand_flash_ids[] = {/* Manufacturer IDs */ struct nand_manufacturer nand_manuf_ids[] = { - {NAND_MFR_TOSHIBA ,"Toshiba" , &toshiba_nand_manuf_ops}, - {NAND_MFR_SAMSUNG ,"Samsung" , &samsung_nand_manuf_ops}, + {NAND_MFR_AMD ,"AMD/Spansion" , &amd_nand_manuf_ops}, + {NAND_MFR_ATO ,"ATO" }, + {NAND_MFR_EON ,"Eon" }, + {NAND_MFR_EON ,"ESMT" }, {NAND_MFR_FUJITSU ,"Fujitsu" }, - {NAND_MFR_NATIONAL ,"National" }, - {NAND_MFR_RENESAS ,"Renesas" }, - {NAND_MFR_STMICRO ,"ST Micro" }, {NAND_MFR_HYNIX ,"Hynix" , &hynix_nand_manuf_ops}, - {NAND_MFR_MICRON ,"Micron" , µn_nand_manuf_ops}, - {NAND_MFR_AMD ,"AMD/Spansion" , &amd_nand_manuf_ops}, + {NAND_MFR_INTEL ,"Intel" }, {NAND_MFR_MACRONIX ,"Macronix" , ¯onix_nand_manuf_ops}, - {NAND_MFR_EON ,"Eon" }, + {NAND_MFR_MICRON ,"Micron" , µn_nand_manuf_ops}, + {NAND_MFR_NATIONAL ,"National" }, + {NAND_MFR_RENESAS ,"Renesas" }, + {NAND_MFR_SAMSUNG ,"Samsung" , &samsung_nand_manuf_ops}, {NAND_MFR_SANDISK ,"SanDisk" }, - {NAND_MFR_INTEL ,"Intel" }, - {NAND_MFR_ATO ,"ATO" }, + {NAND_MFR_STMICRO ,"ST Micro" }, + {NAND_MFR_TOSHIBA ,"Toshiba" , &toshiba_nand_manuf_ops}, + {NAND_MFR_WINBOND ,"Winbond" }, {0x0 ,"Unknown" } };
include/linux/mtd/rawnand.h +13 -10
@@ -1030,20 +1030,23 @@ static inline void *nand_get_manufacturer_data(struct nand_chip *chip)/* * NAND Flash Manufacturer ID Codes */ -#define NAND_MFR_TOSHIBA 0x98 -#define NAND_MFR_SAMSUNG 0xec +#define NAND_MFR_AMD 0x01 +#define NAND_MFR_ATO 0x9b +#define NAND_MFR_EON 0x92 +#define NAND_MFR_ESMT 0xc8#define NAND_MFR_FUJITSU 0x04 -#define NAND_MFR_NATIONAL 0x8f -#define NAND_MFR_RENESAS 0x07 -#define NAND_MFR_STMICRO 0x20#define NAND_MFR_HYNIX 0xad -#define NAND_MFR_MICRON 0x2c -#define NAND_MFR_AMD 0x01 +#define NAND_MFR_INTEL 0x89#define NAND_MFR_MACRONIX 0xc2 -#define NAND_MFR_EON 0x92 +#define NAND_MFR_MICRON 0x2c +#define NAND_MFR_NATIONAL 0x8f +#define NAND_MFR_RENESAS 0x07 +#define NAND_MFR_SAMSUNG 0xec#define NAND_MFR_SANDISK 0x45 -#define NAND_MFR_INTEL 0x89 -#define NAND_MFR_ATO 0x9b +#define NAND_MFR_STMICRO 0x20 +/* Kioxia is new name of Toshiba memory. */ +#define NAND_MFR_TOSHIBA 0x98 +#define NAND_MFR_WINBOND 0xef/* The maximum expected count of bytes in the NAND ID sequence */ #define NAND_MAX_ID_LEN 8
Signature · 1 line
2.45.2
Re: [PATCH 4/5] mtd: nand: Update NAND manufacturer Ids
Hi Benedikt ,
Quoted 15 lines · Benedikt Spranger
Align manufacturer Ids with the Id list from Linux kernel v6.11. While at it, sort the entries in alphabetical order.
Signed-off-by Benedikt Spranger <[email protected]>Reviewed-by John Ogness <[email protected]>--- drivers/mtd/nand/raw/nand_ids.c | 22 ++++++++++++---------- include/linux/mtd/rawnand.h | 23 +++++++++++++---------- 2 files changed, 25 insertions(+), 20 deletions(-)drivers/mtd/nand/raw/nand_ids.c +0
-0
drivers/mtd/nand/raw/nand_ids.c struct nand_flash_dev nand_flash_ids[] = { · line 186
Quoted 9 lines
drivers/mtd/nand/raw/nand_ids.c +4
-2@@ -180,20 +180,22 @@ struct nand_flash_dev nand_flash_ids[] = {/* Manufacturer IDs */ struct nand_manufacturer nand_manuf_ids[] = { - {NAND_MFR_TOSHIBA ,"Toshiba" , &toshiba_nand_manuf_ops}, - {NAND_MFR_SAMSUNG ,"Samsung" , &samsung_nand_manuf_ops}, + {NAND_MFR_AMD ,"AMD/Spansion" , &amd_nand_manuf_ops}, + {NAND_MFR_ATO ,"ATO" }, + {NAND_MFR_EON ,"Eon" }, + {NAND_MFR_EON ,"ESMT" },
Did you mean NAND_MFR_ESMT here ?
Quoted 61 lines
drivers/mtd/nand/raw/nand_ids.c +8
-8{NAND_MFR_FUJITSU, "Fujitsu"}, - {NAND_MFR_NATIONAL, "National"}, - {NAND_MFR_RENESAS, "Renesas"}, - {NAND_MFR_STMICRO, "ST Micro"}, {NAND_MFR_HYNIX, "Hynix", &hynix_nand_manuf_ops}, - {NAND_MFR_MICRON, "Micron", µn_nand_manuf_ops}, - {NAND_MFR_AMD, "AMD/Spansion", &amd_nand_manuf_ops}, + {NAND_MFR_INTEL, "Intel"}, {NAND_MFR_MACRONIX, "Macronix", ¯onix_nand_manuf_ops}, - {NAND_MFR_EON, "Eon"}, + {NAND_MFR_MICRON, "Micron", µn_nand_manuf_ops}, + {NAND_MFR_NATIONAL, "National"}, + {NAND_MFR_RENESAS, "Renesas"}, + {NAND_MFR_SAMSUNG, "Samsung", &samsung_nand_manuf_ops}, {NAND_MFR_SANDISK, "SanDisk"}, - {NAND_MFR_INTEL, "Intel"}, - {NAND_MFR_ATO, "ATO"}, + {NAND_MFR_STMICRO, "ST Micro"}, + {NAND_MFR_TOSHIBA, "Toshiba", &toshiba_nand_manuf_ops}, + {NAND_MFR_WINBOND, "Winbond"}, {0x0, "Unknown"} };include/linux/mtd/rawnand.h +13
-10@@ -1030,20 +1030,23 @@ static inline void *nand_get_manufacturer_data(struct nand_chip *chip)/* * NAND Flash Manufacturer ID Codes */ -#define NAND_MFR_TOSHIBA 0x98 -#define NAND_MFR_SAMSUNG 0xec +#define NAND_MFR_AMD 0x01 +#define NAND_MFR_ATO 0x9b +#define NAND_MFR_EON 0x92 +#define NAND_MFR_ESMT 0xc8#define NAND_MFR_FUJITSU 0x04 -#define NAND_MFR_NATIONAL 0x8f -#define NAND_MFR_RENESAS 0x07 -#define NAND_MFR_STMICRO 0x20#define NAND_MFR_HYNIX 0xad -#define NAND_MFR_MICRON 0x2c -#define NAND_MFR_AMD 0x01 +#define NAND_MFR_INTEL 0x89#define NAND_MFR_MACRONIX 0xc2 -#define NAND_MFR_EON 0x92 +#define NAND_MFR_MICRON 0x2c +#define NAND_MFR_NATIONAL 0x8f +#define NAND_MFR_RENESAS 0x07 +#define NAND_MFR_SAMSUNG 0xec#define NAND_MFR_SANDISK 0x45 -#define NAND_MFR_INTEL 0x89 -#define NAND_MFR_ATO 0x9b +#define NAND_MFR_STMICRO 0x20 +/* Kioxia is new name of Toshiba memory. */ +#define NAND_MFR_TOSHIBA 0x98 +#define NAND_MFR_WINBOND 0xef/* The maximum expected count of bytes in the NAND ID sequence */ #define NAND_MAX_ID_LEN 8
Re: [PATCH 4/5] mtd: nand: Update NAND manufacturer Ids
On Tue, 12 Nov 2024 15:39:23 +0200
Eugen Hristev <[email protected]> wrote:
Hi Eugen,
Quoted 17 lines · Benedikt Spranger
Quoted 16 lines
Align manufacturer Ids with the Id list from Linux kernel v6.11. While at it, sort the entries in alphabetical order.
Signed-off-by Benedikt Spranger <[email protected]>Reviewed-by John Ogness <[email protected]>--- drivers/mtd/nand/raw/nand_ids.c | 22 ++++++++++++---------- include/linux/mtd/rawnand.h | 23 +++++++++++++---------- 2 files changed, 25 insertions(+), 20 deletions(-)drivers/mtd/nand/raw/nand_ids.c +0
-0@@ -180,20 +180,22 @@ struct nand_flash_dev nand_flash_ids[] = {
Quoted 10 lines
drivers/mtd/nand/raw/nand_ids.c struct nand_flash_dev nand_flash_ids[] = { · line 186
Quoted 8 lines
drivers/mtd/nand/raw/nand_ids.c +4
-2/* Manufacturer IDs */ struct nand_manufacturer nand_manuf_ids[] = { - {NAND_MFR_TOSHIBA ,"Toshiba" , &toshiba_nand_manuf_ops}, - {NAND_MFR_SAMSUNG ,"Samsung" , &samsung_nand_manuf_ops}, + {NAND_MFR_AMD ,"AMD/Spansion" , &amd_nand_manuf_ops}, + {NAND_MFR_ATO ,"ATO" }, + {NAND_MFR_EON ,"Eon" }, + {NAND_MFR_EON ,"ESMT" },Did you mean
NAND_MFR_ESMThere ?
Yes, fatfingered that...
Regards
Benedikt Spranger
Re: [PATCH 4/5] mtd: nand: Update NAND manufacturer Ids
Quoted 31 lines · Benedikt Spranger
On Tue, 12 Nov 2024 15:39:23 +0200
Eugen Hristev <[email protected]> wrote:Hi Eugen,
Quoted 17 lines · Benedikt Spranger
Quoted 16 lines
Align manufacturer Ids with the Id list from Linux kernel v6.11. While at it, sort the entries in alphabetical order.
Signed-off-by Benedikt Spranger <[email protected]>Reviewed-by John Ogness <[email protected]>--- drivers/mtd/nand/raw/nand_ids.c | 22 ++++++++++++---------- include/linux/mtd/rawnand.h | 23 +++++++++++++---------- 2 files changed, 25 insertions(+), 20 deletions(-)drivers/mtd/nand/raw/nand_ids.c +0
-0@@ -180,20 +180,22 @@ struct nand_flash_dev nand_flash_ids[] = {Quoted 10 lines
drivers/mtd/nand/raw/nand_ids.c struct nand_flash_dev nand_flash_ids[] = { · line 186
Quoted 8 lines
drivers/mtd/nand/raw/nand_ids.c +4
-2/* Manufacturer IDs */ struct nand_manufacturer nand_manuf_ids[] = { - {NAND_MFR_TOSHIBA ,"Toshiba" , &toshiba_nand_manuf_ops}, - {NAND_MFR_SAMSUNG ,"Samsung" , &samsung_nand_manuf_ops}, + {NAND_MFR_AMD ,"AMD/Spansion" , &amd_nand_manuf_ops}, + {NAND_MFR_ATO ,"ATO" }, + {NAND_MFR_EON ,"Eon" }, + {NAND_MFR_EON ,"ESMT" },Did you mean
NAND_MFR_ESMThere ?
Quoted 4 lines
Yes, fatfingered that...
Regards
Benedikt Spranger
Unfortunately you will need a new revision anyway.
I get this while building sama5d4ek_nandflash_defconfig
arm-none-linux-gnueabihf-ld.bfd: drivers/mtd/nand/raw/nand_base.o: in function `nand_reset_data_interface':
..drivers/mtd/nand/raw/nand_base.c:948:(.text.nand_reset+0xc): undefined reference to nand_get_default_data_interface' arm-none-linux-gnueabihf-ld.bfd: drivers/mtd/nand/raw/nand_base.o: in function nand_flash_detect_onfi':
..drivers/mtd/nand/raw/nand_base.c:3884:(.text.nand_detect+0x318):
undefined reference to `nand_manuf_ids' arm-none-linux-gnueabihf-ld.bfd:
drivers/mtd/nand/raw/nand_base.c:3884:(.text.nand_detect+0x31c):
undefined reference to nand_flash_ids' arm-none-linux-gnueabihf-ld.bfd: drivers/mtd/nand/raw/nand_base.o: in function nand_init_data_interface':
drivers/mtd/nand/raw/nand_base.c:1047:(.text.nand_scan_ident+0x1ec):
undefined reference to `onfi_init_data_interface'
make[1]: *** [scripts/Makefile.xpl:542: spl/u-boot-spl] Error 1
PATCH 5/5 mtd: nand: raw: atmel_nand: Add missing nand_scan_ident()
In reply to Benedikt SprangerIn board_nand_init() the used NAND flash is not evaluated. This left vital parts of internal structures uninitialized and SPL NAND flash access is broken.
Add the missing nand_scan_ident() to board_nand_init().
--- drivers/mtd/nand/raw/atmel_nand.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mtd/nand/raw/atmel_nand.c +4 -0
@@ -1423,6 +1423,10 @@ int board_nand_init(struct nand_chip *nand) nand->bbt_options |=NAND_BBT_USE_FLASH ;#endif + ret =nand_scan_ident (mtd,CONFIG_SYS_NAND_MAX_CHIPS ,NULL ); +if (ret) +return ret; +#ifdef CONFIG_ATMEL_NAND_HWECC #ifdef CONFIG_ATMEL_NAND_HW_PMECC ret =atmel_pmecc_nand_init_params (nand, mtd);
Signature · 1 line
2.45.2
Hello Benedikt,
Am Fri, Oct 18, 2024 at 10:30:00AM +0200 schrieb Benedikt Spranger:
Quoted 10 lines
Hi,
while porting an ATSAMA5D2 based board (booting from NAND flash with UBI) I stumbled over generic, NAND- and UBI related asperity:
1. tiny-printf does not handle NULL arguments to '%s' in a proper way
2.vtbl_check()has an useless debug output due to a typo
3. NAND: An informative output fails badly, if the NAND vendor is unknown
4. thenand_atmeldriver lacks a vital initialisation
Quoted 4 lines
OK, you might say the
nand_atmelNAND driver is obsolete, but it was the only solution to get booting from NAND running. The new DM based NAND driver refused to do anything usefull, so I dropped it after spending a couple of days debugging it:
Strange. I have at least three different boards with SAMA5D27 successfully booting from NAND flash with the new DM based driver (unfortunately none of them upstreamed, which also won't change in the foreseeable future, sorry).
Do you use at91bootstrap as 2nd level bootloader like me or something else? For me it was basically getting the dts for U-Boot correct, but I got that running with all U-Boot releases since 2023.04 up to 2024.10. Could you share some more detail?
Quoted 1 line
<RANT>brilliant!</RANT>
Did you talk with Microchip about it?
Greets
Alex
Quoted 24 lines
regards
Benedikt SprangerBenedikt Spranger (5):
tiny-printf: Handle NULL pointer argument to %sdrivers/mtd/ubispl/ubispl.c: Fix error message
mtd: nand: raw: Fix potential NULL pointer dereference
mtd: nand: Update NAND manufacturer Ids
mtd: nand: raw:atmel_nand: Add missingnand_scan_ident()drivers/mtd/nand/raw/atmel_nand.c | 4 ++++ drivers/mtd/nand/raw/nand_base.c | 8 ++++---- drivers/mtd/nand/raw/nand_ids.c | 22 ++++++++++++---------- drivers/mtd/ubispl/ubispl.c | 2 +- include/linux/mtd/rawnand.h | 23 +++++++++++++---------- lib/tiny-printf.c | 2 +- 6 files changed, 35 insertions(+), 26 deletions(-)Signature · 1 line
2.45.2
On Fri, 18 Oct 2024 15:11:20 +0200
Alexander Dahl <[email protected]> wrote:
Hello Alexander,
Quoted 10 lines
Am Fri, Oct 18, 2024 at 10:30:00AM +0200 schrieb Benedikt Spranger:
Quoted 4 lines
OK, you might say the
nand_atmelNAND driver is obsolete, but it was the only solution to get booting from NAND running. The new DM based NAND driver refused to do anything usefull, so I dropped it after spending a couple of days debugging it:Strange. I have at least three different boards with SAMA5D27 successfully booting from NAND flash with the new DM based driver (unfortunately none of them upstreamed, which also won't change in the foreseeable future, sorry).
OK.
Quoted 2 lines
Do you use at91bootstrap as 2nd level bootloader like me or something else?
I use the U-Boot SPL. There is no UBI support in at91boostrap. There were some attemps, but...
No interest at the at91bootstrap side.
Quoted 3 lines
For me it was basically getting the dts for U-Boot correct, but I got that running with all U-Boot releases since 2023.04 up to 2024.10. Could you share some more detail?
I face all the trouble in SPL. And since the SPL is the essential part here (UBI support) I gave up at one point. I simply couldn't any usefull read data from the NAND flash, but all 0.
Regards
Benedikt Spranger
Hello Benedikt,
Am Fri, Oct 18, 2024 at 04:19:08PM +0200 schrieb Benedikt Spranger:
Quoted 15 lines
On Fri, 18 Oct 2024 15:11:20 +0200
Alexander Dahl <[email protected]> wrote:Hello Alexander,
Quoted 10 lines
Am Fri, Oct 18, 2024 at 10:30:00AM +0200 schrieb Benedikt Spranger:
Quoted 4 lines
OK, you might say the
nand_atmelNAND driver is obsolete, but it was the only solution to get booting from NAND running. The new DM based NAND driver refused to do anything usefull, so I dropped it after spending a couple of days debugging it:Strange. I have at least three different boards with SAMA5D27 successfully booting from NAND flash with the new DM based driver (unfortunately none of them upstreamed, which also won't change in the foreseeable future, sorry).
Quoted 7 lines
OK.
Quoted 2 lines
Do you use at91bootstrap as 2nd level bootloader like me or something else?
I use the U-Boot SPL. There is no UBI support in at91boostrap. There were some attemps, but...
No interest at the at91bootstrap side.
Yeah, been there. Wanted at91bootstrap to boot from SPI-NOR which is _not_ Quad-SPI, and the feature request was closed with "if you wanna do it by yourself, ask our support for help". :-/
Quoted 6 lines
Quoted 3 lines
For me it was basically getting the dts for U-Boot correct, but I got that running with all U-Boot releases since 2023.04 up to 2024.10. Could you share some more detail?
I face all the trouble in SPL. And since the SPL is the essential part here (UBI support) I gave up at one point. I simply couldn't any usefull read data from the NAND flash, but all 0.
You can not store bootstrap or SPL in UBI, it must sit in first sector of raw NAND, I suppose that's how you load SPL? Did you try reading/writing raw NAND from there? I'm not familiar with SPL, does it consider dts? I could share my dts parts if that helps you.
(What I do here: SoC loads at91bootstrap from raw NAND at offset 0, at91bootstrap loads U-Boot from raw NAND at some offset like 0x20000, U-Boot (proper) loads everything else from UBI.)
Greets
Alex
Hello,
Quoted 25 lines · Alexander Dahl
Hello Benedikt,
Am Fri, Oct 18, 2024 at 04:19:08PM +0200 schrieb Benedikt Spranger:
Quoted 22 lines
On Fri, 18 Oct 2024 15:11:20 +0200
Alexander Dahl <[email protected]> wrote:Hello Alexander,
Quoted 10 lines
Am Fri, Oct 18, 2024 at 10:30:00AM +0200 schrieb Benedikt Spranger:
Quoted 4 lines
OK, you might say the
nand_atmelNAND driver is obsolete, but it was the only solution to get booting from NAND running. The new DM based NAND driver refused to do anything usefull, so I dropped it after spending a couple of days debugging it:Strange. I have at least three different boards with SAMA5D27 successfully booting from NAND flash with the new DM based driver (unfortunately none of them upstreamed, which also won't change in the foreseeable future, sorry).
OK.
Quoted 2 lines
Do you use at91bootstrap as 2nd level bootloader like me or something else?
I use the U-Boot SPL. There is no UBI support in at91boostrap. There were some attemps, but...
No interest at the at91bootstrap side.
It's not about interest. There are two main reasons:
First, all open source UBI stacks are GPL. At91bootstrap is not GPL and it cannot take GPL restricted code (being MIT ).
Second, all UBI stacks are huge in terms of code and memory. At91bootstrap is a second stage that should fit in 16k , 32k or 64k depending on the platform. So far this restriction could not be met by any UBI implementation. ... and yes, doing a custom in-house small UBI implementation would be challenging, and costly.
Quoted 4 lines
Yeah, been there. Wanted at91bootstrap to boot from SPI-NOR which is _not_ Quad-SPI, and the feature request was closed with "if you wanna do it by yourself, ask our support for help". :-/
iirc at91bootstrap can boot from raw spi-nor (yes, not UBI)
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
For me it was basically getting the dts for U-Boot correct, but I got that running with all U-Boot releases since 2023.04 up to 2024.10. Could you share some more detail?
Quoted 8 lines
Quoted 3 lines
I face all the trouble in SPL. And since the SPL is the essential part here (UBI support) I gave up at one point. I simply couldn't any usefull read data from the NAND flash, but all 0.
You can not store bootstrap or SPL in UBI, it must sit in first sector of raw NAND, I suppose that's how you load SPL? Did you try reading/writing raw NAND from there? I'm not familiar with SPL, does it consider dts? I could share my dts parts if that helps you.
SPL should use dts. However on at91 platforms, SPL is dangerously close to the SRAM limit where it should fit, and it has been challenging in the last years to either make it fit or remove it.
Quoted 4 lines
(What I do here: SoC loads at91bootstrap from raw NAND at offset 0, at91bootstrap loads U-Boot from raw NAND at some offset like
0x20000, U-Boot (proper) loads everything else from UBI.)
Either way, it is interesting to see that the U-boot proper NAND dm driver does not work without at91bootstrap. There may be NAND quirks in at91bootstrap board init that may influence this (pins resets, timing delays, etc).
You can test NAND driver by booting at91bootstrap and Uboot from another medium, like sd-card. In this way, at91bootstrap will not touch NAND device, and you have a clean U-boot booted.
Eugen
Quoted 3 lines
Greets
Alex
Hello Eugen,
Am Mon, Oct 21, 2024 at 10:17:54AM +0300 schrieb Eugen Hristev:
Quoted 28 lines
Hello,
Quoted 24 lines · Alexander Dahl
Hello Benedikt,
Am Fri, Oct 18, 2024 at 04:19:08PM +0200 schrieb Benedikt Spranger:
Quoted 21 lines
On Fri, 18 Oct 2024 15:11:20 +0200
Alexander Dahl <[email protected]> wrote:Hello Alexander,
Quoted 10 lines
Am Fri, Oct 18, 2024 at 10:30:00AM +0200 schrieb Benedikt Spranger:
Quoted 4 lines
OK, you might say the
nand_atmelNAND driver is obsolete, but it was the only solution to get booting from NAND running. The new DM based NAND driver refused to do anything usefull, so I dropped it after spending a couple of days debugging it:Strange. I have at least three different boards with SAMA5D27 successfully booting from NAND flash with the new DM based driver (unfortunately none of them upstreamed, which also won't change in the foreseeable future, sorry).
OK.
Quoted 2 lines
Do you use at91bootstrap as 2nd level bootloader like me or something else?
I use the U-Boot SPL. There is no UBI support in at91boostrap. There were some attemps, but...
No interest at the at91bootstrap side.
Quoted 9 lines
It's not about interest. There are two main reasons:
First, all open source UBI stacks are GPL. At91bootstrap is not GPL and it cannot take GPL restricted code (being MIT ).
Second, all UBI stacks are huge in terms of code and memory. At91bootstrap is a second stage that should fit in 16k , 32k or 64k depending on the platform. So far this restriction could not be met by any UBI implementation.
... and yes, doing a custom in-house small UBI implementation would be challenging, and costly.
I suspected technical reasons, but nice to know it's also licensing.
(Side note: To increase robustness we considered storing bootloaders (and maybe U-Boot env) in SPI-NOR flash with longer data retention, and use UBI on raw NAND for everything else.)
Quoted 7 lines
Quoted 5 lines
Yeah, been there. Wanted at91bootstrap to boot from SPI-NOR which is _not_ Quad-SPI, and the feature request was closed with "if you wanna do it by yourself, ask our support for help". :-/
iirc at91bootstrap can boot from raw spi-nor (yes, not UBI)
Speaking of at91bootstrap 3.x and later: It can, but only if you use the QSPI port, it does not work with flexcom for example. See
https://github.com/linux4sam/at91bootstrap/issues/181 for reference.
Quoted 18 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
For me it was basically getting the dts for U-Boot correct, but I got that running with all U-Boot releases since 2023.04 up to 2024.10. Could you share some more detail?
Quoted 8 lines
Quoted 3 lines
I face all the trouble in SPL. And since the SPL is the essential part here (UBI support) I gave up at one point. I simply couldn't any usefull read data from the NAND flash, but all 0.
You can not store bootstrap or SPL in UBI, it must sit in first sector of raw NAND, I suppose that's how you load SPL? Did you try reading/writing raw NAND from there? I'm not familiar with SPL, does it consider dts? I could share my dts parts if that helps you.
SPL should use dts. However on at91 platforms, SPL is dangerously close to the SRAM limit where it should fit, and it has been challenging in the last years to either make it fit or remove it.
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
(What I do here: SoC loads at91bootstrap from raw NAND at offset 0, at91bootstrap loads U-Boot from raw NAND at some offset like
0x20000, U-Boot (proper) loads everything else from UBI.)Either way, it is interesting to see that the U-boot proper NAND dm driver does not work without at91bootstrap.
There may be NAND quirks in at91bootstrap board init that may influence this (pins resets, timing delays, etc).
Think this is a misunderstanding here. I have this combination running, and from the discussions on NAND issues on at91 on this list I think at least two developers at Microchip, too. From my understanding U-Boot proper completely (re)initializes everything required to get NAND to work. I can not speak about U-Boot SPL though, never tried that.
Quoted 3 lines
You can test NAND driver by booting at91bootstrap and Uboot from another medium, like sd-card. In this way, at91bootstrap will not touch NAND device, and you have a clean U-boot booted.
Lets hear what Benedikt has tried. ;-)
Greets
Alex
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Yeah, been there. Wanted at91bootstrap to boot from SPI-NOR which is _not_ Quad-SPI, and the feature request was closed with "if you wanna do it by yourself, ask our support for help". :-/
Quoted 6 lines
Quoted 1 line
iirc at91bootstrap can boot from raw spi-nor (yes, not UBI)
Speaking of at91bootstrap 3.x and later: It can, but only if you use the QSPI port, it does not work with flexcom for example. See
https://github.com/linux4sam/at91bootstrap/issues/181 for reference.
Judging by the answer, we are both right, my memory was saying it works, and apparently for some older SoCs it's also implemented, while not for sam9x60 at the moment.
I remember using a flexcom in SPI mode was fairly simple and should work out of the box with the existing SPI driver in at91bootstrap, just that the flexcom mode has to be correctly configured, pinout, etc.
On Mon, 21 Oct 2024 10:17:54 +0300
Eugen Hristev <[email protected]> wrote:
Hi,
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Do you use at91bootstrap as 2nd level bootloader like me or something else?
I use the U-Boot SPL. There is no UBI support in at91boostrap. There were some attemps, but...
No interest at the at91bootstrap side.It's not about interest. There are two main reasons:
First, all open source UBI stacks are GPL. At91bootstrap is not GPL and it cannot take GPL restricted code (being MIT ).
I do not recall any issue mentioned about a license issue, when I send out UBI patches for the AT91boostrap over a decade ago. It was a simple "nice, I put it in a branch, but we do not need it."
I followed the UBI topic in AT91bootstrap loosely after that.
Quoted 1 line
Second, all UBI stacks are huge in terms of code and memory.
OK. Maybe we have a different view on huge. The board I am supporting now is the successor of a AT91SAM9263 board. This (old) board use AT91boootstrap with UBI support. BTW: The original requirement for UBI support was to fit into 4k (PPC 440 bootloader).
Quoted 3 lines
At91bootstrap is a second stage that should fit in 16k , 32k or 64k depending on the platform. So far this restriction could not be met by any UBI implementation.
OK. This need some more in depth view:
A SPL needs UBI read support only. This support can be done in less then 4k, as I mentioned before. So UBI full read/write support? You're right. It does not fit.
Needed read support?
It definitly fit (and works fine for over a decade).
Quoted 2 lines
... and yes, doing a custom in-house small UBI implementation would be challenging, and costly.
If you look at ubispl, you got some clue, what's needed. The UBI support to the AT91boostrap (for the AT91SAM9263) is about ~450 LOC. Managable, but why should I do it, when U-Boot SPL does the job...
Quoted 6 lines
Quoted 3 lines
(What I do here: SoC loads at91bootstrap from raw NAND at offset 0, at91bootstrap loads U-Boot from raw NAND at some offset like
0x20000, U-Boot (proper) loads everything else from UBI.)Either way, it is interesting to see that the U-boot proper NAND dm driver does not work without at91bootstrap.
To be clear: The U-Boot *SPL* does not work with the NAND dm driver.
The old NAND driver does. So from a developers view I can spend some spare cycles on that, from a overall project view: we use the old driver, since it is working.
Regards
Benedikt Spranger
Quoted 11 lines · Benedikt Spranger
On Mon, 21 Oct 2024 10:17:54 +0300
Eugen Hristev <[email protected]> wrote:Hi,
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Do you use at91bootstrap as 2nd level bootloader like me or something else?
I use the U-Boot SPL. There is no UBI support in at91boostrap. There were some attemps, but...
No interest at the at91bootstrap side.
Quoted 7 lines
Quoted 3 lines
It's not about interest. There are two main reasons:
First, all open source UBI stacks are GPL. At91bootstrap is not GPL and it cannot take GPL restricted code (being MIT ).I do not recall any issue mentioned about a license issue, when I send out UBI patches for the AT91boostrap over a decade ago. It was a simple "nice, I put it in a branch, but we do not need it."
I followed the UBI topic in AT91bootstrap loosely after that.
The patches that I saw ( I do not recall whether they were yours or not) while I was maintaining the project were GPL and about 4000 LOC. It was adding more than 12k to the size.
Quoted 10 lines
Quoted 2 lines
Second, all UBI stacks are huge in terms of code and memory.
OK. Maybe we have a different view on huge. The board I am supporting now is the successor of a AT91SAM9263 board. This (old) board use AT91boootstrap with UBI support. BTW: The original requirement for UBI support was to fit into 4k (PPC 440 bootloader).
Quoted 3 lines
At91bootstrap is a second stage that should fit in 16k , 32k or 64k depending on the platform. So far this restriction could not be met by any UBI implementation.
Quoted 7 lines
OK. This need some more in depth view:
A SPL needs UBI read support only. This support can be done in less then 4k, as I mentioned before. So UBI full read/write support? You're right. It does not fit.Needed read support?
It definitly fit (and works fine for over a decade).
I am glad you see you have an implementation that works. I am no longer maintaining that project so I cannot say anything about the possibility of ever merging it.
Quoted 6 lines
Quoted 3 lines
... and yes, doing a custom in-house small UBI implementation would be challenging, and costly.
If you look at ubispl, you got some clue, what's needed. The UBI support to the AT91boostrap (for the AT91SAM9263) is about ~450 LOC. Managable, but why should I do it, when U-Boot SPL does the job...
I can understand that. Nobody asked you to do it.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
(What I do here: SoC loads at91bootstrap from raw NAND at offset 0, at91bootstrap loads U-Boot from raw NAND at some offset like
0x20000, U-Boot (proper) loads everything else from UBI.)
Quoted 7 lines
Quoted 2 lines
Either way, it is interesting to see that the U-boot proper NAND dm driver does not work without at91bootstrap.
To be clear: The U-Boot *SPL* does not work with the NAND dm driver.
The old NAND driver does. So from a developers view I can spend some spare cycles on that, from a overall project view: we use the old driver, since it is working.
Ok, so my understanding was wrong, in fact you cannot use NAND dm in the SPL. It may be that there are some missing components from U-boot proper that are not built in (or some quirk/initialization) So this can be looked into by the people interested, and I can understand that you have a solution that works for you.
Quoted 3 lines
Regards
Benedikt Spranger
Am Mon, 21 Oct 2024 08:03:35 +0200
schrieb Alexander Dahl <[email protected]>:
Quoted 34 lines
Hello Benedikt,
Am Fri, Oct 18, 2024 at 04:19:08PM +0200 schrieb Benedikt Spranger:
Quoted 16 lines
On Fri, 18 Oct 2024 15:11:20 +0200
Alexander Dahl <[email protected]> wrote:Hello Alexander,
Quoted 11 lines
Am Fri, Oct 18, 2024 at 10:30:00AM +0200 schrieb Benedikt Spranger:
Quoted 4 lines
OK, you might say the
nand_atmelNAND driver is obsolete, but it was the only solution to get booting from NAND running. The new DM based NAND driver refused to do anything usefull, so I dropped it after spending a couple of days debugging it:Strange. I have at least three different boards with SAMA5D27 successfully booting from NAND flash with the new DM based driver (unfortunately none of them upstreamed, which also won't change in the foreseeable future, sorry).
Quoted 7 lines
OK.
Quoted 2 lines
Do you use at91bootstrap as 2nd level bootloader like me or something else?
I use the U-Boot SPL. There is no UBI support in at91boostrap. There were some attemps, but...
No interest at the at91bootstrap side.Yeah, been there. Wanted at91bootstrap to boot from SPI-NOR which is _not_ Quad-SPI, and the feature request was closed with "if you wanna do it by yourself, ask our support for help". :-/
Quoted 3 lines
Quoted 3 lines
For me it was basically getting the dts for U-Boot correct, but I got that running with all U-Boot releases since 2023.04 up to 2024.10. Could you share some more detail?
Quoted 6 lines
Quoted 3 lines
I face all the trouble in SPL. And since the SPL is the essential part here (UBI support) I gave up at one point. I simply couldn't any usefull read data from the NAND flash, but all 0.
You can not store bootstrap or SPL in UBI, it must sit in first sector of raw NAND, I suppose that's how you load SPL?
Sorry for not beeing that clear.
The SPL sits in the first Page in NAND flash. It does it's magic and then load the U-Boot payload from an UBI volume (Or directly load a kernel). Then it "starts" the payload.
Quoted 1 line
Did you try reading/writing raw NAND from there?
I try to read from SPL. That's all what ubispl wants. No need for write support here.
Quoted 1 line
I'm not familiar with SPL, does it consider dts?
It consider dts.
Quoted 1 line
I could share my dts parts if that helps you.
That would be great. I definitly give it a try.
So here is a quick extract (EBI is also used otherwise) of what I did. Hopefully I did not forget anything...
arch/arm/dts/at91-sama5d27_ABC.dts +55 -0
@@ -63,7 +63,62 @@ bias-disable; bootph-all; }; + + pinctrl_nand0_default: nand0_default { + pinmux = + <PIN_PA0__D0>, + <PIN_PA1__D1>, + <PIN_PA2__D2>, + <PIN_PA3__D3>, + <PIN_PA4__D4>, + <PIN_PA5__D5>, + <PIN_PA6__D6>, + <PIN_PA7__D7>, + <PIN_PA8__NWE_NANDWE>, + <PIN_PA9__NCS3>, + <PIN_PA10__A21_NANDALE>, + <PIN_PA11__A22_NANDCLE>, + <PIN_PA12__NRD_NANDOE>, + <PIN_PA21__NANDRDY>; + bias-disable; + }; }; }; }; }; + +&ebi { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_nand0_default>; + status = "okay"; + + nand_controller: nand-controller { + status = "okay"; + + nand@3 { + reg = <0x3 0x0 0x800000>; + //atmel,rb = <0>; + nand-bus-width = <8>; + nand-ecc-mode = "hw"; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-on-flash-bbt; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + spl@0 { + label = "spl"; + reg = <0x0 0x40000>; + }; + + ubi@40000 { + label = "UBI"; + reg = <0x40000 0x0>; + }; + }; + }; + }; +};
Quoted 3 lines
(What I do here: SoC loads at91bootstrap from raw NAND at offset 0, at91bootstrap loads U-Boot from raw NAND at some offset like
0x20000, U-Boot (proper) loads everything else from UBI.)
From my experience that can cause significant headache starting after 5-6 years in use. That's what I try to avoid :)
Regards
Benedikt Spranger
Hello Benedikt,
Am Mon, Oct 21, 2024 at 12:20:17PM +0200 schrieb Benedikt Spranger:
Quoted 8 lines
The SPL sits in the first Page in NAND flash. It does it's magic and then load the U-Boot payload from an UBI volume (Or directly load a kernel). Then it "starts" the payload.
Quoted 1 line
Did you try reading/writing raw NAND from there?
I try to read from SPL. That's all what ubispl wants. No need for write support here.
Quoted 6 lines
Quoted 1 line
I'm not familiar with SPL, does it consider dts?
It consider dts.
Quoted 1 line
I could share my dts parts if that helps you.
That would be great. I definitly give it a try.
So here is a quick extract (EBI is also used otherwise) of what I did.
Using EBI for accessing an FPGA here on one of three boards. So I'll share that dts excerpt from my v2024.10 branch.
Quoted 57 lines
Hopefully I did not forget anything...
arch/arm/dts/at91-sama5d27_ABC.dts +45
-0@@ -63,7 +63,62 @@ bias-disable; bootph-all; }; + + pinctrl_nand0_default: nand0_default { + pinmux = + <PIN_PA0__D0>, + <PIN_PA1__D1>, + <PIN_PA2__D2>, + <PIN_PA3__D3>, + <PIN_PA4__D4>, + <PIN_PA5__D5>, + <PIN_PA6__D6>, + <PIN_PA7__D7>, + <PIN_PA8__NWE_NANDWE>, + <PIN_PA9__NCS3>, + <PIN_PA10__A21_NANDALE>, + <PIN_PA11__A22_NANDCLE>, + <PIN_PA12__NRD_NANDOE>, + <PIN_PA21__NANDRDY>; + bias-disable; + }; }; }; }; }; + +&ebi { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_nand0_default>; + status = "okay"; + + nand_controller: nand-controller { + status = "okay"; + + nand@3 { + reg = <0x3 0x0 0x800000>; + //atmel,rb = <0>; + nand-bus-width = <8>; + nand-ecc-mode = "hw"; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-on-flash-bbt; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + spl@0 { + label = "spl"; + reg = <0x0 0x40000>;
arch/arm/dts/at91-sama5d27_ABC.dts line 124
Quoted 10 lines
arch/arm/dts/at91-sama5d27_ABC.dts +10
-0+ }; + + ubi@40000 { + label = "UBI"; + reg = <0x40000 0x0>; + }; + }; + }; + }; +};
I have no partitions defined, but that should not hurt. Split pinctrl settings here, but that's basically because I have more child nodes on the EBI node in Linux which I don't use in U-Boot here. Should not make such a difference.
Do you have external pull-ups for the A21_NANDALE, A22_NANDCLE, NANDRDY, and NCS3 lines? Maybe cross check that with the board code you probably have for the old non-DM NAND driver.
Now my example:
&ebi {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ebi_default>;
status = "okay"; nand_controller: nand-controller {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_nand_default>;
status = "okay";
nand@3 {
reg = <0x3 0x0 0x800000>;
atmel,rb = <0>;
nand-bus-width = <8>;
nand-ecc-mode = "hw";
nand-on-flash-bbt;
nand-ecc-strength = <8>;
nand-ecc-step-size = <512>;
label = "atmel_nand";
};
};};
&pioA {
pinctrl_ebi_default: ebi_default {
rd_we_data {
pinmux = <PIN_PA22__D0>,
<PIN_PA23__D1>,
<PIN_PA24__D2>,
<PIN_PA25__D3>,
<PIN_PA26__D4>,
<PIN_PA27__D5>,
<PIN_PA28__D6>,
<PIN_PA29__D7>,
<PIN_PA30__NWE_NANDWE>,
<PIN_PB2__NRD_NANDOE>;
bias-disable;
atmel,drive-strength = <ATMEL_PIO_DRVSTR_ME>;
};
}; pinctrl_nand_default: nand_default {
ale_cle_rdy_cs {
pinmux = <PIN_PB0__A21_NANDALE>,
<PIN_PB1__A22_NANDCLE>,
<PIN_PC8__NANDRDY>,
<PIN_PA31__NCS3>;
bias-pull-up;
};
};};
Notice mine uses IO Set 1 here, but your's should work with IO Set 2 as well.
Quoted 5 lines
Quoted 3 lines
(What I do here: SoC loads at91bootstrap from raw NAND at offset 0, at91bootstrap loads U-Boot from raw NAND at some offset like
0x20000, U-Boot (proper) loads everything else from UBI.)From my experience that can cause significant headache starting after 5-6 years in use. That's what I try to avoid :)
I'm aware of that. The data retention time for the NAND flash used here is 10 years according to datasheet. No big deal on Linux when running ubihealthd for everything stored in UBI, but everything outside of that is about to fail some day. :-/
Greets
Alex