Keil µCvision3 V3.20a Compilation (Keil232a)

 

 
1.0

 

NOTE: Is not possible to flash an application in Embedded Flash with SAM-ICE. For flash you must be use an external tools provide by ATMEL, Please check the SAM-BA feature

Introduction

The goal of this demonstration project is to describe the KEIL compilation with AT91 target under some compilation tools

ADS Compilation

GCC Compilation

KEIL Compilation

Flash download

Cross compiling using KEIL V3.20a

A default KEIL project (Workspace) “BasicSAM7.Uv2” file is delivered with this example.

The processor selected must be ARM7 tm for compiler and assembler.

Compilation

· In First open the KEIL tools

· In Project menu select Open Project in builder and get the project file compil/BasicSAM7__xxx.Uv2

· Rebuild this project

. And debug

 

 Compilation files

BasicSAM7_xxx.Uv2

Main KEIL project file

BasicSAM7_xxx.opt

Project Option

resource/

All project Resource files

resource/ADS_xxx.lin

ADS 1.2 Area definition Linker file (scatter loading). Mapping memory and sections definition. Defines the memory map for the target board

resource/GCC_xxx.ld

GCC Area definition Linker file. Mapping memory and sections definition. Defines the memory map for the target board

Resource/SAM7_xxx_RAM.ini

Script file for set the processor before download and debug through ICE.

Resource/SAM7_Flash_RAM.ini

Script file for set the processor before download the flash memory with the Embedded Flash loader through ICE.

SrcXXX/

directory including the specific source code

SrcXXX/Cstartup.s79

Cstartup code include the reference for INTRAMSTART_REMAP define in linker file

SrcXXX/Cstartup_xxxx.c

Cstartup code Linked in ARM mode (32bits)

Obj_xxx/

KEIL object and list directory

 

Compilation files generate (can be deleted)

BasicSAM7_xxx.bak

Backup files

BasicSAM7_xxx.dep

Dependencies for Project

 

1 ADS Compilation

A default ADS KEIL project (Workspace) “BasicSAM7_ADS.Uv2” file is delivered with this example. The processor selected must be ARM7 tm for compiler and assembler. This project includes two workspaces one for RAM debug and the second for Flash download and debug.

 

Main features:

-         Uses ADS 1.2 compilation tools chain

-         Generate a RAM workspace for RAM debug

-         Use a Flash workspace for download in flash and debug

-         Generate a binary file for external download

 

ADS Compilation

When you compiles the project you will generate two following warning

..\src\main.c(96): warning: C2871W: static 'i' declared but not used

linking...

.\resource\ADS_Flash.lin(16): warning: L6314W: .\resource\ADS_Flash.lin(line 16, col 13) No section matches pattern *(EMPTY).

User command #1: fromelf.exe -bin ./Obj_ADS/BasicSAM7_ADS_Flash.axf -output  ./Obj_ADS/BasicSAM7_ADS_Flash.bin

".\Obj_ADS\BasicSAM7_ADS_Flash.axf" - 0 Error(s), 2 Warning(s).

 

First warning is generates by the unused variable “i”

Second is generates by the scatter file stack definition.

 

ADS Setting

-         Device

-          AT91SAM7S64

-         Target

-          48. Mhz

-          Operating system None

-         Outupt

-          Select folder for object ( ./Obj_ADS)

-          Name Of executable BasicSAM7_ADS_FLASH (BasicSAM7_ADS for RAM workspace)

-          Create Executable

-          Debug Information

-          Beep When complete

-          Run User Program #1 :  fromelf.exe -bin ./Obj_ADS/BasicSAM7_ADS_Flash.axf -output  ./Obj_ADS/BasicSAM7_ADS_Flash.bin (only for Flash workspace)

-         Listing

-         Select folder for listing ( ./Obj_ADS)           

-          Linker Listing

-         C

-          Enable ARM/Thumb Interworking  

-          Level 2 (-02)

-          Split Load and store multiple

-          Use the Thumb compiler

-          Include .\SrcADS,..\..\

-         ASM

-          Include ../../

-         Linker

-          Report ‘might fail’ Conditions as Errors

-          Scatter file .\resource\ADS_Flash.lin (use file .\resource\ADS_RAM.lin for RAM workspace)

-         Debug

-          Use: ULINK ARM Debugger setting

ULINK USB Adapter

Serial N°(set)

ULINK Version V2.00

Device family ARM7

Max JTAG Clock: 1 MHz

Debug

        Verify Code download

