[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/Deluge/TOSBoot Makefile, 1.2, 1.3 TOSBoot.nc, 1.2, 1.3 TOSBootM.nc, 1.3, 1.4 TOSBootProgFlashM.nc, 1.2, NONE TOSBootSTM25PC.nc, 1.2, NONE TOSBootSTM25PM.nc, 1.3, NONE

Jonathan Hui jwhui at users.sourceforge.net
Thu Apr 21 10:31:43 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/TOSBoot
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9078

Modified Files:
	Makefile TOSBoot.nc TOSBootM.nc 
Removed Files:
	TOSBootProgFlashM.nc TOSBootSTM25PC.nc TOSBootSTM25PM.nc 
Log Message:
- Cleaned up bootloader for msp430. Reduces code size by more than
half and now sits at under 2K of code.



Index: Makefile
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/TOSBoot/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Makefile	4 Dec 2004 07:22:48 -0000	1.2
--- Makefile	21 Apr 2005 17:31:40 -0000	1.3
***************
*** 6,9 ****
--- 6,11 ----
  -I%T/../beta/Deluge/Deluge \
  -I%T/../beta/Deluge/Deluge/TOSBoot \
+ -Imsp430 \
+ -Istm25p \
  -DBOOTLOADER_START=0x4000
  

Index: TOSBoot.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/TOSBoot/TOSBoot.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TOSBoot.nc	26 Nov 2004 18:59:10 -0000	1.2
--- TOSBoot.nc	21 Apr 2005 17:31:40 -0000	1.3
***************
*** 40,53 ****
    components
      TOSBootM,
-     HPLInitC,
      InternalFlashC as IntFlash,
      LedsC,
!     TOSBootProgFlashM as ProgFlash,
!     TOSBootSTM25PC as ExtFlash;
  
    TOSBootM.SubControl -> ExtFlash.StdControl;
  
    TOSBootM.ExtFlash -> ExtFlash;
-   TOSBootM.HardwareInit -> HPLInitC;
    TOSBootM.IntFlash -> IntFlash;
    TOSBootM.Leds -> LedsC;
--- 40,51 ----
    components
      TOSBootM,
      InternalFlashC as IntFlash,
      LedsC,
!     ProgFlashM as ProgFlash,
!     STM25PC as ExtFlash;
  
    TOSBootM.SubControl -> ExtFlash.StdControl;
  
    TOSBootM.ExtFlash -> ExtFlash;
    TOSBootM.IntFlash -> IntFlash;
    TOSBootM.Leds -> LedsC;

Index: TOSBootM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/TOSBoot/TOSBootM.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TOSBootM.nc	4 Dec 2004 07:22:48 -0000	1.3
--- TOSBootM.nc	21 Apr 2005 17:31:40 -0000	1.4
***************
*** 28,32 ****
  module TOSBootM {
    uses {
-     command result_t HardwareInit();
      interface InternalFlash as IntFlash;
      interface Leds;
--- 28,31 ----
***************
*** 38,41 ****
--- 37,44 ----
  implementation {
  
+   void wait(uint16_t t) {
+     TOSH_uwait(t);
+   }
+ 
    void startupLeds() {
  
***************
*** 48,54 ****
        for (j = 1024; j > 0; j -= 4) {
  	call Leds.set(output);
! 	TOSH_uwait(j);
  	call Leds.set(output >> 0x1);
! 	TOSH_uwait(1024-j);
        }
        output >>= 0x1;
--- 51,57 ----
        for (j = 1024; j > 0; j -= 4) {
  	call Leds.set(output);
! 	wait(j);
  	call Leds.set(output >> 0x1);
! 	wait(1024-j);
        }
        output >>= 0x1;
***************
*** 62,79 ****
      uint8_t i, j;
  
!     for ( i = 0; i < 3; i++ ) {
        call Leds.set(output);
        for ( j = 0; j < 4; j++ )
! 	TOSH_uwait(0x7fff);
!       call Leds.set(0x0);
!       for ( j = 0; j < 4; j++ )
! 	TOSH_uwait(0x7fff);
      }
  
    }
  
!   result_t programBuf(uint32_t addr, uint8_t* buf, uint16_t len) {
!     call ProgFlash.write(addr, buf, len);
!     return SUCCESS;
    }
  
--- 65,82 ----
      uint8_t i, j;
  
!     for ( i = 0; i < 6; i++, output = ~output ) {
        call Leds.set(output);
        for ( j = 0; j < 4; j++ )
! 	wait(0x7fff);
      }
  
    }
  
!   uint32_t extFlashRead32() {
!     uint32_t result = 0;
!     uint8_t i;
!     for ( i = 0; i < 4; i++ )
!       result |= ((uint32_t)call ExtFlash.readByte() & 0xff) << (i*8);    
!     return result;
    }
  
***************
*** 81,125 ****
  
      uint8_t  buf[TOSBOOT_INT_PAGE_SIZE];
!     uint32_t pageAddr;
      uint32_t intAddr;
      uint32_t secLength;
-     uint16_t i;
  
      call ExtFlash.startRead(startAddr);
  
!     intAddr = 0;
!     for ( i = 0; i < 4; i++ )
!       intAddr |= ((uint32_t)call ExtFlash.readByte() & 0xff) << (i*8);
  
!     secLength = 0;
!     for ( i = 0; i < 4; i++ )
!       secLength |= ((uint32_t)call ExtFlash.readByte() & 0xff) << (i*8);   
  
!     while (secLength > 0) {
!       for ( i = 0; i < secLength; i++, intAddr++) {
! 	if (i != 0 && intAddr % TOSBOOT_INT_PAGE_SIZE == 0) {
! 	  pageAddr = (intAddr / TOSBOOT_INT_PAGE_SIZE) - ((uint32_t) 1);
! 	  call Leds.set(pageAddr);
! 	  if (programBuf(pageAddr * TOSBOOT_INT_PAGE_SIZE, buf, TOSBOOT_INT_PAGE_SIZE) == FAIL)
! 	    return FAIL;
! 	}
  
! 	buf[intAddr % TOSBOOT_INT_PAGE_SIZE] = call ExtFlash.readByte();
!       }
  
!       pageAddr = intAddr / TOSBOOT_INT_PAGE_SIZE;
!       if (intAddr % TOSBOOT_INT_PAGE_SIZE == 0)
! 	pageAddr--;
!       
!       if (programBuf(pageAddr * TOSBOOT_INT_PAGE_SIZE, buf, TOSBOOT_INT_PAGE_SIZE) == FAIL)
! 	return FAIL;
  
!       intAddr = 0;
!       for ( i = 0; i < 4; i++ )
! 	intAddr |= ((uint32_t)call ExtFlash.readByte() & 0xff) << (i*8);
  
!       secLength = 0;
!       for ( i = 0; i < 4; i++ )
! 	secLength |= ((uint32_t)call ExtFlash.readByte() & 0xff) << (i*8);
  
      }
--- 84,123 ----
  
      uint8_t  buf[TOSBOOT_INT_PAGE_SIZE];
!     uint32_t pageAddr, newPageAddr;
      uint32_t intAddr;
      uint32_t secLength;
  
      call ExtFlash.startRead(startAddr);
  
!     intAddr = extFlashRead32();
!     secLength = extFlashRead32();
  
!     while ( secLength ) {
!       
!       pageAddr = newPageAddr = intAddr / TOSBOOT_INT_PAGE_SIZE;
  
!       // fill in ram buffer for internal program flash sector
!       do {
  
! 	// check if secLength is all ones
! 	if (!(secLength+1))
! 	  return FAIL;
  
! 	buf[intAddr++ % TOSBOOT_INT_PAGE_SIZE] = call ExtFlash.readByte();
! 	newPageAddr = intAddr / TOSBOOT_INT_PAGE_SIZE;
! 	
! 	if ( --secLength == 0 ) {
! 	  intAddr = extFlashRead32();
! 	  secLength = extFlashRead32();
! 	}
  
!       } while ( pageAddr == newPageAddr && secLength );
!       
!       call Leds.set(pageAddr);
  
!       // write out page
!       if (call ProgFlash.write(pageAddr*TOSBOOT_INT_PAGE_SIZE, buf,
! 			       TOSBOOT_INT_PAGE_SIZE) == FAIL)
! 	return FAIL;
  
      }
***************
*** 144,148 ****
  
      uint32_t newImgAddr;
-     uint8_t  loadImg;
      uint8_t  gestureCount;
      uint8_t  oneByte;
--- 142,145 ----
***************
*** 159,164 ****
      call IntFlash.read((uint8_t*)TOSBOOT_FLAGS_ADDR, &flags, sizeof(flags));
  
-     call IntFlash.read((uint8_t*)TOSBOOT_LOAD_IMG_ADDR, &loadImg, sizeof(loadImg));
- 
      if (gestureCount >= TOSBOOT_GESTURE_MAX_COUNT
  	&& !(flags & TOSBOOT_GOLDEN_IMG_LOADED)) {
--- 156,159 ----
***************
*** 174,181 ****
  	reboot();
        
-       // update current image start address
-       addr = TOSBOOT_GOLDEN_IMG_ADDR;
-       call IntFlash.write((uint8_t*)TOSBOOT_CUR_IMG_START_ADDR, &addr, sizeof(addr));
- 
        // clear gesture counter
        gestureCount = 0xff;
--- 169,172 ----
***************
*** 185,199 ****
      call IntFlash.write((uint8_t*)TOSBOOT_GESTURE_COUNT_ADDR, &gestureCount, sizeof(gestureCount));
      
!     if (loadImg != 0xff) {
        // get address of new program
        call IntFlash.read((uint8_t*)TOSBOOT_NEW_IMG_START_ADDR, &newImgAddr, sizeof(newImgAddr));
! 
        if (programImage(newImgAddr) == FAIL)
  	reboot();
        
        // update current image start address
!       call IntFlash.write((uint8_t*)TOSBOOT_CUR_IMG_START_ADDR, &newImgAddr, sizeof(newImgAddr));
!       oneByte = 0xff;
!       call IntFlash.write((uint8_t*)TOSBOOT_LOAD_IMG_ADDR, &oneByte, sizeof(oneByte));
      }
  
--- 176,189 ----
      call IntFlash.write((uint8_t*)TOSBOOT_GESTURE_COUNT_ADDR, &gestureCount, sizeof(gestureCount));
      
!     if (!(flags & TOSBOOT_REPROGRAM)) {
        // get address of new program
        call IntFlash.read((uint8_t*)TOSBOOT_NEW_IMG_START_ADDR, &newImgAddr, sizeof(newImgAddr));
!       
        if (programImage(newImgAddr) == FAIL)
  	reboot();
        
        // update current image start address
!       flags |= TOSBOOT_REPROGRAM;
!       call IntFlash.write((uint8_t*)TOSBOOT_FLAGS_ADDR, &flags, sizeof(flags));
      }
  
***************
*** 213,230 ****
      __nesc_disable_interrupt();
  
!     TOSH_SET_PIN_DIRECTIONS();
  
!     TOSH_MAKE_UCLK0_OUTPUT();
!     TOSH_MAKE_SIMO0_OUTPUT();
!     TOSH_MAKE_SOMI0_INPUT();
!     BCSCTL1 = RSEL0 + RSEL1 + RSEL2;
!     DCOCTL = DCO0 + DCO1 + DCO2;
!     
!     call SubControl.init();
!     call SubControl.start();
!     
!     call Leds.init();
!     
!     startupSequence();
  
      return 0;
--- 203,221 ----
      __nesc_disable_interrupt();
  
!     atomic {
!       
!       TOSH_SET_PIN_DIRECTIONS();
!       
!       BCSCTL1 = RSEL0 + RSEL1 + RSEL2;
!       DCOCTL = DCO0 + DCO1 + DCO2;
!       
!       call SubControl.init();
!       call SubControl.start();
!       
!       call Leds.init();
!       
!       startupSequence();
  
!     }
  
      return 0;

--- TOSBootProgFlashM.nc DELETED ---

--- TOSBootSTM25PC.nc DELETED ---

--- TOSBootSTM25PM.nc DELETED ---



More information about the Tinyos-beta-commits mailing list