[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/Deluge/TOSBoot/stm25p STM25PM.nc, 1.1, 1.2

Jonathan Hui jwhui at users.sourceforge.net
Tue May 17 13:48:26 PDT 2005


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

Modified Files:
	STM25PM.nc 
Log Message:
- Now verifies the image by checking CRCs across the image before
reprogramming. Was badly needed, since earlier versions did not check
whether the binary was valid.

- Since there is no hardware protection for the bootloader section on
the msp430, software checks help ensure that the bootloader is not
overwritten.

- Handles errors better:
1) If an image is inavlid, don't reprogram.
2) If an image started to program but fails in the middle, try
   reprogramming again. If reprogramming still fails after three
   times, try reprogramming with golden image.
3) If golden image is invalid, don't reprogram.
4) If golden image started to program but fails in the middle, try
   reprogramming again.

- Additional improvements in code size means the added functionality
is implemented in the same code size (just under 2K).



Index: STM25PM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/TOSBoot/stm25p/STM25PM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** STM25PM.nc	21 Apr 2005 17:31:41 -0000	1.1
--- STM25PM.nc	17 May 2005 20:48:24 -0000	1.2
***************
*** 45,50 ****
      TOSH_MAKE_FLASH_CS_OUTPUT();
      call USARTControl.setModeSPI();
-     call USARTControl.disableRxIntr();
-     call USARTControl.disableTxIntr();
      return SUCCESS;
    }
--- 45,48 ----
***************
*** 63,67 ****
  
      TOSH_SET_FLASH_CS_PIN();
-     TOSH_CLR_FLASH_HOLD_PIN();    
  
      call USARTControl.disableSPI();
--- 61,64 ----
***************
*** 78,127 ****
      TOSH_SET_FLASH_HOLD_PIN();
  
!     // command byte
!     call USARTControl.tx(0xab);
!     while(!(call USARTControl.isTxIntrPending()));
!     
!     // dummy bytes
!     for ( i = 0; i < 3; i++ ) {
!       call USARTControl.tx(0);
        while(!(call USARTControl.isTxIntrPending()));
      }
      
-     // signature
-     call USARTControl.rx(); // clear receive interrupt
-     call USARTControl.tx(0);
-     while(!(call USARTControl.isRxIntrPending()));
-     call USARTControl.rx(); // read signature
- 
      TOSH_SET_FLASH_CS_PIN();
-     TOSH_CLR_FLASH_HOLD_PIN();
  
    }
  
!   command result_t TOSBootExtFlash.startRead(uint32_t addr) {
  
      uint8_t i;
! 
      powerOnFlash();
! 
      TOSH_CLR_FLASH_CS_PIN();
!     TOSH_SET_FLASH_HOLD_PIN();
! 
!     // command
!     call USARTControl.tx(0x3);
!     while(!(call USARTControl.isTxIntrPending()));
  
      // address
!     for ( i = 3; i > 0; i-- ) {
        call USARTControl.tx((addr >> (i-1)*8) & 0xff);
        while(!(call USARTControl.isTxIntrPending()));
      }    
-     call USARTControl.rx(); // clear receive interrupt
- 
-     return SUCCESS;
  
    }
  
    command uint8_t TOSBootExtFlash.readByte() {
      call USARTControl.tx(0);
      while(!(call USARTControl.isRxIntrPending()));
--- 75,109 ----
      TOSH_SET_FLASH_HOLD_PIN();
  
!     // command byte + 3 dummy bytes + signature
!     for ( i = 0; i < 5; i++ ) {
!       call USARTControl.tx(0xab);
        while(!(call USARTControl.isTxIntrPending()));
      }
      
      TOSH_SET_FLASH_CS_PIN();
  
    }
  
!   command void TOSBootExtFlash.startRead(uint32_t addr) {
  
      uint8_t i;
!     
      powerOnFlash();
!     
      TOSH_CLR_FLASH_CS_PIN();
!     
!     // add command byte to address
!     addr |= (uint32_t)0x3 << 24;
  
      // address
!     for ( i = 4; i > 0; i-- ) {
        call USARTControl.tx((addr >> (i-1)*8) & 0xff);
        while(!(call USARTControl.isTxIntrPending()));
      }    
  
    }
  
    command uint8_t TOSBootExtFlash.readByte() {
+     call USARTControl.rx();
      call USARTControl.tx(0);
      while(!(call USARTControl.isRxIntrPending()));
***************
*** 129,140 ****
    }
  
!   command result_t TOSBootExtFlash.stopRead() {
! 
      TOSH_SET_FLASH_CS_PIN();
- 
-     return SUCCESS;
- 
    }
  
  }
- 
--- 111,117 ----
    }
  
!   command void TOSBootExtFlash.stopRead() {
      TOSH_SET_FLASH_CS_PIN();
    }
  
  }



More information about the Tinyos-beta-commits mailing list