From 6061f45930a7b91681a41cb84dea385454813054 Mon Sep 17 00:00:00 2001 From: razvanm Date: Thu, 23 Apr 2009 00:44:56 +0000 Subject: [PATCH] Fix for Deluge T2 to properly deal with images bigger than 64K. --- tools/tinyos/misc/tos-build-deluge-image | 5 ++++- tools/tinyos/misc/tos-deluge | 2 +- .../net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc | 2 +- tos/lib/tosboot/TOSBootM.nc | 8 +++----- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/tinyos/misc/tos-build-deluge-image b/tools/tinyos/misc/tos-build-deluge-image index 3095167a..0dddf828 100755 --- a/tools/tinyos/misc/tos-build-deluge-image +++ b/tools/tinyos/misc/tos-build-deluge-image @@ -130,10 +130,11 @@ except: all = [] section = [] end_addr = None +offset = 0 for line in image.split(): #print "DEBUG:", line length = int(line[1:3], 16) - addr = int(line[3:7], 16) + addr = int(line[3:7], 16) + offset rectype = int(line[7:9], 16) data = [] if len(line) > 11: @@ -155,6 +156,8 @@ for line in image.split(): start_addr = addr section += data end_addr = addr + length + elif rectype == 0x02: + offset = int(line[9:9+4], 16) << 4 elif rectype == 0x01: all.append((start_addr, section)) section = [] diff --git a/tools/tinyos/misc/tos-deluge b/tools/tinyos/misc/tos-deluge index 9ec58283..d9c87463 100755 --- a/tools/tinyos/misc/tos-deluge +++ b/tools/tinyos/misc/tos-deluge @@ -70,7 +70,7 @@ class FMReqPacket(tos.Packet): tos.Packet.__init__(self, [('cmd', 'int', 1), ('imgNum', 'int', 1), - ('offset', 'int', 2), + ('offset', 'int', 4), ('length', 'int', 2), ('data', 'blob', None)], packet) diff --git a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc index 06420ce4..e758e77a 100644 --- a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc +++ b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc @@ -45,7 +45,7 @@ implementation typedef nx_struct SerialReqPacket { nx_uint8_t cmd; nx_uint8_t imgNum; - nx_uint16_t offset; + nx_uint32_t offset; nx_uint16_t len; nx_uint8_t data[0]; } SerialReqPacket; diff --git a/tos/lib/tosboot/TOSBootM.nc b/tos/lib/tosboot/TOSBootM.nc index e04718f4..fb73723e 100644 --- a/tos/lib/tosboot/TOSBootM.nc +++ b/tos/lib/tosboot/TOSBootM.nc @@ -96,10 +96,11 @@ implementation { } bool verifyImage(ex_flash_addr_t startAddr) { - uint16_t addr; + uint32_t addr; uint8_t numPgs; uint8_t i; + if (!verifyBlock(startAddr + offsetof(DelugeIdent,crc), startAddr, offsetof(DelugeIdent,crc))) return FALSE; @@ -118,9 +119,6 @@ implementation { for ( i = 0; i < numPgs; i++ ) { if (!verifyBlock(startAddr + i*sizeof(uint16_t), startAddr + addr, DELUGE_BYTES_PER_PAGE)) { - if (i == 0) - while (1) - call Leds.flash(2); return FALSE; } addr += DELUGE_BYTES_PER_PAGE; @@ -131,7 +129,7 @@ implementation { error_t programImage(ex_flash_addr_t startAddr) { uint8_t buf[TOSBOOT_INT_PAGE_SIZE]; - uint16_t pageAddr, newPageAddr; + uint32_t pageAddr, newPageAddr; in_flash_addr_t intAddr; in_flash_addr_t secLength; ex_flash_addr_t curAddr; -- 2.39.2