[Tinyos-beta-commits] CVS: tinyos-1.x/beta/platform/imote2
binarymover.s, 1.2, 1.3 flash.s, 1.1, 1.2 FlashM.nc, 1.7, 1.8
Josh
jsherbach at users.sourceforge.net
Fri Sep 2 09:02:03 PDT 2005
Update of /cvsroot/tinyos/tinyos-1.x/beta/platform/imote2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15743
Modified Files:
binarymover.s flash.s FlashM.nc
Log Message:
fin
Index: binarymover.s
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/imote2/binarymover.s,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** binarymover.s 1 Sep 2005 18:12:28 -0000 1.2
--- binarymover.s 2 Sep 2005 16:02:01 -0000 1.3
***************
*** 28,33 ****
__Binary_Mover:
! .func __Binary_Mover @r0 = addr
! @r1 = size
ldr r5,=ARM_CPSR_INT_MASK @Store int mask value
--- 28,33 ----
__Binary_Mover:
! .func __Binary_Mover @r1 = addr
! @r2 = size
ldr r5,=ARM_CPSR_INT_MASK @Store int mask value
***************
*** 54,58 ****
ldr r4,=0x0 @Counter
! cmp r4,r1
beq __Binary_Mover_end @If imagesize is 0 then skip a bunch of stuff
--- 54,58 ----
ldr r4,=0x0 @Counter
! cmp r4,r2
beq __Binary_Mover_end @If imagesize is 0 then skip a bunch of stuff
***************
*** 109,113 ****
__Binary_Mover_Erase_loop_end:
! cmp r4,r1
blo __Binary_Mover_Erase_loop @Repeat
--- 109,113 ----
__Binary_Mover_Erase_loop_end:
! cmp r4,r2
blo __Binary_Mover_Erase_loop @Repeat
***************
*** 118,122 ****
ldr r4,=0x0 @Reset counter for writing
__Binary_Mover_Write_loop:
! ldrh r6,[r0, r4] @Get data
ldr r5,=FLASH_CLEARSTATUS @Write word start
--- 118,122 ----
ldr r4,=0x0 @Reset counter for writing
__Binary_Mover_Write_loop:
! ldrh r6,[r1, r4] @Get data
ldr r5,=FLASH_CLEARSTATUS @Write word start
***************
*** 135,142 ****
add r4,r4,#0x2 @Increment Counter
! cmp r4,r1
blo __Binary_Mover_Write_loop @Repeat
__Binary_Mover_end:
ldr r5,=0x40000000
add r5,r5,#0xa00000
--- 135,147 ----
add r4,r4,#0x2 @Increment Counter
! cmp r4,r2
blo __Binary_Mover_Write_loop @Repeat
__Binary_Mover_end:
+ ldr r6,=0x1 @switching to 0 LEDs
+ mov r6,r6,LSL #9
+ str r6,[r9] @Turn off 1 LED
+
+
ldr r5,=0x40000000
add r5,r5,#0xa00000
***************
*** 148,153 ****
add r4,r5,#0x4 @r4 contains 0x40a0 0010 OSCR0
ldr r6,[r4]
! add r6,r6,#0x1000
! str r6,[r5] @osmr3 = oscr0 + 0x1000
__Binary_Mover_spin:
b __Binary_Mover_spin @spin until watchdog timer resets this
--- 153,158 ----
add r4,r5,#0x4 @r4 contains 0x40a0 0010 OSCR0
ldr r6,[r4]
! add r6,r6,#0x10000
! str r6,[r5] @osmr3 = oscr0 + 0x10000
__Binary_Mover_spin:
b __Binary_Mover_spin @spin until watchdog timer resets this
Index: flash.s
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/imote2/flash.s,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** flash.s 25 Aug 2005 22:31:20 -0000 1.1
--- flash.s 2 Sep 2005 16:02:01 -0000 1.2
***************
*** 27,30 ****
--- 27,34 ----
.global __Flash_Program_Word
.global __Flash_Program_Buffer
+ .global __Flash_Erase_true_end
+ .global __Flash_Program_Word_true_end
+ .global __Flash_Program_Buffer_true_end
+
__Flash_Erase:
***************
*** 49,52 ****
--- 53,58 ----
ldrh r5,[r1]
LDMFD R13!, {R4 - R5, PC}
+ __Flash_Erase_true_end:
+ nop;
.endfunc
***************
*** 72,75 ****
--- 78,83 ----
ldrh r5,[r1]
LDMFD R13!, {R4 - R5, PC}
+ __Flash_Program_Word_true_end:
+ nop;
.endfunc
***************
*** 115,117 ****
--- 123,127 ----
ldrh r5,[r1]
LDMFD R13!, {R1 - R12, PC}
+ __Flash_Program_Buffer_true_end:
+ nop;
.endfunc
Index: FlashM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/imote2/FlashM.nc,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** FlashM.nc 1 Sep 2005 18:16:06 -0000 1.7
--- FlashM.nc 2 Sep 2005 16:02:01 -0000 1.8
***************
*** 13,19 ****
uint16_t unlock(uint32_t addr);
uint16_t lock(uint32_t addr);
- uint16_t getSR(uint32_t addr);
uint16_t eraseFlash(uint32_t addr);
- uint32_t CFIQuery();
uint16_t programWord(uint32_t addr, uint16_t data);
uint16_t programBuffer(uint32_t addr, uint16_t data[], uint8_t datalen);
--- 13,17 ----
***************
*** 28,31 ****
--- 26,32 ----
extern void __Flash_Program_Word() __attribute__ ((C,spontaneous));
extern void __Flash_Program_Buffer() __attribute__ ((C,spontaneous));
+ extern uint32_t __Flash_Erase_true_end __attribute__ ((C));
+ extern uint32_t __Flash_Program_Word_true_end __attribute__ ((C));
+ extern uint32_t __Flash_Program_Buffer_true_end __attribute__ ((C));
command result_t StdControl.init() {
***************
*** 148,191 ****
i++)
FlashPartitionState[i] = FLASH_STATE_PROGRAM;
!
! for(blocklen = 0, i = blockAddr;
! i < addr + numBytes;
! i += FLASH_BLOCK_SIZE, blocklen++)
! unlock(i);
!
! if(programBufferSupported == 2){
! uint16_t testBuf[1];
! if(addr % 2 == 0){
! testBuf[0] = data[0] | ((*((uint8_t *)(addr + 1))) << 8);
! status = programBuffer(addr, testBuf, 1);
}
- else{
- testBuf[0] = *((uint8_t *)(addr - 1)) | (data[0] << 8);
- status = programBuffer(addr - 1, testBuf, 1);
- }
- if(status == FLASH_NOT_SUPPORTED)
- programBufferSupported = 0;
- else
- programBufferSupported = 1;
- programBufferSupported = 0;
- }
! if(blocklen == 1)
! writeHelper(addr,data,numBytes,0xFF,0xFF);
! else{
! uint32_t bytesLeft = numBytes;
! writeHelper(addr,data, blockAddr + FLASH_BLOCK_SIZE - addr,0xFF,0xFF);
! bytesLeft = numBytes - (FLASH_BLOCK_SIZE - (addr - blockAddr));
! for(i = 1; i < blocklen - 1; i++){
writeHelper(blockAddr + i * FLASH_BLOCK_SIZE,
! (uint8_t *)(data + numBytes - bytesLeft),
! FLASH_BLOCK_SIZE,0xFF,0xFF);
! bytesLeft -= FLASH_BLOCK_SIZE;
}
- writeHelper(blockAddr + i * FLASH_BLOCK_SIZE,
- data + (numBytes - bytesLeft), bytesLeft, 0xFF,0xFF);
}
-
for(i = addr / FLASH_PARTITION_SIZE;
i < (numBytes + addr) / FLASH_PARTITION_SIZE;
--- 149,192 ----
i++)
FlashPartitionState[i] = FLASH_STATE_PROGRAM;
! atomic{
! for(blocklen = 0, i = blockAddr;
! i < addr + numBytes;
! i += FLASH_BLOCK_SIZE, blocklen++)
! unlock(i);
! if(programBufferSupported == 2){
! uint16_t testBuf[1];
!
! if(addr % 2 == 0){
! testBuf[0] = data[0] | ((*((uint8_t *)(addr + 1))) << 8);
! status = programBuffer(addr, testBuf, 1);
! }
! else{
! testBuf[0] = *((uint8_t *)(addr - 1)) | (data[0] << 8);
! status = programBuffer(addr - 1, testBuf, 1);
! }
! if(status == FLASH_NOT_SUPPORTED)
! programBufferSupported = 0;
! else
! programBufferSupported = 1;
! // programBufferSupported = 0;
}
! if(blocklen == 1)
! writeHelper(addr,data,numBytes,0xFF,0xFF);
! else{
! uint32_t bytesLeft = numBytes;
! writeHelper(addr,data, blockAddr + FLASH_BLOCK_SIZE - addr,0xFF,0xFF);
! bytesLeft = numBytes - (FLASH_BLOCK_SIZE - (addr - blockAddr));
! for(i = 1; i < blocklen - 1; i++){
! writeHelper(blockAddr + i * FLASH_BLOCK_SIZE,
! (uint8_t *)(data + numBytes - bytesLeft),
! FLASH_BLOCK_SIZE,0xFF,0xFF);
! bytesLeft -= FLASH_BLOCK_SIZE;
! }
writeHelper(blockAddr + i * FLASH_BLOCK_SIZE,
! data + (numBytes - bytesLeft), bytesLeft, 0xFF,0xFF);
}
}
for(i = addr / FLASH_PARTITION_SIZE;
i < (numBytes + addr) / FLASH_PARTITION_SIZE;
***************
*** 198,201 ****
--- 199,203 ----
command result_t Flash.erase(uint32_t addr){
uint16_t status, i;
+ uint32_t j;
if(addr > 0x02000000) //not in the flash memory space
***************
*** 217,230 ****
FlashPartitionState[addr / FLASH_PARTITION_SIZE] = FLASH_STATE_ERASE;
! for(i = 0; i < FLASH_BLOCK_SIZE; i++){
! uint32_t tempCheck = *(uint32_t *)(addr + i);
if(tempCheck != 0xFFFFFFFF)
break;
! if(i == FLASH_BLOCK_SIZE - 1)
return SUCCESS;
}
!
! unlock(addr);
! status = eraseFlash(addr);
FlashPartitionState[addr / FLASH_PARTITION_SIZE] = FLASH_STATE_READ_INACTIVE;
if(status != 0x80)
--- 219,233 ----
FlashPartitionState[addr / FLASH_PARTITION_SIZE] = FLASH_STATE_ERASE;
! for(j = 0; j < FLASH_BLOCK_SIZE; j++){
! uint32_t tempCheck = *(uint32_t *)(addr + j);
if(tempCheck != 0xFFFFFFFF)
break;
! if(j == FLASH_BLOCK_SIZE - 1)
return SUCCESS;
}
! atomic{
! unlock(addr);
! status = eraseFlash(addr);
! }
FlashPartitionState[addr / FLASH_PARTITION_SIZE] = FLASH_STATE_READ_INACTIVE;
if(status != 0x80)
***************
*** 233,269 ****
return SUCCESS;
}
!
! uint32_t CFIQuery() __attribute__((noinline)){
! uint32_t result, retval = 0;
! uint16_t query;
! uint8_t i;
!
! for(i = 0; i < 3; i++){
! query = i + 0x10;
! query = query << 1;
! asm volatile(
! "ldr r1,=FLASH_CFIQUERY; \
! ldr r2,=FLASH_READARRAY; \
! ldr r3,=0x0; \
! ldr r4,=FLASH_CLEARSTATUS; \
! b _goCFIQueryCacheLine; \
! .align 5; \
! _goCFIQueryCacheLine: \
! strh r4,[r3]; \
! strh r1,[r3]; \
! ldrh %0,[r3, %1]; \
! strh r2,[r3]; \
! ldrh r2,[r3]; \
! nop; \
! nop; \
! nop;"
! :"=r"(result)
! :"r"(query)
! : "r1", "r2", "r3", "r4", "memory");
! retval = ((result & 0xff) << (8 * i));
! }
! return retval;
! }
!
uint16_t unlock(uint32_t addr) __attribute__((noinline)){
//addr <<= 1;
--- 236,240 ----
return SUCCESS;
}
!
uint16_t unlock(uint32_t addr) __attribute__((noinline)){
//addr <<= 1;
***************
*** 318,322 ****
uint16_t programBuffer(uint32_t addr, uint16_t data[], uint8_t datalen) __attribute__((noinline)){
uint16_t status;
! uint32_t programBufferCommands[40];/* even though there are only 33 lines
* of assembly by my count it seems
* to work better if I allocate / allow
--- 289,293 ----
uint16_t programBuffer(uint32_t addr, uint16_t data[], uint8_t datalen) __attribute__((noinline)){
uint16_t status;
! /* uint32_t programBufferCommands[40];/* even though there are only 33 lines
* of assembly by my count it seems
* to work better if I allocate / allow
***************
*** 324,347 ****
* is an issue*/
! memcpy(programBufferCommands,__Flash_Program_Buffer,40 * 4);
datalen -= 1;
! atomic{
! asm volatile(
! "mov r1, %1; \
! mov r2, %2; \
! mov r3, %3; \
! mov r14, PC; \
! mov PC, %4; \
! mov %0, r0;"
! /*
! bl __Flash_Program_Buffer; \
! mov %0, r0;"
! */
! :"=r"(status)
! :"r"(addr), "r"(data),"r"(datalen),
! "r"(programBufferCommands)
! : "r0", "r1", "r2", "r3", "r14", "memory");
! }
return status;
}
--- 295,312 ----
* is an issue*/
! // memcpy(programBufferCommands,__Flash_Program_Buffer,40 * 4);
datalen -= 1;
! asm volatile("mov r1, %1; \
! mov r2, %2; \
! mov r3, %3; \
! bl __Flash_Program_Buffer; \
! mov %0, r0;"
! /*mov r14, PC; \
! mov PC, %4; \
! mov %0, r0;"*/
! :"=r"(status)
! :"r"(addr), "r"(data),"r"(datalen)//, "r"(programBufferCommands)
! : "r0", "r1", "r2", "r3", "r14", "memory");
return status;
}
***************
*** 349,366 ****
uint16_t programWord(uint32_t addr, uint16_t data) __attribute__((noinline)){
uint16_t status;
! uint32_t programWordCommands[16];
!
! memcpy(programWordCommands,__Flash_Program_Word,16 * 4);
! atomic{
! asm volatile(
! "mov r1, %1; \
! mov r2, %2; \
! mov r14, PC; \
! mov PC, %3; \
! mov %0, r0;"
! :"=r"(status)
! :"r"(addr), "r"(data),"r"(programWordCommands)
! : "r0", "r1", "r2", "memory");
! }
return status;
}
--- 314,338 ----
uint16_t programWord(uint32_t addr, uint16_t data) __attribute__((noinline)){
uint16_t status;
! /* uint32_t *binary, *temp;
! uint32_t binSize = (uint32_t)&__Flash_Program_Word_true_end;
! binSize -= (uint32_t)__Flash_Program_Word;
! binary = (uint32_t *)malloc(binSize + 4);
! temp = (uint32_t *)((uint32_t)binary + 4 - ((uint32_t)binary & 0x3));
! memcpy(temp,__Flash_Program_Word, binSize);*/
!
! asm volatile(
! "mov r1, %1; \
! mov r2, %2; \
! bl __Flash_Program_Word; \
! mov %0, r0;"
! /*
! mov r3, %3; \
! mov r14, PC; \
! mov PC, r3; \
! mov %0, r0;" */
! :"=r"(status)
! :"r"(addr), "r"(data)//,"r"(temp)
! : "r0", "r1", "r2", "r3", "memory");
! // free(binary);
return status;
}
***************
*** 368,408 ****
uint16_t eraseFlash(uint32_t addr) __attribute__((noinline)){
uint16_t status;
! uint32_t eraseFlashCommands[17];
!
! memcpy(eraseFlashCommands,__Flash_Erase,17 * 4);
! atomic{
! asm volatile(
! "mov r1, %1; \
! mov r14, PC; \
! mov PC, %2; \
! mov %0, r0;"
! :"=r"(status)
! :"r"(addr), "r"(eraseFlashCommands)
! : "r0", "r1", "memory");
! }
return status;
}
- uint16_t getSR(uint32_t addr) __attribute__((noinline)){
- uint16_t result;
- //addr <<= 1; cut?
- asm volatile(
- "ldr r1,=FLASH_READSTATUS; \
- ldr r2,=FLASH_READARRAY; \
- b _goRSRCacheLine; \
- .align 5; \
- _goRSRCacheLine: \
- strh r1,[%1]; \
- ldrh r3,[%1]; \
- strh r2,[%1]; \
- ldrh r2,[%1]; \
- mov %0, r3; \
- nop; \
- nop; \
- nop;"
- :"=r"(result)
- :"r"(addr)
- : "r1", "r2", "r3", "memory");
- return result;
- }
}
--- 340,365 ----
uint16_t eraseFlash(uint32_t addr) __attribute__((noinline)){
uint16_t status;
! /* uint32_t *binary, *temp;
! uint32_t binSize = (uint32_t)&__Flash_Erase_true_end;
! binSize -= (uint32_t)__Flash_Erase;
! binary = (uint32_t *)malloc(binSize + 4);
! temp = (uint32_t *)((uint32_t)binary + 4 - ((uint32_t)binary & 0x3));
! memcpy(temp,__Flash_Erase, binSize);*/
!
! asm volatile(
! "mov r1, %1; \
! bl __Flash_Erase; \
! mov %0, r0;"
! /*
! mov r2, %2; \
! mov r14, PC; \
! mov PC, r2; \
! mov %0, r0;"*/
! :"=r"(status)
! :"r"(addr)//, "r"(temp)
! : "r0", "r1", "r2", "memory");
! // free(binary);
return status;
}
}
More information about the Tinyos-beta-commits
mailing list