Software & Tools - AT91SAM Community

advertisement
AT91SAM Boot Strategies
Application Deployment
Frederic BOYER
Support & Training Group Engineer
AT91 Training Coordinator
ARM MCU & MPU
Outline
 Introduction
 Boot Solutions
 Application Deployment
 NVM Programming Solutions
ARM-Based Products Group
2
1. Introduction
1. Introduction
NAND vs. NOR Flash
Advantage of NAND
Advantage of NOR
High Speed Program/Erase
Low Cost-per-bit
High Capacity
High Speed Random Access
Byte Programming
Code execution
Disadvantage of NAND
Disadvantage of NOR
Slow Random Access Time
Difficulty of Byte Programming
Slow Program Speed
Slow Erase Speed
Applications
Applications
Suitable for Data Memory
Program/Data Mass Storage
Suitable for Code Memory
eXecute In Place (XIP)
ARM-Based Products Group
4
1. Introduction
NOR vs. NAND Boot Considerations
 NOR Flash
 Used as an eXecute In Place (XIP) memory: no need to copy
the program into RAM
 Used to replace ROM
 NAND Flash
 Programs stored cannot be executed directly
 Code Shadowing must be performed: memory contents must be
first copied into memory-mapped RAM and executed there
 Used to replace Hard Disk Drive
ARM-Based Products Group
5
1. Introduction
AT91SAM Boot Strategies Introduction
 To ensure maximum boot possibilities, memory layout
can be changed with different parameters.
 On our AT91SAM, either GPNVM bit or BMS pin is
responsible for the boot memory selection:
 GPNVM bit for embedded flash µC: SAM7, SAM9XE.
 BMS pin for the others: SAM926x, SAM9G20, SAM9R(L)…
GPNVM bit
(Embedded Flash based µC)
OR
BMS pin
(Flashless µC)
Power Up
Boot Memory Selection
ARM-Based Products Group
6
1. Introduction
AT91SAM Boot Strategies Introduction (cont.)
 Regarding GPNVM bit or BMS pin state, the µC will either:
 Boot from ROM
 Or Boot from the XIP memory (internal or external Flash)
Boot Memory Selection
Boot From ROM
OR
Boot From
(Int. or Ext.) Flash
ARM-Based Products Group
7
1. Introduction
Boot Memory Selection for Flash based µC
(SAM7 and SAM9XE)
 GPNVM bit is sampled when VDDCORE is powered.
 GPNVM can be:
 Set thanks to the EFC Controller
 Cleared thanks to the EFC Controller or by asserting the ERASE pin.
Power Up
No
Boot From ROM
GPNVM bit = 1
Yes
Boot From
Embedded Flash
ARM-Based Products Group
8
1. Introduction
Boot Memory Selection for Flashless µC
(SAM926x, SAM9R(L), SAM9G20)
 BMS pin is sampled when VDDCORE is powered.
Power Up
Yes
Boot From ROM
BMS pin = 1
No
Boot From
External 16-bit Flash
ARM-Based Products Group
9
2. Boot Solutions
2. Boot Solutions
Booting From an eXecute In Place Memory
 XIP Memories used for booting purpose are:
 Embedded Flash (SAM7, SAM9XE)
 External 16-bit Flash (SAM926x, SAM9R(L), SAM9G20…)
 No boot program is executed, no initialization
performed
 Whole microcontroller configuration must be made in
the application, such as:
 Clocks configuration: Main Oscillator, PLL
 Embedded Flash Controller configuration (Wait States…)
 External Bus Interface configuration (Setup, Hold…)
ARM-Based Products Group
11
2. Boot Solutions
Booting from ROM
AT91SAM
BootROM
NVM Memory
Bootloader
SAM-BA Boot
2nd Level
Bootloader
ISP
FFPI
Gang
Programmer
Interface
ARM-Based Products Group
IAP Function
IAP
12
2. Boot Solutions
BootROM Applications
NVM
Bootloader
SAM-BA
Boot
FFPI
IAP
Function
SAM7S
-
X
X
-
SAM7X/XC
-
X
X
-
SAM7SE
-
X
X
-
SAM7L
-
X
X
X
SAM9XE
-
X
X
X
SAM9260
X
X
-
-
SAM9261(S)
X
X
-
-
SAM9263
X
X
-
-
SAM9R(L)64
X
X
-
-
SAM9G10
X
X
-
-
SAM9G20
X
X
-
-
SAM9G45
X
X
-
-
Flash AT91 µC
FlashLess AT91 µC
ARM-Based Products Group
13
2. Boot Solutions
NVM Memory Bootloader Application
 Contrary to XIP memories, it is not possible to boot directly from a
