AT91Bootstrap flashing from u-boot

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

jcarrillo
Posts: 11
Joined: Thu Jun 19, 2014 9:37 am

AT91Bootstrap flashing from u-boot

Thu Oct 09, 2014 7:04 pm

Hi all,

Does anyone know how to write in NAND Flash the at91bootstrap image from u-boot?

In SAM-BA, the TCL command used for the most of the images is

Code: Select all

send_file {NandFlash} <FILE> <ADDRESS> 0 
which flashes the file "as is".

On the other hand, the comand used for at91bootstrap is

Code: Select all

NANDFLASH::SendBootFilePmeccCmd <BOOTSTRAP_FILE>
I don't know the specific processing this comand performs (I guess adds redundancy and so on).

Thank you for your time.
blue_z
Location: USA
Posts: 2021
Joined: Thu Apr 19, 2007 10:15 pm

Re: AT91Bootstrap flashing from u-boot

Fri Oct 10, 2014 1:10 am

jcarrillo wrote:Does anyone know how to write in NAND Flash the at91bootstrap image from u-boot?
Well I've done it. Does that count?
jcarrillo wrote:On the other hand, the comand used for at91bootstrap is

Code: Select all

NANDFLASH::SendBootFilePmeccCmd <BOOTSTRAP_FILE>
I don't know the specific processing this comand performs (I guess adds redundancy and so on).
IIRC there's no "redundancy" as you speculate, but simply a hack to ensure that the byte length of the image is installed in word 6 of the ARM exception vector.
Some versions of AT91Bootstrap correctly build with the length in the image, whereas there are also versions that leave a branch instruction in word 6.
Refer to the "Boot Strategies" section of your SoC datasheet for details.

Regards
blue_z
Location: USA
Posts: 2021
Joined: Thu Apr 19, 2007 10:15 pm

Re: AT91Bootstrap flashing from u-boot

Mon Feb 08, 2016 9:52 pm

If your SoC has a NAND Flash Controller and PMECC, then the recommended setup for NAND booting is to provide the NAND Flash parameters and ECC requirements by a specific header written at the beginning of the first page of the NAND Flash.
The AT91Bootstrap image would immediately follow this NAND parameter header (at offset +0xD0).

This header of NAND and PMECC parameters is simply 208 (0xD0) bytes consisting of a 32-bit word repeated 52 times.
Refer to the SoC datasheet for the encoding of the parameters.
For the following Atmel boards the word values are:

Code: Select all

