From 1f72a047e7728c862e6dd46f09682181b662aec4 Mon Sep 17 00:00:00 2001 From: Martin Cerveny Date: Mon, 25 Mar 2013 12:23:16 +0100 Subject: [PATCH] Support for ihex 0x04 command. Check range of programm flash. --- tools/tinyos/misc/tos-build-deluge-image.in | 5 ++++- tos/lib/tosboot/TosBootP.nc | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/tinyos/misc/tos-build-deluge-image.in b/tools/tinyos/misc/tos-build-deluge-image.in index d6a2260c88..0f6cbe6d35 100755 --- a/tools/tinyos/misc/tos-build-deluge-image.in +++ b/tools/tinyos/misc/tos-build-deluge-image.in @@ -141,10 +141,11 @@ all = [] section = [] end_addr = None offset = 0 +addr_high = 0 for line in image.split(): #print "DEBUG:", line length = int(line[1:3], 16) - addr = int(line[3:7], 16) + offset + addr = int(line[3:7], 16) + offset + addr_high rectype = int(line[7:9], 16) data = [] if len(line) > 11: @@ -172,6 +173,8 @@ for line in image.split(): all.append((start_addr, section)) section = [] start_addr = addr + elif rectype == 0x04: + addr_high = int(line[9:9+4], 16) << 16 sys.stderr.write('Ihex read complete:\n') sys.stderr.write(' ' + '\n '.join(["%5d bytes starting at 0x%X" % (len(l), a) for (a, l) in all])) diff --git a/tos/lib/tosboot/TosBootP.nc b/tos/lib/tosboot/TosBootP.nc index ddaf0aee8d..12fac7c7e7 100644 --- a/tos/lib/tosboot/TosBootP.nc +++ b/tos/lib/tosboot/TosBootP.nc @@ -189,9 +189,29 @@ implementation { intAddr++; curAddr++; if ( --secLength == 0 ) { + while (TRUE) { intAddr = extFlashReadAddr(); secLength = extFlashReadAddr(); curAddr = curAddr + 8; +#if defined(PLATFORM_TELOSB) || defined (PLATFORM_EPIC) || defined (PLATFORM_TINYNODE) + if (FALSE) { + // TODO: check of valid flash address range needed +#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) + if (intAddr > FLASHEND) { + // ram, eeprom, fuses ... programming not supported +#elif defined(PLATFORM_MULLE) + if (FALSE) { + // TODO: check of valid flash address range needed +#else + #error "Target platform is not currently supported by Deluge T2" +#endif + curAddr += secLength; // skip block + call ExtFlash.stopRead(); + call ExtFlash.startRead(curAddr); + continue; + } + break; + } } newPageAddr = intAddr / TOSBOOT_INT_PAGE_SIZE;