Use reset at start-up

JTAG Device Chain

        Automatic detection

-          Initialization file:  .\resource\SAM7_ADS_Flash.ini (.\resource\SAM7_ADS_RAM.ini for RAM workspace)

-          Breakpoints

-          Toolbox

-         Utilities (For Flash workspace only)

-          Update target before debugging

-          Init File: .\resource\SAM7_FLASH.ini

-          Use Target Driver for Flash Programming ULINK ARM Debugger

Setting

Do no Erase

Program

RAM For algorithm Start 0x00200000 Size 0x4000

Programming algorithm: AT91SAM7S64 Flash no remap Address Range 0x00000000 –0000FFFF

2 GCC Compilation

A default GCC KEIL project (Workspace) “BasicSAM7_GCC.Uv2” file is delivered with this example. The processor selected must be ARM7 tm for compiler and assembler. This project includes two workspaces one for RAM debug and the second for Flash download and debug.

 

 

Main features:

-         Uses GCC 3.3.1compilation tools chain

-         Generate a RAM workspace for RAM debug

-         Use a Flash workspace for download in flash and debug

-         Generate a binary file for external download

 

 

GCC Compilation

When you compiles the project you will generate following warning

compiling main.c...

../src/main.c(17): warning: `i' defined but not used

linking...

".\Obj_GCC\BasicSAM7_GCC.elf" - 0 Error(s), 1 Warning(s).

 

First warning is generates by the unused variable “i”

 

 

GCC Setting

A specific section is defines in the linker scrip file. This section define the top of internal memory

Used by the start-up file for stack definition. In ram workspace case this value is set at the top of internal memory
    . = ALIGN(4);

   .int_data : 

   {

   *(.internal_ram_top)

   }> STACK

 

 

-         Device

-          AT91SAM7S64

-         Target

-          48. Mhz

-          Operating system None

-         Outupt

-          Select folder for object ( ./Obj_GCC)

-          Name Of executable BasicSAM7_GCC_FLASH (BasicSAM7_GCC for RAM workspace)

-          Create Executable

-          Debug Information

-          Beep When complete

-          Run User Program #1 arm-uclibc-objcopy -I elf32-littlearm ./Obj_GCC/BasicSAM7_GCC_FLASH.elf -O binary ./Obj_GCC/BasicSAM7_GCC_FLASH.bin (only for Flash workspace)

-         Listing

-         Select folder for listing ( ./Obj_GCC)           

-          Linker Listing

-         CC

-          Enable APCS (ARM Procedure Call Standard)          

-          Support Calls Between ARM and THUMB Instruction set      

-          Level 2 (size)

-          Compile Thumb code

-          Include ./SrcGCC/,../../

-         Assembler

-         Linker

-          Do not use >Standard System Startup files

-          Linker script file:  .\resource\GCC_Flash.ld (use file .\resource\GCC_RAM.ld for RAM workspace)

-         Debug

-          Use: ULINK ARM Debugger setting

ULINK USB Adapter

Serial N°(set)

ULINK Version V2.00

Device family ARM7

Max JTAG Clock: 1 MHz

Debug

        Verify Code download

Use reset at start-up

JTAG Device Chain

        Automatic detection

-          Initialization file:  .\resource\SAM7_GCC_Flash.ini (.\resource\SAM7_GCC_RAM.ini for RAM workspace)

-          Breakpoints

-          Toolbox

-         Utilities (For Flash workspace only)

-          Update target before debugging

-          Init File: .\resource\SAM7_FLASH.ini

-          Use Target Driver for Flash Programming ULINK ARM Debugger

Setting

Do no Erase

Program

RAM For algorithm Start 0x00200000 Size 0x4000

Programming algorithm: AT91SAM7S64 Flash no remap Address Range 0x00000000 –0000FFFF

 

3 KEIL Compilation

A default GCC KEIL project (Workspace) “BasicSAM7_KEIL.Uv2” file is delivered with this example. The processor selected must be ARM7 tm for compiler and assembler. This project includes two workspaces one for RAM debug and the second for Flash download and debug.

 

 

Main features:

-         Uses KEIL 1compilation tools chain

-         Generate a RAM workspace for RAM debug

-         Use a Flash workspace for download in flash and debug

-         Not Generate a binary file for external download

 

 

KEIL Compilation

When you compiles the project you will generate following warning

compiling main.c...

../src/main.c(17): warning: `i' defined but not used

linking...

