Use SAM-BA
Programming a demo can be done by using the .bat or .sh scripts provided or by using the SAM-BA GUI. We'll focus on the latest solution. The components of the demo are configured to be stored in nand flash so we'll use this media.
Connecting to the board
Start SAM-BA, you'll have the following pop-up:
1. Select the connection to the board.
2. Select the board to connect to.
3. Click on
Connect
.
Enabling the media
First of all, you have to load the nand flash applet:
1. Select the tab corresponding to the media you want to use. By default, our demo is in nand flash.
2. Select the
Enable NandFlash
choice in the drop down list, usually it is the default choice.
3. Click on
Execute
.
Erasing the memory
Before programming components, it is strongly recommended to erase the memory. You can erase the whole memory if you want to start from scratch or you can erase only some parts of the memory. This latest solution is useful if you want to update a component, for instance you want to update the kernel but you don't want to loose your u-boot environment and your rootfs.
To erase the whole nand flash:
1. Select
Erase all
in the drop down list.
2. Click on
Execute
.
To erase only a part of the memory, you will have to use the
NANDFLASH::EraseBlocks
command. Its first parameter is the offset from which erase will start, the second one is the size to erase.
If you want to erase a specific component for instance the rootfs, have a look to
nand flash memory map to get the offset and size value.
Here is an example to erase the rootfs on a 256 MB nand flash:
1. Type
NANDFLASH::EraseBlocks 0x800000 0xF800000
in the console and press
Enter
.
Configuring ECC
With some devices, you can use PMECC. In this case, components have been compiled to use it.
To configure and enable PMECC, follow these steps:
1. Select
Enable OS PMECC parameters
in the drop down list.
2. Click on
Execute
.
You will have a configuration pop-up whose field values depend on the board reference
:
|
|
SAMA5D3X-EK |
AT91SAM9X5-EK and AT91SAM9N12-EK |
Others |
|
|
|
|
|
|
To flash
AT91Bootstrap, do as following:
1. Select
Send Boot File
in the drop down list.
2. Click on
Execute
.
3. A pop-up will ask you to select the
AT91Bootstrap binary. Once done, click on
Open
.
Flashing U-Boot, the Linux kernel, the device tree binary and the rootfs
If you are using PMECC you have to redo the ECC configuration step and to select the trimffs
option before flashing the rootfs.
Then you can follow this:
1. Click on the open file button and select the appropriate binary.
2. Set the address according to the
nand flash memory map. In this case, we are flashing U-Boot.
3. Click on
Send File
.
There is an extra step for U-Boot: the setup of the environment. When you are using the scripts, the U-Boot environment is generated and stored into a file which will be flashed into the nand. Here we don't have the U-boot environment binary so you have to run U-Boot on the board and to enter these commands (replace dtbSize and kernelSize by appropriate values):
setenv bootargs 'console=ttyS0,115200 mtdparts=atmel_nand:8M(bootstrap/uboot/kernel)ro,-(rootfs) rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs'
setenv bootcmd 'nand read 0x21000000 0x00180000 dtbSize; nand read 0x22000000 0x00200000 kernelSize; bootm 0x22000000 - 0x21000000'
save
Notes
: