42
AT91SAM Boot Strategies Application Deployment Frederic BOYER Support & Training Group Engineer AT91 Training Coordinator ARM MCU & MPU

AT91SAM Boot Strategies Application Deployment Frederic BOYER Support & Training Group Engineer AT91 Training Coordinator ARM MCU & MPU

Embed Size (px)

Citation preview

AT91SAM Boot StrategiesApplication Deployment

Frederic BOYERSupport & Training Group EngineerAT91 Training CoordinatorARM MCU & MPU

2

ARM-Based Products Group

Outline

Introduction

Boot Solutions

Application Deployment

NVM Programming Solutions

1. Introduction

4

ARM-Based Products Group

NAND vs. NOR Flash

Advantage of NANDAdvantage of NAND

High Speed Program/EraseLow Cost-per-bitHigh Capacity

Disadvantage of NANDDisadvantage of NAND

Slow Random Access TimeDifficulty of Byte Programming

Advantage of NORAdvantage of NOR

High Speed Random AccessByte ProgrammingCode execution

Disadvantage of NORDisadvantage of NOR

Slow Program SpeedSlow Erase Speed

ApplicationsApplications

Suitable for Data MemoryProgram/Data Mass Storage

Applications

Suitable for Code MemoryeXecute In Place (XIP)

1. Introduction

5

ARM-Based Products Group

NOR vs. NAND Boot Considerations

NOR Flash Used as an eXecute In Place (XIP) memoryeXecute 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 ShadowingCode Shadowing must be performed: memory contents must be first copied into memory-mapped RAM and executed there

Used to replace Hard Disk Drive

1. Introduction

6

ARM-Based Products Group

AT91SAM Boot Strategies Introduction

GPNVM bitGPNVM bit(Embedded Flash based µC)

BMS pinBMS pin(Flashless µC)OR

Boot Memory Selection

Power UpPower Up

To ensure maximum boot possibilities, memory layout can be changed with different parameters.

On our AT91SAM, either GPNVM bitGPNVM bit or BMS pinBMS 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)…

1. Introduction

7

ARM-Based Products Group

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 From Boot From (Int. or Ext.) Flash(Int. or Ext.) FlashBoot From ROMBoot From ROM OR

Boot Memory Selection

1. Introduction

8

ARM-Based Products Group

Boot Memory Selection for Flash based µC(SAM7 and SAM9XE)

Boot From Boot From Embedded FlashEmbedded FlashBoot From ROMBoot From ROM

GPNVM bit = 1No Yes

Power UpPower Up

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.

1. Introduction

9

ARM-Based Products Group

Boot Memory Selection for Flashless µC(SAM926x, SAM9R(L), SAM9G20)

Boot From Boot From External 16-bit FlashExternal 16-bit FlashBoot From ROMBoot From ROM

BMS pin = 1Yes No

Power UpPower Up

BMS pin is sampled when VDDCORE is powered.

1. Introduction

2. Boot Solutions

11

ARM-Based Products Group

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

2. Boot Solutions

12

ARM-Based Products Group

NVM MemoryNVM MemoryBootloaderBootloader SAM-BA BootSAM-BA Boot FFPIFFPI IAP FunctionIAP Function

22ndnd Level LevelBootloaderBootloader ISPISP Gang Gang

ProgrammerProgrammerInterfaceInterface

IAPIAP

AT91SAMAT91SAMBootROMBootROM

2. Boot Solutions

Booting from ROM

AT91SAM Boot ROM supports numerous applications

13

ARM-Based Products Group

BootROM Applications

2. Boot Solutions

Flash AT91 µCNVM

BootloaderSAM-BA

BootFFPI IAP Function

SAM7S - X X -

SAM7X/XC - X X -

SAM7SE - X X -

SAM7L - X X X

SAM9XE - X X X

FlashLess AT91 µC

SAM9260 X X - -

SAM9261(S) X X - -

SAM9263 X X - -

SAM9R(L)64 X X - -

SAM9G10 X X - -

SAM9G20 X X - -

SAM9G45 X X - -

14

ARM-Based Products Group

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

Valid Code ?Yes

No

NVM-Boot

Next NVM-Boot

Copy code fromNVM memory into SRAM

Reset Peripherals, remap and execute code out of SRAM

No need for externalNOR Flash memory !

1st Level Bootloader

2. Boot Solutions

15

ARM-Based Products Group

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 Cardswhich are not High Capacity SDHC

EEPROM: any I²C Memory EEPROM

One NVM memory for a whole application !!!

2. Boot Solutions

16

ARM-Based Products Group

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*

2. Boot Solutions

* Max code size value must be checked in the Boot Program section of each product datasheet

17

ARM-Based Products Group

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*

Vector 1

Vector 2

Vector 3

Vector 4

Vector 5

Vector 6

Vector 7

Vector 8‘e59’ LDR opcode

What is a valid code (cont’d)?

00 e59ff07404 e59ff01408 e59ff014 0c e59ff014 10 e59ff014 14 00000800 18 e59ff060 1C e59ff00C

ResetUndefined InstructionSoftware InterruptPrefect AbortData abortReserved: SIZE OF THE IMAGENormal interruptFast interrupt

ARM exception vectors

2. Boot Solutions

* Max code size value must be checked in the Boot Program section of each product datasheet

18

ARM-Based Products Group

2. Boot Solutions

NVM Memory Bootloader Support

AT91 NVMDataFlash

(SPI)

Serial

Flash

(SPI)

SLC NandFlash

(EBI)

Standard

SDCard

(MCI)

EEPROM

(TWI)

SAM9260 rev A

SAM9260 rev B

X

X

-

-

-

X

-

-

-

-

SAM9261(S) rev A

SAM9261 rev B

X

X

-

X

-

X

-

X

-

X

SAM9263 rev A

SAM9263 rev B

X

X

-

-

-

X

-

X

-

-

SAM9R(L)64 rev A X - X X -

SAM9G10 rev A X X X X X

SAM9G20 rev A

SAM9G20 rev B

X

X

X

X

X

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.

19

ARM-Based Products Group

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?

2. Boot Solutions

20

ARM-Based Products Group

AT91SAM9R(L)64 Boot ROM Sequence

NandFlash-Booton

EBI Chip Select 3

SD Card Booton

MCI

DataFlash-Booton

SPI Chip Select 0

SAM-BA Boot

2. Boot Solutions

21

ARM-Based Products Group

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.

Free AT91 ISP Programming Solutions

2. Boot Solutions

22

ARM-Based Products Group

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

Ease IAPDevelopment

2. Boot Solutions

23

ARM-Based Products Group

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)

Security Bit Must Be Cleared

TST=1

H/W Programming Solution For Gang Prog.

2. Boot Solutions

3. AT91SAM Application Deployment

25

ARM-Based Products Group

Standard Application Deployment

1st Level Bootloader(NVM Memory Bootloader)

2nd LevelBootloader

(Optional)3rd Level

Bootloader

Main Application

AT91 AT91 BootstrapBootstrap

U-bootU-bootE-bootE-boot

LinuxLinuxWinCEWinCE

Standalone AppStandalone App

FLASHMedia(s)

3. Application Deployment

26

ARM-Based Products Group

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

NAND Flash

AT45 DataFlash

25xxx Serial Flash

SD Card

CFI NOR Flash

I2C EEPROM In Dev In Dev In Dev

Free

3. Application Deployment

27

ARM-Based Products Group

Getting Started

NVM Boot AT91Bootstrap0x0000

0x8400

DATA FLASH

AT91Bootstrap

SRAM

DataFlash Boot

SAMBA Boot

ROM

SDRAM

AT91BootstrapAT91Bootstrap0x300000

Application

0x20000000

AT91Bootstrap

Application

Application

Current running Application in Red

DATAFLASH Boot Example

3. Application Deployment

DataFlash Boot

28

ARM-Based Products Group

NVM Boot

NAND FLASH Boot Example

SRAM

NandFlash-Boot

SAMBA Boot

ROM

SDRAM

NandFlash-Boot

0x300000 0x20000000

Current running Application in Red

U-Boot

0x0000

0x60000

0x20000

NAND FLASH

Linux Kernel

AT91BootstrapAT91Bootstrap

Linux Kernel

U-Boot

AT91Bootstrap U-Boot

Linux Kernel0x22200000

3. Application Deployment

AT91SAM NVM Programming Solutions

30

ARM-Based Products Group

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

Free

Free

4. NVM Programming Solutions

31

ARM-Based Products Group

SAM-BA GUI (AT91 ISP)

Customizing SAM-BA is possible by adding or modifying TCL scripts files

Command Line Mode: allows memory programming without any GUI interaction

Create your own board

Add memory modules

Modify Memory

Algorithms

Enable the NAND Flash, then Use the Sendboot file script

4. NVM Programming Solutions

Appendix

AT91SAM Boot Program Algorithm Flow Diagrams

33

ARM-Based Products Group

AT91SAM7X/XC/SE Boot Sequence

NoTST = 1

Yes

PA0=PA1=1

PA2 = 0

Yes

Power Up

GPNVM2 = 1No Yes

FFPIBoot From Flash

User Application

Boot From ROM

SAM-BA Boot

Security Bit

Must Be Cleared

34

ARM-Based Products Group

AT91SAM7S Boot Sequence

NoTST = 1

Yes

PA0=PA1=1

Power Up

PA2 = 1

YesNo

Power Up

with TST=0

Yes

Boot From Flash

User Application

Boot From Flash

SAM-BA Boot

SAM-BA BootRecovery

≈ 10 seconds

FFPI

Security Bit

Must Be Cleared

Boot FromROM

35

ARM-Based Products Group

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

Security Bit Must Be Cleared

TST=1

Power UpPower Up

36

ARM-Based Products Group

AT91SAM7L Boot Sequence

NoTST = 1

Yes

PC0=PC1=1

Yes

Power Up

GPNVM1 = 1No Yes

FFPIBoot From Flash

User Application

Boot From ROM

SAM-BA Boot

Security Bit

Must Be Cleared

IAP Function

37

ARM-Based Products Group

AT91SAM9XE Boot Sequence

NoTST = 1

Yes

Yes

Power Up

GPNVM3 = 1No Yes

FFPIBoot From Flash

User Application

Boot From ROM

SAM-BA Boot

Security Bit

Must Be Cleared

IAP Function

PA0=PA1=1

PA2 = 0

38

ARM-Based Products Group

AT91SAM9260 Boot SequencePower Up

BMS = 1Yes No

Boot From ROM

DataFlash-Booton

SPI0 Chip Select 1

DataFlash-Booton

SPI0 Chip Select 0

NandFlash-Booton

EBI Chip Select 3

SAM-BA Boot

Boot From External Memory

on EBI Chip Select 0

User Application

Boot From External 16-bit Flash

Not Supported

On revision AOptional

39

ARM-Based Products Group

AT91SAM9261(S) Boot SequencePower Up

BMS = 1Yes No

Boot From ROM

DataFlash-Boot onSPI0 Chip Select 0

SerialFlash-Boot onSPI0 Chip Select 0

NandFlash-Boot onEBI Chip Select 3

SAM-BA Boot

Boot From External Memory

on EBI Chip Select 0

User Application

SDCard-Boot onMCI

EEPROM-Boot onTWI

Boot From External 16-bit Flash

Not Supported

On revision AOptional

40

ARM-Based Products Group

AT91SAM9263 Boot SequencePower Up

BMS = 1Yes NoBoot From ROM

Boot From External Memory

on EBI0 Chip Select 0

User ApplicationNandFlash-Boot

onEBI0 Chip Select 3

SD Card Booton

MCI1

DataFlash-Booton

SPI0 Chip Select 0

SAM-BA Boot

Boot From External 16-bit Flash

Not Supported

On revision AOptional

41

ARM-Based Products Group

AT91SAM9R(L)64 Boot SequencePower Up

BMS = 1Yes NoBoot From ROM

EBI Chip Select 0

User ApplicationNandFlash-Boot

onEBI Chip Select 3

SD Card Booton

MCI

DataFlash-Booton

SPI Chip Select 0

SAM-BA Boot

Boot From External 16-bit Flash

Optional

42

ARM-Based Products Group

AT91SAM9G20 Boot SequencePower Up

BMS = 1Yes No

Boot From ROM

NandFlash-Boot onEBI Chip Select 3

SAM-BA Boot

Boot From External Memory

on EBI Chip Select 0

User Application

SDCard-Boot on MCI

EEPROM-Boot on TWI

Boot From External 16-bit Flash

SerialFlash-Boot then DataFlash-Boot

on SPI0 Chip Select 0

SerialFlash-Boot then DataFlash-Boot

on SPI0 Chip Select 1

Optional