Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Porting Paulus on ATSAM4E

File structure

After installation of Paulus the source code is stored in the file structure shown in Table 1 describes the contents.

...

In module atsam4e / init.c there must be the functions getBitRate() and getNodeId() available. Usually the CANopen network parameters are provided by reading jumpers or by loading from flash memory.

Development environment

Paulus on the platform of ATSAM4E was developed with the IAR Embeded Workbench for ARM v6.50.

Paulus configuration

In general the initialization function initializes only the absolutely necessary peripherals like clock system, CAN controller, memory management as needed by Paulus and a timer for Heartbeat or LSS. Nevertheless, there might be situations where it makes sense that Paulus initializes other functionalities which are later used by the application as well. As an example consider the serial interface for debug messages.

CAN bit rate

The CAN bit rate is coded by the index of the CAN bit timing table according to /CiA-305/. The index of the default CAN bit rate is specified about the compiler-define BITRATE_INDEX_<bit_rate> in /atsam4e/bl_config.h:

...

The default CAN bit rate is 125 kbit/s and can be changed by LSS services. The LSS services are described in /Paulus_man/ and base on /CiA-305/. The supported CAN bit rates are depending on the clock of the CAN controller and are listed in /atsam4e/atsam4e_can.c. The value FFh for segment2 marks unsupported CAN bit rates. The clock for the activation of the CAN bit rate is generated by timer TC0 with a period of 1 ms.

Heartbeat producer

Timer TC0 is also used for the generation of Heartbeat producer messages.

Debug output

By the compiler-define DEBUG a debug output can be activated about the serial interface usart1. The compiler-define is set in file /atsam4e/bl_config.h:

...

In general the initialization function will initialize only the absolutely necessary peripherals like clock system, CAN controller, memory management as needed by Paulus. Nevertheless, there might be situations where it makes sense that Paulus initializes other functionalities which are later used by the application as well. As an example consider the serial interface for debug messages.

Generating application software

The application software consists of an application header and an application program.

...

Figure 1: Application software structure

The application program has to be prepared for download by the following steps:

  •     build the application program in binary format

  •     calculate the CRC of the application program, build the application header and generate the application software to download

  •     configure the start address of the application software in Paulus

Paulus checksum

The program paulus_cksum calculates the CRC checksum of the binary application program, generates the application header and stores the application header and the application program in a new file. This file can be loaded in the device by Paulus.

...

Code Block
languagec
C:\BootloaderPaulus_ATSAM4E\tools>paulus_cksum.exe -v -C -l 256 -x 0x00410100 s1_atsam4e.bin  -O s1_download.bin

reduce Flash end to file end: 0x00003c10

reduce EndAddr to the Flash end 0x00003c0f

address - crc: 0x00000000,  start: 0x00000000,  end: 0x00003c0f,  exec 0x00410100

Flash end: 0x00003c10

out: >s1_download.bin<

input: >s1_atsam4e.bin<

calc CRC from 0x00000000 to 0x00003c0f

size: 0x00003c10,  crc: 0x0a8a

 Writing Appl. to >s1_download.bin<:

 length: 15376/0x3c10,  crc: 0x0a8a, execadr: 0x00410100

...

More detailed information from this tool can find in /Paulus_CRC/.

Start address

It is important that the start address of the application software in the flash memory and the information in the Paulus configuration in atsam4e/atsam4e_flash.h are identical. The application software is stored as a separate program in the flash memory additionally to the bootloader program. Therefore the application software is flashed to:

...

The length of the application header is 256 byte. The program start of the application is at address (FLASH_PROGRAM_START_ADR + 256 bytes).

Memory

Shared RAM

The shared RAM for data exchange between bootloader and application starts at address 0x20000000. The size of the shared RAM is specified in <target>/bl_interface.h by the compiler-define BL_JUMPCODE_SIZE. The shared memory is installed in <target>/bl_interface.h as follow:

...

The keyword for the re-start of the application program is set in byte 0-3 of jumpcode. Paulus uses the keyword “APPL” or “BOOT”  to start the application program, see /Paulus_man/.

Flash

The total size of the ATSAM4 flash is 1024Kb. The current implementation of Paulus occupies a memory area of 64Kb from this. Therefore 960 Kb flash memory area available for the application software.

...

The flash area for configuration data of Paulus is located at address 0x00408000. On this address and the following Paulus stores the node-ID and the CAN bit rate index during the execution of the LSS service “LSS store configuration“. The addresses are configurable in <target>/bl_interface.h:

...

After the next re-start Paulus uses this node-ID and this CAN bit rate index for communication. If the LSS services are not used, Paulus uses the node-ID and CAN bit rate index configured in <target>/bl_config.h.

Example application

CANopenSlave1 is an example for an application program. The directory example/ CANopenSlave1 contains the compiler project and the application-specific functions. For compilation the CANopen Library and the suitable driver package is necessary. The CANopen Library and the driver package belong not to the delivery scope of Paulus. The binary application software in example/ CANopenSlave1/bin/s1_download.bin can be used for a quick start.

...

This example has included source files bl_interface.c, bl_interface.h from bootloader. The application program can request an update by jumping back into Paulus by writing of the program control command start application program (value 1) on object 1F51h/1. The application program calls the macro BOOTLOADER_JUMP(APPL). This call is implemented in usr_301.c /sdoWrInd(). The application program stores the keyword “APPL” in the shared RAM and jumps into Paulus. Paulus is re-started and stays running until the application program is started by command.

References

/CiA-305/

CANopen Layer Setting Services and Protocols, CiA

/Paulus_CRC/

manual “Paulus Checksum Tool”, see file  tools/manual_cksum.pdf

/Paulus_man/

manual “Paulus User Manual”, see file  UserMan_Paulus_Bootloader_e.pdf

...