AT91SAM9x5-EK      0xC0C00405
AT91SAM9N12-EK   0xC0C00405
SAMA5D2-XULT       0xC???????
SAMA5D2-PTC-EK    0xC1E04E07    (this value from SAM-BA doesn't correlate with Micron datasheet)
SAMA5D3x-EK          0xC0902405
SAMA5D3-XPLD       0xC0902405
SAMA5D4-EK            0xC1E04E07
SAMA5D4-XULT       0xC1E04E07
These values are board specific (i.e. the pairing of SoC and NAND), rather than SoC specific.
If your board uses a different NAND chip than the Atmel board, then the NAND parameter header value may well be different.

The following U-Boot commands would build/install the NAND parameter header and AT91Bootstrap image in the NAND flash of a SAMA5D4-XULT:

Code: Select all

U-Boot> mw.b 20000000 ff 40000
U-Boot> mw.l 20000000 c1e04e07 34
U-Boot> tftpboot 200000d0 boot.bin
U-Boot> nand erase 0 40000
U-Boot> nand write 20000000 0 40000
Regards
klavrov
Posts: 1
Joined: Tue Jun 07, 2016 1:15 pm

Re: AT91Bootstrap flashing from u-boot

Tue Aug 09, 2016 3:36 pm

blue_z wrote:
For the following Atmel boards the word values are:

Code: Select all

AT91SAM9x5-EK      0xC0C00405
AT91SAM9N12-EK     0xC0C00405
SAMA5D2-XULT       0xC???????
SAMA5D3x-EK        0xC0902405
SAMA5D3-XPLD       0xC0902405
SAMA5D4-EK         0xC1E04E07
SAMA5D4-XULT       0xC1E04E07
To fill Q-marks:

Code: Select all

SAMA5D2-XULT     0xC0098DA5
gselabs
Posts: 25
Joined: Sun Feb 17, 2019 7:04 pm

Re: AT91Bootstrap flashing from u-boot

Mon Jul 29, 2019 7:26 pm

The following script is extremely use-full for ECC parameters calculation:

Code: Select all

https://github.com/linux4sam/at91bootstrap/blob/master/scripts/pmecc_head.py
moonsea
Posts: 4
Joined: Wed Jan 08, 2020 10:04 am

Re: AT91Bootstrap flashing from u-boot

Wed Jan 08, 2020 3:40 pm

The python file is good information. But it does presumes that the parameters to write into the header are known.

I need to create a header in run-time based on the ECC parameters currently in use for the nand. In my case these may vary from board to board, as we might change from 4 to 8 bit ECC in the future, and I need to be forward compatible. Is it possible to find these parameters somehow?
blue_z
Location: USA
Posts: 2021
Joined: Thu Apr 19, 2007 10:15 pm

Re: AT91Bootstrap flashing from u-boot

Fri Jan 10, 2020 3:59 am

moonsea wrote: But it does presumes that the parameters to write into the header are known.

I need to create a header in run-time based on the ECC parameters currently in use for the nand.
...
Is it possible to find these parameters somehow?
You seem to overuse the word "parameters", and use it to refer to both the encoded values of the header as well as the attributes of the NAND device.
Can you rephrase your question to be more precise?

Regards
moonsea
Posts: 4
Joined: Wed Jan 08, 2020 10:04 am

Re: AT91Bootstrap flashing from u-boot

Mon Jan 13, 2020 9:23 am

blue_z wrote:
Fri Jan 10, 2020 3:59 am
moonsea wrote: But it does presumes that the parameters to write into the header are known.

I need to create a header in run-time based on the ECC parameters currently in use for the nand.
...
Is it possible to find these parameters somehow?
You seem to overuse the word "parameters", and use it to refer to both the encoded values of the header as well as the attributes of the NAND device.
Can you rephrase your question to be more precise?

Regards
Ok, I'll give it a try.

The scenario is that I want to create the header in run-time for our units to be updated. The header will be used for creating a separate boot sequence to the update of the main system on the board. The update will be initiated from the main system. The header will be created and together with at91bootstrap image be written into nand memory. The at91bootstrap will load the kernel and initrootfs file system that will accomplish the firmware update.
The units currently out in the field have 4 ecc bits, but due to replacing of the nand flash memory, this will probably be changed to 8 ecc bits. So when creating the header I need to somehow know if the nand on the board is using 4 or 8 bits ecc.

If it is possible to find the data out from the system that maybe would be the easiest way, otherwise I will need to create some way of storing that the number of ecc-bits, and if this setting is not present, assume that it is 4 bits.
blue_z
Location: USA
Posts: 2021
Joined: Thu Apr 19, 2007 10:15 pm

Re: AT91Bootstrap flashing from u-boot

Wed Jan 15, 2020 10:09 pm

moonsea wrote: ... I need to somehow know if the nand on the board is using 4 or 8 bits ecc.
You seem to be conflating two different values. The actual correction capability implemented for a NAND chip on a board could be different from the minimum ECC capability recommended/required by the manufacturer.

moonsea wrote: If it is possible to find the data out from the system that maybe would be the easiest way ...
Seems like you've replaced "parameter" with "data".

If you are "replacing ... the nand flash memory", then the only valid "data" you should expect to read from the NAND chip are the manufacturer, chip, and other identifier codes.
Consult the NAND chip's datasheet for details of the READ ID command.

I still do not understand what information you're looking for.

Regards
moonsea
Posts: 4
Joined: Wed Jan 08, 2020 10:04 am

Re: AT91Bootstrap flashing from u-boot

Mon Jan 20, 2020 5:58 pm

blue_z wrote:
Wed Jan 15, 2020 10:09 pm
moonsea wrote: ... I need to somehow know if the nand on the board is using 4 or 8 bits ecc.
You seem to be conflating two different values. The actual correction capability implemented for a NAND chip on a board could be different from the minimum ECC capability recommended/required by the manufacturer.

moonsea wrote: If it is possible to find the data out from the system that maybe would be the easiest way ...
Seems like you've replaced "parameter" with "data".

If you are "replacing ... the nand flash memory", then the only valid "data" you should expect to read from the NAND chip are the manufacturer, chip, and other identifier codes.
Consult the NAND chip's datasheet for details of the READ ID command.

I still do not understand what information you're looking for.

Regards

The data I want to read is what the number of ecc bits, the sector size and the size of the OOB area was used for a memory. But I reckoned I can solve it by storing this data in a nor memory, so it is not really necessary to read it from the nand memory itself in run-time.
Thanks anyway for trying to understand what I mean :)

Regards

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 2 guests