Implementing a CANopen compliant boot loader and monitor/debugger core for Flash Microcontroller"A best common practice approach"By Olaf Pfeiffer and Andrew Ayre of Embedded Systems Academy |
|
|||||||||
|
Goal of this paper is to define the minimal CANopen functions, features and variables that a boot loader needs to support to still be recognized as a CANopen node in a system. For the scope of this document we define the boot loader to be a piece of code that is shipped pre-installed with Flash microcontrollers. Using hardware or software mechanisms, the microcontroller can be set into boot mode - which means the application code is bypassed and the boot loader code is executed. This documents requires some intermediate knowledge about CANopen. The specifications DS 301 V4.01 and DSP302 V2.0 were used as a guideline for this document. FunctionalityThe minimal expected functionality of the CANopen compliant boot loader is:
Extended functionality may include:
|
|
||||||||
Minimizing code resources by minimizing functionalityMost Flash microcontrollers only offer limited code space in the boot area forcing us to minimize the CANopen implementation used. A minimal CANopen implementation as suggested in this document would never be a "true" CANopen node just by itself. As it does not have any application program and as there is no application I/O it is feasible to violate DS 301 V4.01 if the result is to further minimize the code size. A CANopen compliant boot loader would not listen to the NMT master message changing operating states, as it would not have any operating states. There are no PDOs (Process Data Objects). As there is no operating state and no process data, node guarding and heartbeat do not need to be supported. Note: This is a violation to DS 301 V4.01, which states that every CANopen node MUST support either node guarding or heartbeat. The communication channels required are the boot-up message and the SDO (Service Data Object). Optionally the Emergency message may be used when debugging is supported. Background info: the node transmits the boot-up message after start-up. It informs other nodes on the network that this node now started up and awaits configuration. The SDO communication channel is used for transmitting configuration data. The CANopen Object DictionaryMandatory object dictionary entries for a CANopen compliant boot loader: [1000h] [1000h] [1018h] [1F50h] [1F51h] Optional entry for password and erase command The functionality implemented so far is sufficient to allow re-programming of Flash memory in a device. However, it does not offer much security. There is no protection mechanism to protect the Flash memory from unintentional overwrite. Additional security can be added by implementing an additional object dictionary containing a password. Only after the correct value is written to that password does the object 1F50h get enabled/functional. If this functionality is used, it is recommended to do so using the following object dictionary entry: [7F50h] Debugging SupportAdding debugging support to the boot loader is optional. However, if debugging is supported, all of the following functions and object dictionary entries must be supported. Not all details of debugging are specified in this part of the document, as data and address types depend on the microcontroller architecture used. However, in order to cover as many microcontroller architectures as possible, all address values are using 4 bytes. The byte ordering is CANopen compatible (lowest byte comes first, followed by each higher significant byte). If a microcontroller uses the Harvard architecture, addresses need to be mapped to a van Neuman model (as done on 8051 architectures by "generic pointers"). The following debugger functions are defined in this document:
Object dictionary entry for debug-functionality [1025h] It should be noted that it is possible to access this object dictionary entry while the user code is running, allowing access to variables at run-time. Sub-index 1 "Command" Sub-index 2 "Status" Sub-index 3 "Reply" Sub-index 4 "Data" Using the emergency message for debug informationAs usual with SDOs (Service Data Objects), the SDO client initiates all communication. In this case the host PC running the debugger software. This means that only the host PC can initiate accesses to the Object Dictionary entries. If the monitor/debugger firmware needs to report an urgent change-of-debugging-state to the host, it does so with the emergency message. The Error code to be used is 6200h "User Software". The 5 manufacturer specific bytes in the emergency message are used as follows:
|
ESAcademy, 2002 All materials |