".\Obj_GCC\BasicSAM7_GCC.elf" - 0 Error(s), 1 Warning(s).

 

First warning is generates by the unused variable “i”

 

KEIL Setting

 

Some specifics conditional assembly parameter can be set for Flash or RAM works space and another for THUMB or ARM selection.

- In field Asm Conditional assembly control Symbols 

For RAM workspace uses RAM and for Flash Workspace uses

For ARM instruction set uses ARM_MODE in For THUMB is default

 

-         Device

-          AT91SAM7S64

-         Target

-          48. Mhz

-          Operating system None

-          Un-use On-chip ROM 0x0 – 0xFFFF

-          Un-Use On-chip RAM 0x0 – 0x3FFF

-         Outupt

-          Select folder for object ( ./Obj_KEIL)

-          Name Of executable BasicSAM7_KEIL_FLASH (BasicSAM7_KEIL for RAM workspace)

-          Create Executable

-          Create HEX File (only for Flash workspace)

-          Debug Information

-          Beep When complete

-         Run User Program #1 arm-uclibc-objcopy -I ihex ./Obj_KEIL/BasicSAM7_KEIL_FLASH.hex -O binary ./Obj_KEIL/BasicSAM7_KEIL_FLASH.bin (only for Flash workspace)

-         Listing

-         Select folder for listing ( ./Obj_KEIL)           

-          Linker Listing

-          C        

-          Level: 6: Common trail merging)

-          Emphasis: Favor code size

-          Warning level 2

-          Treat plain char as ‘unsigned char’          

-          Use Thumb Mode

-          Include ./SrcKEIL/,../../

-         Assembler

-          Macro processor Standard

-         Case sensitive symbols

-          Set FLASH

-          Include Paths: ../../

-         LA Misc

-          Warning level 2

-          Case sensitive symbols

-         LA locate

-          Use memory layout form Target Dialog

-          User Classes: CODE (0x000000-0x0FFFF), CONST (0x0-0xFFFF), DATA (0x0200000-0x0203FFF)

-         Debug

-          Use: ULINK ARM Debugger setting

ULINK USB Adapter

Serial N°(set)

ULINK Version V2.00

Device family ARM7

Max JTAG Clock: 1 MHz

Debug

        Verify Code download

Use reset at start-up

JTAG Device Chain

        Automatic detection

-          Initialization file:  .\resource\SAM7_KEIL_Flash.ini (.\resource\SAM7_KEIL_RAM.ini for RAM workspace)

-          Breakpoints

-          Toolbox

-         Utilities (For Flash workspace only)

-          Update target before debugging

-          Init File: .\resource\SAM7_FLASH.ini

-          Use Target Driver for Flash Programming ULINK ARM Debugger

Setting

Do no Erase

Program

RAM For algorithm Start 0x00200000 Size 0x4000

Programming algorithm: AT91SAM7S64 Flash no remap Address Range 0x00000000 –0000FFFF

4 Flash download With U-LINK Only

Some ways are available for flash Application after compilation.

-         Pushes the “load” button

-         Selects in the flash menu the Flash -> download

-         Pushes the “Start/stop Debug session

 

Note: If you change and load the application without flash you can generates some warning for check memory procedure.

 

Flash Download features

-         Run in internal RAM 0x0020 0000 – 0x0000 2000

-         Write the code 0x0000 0000 to flash address 0x0010 0000 (Remap done)

-         No need to erase sector use MC_FMR.NEBP = 0. A page erase is performed before programming.

-         Unlock sector before write

-         No lock sector after write

 

 

Flash utility Setting

-         Utilities (For Flash workspace only)

-          Update target before debugging

-          Init File: .\resource\SAM7_FLASH.ini

-          Use Target Driver for Flash Programming ULINK ARM Debugger

Setting

Do no Erase

Program

RAM For algorithm Start 0x00200000 Size 0x4000

Programming algorithm: AT91SAM7S64 Flash no remap Address Range 0x00000000 –0000FFFF

5 Flash download With J-LINK

The FlashDL licence and RDI are required to use the J-link Feature

 

6 Flash download With SAM-ICE

The FlashDL licence is required to use the KEIL Flash Feature the other way is to use the ATMEL SAM-BA tools to load the binary file in the flash .

 

Troubleshooting

1) The reset icon is not available when push reset the remap is done and the first address works in Flash area.

2) The Flash icon can be no works; In this case you must be check the flash driver installation if not install please re-install.

3) Under ADS compilation

If you can’t generate the binary file you must quit and re open the project for load the parameter