DataFlash, serial Flash, NAND Flash, SDCard or EEPROM
 NVM Memory content must be first copied into memory-mapped RAM
and executed there
 NMV Memory Bootloader called “NVM-Boot” is responsible for this
copy
NVM-Boot
Valid Code ?
No
Next NVM-Boot
Yes
Copy code from
NVM memory into SRAM
Reset Peripherals, remap
and execute code out of SRAM
ARM-Based Products Group
14
2. Boot Solutions
Supported NVM Memories
 Serial DataFlash: ATMEL AT45D and AT45DCB
 Serial Flash: Industry’s most advanced 25xxx
compatible serial Flash (ATMEL AT25/26, SST,
ST, Winbond…)
 SLC NandFlash: 8- and 16-bit, small and large
blocks
 SDCard: any FAT12/16/32 formatted SD Cards
which are not High Capacity SDHC
 EEPROM: any I²C Memory EEPROM
ARM-Based Products Group
15
2. Boot Solutions
What is a valid code?
SD Card Example:
 boot.bin file in the root directory of any FAT12/16/32 formatted
SD Cards
 Code size < AT91SAM internal SRAM size*
* Max code size value must be checked in the Boot Program section of each product datasheet
ARM-Based Products Group
16
2. Boot Solutions
What is a valid code (cont’d)?
DataFlash, NAND Flash, Serial Flash & EEPROM example:
 The ARM exception vectors must have valid ARM instructions (B or LDR),
excluding the 6th vector
 The 6th vector (reserved vector @ 0x14), must correspond to the size of the
image to be copied in internal SRAM.
 Code size < AT91SAM internal SRAM size*
00
04
08
0c
10
14
18
1C
e59ff074
e59ff014
e59ff014
e59ff014
e59ff014
00000800
e59ff060
e59ff00C
‘e59’  LDR opcode
Vector 1
Reset
Undefined Instruction
Software Interrupt
Prefect Abort
Data abort
Reserved: SIZE OF THE IMAGE
Normal interrupt
Fast interrupt
Vector 2
Vector 3
Vector 4
Vector 5
Vector 6
Vector 7
Vector 8
ARM exception vectors
* Max code size value must be checked in the Boot Program section of each product datasheet
ARM-Based Products Group
17
2. Boot Solutions
NVM Memory Bootloader Support
AT91
NVM
DataFlash
(SPI)
Serial
Standard
Flash
SLC
NandFlash
(SPI)
(EBI)
(MCI)
SDCard
EEPROM
(TWI)
SAM9260 rev A
X
-
-
-
-
SAM9260 rev B
X
-
X
-
-
SAM9261(S) rev A
X
-
-
-
-
SAM9261 rev B
X
X
X
X
X
SAM9263 rev A
X
-
-
-
-
SAM9263 rev B
X
-
X
X
-
SAM9R(L)64 rev A
X
-
X
X
-
SAM9G10 rev A
X
X
X
X
X
SAM9G20 rev A
X
X
X
X
X
SAM9G20 rev B
X
X
X
X
X
SAM9G45 rev A
X
X
X
X
X
 H/W (driven pins, clocks) & S/W (max downloadable code size)
constraints can be found in the Boot Program section of the product.
ARM-Based Products Group
18
2. Boot Solutions
No Valid Code Found
As soon as valid code is found in a bootable memory,
the boot ROM sequence is completed.
If no valid code is found,
what is the next step?
ARM-Based Products Group
19
2. Boot Solutions
AT91SAM9R(L)64 Boot ROM Sequence
SD Card Boot
on
MCI
NandFlash-Boot
on
EBI Chip Select 3
DataFlash-Boot
on
SPI Chip Select 0
SAM-BA Boot
ARM-Based Products Group
20
2. Boot Solutions
SAM-BA Boot Application
 SAM-BA Boot is a little monitor that provides In-System Programming
