Sam-Ba User Guide
Sam-Ba User Guide
....................................................................................................................
User Guide
6421B–ATARM–xx-xxx-11
1-2 SAM-BA User Guide
6421B–ATARM–xx-xxx-11
Section 1
Introduction .................................................................................................................1-1
1.1 Scope ................................................................................................................................. 1-1
1.2 Key Features ..................................................................................................................... 1-1
Section 2
Installation...................................................................................................................2-1
2.1 Windows® Vista and Windows® 7..................................................................................... 2-1
2.2 Installing and Using Two Versions in Parallel .................................................................... 2-1
2.3 Installing SAM-BA .............................................................................................................. 2-1
Section 3
SAM-BA Architecture..................................................................................................3-1
3.1 Contents............................................................................................................................. 3-2
3.1.1 applets Directory .................................................................................................. 3-2
3.1.2 doc Directory........................................................................................................ 3-2
3.1.3 drv Directory ........................................................................................................ 3-2
3.1.4 examples Directory .............................................................................................. 3-2
3.1.5 tcl_lib Directory .................................................................................................... 3-2
3.1.6 sam-ba.exe .......................................................................................................... 3-2
Section 4
Board Connection .......................................................................................................4-1
4.1 USB Connection................................................................................................................. 4-1
4.1.1 USB CDC Driver Installation ................................................................................ 4-1
4.2 JLINK/SAM_ICE Connection ............................................................................................. 4-8
4.2.1 J-LINK Speed ...................................................................................................... 4-8
4.2.2 Updating J-Link/SAM-ICE Software..................................................................... 4-9
4.2.3 JTAG Communication Link .................................................................................. 4-9
4.3 COM Port Connection ...................................................................................................... 4-10
4.4 Connect & Disconnect...................................................................................................... 4-10
Section 5
Running SAM-BA........................................................................................................5-1
5.1 Execute SAM-BA ............................................................................................................... 5-1
5.2 Select Connection .............................................................................................................. 5-1
5.2.1 Optional J-LINK Speed Selection When Connecting with J-LINK ....................... 5-2
5.3 Select Target Board ........................................................................................................... 5-3
5.4 Customize Low level Initialization ...................................................................................... 5-3
5.4.1 User Interface of Low Level Initialization SAM-BA .............................................. 5-3
5.5 SAM-BA Task..................................................................................................................... 5-4
Section 7
SAM-BA TCL Commands...........................................................................................7-1
7.1 SAM-BA Scripting Environment ......................................................................................... 7-1
7.2 SAM-BA Built-in Commands .............................................................................................. 7-2
7.2.1 Command Description ......................................................................................... 7-2
7.2.2 Additional Command ........................................................................................... 7-4
7.3 Example Scripts ................................................................................................................. 7-5
Section 8
Sam-ba.dll...................................................................................................................8-1
8.1 API Function....................................................................................................................... 8-1
8.1.1 AT91Boot_Scan................................................................................................... 8-1
8.1.2 AT91Boot_Open .................................................................................................. 8-2
8.1.3 AT91Boot_Close.................................................................................................. 8-2
8.1.4 AT91Boot_Write_Int ............................................................................................ 8-3
8.1.5 AT91Boot_Write_Short ........................................................................................ 8-3
8.1.6 AT91Boot_Write_Byte ......................................................................................... 8-3
8.1.7 AT91Boot_Write_Data ......................................................................................... 8-4
8.1.8 AT91Boot_Read_Int ............................................................................................ 8-4
8.1.9 AT91Boot_Read_Short........................................................................................ 8-5
8.1.10 AT91Boot_Read_Byte ......................................................................................... 8-5
8.1.11 AT91Boot_Read_Data......................................................................................... 8-6
8.1.12 AT91Boot_Go ...................................................................................................... 8-6
8.1.13 AT91Boot_JlinkSetSpeed .................................................................................... 8-6
8.2 API Using Sam-ba.dll ......................................................................................................... 8-7
8.2.1 ole_with_mfc ........................................................................................................ 8-7
Section 9
Applets........................................................................................................................9-1
9.1 Applet Workflow ................................................................................................................. 9-1
9.2 Applet Startup .................................................................................................................... 9-2
9.3 Runtime Operations ........................................................................................................... 9-4
9.4 Applet Mailbox.................................................................................................................... 9-4
9.5 Build Applets ...................................................................................................................... 9-6
9.5.1 Required Tools for Compilation Applets .............................................................. 9-6
9.5.2 Make .................................................................................................................... 9-6
9.6 Applets Initialization and Usage ......................................................................................... 9-6
9.6.1 Memory Programming Principle ......................................................................... 9-6
9.6.2 External Memory.................................................................................................. 9-7
Section 10
SAM-BA TCL Scripts ................................................................................................10-1
10.1 Scripts Overview .............................................................................................................. 10-1
10.2 Board Description File...................................................................................................... 10-2
10.2.1 Memory Scripts Example: .................................................................................. 10-2
10.2.2 NAND Flash Module Declare Example.............................................................. 10-3
10.2.3 NAND Flash Memory Scripts Example .............................................................. 10-3
Section 11
NAND Flash with PMECC Interface .........................................................................11-1
11.1 NAND PMECC Interface ................................................................................................. 11-1
11.1.1 Pmecc Configuration ......................................................................................... 11-1
11.1.2 Enable OS PMECC Parameters ........................................................................ 11-3
11.2 PMECC Header Configuration in Command Line........................................................... 11-4
11.3 NAND Flash Boot............................................................................................................. 11-5
11.4 Example of TCL Script for NAND Flash ........................................................................... 11-5
Section 12
SAM-BA Customization ............................................................................................12-1
12.1 Add a New Board ............................................................................................................. 12-1
12.2 Modify Main Oscillator..................................................................................................... 12-2
12.3 Modify Pinout ................................................................................................................... 12-4
12.4 Check Point When Failed to Access Customer External Memory ................................... 12-6
12.4.1 SDRAM/DDRAM Access ................................................................................... 12-6
12.4.2 NAND Flash Access .......................................................................................... 12-6
12.4.3 DataFlash & Serial Flash Access ...................................................................... 12-6
Section 13
OTP Interface ...........................................................................................................13-1
13.1 OTP Interface................................................................................................................... 13-1
13.2 OTP read.......................................................................................................................... 13-1
13.3 OTP Fuse......................................................................................................................... 13-2
Section 14
Revision History........................................................................................................13-1
14.1 Revision History ............................................................................................................... 13-1
Welcome to SAM-BA® User Guide. The purpose of this guide is to provide users with detailed reference
information that can help them to use the tools to best suit their application requirements. This guide also
gives the users helpful guidance to customize new boards or programming algorithm for a new device
with maximum efficiency.
1.1 Scope
The SAM Boot Assistant (SAM-BA®) software provides a means of easily programming different Atmel
AT91SAM ARM® Thumb® -based devices. It runs under Windows® XP, Windows® vista and Windows®
7.
The latest version of SAM-BA® is available on the ATMEL® web site, at the following address:
http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3883.
Installation is automatic using the <sam-ba_X.Y.exe> install program (X.Y is the version number).
Accept the default installation directory or specify a directory of choice, and select <Next>.
Installing.
Installation is complete.
SAM-BA provides tools for programming all Atmel ARM-based devices microcontrollers, including
SAM3, SAM7 and SAM9. They are based on a common dynamic linked library (DLL), sam-ba.dll. It is an
OLE COM component distributed under a DLL allowing automation tool.
It is also possible to execute the SAM-BA functions in command lines via a TCL shell. An intermediate
DLL (AT91BOOT_TCL.DLLl) is used to transform TCL commands to the sam-ba.dll. Several communi-
cation links are available such as USB, serial port (RS232) or JTAG.
The SAM-BA has two parts, the host and the target device, as shown in Figure 3-1. The host part runs
on computer. It sends programming files and programming instructions over a download cable to the tar-
get. The target part is a hardware design, running in the ARM® Thumb®-based devices. It accepts the
programming data— content and required information about the target external memory device— sent
by the host, and follows the instructions to write/read data to/from the external memory device.
3.1 Contents
3.1.6 sam-ba.exe
Executable file of SAM-BA.
SAM-BA scans active USB connections with AT91SAM based boards, and it is mandatory to connect
the target to the PC before launching SAM-BA. When SAM-BA starts, the communication interface to be
used is chosen. All connected devices are listed in the Select the connection list. Connections are
described by the following strings in the list:
\USBserial\COMxx for USB connected devices
– \usb\ARMx (compatible name for SAM-BA version earlier than 2.11)
\jlink\ARMx for SAM-ICE/JLink connected devices
COMxx for available COM ports (Support COM port number lager than ‘9’)
Notes:
1. To select another board, SAM-BA must be restarted.
2. xx in COMxx specifies a COM port number.
Communication link can be serial COM port, USB or JTAG. To use USB and COM port link, SAM-BA
needs SAM-BA Boot to be running on the target (it is part of the ROM Code of each device). So the chip
must boot on the ROM code and a bootable program must not be found on any external memory such as
Dataflash® or Nandflash. To use the JTAG link with a SAM-ICE or J-Link probe, a SAM-BA Boot like
application is loaded by the probe into the internal SRAM of chip after the probe has performed a reset of
the device.
Case 2: I have installed SAM-BA 2.10 before, and the usb port is recognized as an ATMEL AT91xxxxx
Test Board on Windows XP.
That means a previous version of USB driver (atm6124.sys) has already been installed from previous
versions of SAM-BA. The users have to uninstall this driver first, or connect the board to another USB
port on the computer where the board will not be detected.
To uninstall a previously installed driver on a USB port, the users have to open the Windows Device
Manager tool (the following steps are introduced based on Windows XP. However, they are very similar
for the other versions of OS).
Connect the board to the computer via a USB port and power it up.
Select Control panel -> System -> 'Hardware' pane -> Device Manager, and expand the Universal
Serial Bus controllers folder.
Select <Uninstall> and confirm (the entry then disappears from the list).
Power the board off.
Choose to install from a list or specific location (Advanced), and then click <Next> button.
IMPORTANT: If the users change the USB port on which they connect the board, they need to repeat
the installation procedures described above.
In the Device Manager window, the board appears in the Ports (COM & LPT) folder, with the virtual
COM port name indicated in parenthesis.
IMPORTANT: The users just need to select \USBserial\COMxx when SAM-BA shows the Choose
Connection message box, because SAM-BA has converted this virtual COM port name to usb\ARMx.
Case 3: I have installed SAM-BA 2.10 before, and the USB port is recognized as an AT91 USB To
Serial Converter.
To uninstall a previously installed driver on a USB port, the users have to open the Windows Device
Manager tool (the following steps are introduced based on Windows XP. However, they are very similar
for the other versions of OS):
Connect the board to the computer via a USB port and power it up.
Select Control panel -> System -> 'Hardware' pane -> Device Manager, and expand the Ports
(COM&LPT) folder.
Right-click on the AT91 USB To Serial Converter (COMxx) entry.
Select <uninstall> and confirm (the entry then disappears from the list).
Select the Model AT91 USB to Serial Converter in the list and click <Next>.
Case 4: I have already uninstalled the previous driver, but it is still recognized as the previous driver.
Try the following steps to remove the inf completely and reinstall it.
1. Use the Windows Explorer Search option and perform a search operation for AT91 USB to Serial
Converter string in all the files located in the c:\windows\inf directory.
The users may notice that they can’t find this folder, because it’s a hidden folder. To view hidden folders,
in menu bar select Tools -> Folder Options -> ‘view’ tab, and select show hidden files and folders.
2. Go back to the above folder and it should now be viewable. Within this folder users will find INF and
PNF files, the device drivers that are being loaded when Windows starts, depending on when they
installed the previous driver (atm6124.sys for example).
3. The users can search and delete this corresponding INF and PNF files associated with the previous
(or wrong) drivers installed.
4. The result will point to a file named oemxxx.inf, where xxx is a number which may differ from one
computer to another.
This file should have a header similar to the below:
;
; WPUSBSERIAL.INF (for Windows 2000)
;
; Copyright (c) 2000, WondeProud? Technology Inc.
5. On the faulty computer's USB connector, plug the USB cable with the board powered on.
6. Delete the oemxxx.inf file previously found.
7. Open Device manager in Control Panel -> System -> ‘Hardware’ pane.
8. Expand the Ports (COM & LPT) folder and right-click on the AT91 USB to Serial Converter
(COMxx) entry.
9. Select Update Driver…, choose Browse my computer for driver software and install the new INF
file atm6124_cdc.inf manually.
Select external crystal in crystal list, click <Set> button to finish configuration.
Or, check Bypass Main Oscillator, and enter user external clock on XIN. Click <Set> button to finish
configuration.
Note: If the users connect with USB, the modification of crystal or bypass mode may not always be
allowed for USB PLL configuration. Please check Boot Program section of product datasheet.
For more detailed information about how to customize user main oscillator, please refer to “SAM-BA
Customization” section.
If selecting yes, the following dialog in Figure 5-9 will ask to close the current SAM-BA.
When SAM-BA is launched, after selection of the board and the communication link, the main window
appears (see Figure 6-1). It contains three different areas (from top to bottom):
Memory Display area
Memory Download area
TCL Shell area
The Memory Display area and the Memory Download area are used to simplify the memory access.
The TCL shell area is a standard TCL shell. Everything typed in the shell is interpreted by a TCL inter-
preter. This area gives access to TCL commands. Type “puts Welcome” and the result is “Welcome”.
Type “expr 3 + 7” and the result is “10”.
Note: A forbidden address corresponds to an address outside the selected memory range address.
Compare the selected file with the memory content using the Compare sent file with memory button. A
message box will be displayed if the file matches or not with the memory content of the file size. Make
sure that the memory is correctly initialized before comparing any data.
TCL is a commonly used scripting language for automation. This interpreted language offers a standard
set of commands which can be extended with application specific commands written in C or other lan-
guages. Tutorials and manuals can be downloaded at: http://www.tcl.tk/doc/.
Specific commands have been added to the SAM-BA TCL interpreter to interface with AT91SAM
devices. These basic commands can be used to easily build more complex routines. In order to commu-
nicate with the board, API functions are available to deal with AT91Boot_DLL.dll library.
proc foo {
global target
puts “ $target(board) is connected with $target(connection)”
}
Output: nothing
7.2.1.3 send_file
Send a file in a specified memory.
Memory: memory tag.
Name: absolute path file name (in quotes) or relative path from the current directory (in quotes).
Address: address in decimal or hexadecimal (in quotes).
Output: information about the corresponding command on the TCL Shell.
7.2.1.4 receive_file
Receive data into a file from a specified memory.
Memory: memory tag.
Name: absolute path file name in quotes or relative path (from the current directory) file name in
quotes.
Address: address in decimal or hexadecimal (in quotes).
Size: size in decimal or hexadecimal (in quotes).
Output: information about the corresponding command on the TCL Shell.
7.2.1.5 compare_file
Compare a file with memory data.
Memory: memory tag.
Name: absolute path file name (in quotes) or relative path from the current directory (in quotes).
Address: address of the first data to compare with the file in decimal or hexadecimal (in quotes).
Output: information about the command progress on the TCL Shell.
7.2.1.6 TCL_Compare
Binary comparison of two files.
FileName1: absolute path file name (in quotes) or relative path from the current directory (in quotes) of
the first file to compare.
FileName2: absolute path file name (in quotes) or relative path from the current directory (in quotes) of
the second file to compare with the first.
Output: return ‘1’ in the case of error, and ‘0’ if files are identical.
7.2.1.7 TCL_Go
Jump to a specified address and execute the code.
Handle: handler number of the communication link established with the board.
Address: address to jump to in decimal or hexadecimal.
Note: If the users do not want to exit SAM-BA, the code must include lines that enable a return to the
SAM-BA application. Otherwise, SAM-BA does not recover correctly. The memory tag (in braces) is the
name of the memory module defined in the memoryAlgo array in the board description file. For example,
{DataFlash AT45DB/DCB} Warning: If you leave SAM-BA, be sure to reboot the board before launching
it next time.
7.2.1.8 TCL_JlinkSetSpeed
Set speed for JLINK connection.
Speed: speed to be configured.
0: default
1: adaptive mode
2: 100KHz
2: 500KHz
3: 1MHz
4: 2MHz
5: 3MHz
6: 4MHz
7: 4.8MHz
The SAM-BA connects a PC with an ARM target device. The API functions of the sam-ba DLL allow
scanning, opening a connection and accessing registers as well as starting code execution at specified
addresses.
8.1.1 AT91Boot_Scan
This function scans connected devices and returns a list of connected devices. Detection is performed in
the following order:
AT91 USB CDC connected devices using usbser.sys driver
Connected SAM-ICE or JLink devices
All available serial COM ports
Note: The AT91Boot_Scan function only checks USB CDC with ATMEL VID&PID
(USB\VID_03EB&PID_6124) and symbol should be AT91 USB to Serial Converter.
Description
CHAR *strConnectedDevices[5];
for (UINT i=0; i<5; i++)
strConnectedDevices[i] = (CHAR *)malloc(100);
AT91Boot_Scan((char *)strConnectedDevices);
8.1.2 AT91Boot_Open
This function opens the communication link on an AT91SAM device depending on the string given in the
argument.
AT91Boot_Open(strConnectedDevices[0], &h_handle);
8.1.3 AT91Boot_Close
This function closes the communication link previously opened on an AT91SAM device.
Description
Code Example
AT91Boot_Close(h_handle);
8.1.4 AT91Boot_Write_Int
This function writes a 32-bit word into the volatile memory of the connected target.
Description
8.1.5 AT91Boot_Write_Short
This function writes a 16-bit word into the volatile memory of the connected target.
Description
8.1.6 AT91Boot_Write_Byte
This function writes a 8-bit word into the volatile memory of the connected target.
Description
– (int)(0x0000): AT91C_BOOT_DLL_OK
– (int)(0xF001): Bad h_handle parameter
– (int)(0xF002): Address is not correctly aligned.
– (int)(0xF005): Communication link is broken.
Code Example
8.1.7 AT91Boot_Write_Data
This function writes X bytes into the volatile memory of the connected target.
Description
Code Example
char bData[10] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
0x09};
AT91Boot_Write_Data(h_handle, 0x200000, bData, 10, &err_code);
8.1.8 AT91Boot_Read_Int
This function reads a 32-bit word from the connected target.
Description
Code Example
int ChipId;
AT91Boot_Read_Int(h_handle, &ChipId, 0xFFFFF240, &err_code);
8.1.9 AT91Boot_Read_Short
This function reads a 16-bit word from the connected target.
Description
short wRead;
AT91Boot_Read_Short(h_handle, &wRead, 0x200000, &err_code);
8.1.10 AT91Boot_Read_Byte
This function reads a 8-bit word from the connected target.
Description
char bRead;
AT91Boot_Read_Byte(h_handle, &bRead, 0x200000, &err_code);
8.1.11 AT91Boot_Read_Data
This function reads X bytes from the connected target.
Description
char bData[10];
AT91Boot_Read_Data(h_handle, 0x200000, bData, 10, &err_code);
8.1.12 AT91Boot_Go
This function allows starting code execution at specified address.
Description
8.1.13 AT91Boot_JlinkSetSpeed
This function allows switching Jlink speed.
Description
– 5: 2MHz
– 6: 3MHz
– 7: 4MHz
– 8: 4.8MHz
Code Example
8.2.1 ole_with_mfc
The project OLE_MFC.dsw is located in examples\samba_dll_usage_VC6\ole_with_mfc folder. It
scans connected devices, opens the first one, and reads DBGU chip ID. If a SAM9261 device is
detected, it programs a small application (BasicMouse) in the DataFlash. To use sam-ba.dll in such a
project, the following steps must be performed:
Create an AT91Boot_DLL class in the project. To do this, copy both at91boot_dll.cpp and
at91boot_dll.h files into the project directory.
Note: Do not use the ClassWizard/Add Class/From a type library... as there is a bug in Visual C++
6.0. The bug prevents any functions containing a char variable as a parameter from being imported.
Initialize OLE libraries by calling AfxOleInit function.
Create an AT91Boot_DLL driver object to manage AT91Boot_DLL COM object.
Create an AT91Boot_DLL COM object instance with the AT91Boot_DLL program ID(1)("
SAMBA_DLL.SAMBADLL.1") by using CreateDispatch function.
Notes:
1. Program ID is stored in the base register and is an easier way to retrieve AT91Boot_DLL Class ID
necessary for CreateDispatch function. Once these four steps have been performed, DLL functions
should be available. For their prototypes and for details on how to call these functions, please see
at91boot_dll.h header file.
2. At this step, if AT91Boot_DLL functions are not available, it is because the AT91Boot_DLL.dll has not
been registered correctly.
Code example:
#include "at91boot_dll.h"
IAT91BootDLL *m_pAT91BootDLL;
AfxOleInit();
m_pAT91BootDLL = new IAT91BootDLL;
m_pAT91BootDLL->CreateDispatch(_T("SAMBA_DLL.SAMBADLL.1"));
8.2.2 ole_without_mfc
This section explains the project OLE_without_MFC.dsw located in examples\samba_dll_usage_VC6\
ole_without_mfc folder.
To use sam-ba.dll in such a project, the following steps must be performed:
Initialize COM library by calling CoInitialize(NULL). Use CoUninitialize() to close COM Library at the
end of the project.
Import sam-ba.dll COM object from AT91Boot_DLL.tlb Type Library file. Eventually rename
namespace if necessary.
Use namespace to share the same namespace as SAMBA_DLL library.
Create a pointer to SAMBA_DLL COM object.
In stdafx.h header file:
In order to be able to program non-volatile memories, SAM-BA uses several small binary files called
applets. For each AT91SAM device, there is one applet dedicated to each external memory device that
the chip can deal with. Each applet contains the programming algorithm for its dedicated memory. Take
a SAM9263 device for example, SAM-BA can program SDRAM, Nandflash, Dataflash, Serialflash, and
Norflash. That is why users will find five binary files in SAM-BA X.Y\tcl_lib\at91sam9263-ek folder.
The applet code consists of:
A mailbox data structure for commands and data read or written by SAM-BA GUI application
At least an init part used to initialize PIOs and configure access to the memory
Some other read, write, erase parts
A buffer area located after the applet code that contains the data to be written or read by the applet
/* Branch to main()
******************/
…
In isp_cstartup.c:
if (isUnInitialized == 1) {
pSrc = &_sidata;
for(pDest = &_sdata; pDest < &_edata;) {
*(pDest ++) = *(pSrc ++);
}
The stack pointer is initialized in the boot ROM. However, on some AT91SAM device revisions, each
time the system leaves SAM-BA Monitor mode after receiving a “GO” command, the stack pointer is not
reset to its initial value which produces a memory leakage. The workaround is to initialize the stack
pointer each time the applet is run. At the end of the applet, the stack pointer is set to the initial value and
the boot ROM is resumed.
…
/* Branch to main()
******************/
mov r0, #1
add r1, pc,#-(8+.-mailbox)
ldr r3, =main
mov lr, pc
bx r3
Each time a GO command is executed, the boot ROM resets PIO. Applets must configure PIO each time
it is resumed.
A mailbox shared between applet and host application is located at the beginning of the execution
region, just behind the jump instruction. Then it is easy for the host application to determine where the
mailbox is located.
For SAM7 and SAM9, mailbox address = applet load address + 4.
For SAM3, mailbox address = applet load address + 0x40.
** Structure for storing parameters for each command that can be performed by
the applet. */
struct _Mailbox {
proc GENERIC::Init
{appletAddr appletMailboxAddr appletFileName {appletArgList 0}} {
global target
# Load the applet to the target
if {[catch {GENERIC::LoadApplet $appletAddr $appletFileName} dummy_err]}
{
error "Applet $appletFileName can not be loaded" }
# Mailbox is 32 word long (add variable here if users need read/write more
data)
set argIdx 0
foreach arg $appletArgList {
# Write the Cmd op code in the argument area
TCL_Write_Int $target(handle) $arg [expr $appletAddrArgv0 + $argIdx]
incr argIdx 4
}
# Launch the applet Jumping to the appletAddr
set result [GENERIC::Run $appletCmd(init)]
. . .
}
9.5.2 Make
All make command lines to be executed to compile each applet for each board&memory can be found in
sam-ba 2.11\applets\build.log file. Usually, the users won't need to recompile all the applets for all of the
boards, but just copy the command line from build.log concerning the applet/board they want to compile.
For example, to build a dataflash-applet on at91sam9m10-ek/at91sam9m10 with sram:
devices directory
All device header files are in TCL format.
One device.tcl lists all device names or alias names and the corresponding device IDs.
device.tcl example:
0x819b05a0 at91sam9g45,at91sam9m10
0x019b03a0 at91sam9rl64
. . .
}
boards.tcl
boards.tcl example:
A memory module array is defined for each module declared in the memoryAlgo array.
dftDefault: set to ‘1’ if this memory tab shall be selected when SAM-BA starts (There shall be one
default memory tab among all memory tabs).
dftAddress: base address of the memory module (0x0 for memories not physically mapped, like
DataFlash, or when accesses are not directly done, a monitor is needed, like NAND Flash).
dftSize: size of the memory module.
dftSend: send file procedure name.
dftReceive: receive file procedure name.
dftScripts: name of the array containing the script list, see Table 11-1 (blank if no script is
implemented).
Scripts can be implemented for each memory module. Common uses are SDRAM initialization, Flash
erase operation, or any other frequently used operations. The scripts are displayed in the script listbox of
the corresponding memory tab. Their declaration is done by creating an array named in the dftScripts
field of the memory.
Some AT91SAM devices are embedded with MLC/SLC NAND Controller, with up to 24-bit Programma-
ble Multi-bit Error Correcting Code (PMECC), such as SAM9G15, SAM9X25 devices.
SAM-BA 2.11 supports NAND flash accessing with PEMCC.
Table 11-1. Supported PAGESIZE & SECTORSZ Configuration on Different Page Size
(512/1024/2048/4096/8192 bytes)
Sector Size 512 Bytes Sector Size 1024 Bytes
Sectors Per Page 1 2 4 8 1 2 4 8
Page Size 512 X - - - - - - -
Page Size 1024 - X - - X - - -
Page Size 2048 - - X - - X - -
Page Size 4096 - - - X - - X -
Page Size 8192 - - - - - - - X
tion on 2048 page size NAND flash. The size of ECC redundancy is 80 bytes, and there is not enough
space in spare area (total 64 bytes) to be written. In such case it is shown as “-” in the table.
Users can also modify the value to satisfy special request. The header value ‘0xc0c00405’ means:
Use PMECC
PMECC ecc offset is 48
512-byte sector
4 sectors per page
2-bit error correction per sector
NANDFLASH::NandHeaderValue eccOffect 48
offset of the first ecc byte in spare zone is 48, value = 0x30
NANDFLASH::NandHeaderValue HEADER 0xc0c00405
HEADER value is 0xC0C00405
Type NANDFLASH::NandHeaderValue to display current PMECC configuration
92B
For example:
Type
NANDFLASH::NandHeaderValue
use Pmecc, value = 0x1
4 sectors of data per page, value = 0x2
spare zone in bytes is 64, value = 0x40
2 bits of errors per sector, value = 0x0
The PMECC computation is based on a sector of 512 bytes, value = 0x0
offset of the first ecc byte in spare zone is 48, value = 0x30
HEADER value is 0xC0C00405
## NandFlash Mapping
set bootStrapAddr0x00000000
set ubootAddr0x00080000
set kernelAddr 0x00400000
## Falshing binaries
puts "-I- === Initialize the NAND access ==="
NANDFLASH::Init
puts "-I- === Enable PMECC OS Parameters ==="
NANDFLASH::NandHeaderValue HEADER 0xc0c00405
puts "-I- === Erase all the NAND flash blocs and test the erasing ==="
NANDFLASH::EraseAllNandFlash
puts "-I- === Load the bootstrap: nandflash_at91sam9-ek in the first sector
==="
NANDFLASH::SendBootFilePmeccCmd $bootstrapFile
puts "-I- === Load the u-boot image ==="
send_file {NandFlash} "$ubootFile" $ubootAddr 0
puts "-I- === Load the Kernel image ==="
send_file {NandFlash} "$kernelFile" $kernelAddr 0
The new board name will appear in the Select your board list when SAM-BA is started.
Extclk is the specified frequency of the external clock of the target device. The value of the frequency is
specified by users in SAM-BA GUI. Extclk is used by bypass_LowlevelInit() when mode is
BYPASS_MODE.
switch (mode) {
case EK_MODE:
EK_LowLevelInit();
pMailbox->status = APPLET_SUCCESS;
break;
case USER_DEFINED_CRYSTAL:
user_defined_LowlevelInit(crystalFreq);
pMailbox->status = APPLET_DEV_UNKNOWN;
break;
case BYASS_MODE:
bypass_LowLevelInit(extClk);
pMailbox->status = APPLET_DEV_UNKNOWN;
default:
pMailbox->status = APPLET_DEV_UNKNOWN;
break;
}
If user’s board mounts a crystal of a frequency different from that on the EK board or the target device is
clocked by an external clock, function user_defined_LowlevelInit() or bypass_LowLevelInit() should be
implemented in advance and the lowlevel applet needs to be re-compiled and replace the one in the
board specific folder. For information on how to implement the low level initialization, please refer to
EK_LowLevelInit().
To customize low level initialization, Customize lowlevel must be checked in SAM-BA GUI before
pressing Connect.
In Customize oscillator window, the users should choose the on board crystal frequency in the pull-down
menu. The frequency will be passed to the lowlevel applet as the parameter crystalFreq.
If there is no frequency matched with the one on user’s board, please add the value in the list
mainOsc(crystalList) defined in <board> lowlevel.tcl.
If user’s board is clocked by an external clock, check Bypass Main Oscillator and fill the frequency of
the external cock in External Clock (in Hz). This value will be passed to the lowlevel applet as the
parameter extClk.
If Bypass Main Oscillator is checked, the mode is BYPASS_MODE after pressing Set button. If
Bypass Main Oscillator is unchecked, the mode is USER_DEFINED_CRYSTAL. If pressing Cancel
button, no matter what frequency is specified, the mode is EK_MODE.
Note that the A in names refers to dataflash 0 in SAM-BA GUI TCL file. If users want a second one to be
defined, add BOARD_AT45_B... definitions, it will be usable as dataflash 1 in SAM-BA GUI.
Users can compile the applet now. Open a command line terminal, and change the current directory into
applets\isp-applets\dataflash. Copy the make command for dataflash on SAM9263 from the
applets\build.log file and paste it in the terminal:
Press Enter, and users will get a new dataflash applet in the bin subfolder. Be careful that this new
applet is automatically copied after built in target folder:
SAM-BA v2.11\applets\isp-project\tcl_lib\at91sam9263-ek
Users may need to backup the existing one in runtime folder:
SAM-BA v2.11\tcl_lib\at91sam9263-ek
At last, they may overwrite the existing applet binary from the target folder to sam-ba runtime folder.
If users want, they can edit the tcl_lib\at91sam9263-ek\at91sam9263-ek.tcl file to modify the text dis-
played in SAM-BA Dataflash script Listbox. Find the dataflash script array definition and fix the text
Enable Dataflash with SPI1:
The parameter ‘0’ given to the DATAFLASH::Init script is related to the NPCS index of the dataflash in
the applet. Take a look at the main.c file of this applet to find the dataflash descriptor array.
Users can try it now: launch SAM-BA GUI, select the Dataflash pane and execute Scripts>Enable
Dataflash (SPI1 NPCS0). The dataflash should be correctly detected, and they can read/write files into
it.
Some AT91SAM devices are embedded with One Time Programming (OTP) bits. When the OTP bit is
set, it is seen as ‘1’. The Read/Write functions are handled by the fuse controller block.
The fuse operation must be hand checked by user with warning information.
The fuse operation must be hand checked by user with warning information.
Table 14-1.
Change
Document Comments Request Ref.
6421B
6421A First issue.
Atmel Corporation Atmel Asia Limited Atmel Munich GmbH Atmel Japan
2325 Orchard Parkway Unit 01-5 & 16, 19F Business Campus 9F, Tonetsu Shinkawa Bldg.
San Jose, CA 95131 BEA Tower, Millennium City 5 Parkring 4 1-24-8 Shinkawa
USA 418 Kwun Tong Road D-85748 Garching b. Munich Chuo-ku, Tokyo 104-0033
Tel: (+1) (408) 441-0311 Kwun Tong, Kowloon GERMANY JAPAN
Fax: (+1) (408) 487-2600 HONG KONG Tel: (+49) 89-31970-0 Tel: (81) 3-3523-3551
Tel: (+852) 2245-6100 Fax: (+49) 89-3194621 Fax: (81) 3-3523-7581
Fax: (+852) 2722-1369
Product Contact
Literature Requests
www.atmel.com/literature
Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any
intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMEL’S TERMS AND CONDI-
TIONS OF SALE LOCATED ON ATMEL’S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY
WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDEN-
TAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT
OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no
representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifica-
tions and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically pro-
vided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel’s products are not intended, authorized, or warranted
for use as components in applications intended to support or sustain life.
© 2011 Atmel Corporation. All rights reserved. Atmel®, logo and combinations thereof DataFlash ®, QTouch®, SAM-BA ® and others are regis-
tered trademarks or trademarks of Atmel Corporation or its subsidiaries. ARM ®, Thumb ® and the ARMPowered logo ® and others are registered
trademarks or trademarks of ARM Ltd. Other terms and product names may be trademarks of others.
6421B–ATARM–xx-xxx-11