Menu

Loader

Mike Johnson

Loader protocol

The main point of this is to be able to upgrade module software without having to send it back to the maker to be re-programmed.

The loader occupies the lowest 4k bytes of program memory and gains control after a reset. If there is a valid program loaded above it then it enters the program.

If there is no valid program loaded, then it executes its own main loop, performing anything that may be relavent to a node which can't do anything. This includes read block, write block, setting the canid and NN, NN refresh as well as the loader function. This means it can cope with an error or power failure during re-programming, but not with loading a faulty program.

If a working module receives a software download start packet, it needs to turn off any pulsed outputs, disable interrupts and then jump to the loader at 0x000030.

Boot memory layout

  • 0x0000, reset
  • 0x0008, hp interrupt
  • 0x0018, lp interrupt
  • 0x0020, 7 byte version info for boot loader
  • 0x0030, jump to loader
  • 0x0040, 2 byte canid, 2 byte nodenumber, 60 bytes empty
  • 0x0080, 64 byte block loader text string
  • 0x00C0, 64 byte block identification string assigned by the user

Program memory layout

program baseaddress = 0x1000

  • baseaddress+0x0000, redirected reset
  • baseaddress+0x0008, redirected hp interrupt
  • baseaddress+0x0018, redirected lp interrupt
  • baseaddress+0x0020, 7 byte version info for program
  • baseaddress+0x0027, valid program loaded flag, 0xFF=no program, 0x00=valid program
  • baseaddress+0x0028, 4 bytes start address of XML data description file
  • baseaddress+0x002C, 2 bytes length of XML file.
  • baseaddress+0x002E, 18 spare bytes
  • baseaddress+0x0040, 64 byte block with program identification string

Note. In C18, 16 and 32 bit (2 and 4 byte) data are stored low byte first, the opposite way to CBUS packet data.

5C Software download start (LDRSTRT)

Format: <5C><NNhigh><NNlow>

Directs the module with nodenumber NN to enter the loader in order to receive a software download. The module should stop running by turning off any pulsed outputs, disable interrupts and enter the boot loader. The loader will send an ack back to the PC. The loader should then load a complete program and execute the restart cmd.

5D Reset/restart cmd (LDRRST)

Format: <5D><NNhigh><NNlow>

Directs the module with nodenumber NN to set the valid program loaded flag to 0x00, and execute a reset instruction. Used after loading a compete program without error.

7C Status acknowledge from nodenumber (ACKNN)

Format: [<Priority><CANID>]<7C><NNhigh><NNlow><status>

The module with nodenumber NN sends this to indicate its status after executing something that takes time. Currently used for a block write to a module, Event teaching and Node variables. The status can be application dependant. Currently the status is:

  • 0 for OK
  • 1 for CRC error
  • 2 for timeout
  • 3 for no data
  • 4 for no space.

BC Read block command (LDRRB)

Format: <BC><NNhigh><NNlow><AddressUpper><AddressHigh><AddressLow>

Requests the node with nodenumber NN to transmit a block of 64 bytes from program memory at the address. The reply is 17 memory data packets.

BD Write block command (LDRWB)

Format: <BD><NNhigh><NNlow><AddressUpper><AddressHigh><AddressLow>

Commands the node with nodenumber NN to write a 64 byte block of data to program memory or eeprom. This is followed by 17 memory data packets and the module should then send an ACKNN after the block is written.

FC Memory data packet (LDRDATA)

Format: <FC><NNhigh><NNlow><Offset><data0><data1><data2><data3>

A packet containing 4 bytes of memory data. Since data is always transfered in 64 byte blocks with a CRC8 byte there will always be 17 data packets for a complete block. The CRC8 byte has offset = 64. Since packets do not arrive in order the offset is the address with the 64 byte block. The number of blocks has to be counted to check that they have all arrived.


MongoDB Logo MongoDB