Solutions through different communication channels:
 DBGU Serial port interface
 USB Device port
 Used to interface ISP Software such as SAM-BA GUI.
 Check Boot Program section of the product datasheet for H/W and
S/W constraints such as crystals/clocks support.
ARM-Based Products Group
21
2. Boot Solutions
AT91SAM7L & AT91SAM9XE
IAP Function
 IAP: In Application Programming
 IAP feature is a function located in ROM, that can be called by
any software application
 When called, this function sends the desired FLASH command to
the EFC and waits for the FLASH to be ready
 Executed from ROM, allows FLASH programming by code
running out of FLASH
 This function takes one argument in parameter: the command to
be sent to the EFC
ARM-Based Products Group
22
2. Boot Solutions
FFPI – Fast Flash Programming Interface
Application
 Provides programming solutions for high volume
programming, with two interface options
 Serial: JTAG interface
 Parallel: 8-bit (AT91SAM7S16/32) or 16-bit (other AT91SAM)
Serial (JTAG)
Parallel (8- or 16-bit)
ARM-Based Products Group
23
3. AT91SAM Application Deployment
3. Application Deployment
Standard Application Deployment
1st Level Bootloader
(NVM Memory Bootloader)
2nd Level
Bootloader
AT91
Bootstrap
U-boot
E-boot
FLASH
Media(s)
(Optional)
3rd Level
Bootloader
Main Application
Linux
WinCE
Standalone App
ARM-Based Products Group
25
3. Application Deployment
AT91 Bootstrap
 Free 2nd Level Bootloader for AT91SAM9
 AT91Bootstrap integrates several sets of algorithms:
 Device initialization such as clock speed configuration, PIO settings,
SDRAM initialization
 Physical media algorithms such as DataFlash, NAND Flash, etc.
 Loaded thanks to NVM Memory Bootloader located in ROM
 Current Version is 1.11 and is integrated in our software packages
NVM Memory Bootloader Support
GNU
IAR
Keil
In Dev
In Dev
In Dev
NAND Flash
AT45 DataFlash
25xxx Serial Flash
SD Card
CFI NOR Flash
I2C EEPROM
ARM-Based Products Group
26
3. Application Deployment
DATAFLASH Boot Example
SAMBA Boot
DataFlash
Boot
DataFlash
NVM Boot
Boot
0x8400
0x0000
ROM
0x300000
AT91Bootstrap
SRAM
Application
Getting
Started
AT91Bootstrap
DATA FLASH
0x20000000
Application
SDRAM
Current running Application in Red
ARM-Based Products Group
27
3. Application Deployment
NAND FLASH Boot Example
Linux Kernel
0x60000
SAMBA Boot
U-Boot
0x20000
NVM Boot
NandFlash-Boot
0x0000
ROM
AT91Bootstrap
NAND FLASH
0x22200000
0x300000
AT91Bootstrap
0x20000000
SRAM
Current running Application in Red
ARM-Based Products Group
Linux Kernel
U-Boot
SDRAM
28
AT91SAM
NVM Programming Solutions
4. NVM Programming Solutions
NVM Programming Solutions
 Development Tools such as IAR, Keil integrate their own flash
loaders utility to flash the application during debug phase
 SAM-BA GUI: Atmel’s Free programming solution for on-chip
and on-board memories
 Serial port, USB and JTAG SAM-ICE support
 Graphical or command line interface
 Easy customization to create a custom board, add new memories, etc.
 AT91Boot_DLL.dll: Atmel’s Free solution for customers to create
their own GUI Interfaces
 Gang Programmers: support for all AT91SAM flash-based
microcontrollers thanks to FFPI
ARM-Based Products Group
30
4. NVM Programming Solutions
SAM-BA GUI (AT91 ISP)
 Customizing SAM-BA is possible by adding or modifying TCL
scripts files
 Enable the NAND Flash, then Use the Sendboot file script
 Command Line Mode: allows memory programming without any GUI
