K20hack

During the development of the new Cortex M4 OpenMote we have been working with the Freescale K20 tower module. In this page we describe the main hacks to run OpenWSN stack on it.

Debug Pins

Port NamePin NumberPin Function
PTD7Pin B34FRAME
PTB20Pin B23SLOT
PTE26Pin B25FSM
PTB0Pin B27TASK
PTB2Pin B29ISR
PTA14Pin B35RADIO

SPI to Radio Pins

Port NamePin NumberPin Function
PTD0B46CS0
PTD1B48CLK
PTD2B45MOSI
PTD3B44MISO

Other Radio Pins

Port NamePin NumberPin Function
PTB3B51SLPTR
PTC10B52RST
PTE25B55ISR (IRQ H)

Bootloader

A Mass Storage Device bootloader has been developed so the k20 mote can be plug into the usb port and appear as a flash drive. In that way, by dropping an application to the folder the mote can be flashed.

In this page some of the considerations to develop applications that can be bootloaded are presented.

Memory Map of the Bootloader

The bootloader is placed at the beginning of the flash area. The memory map looks as follow:

MEMORY {
  interrupts  (RX) : ORIGIN = 0x00000000, LENGTH = 0x000003ff #1024 bytes
  code        (RX) : ORIGIN = 0x00000410, LENGTH = 0x0003FBF0 #all flash except the first 1kb
  data        (RW) : ORIGIN = 0x1FFF8000, LENGTH = 0x0000FC00 #63kb ram -- 1kb is kept for isr vector in ram.
  cfmprotrom  (RX) : ORIGIN = 0x00000400, LENGTH = 0x0000010  #16bytes protected area.
}

Application Memory Map

Applications that need to be flashed by the bootloader need to define its memory map taking into account that the bootloader is at the beginning of the flash. Basically any application will start at 0xC000

MEMORY {
  m_interrupts  (RX) : ORIGIN = 0x0000C000, LENGTH = 0x000001BC #some space for the interrupt vector
  m_text        (RX) : ORIGIN = 0x0000C800, LENGTH = 0x0003FBF0 #all flash starting after the bootloader 
  m_data        (RW) : ORIGIN = 0x1FFF8000, LENGTH = 0x0000FC00 #63kb ram -- 1kb is kept for isr vector in ram.
  m_cfmprotrom  (RX) : ORIGIN = 0x0000C400, LENGTH = 0x00000010 #16bytes protected area.
}

note that the bootloader and the application may use all the available ram since they will never execute at the same time.

File Types

The bootloader accepts binary, hex and s19 files. For s19 file there is a restriction on the length of s19 records. The limitation comes from the size of the buffers used by the bootloader to write the flash area. We recommend to use -sreclength 40 in the linker script to create the s19 file with s19 records of an appropriate size.