sam9x5ek

Last modified by Microchip on 2025/07/17 12:21

Information

when choosing the board variant with the -b parameter of SAM-BA, the default PMECC configuration for the NAND populated on the board is valid. You can verify its value by running the command that reads one byte in a dummy file (named test.bin in the following command):

Warning

before accessing the NAND flash, you have to initialize the external RAM:

# sam-ba -p serial -b sam9xx5-ek -a extram 
# sam-ba -p serial -b sam9xx5-ek -a nandflash -c read:test.bin:0:1
Opening serial port 'ttyACM0'
Connection opened.
Compatible device detected: SAM9G35.
Detected memory size is 268435456 bytes.
Page size is 2048 bytes.
Buffer is 131072 bytes (64 pages) at address 0x2000a000.
NAND header value is 0xc0c00405.
Supported erase block sizes: 128KB
Executing command 'read:test.bin:0:1'
Read 1 bytes at address 0x00000000 (100.00%)
Connection closed.

You can figure out that the default PMECC parameter for this sam9xx5-ek board is 0xc0c00405.

Information

Note that if you connect a serial console to the SoC RomCode default UART, you can see even more details about the NAND ECC parameters given by the SAM-BA Applet:

Applet 'NAND Flash' from softpack 3.8 (v3.8).
Initializing NAND ioSet1 Bus Width 16
PMECC configuration: 0xc0c00405
Sector size: 512
Sectors per page: 4
Spare size: 64
ECC bits: 2
ECC offset: 48
ECC size: 16
PMECC enabled
Buffer Address: 0x2000a000
Buffer Size: 67065856 bytes
NAND applet initialized successfully.

If you want to change the default PMECC parameters you can simply specify another value on the SAM-BA command line with the -a nandflash argument as shown below:

# sam-ba -p serial -b sam9xx5-ek -a nandflash:help
Syntax: nandflash:[<ioset>]:[<bus_width>]:[<header>]
Parameters:
   ioset      I/O set
   bus_width  NAND bus width (8/16)
   header     NAND header value
Examples:
   nandflash                 use default board settings
   nandflash:2:8:0xc0098da5  use fully custom settings (IOSET2, 8-bit bus, header is 0xc0098da5)
   nandflash:::0xc0098da5    use default board settings but force header to 0xc0098da5
For information on NAND header values, please refer to SAMA5D4 datasheet section \"12.4.4 Detailed Memory Boot Procedures\".

By reading this in-line documentation we can specify the NAND PMECC parameter with this command:

# sam-ba -p serial -b sam9xx5-ek -a nandflash:::0xc0c00405
Opening serial port 'ttyACM0'
Connection opened.
Compatible device detected: SAM9G35.
Detected memory size is 268435456 bytes.
Page size is 2048 bytes.
Buffer is 131072 bytes (64 pages) at address 0x2000a000.
NAND header value is 0xc0c00405.
Supported erase block sizes: 128KB
Connection closed.