Ideas on extending network reprogramming

Jaein Jeong           (e-mail: jaein@cs)

 

Network reprogramming extension plan

Memory Layout

 

In the current network reprogramming implementation, the program image is stored at the beginning of the external flash memory. After all the records of the program image are stored, the boot loader is called with the start address of the program image (wEEProgStart) in the external flash. The following figure shows that each line of SREC file accounts for two lines in the external flash.

 

If we extend the network reprogramming so that it transfers the delta rather than the whole new image, the previous program image should reside in the external flash memory. Based on the fact that the external flash memory space is as least twice as large as the program memory space, we can divide the external program memory as multiples chunks, each of which is as big as the program memory. For example, MICA2 or MICA2DOT motes can have up to 4 chunks because they have 128KB of program memory and 512KB (=4Mbit) of external flash memory.

 

 

The idea is to keep the pointer (the start address of the program image) to the previous image and the current image. This information should be in the non-volatile storage because it should exist even after the mote is powered off. The internal EEPROM in the microcontroller has enough room (4KB) for the house keeping information.

 

Possible protocol extension

 

Then, we can propose the following changes to the existing protocol:

 

Start Download:

The description in red is the modification.

 

Download:

The current implementation only allows the operation that stores the received data bytes in the current flash memory area (insert). If we extend it to a diff-like scheme, we can have two operations: insert and copy. Copy operation copies the data bytes from the previous area to the current area.

 

            Insert (iCapsule, data)

            Copy (fromCapsulePrev, toCapsuleCur, length)

 

 

Reboot:

The current implementation passes the start of the external flash memory (wEEProgStart) before it calls the boot loader. The extended version should pass the start address of the current memory area.

 

 

Generating new image from delta

Line-based diff scheme

One way to represent the change in the program image is using the line-based diff scheme. After comparing each line of the two files, the diff program generates a script that tells which lines should be copied from the previous image and which lines should be inserted.

 

To check whether this scheme can capture the changes with reasonable size of script, we ran the diff program over two different scenarios. In the first case, the two programs are functionally equivalent and the only difference is the constant which is generated at the build time. In the second case, additional lines of code were added to the source code.

 

 

Case 1

Case 2

Number of lines in the SREC file (old)

1027

1027

Number of lines in the SREC file (new)

1027

1032

Number of lines to insert

1

635

Number of lines to copy

1026

397

 

In the first case, the number of lines to insert is 1 out of 1027. In the second case, which is more realistic, it is 635 out of 1032. Considering that the change is small compared to the whole program size, this is far from the optimal.