interaction
ARM-Based Products Group
31
Appendix
AT91SAM Boot Program Algorithm
Flow Diagrams
AT91SAM7X/XC/SE Boot Sequence
Power Up
Yes
No
TST = 1
No
PA0=PA1=1
GPNVM2 = 1
Yes
PA2 = 0
Yes
Boot From ROM
Boot From Flash
SAM-BA Boot
User Application
FFPI
ARM-Based Products Group
33
AT91SAM7S Boot Sequence
Power Up
Yes
TST = 1
No
Boot From Flash
PA0=PA1=1
User Application
Yes
PA2 = 1
No
FFPI
Boot From
ROM
Yes
SAM-BA Boot
Recovery
≈ 10 seconds
Power Up
with TST=0
ARM-Based Products Group
Boot From Flash
SAM-BA Boot
34
SAM-BA Boot Recovery Application (SAM7S only)
 AT91SAM7S ROM is not mapped by default
 SAM-BA Boot Recovery Application is responsible for
copying SAM-BA Boot into Flash
 10 seconds necessary for the copy
 Needs a power up sequence to run
SAM-BA Boot (TST=0)
Unlock Sectors 0 & 1
Copy SAM-BA Boot
from ROM to FLASH
while(1);
Power Up
ARM-Based Products Group
35
AT91SAM7L Boot Sequence
Power Up
IAP Function
Yes
No
TST = 1
No
GPNVM1 = 1
Yes
PC0=PC1=1
Yes
Boot From ROM
Boot From Flash
SAM-BA Boot
User Application
FFPI
ARM-Based Products Group
36
AT91SAM9XE Boot Sequence
Power Up
IAP Function
Yes
No
TST = 1
No
PA0=PA1=1
GPNVM3 = 1
Yes
PA2 = 0
Yes
Boot From ROM
Boot From Flash
SAM-BA Boot
User Application
FFPI
ARM-Based Products Group
37
AT91SAM9260 Boot Sequence
Power Up
Yes
DataFlash-Boot
on
SPI0 Chip Select 0
DataFlash-Boot
on
SPI0 Chip Select 1
No
BMS = 1
Boot From
External Memory
on EBI Chip Select 0
User Application
NandFlash-Boot
on
EBI Chip Select 3
SAM-BA Boot
Not
Supported
On revision A
ARM-Based Products Group
Optional
38
AT91SAM9261(S) Boot Sequence
Power Up
Yes
No
BMS = 1
SerialFlash-Boot on
SPI0 Chip Select 0
DataFlash-Boot on
SPI0 Chip Select 0
NandFlash-Boot on
EBI Chip Select 3
Boot From
External Memory
on EBI Chip Select 0
User Application
SDCard-Boot on
MCI
EEPROM-Boot on
TWI
Not
Supported
On revision A
SAM-BA Boot
ARM-Based Products Group
Optional
39
AT91SAM9263 Boot Sequence
Power Up
Yes
SD Card Boot
on
MCI1
NandFlash-Boot
on
EBI0 Chip Select 3
BMS = 1
No
Boot From
External Memory
on EBI0 Chip Select 0
User Application
DataFlash-Boot
on
SPI0 Chip Select 0
SAM-BA Boot
Not
Supported
On revision A
ARM-Based Products Group
Optional
40
AT91SAM9R(L)64 Boot Sequence
Power Up
Yes
SD Card Boot
on
MCI
BMS = 1
No
EBI Chip Select 0
User Application
NandFlash-Boot
on
EBI Chip Select 3
DataFlash-Boot
on
SPI Chip Select 0
SAM-BA Boot
Optional
ARM-Based Products Group
41
AT91SAM9G20 Boot Sequence
Power Up
Yes
SerialFlash-Boot then
DataFlash-Boot
on SPI0 Chip Select 0
SerialFlash-Boot then
DataFlash-Boot
on SPI0 Chip Select 1
No
BMS = 1
Boot From
External Memory
on EBI Chip Select 0
User Application
NandFlash-Boot on
EBI Chip Select 3
SDCard-Boot on MCI
EEPROM-Boot on TWI
SAM-BA Boot
Optional
ARM-Based Products Group
42
Download