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.

Erasing the whole memory

To erase the whole nand flash:

1. Select Erase all in the drop down list.

2. Click on Execute.

Partial erase of the memory

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.

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):