[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/imote2/tools/src/bootloader/src
FlashAccess.c, 1.1, 1.2 main.c, 1.1, 1.2
Robbie Adler
radler at users.sourceforge.net
Fri May 4 13:36:20 PDT 2007
Update of /cvsroot/tinyos/tinyos-1.x/contrib/imote2/tools/src/bootloader/src
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2844/src
Modified Files:
FlashAccess.c main.c
Log Message:
fix for iMote2 bootloader....the bootloader will now write protect itself into the FLASH so that subsequent OS-level ops can't overwrite it
Index: FlashAccess.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/imote2/tools/src/bootloader/src/FlashAccess.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** FlashAccess.c 10 Oct 2006 22:34:06 -0000 1.1
--- FlashAccess.c 4 May 2007 20:36:18 -0000 1.2
***************
*** 78,81 ****
--- 78,82 ----
.equ FLASH_LOCKCONF,(0x0001); \
.equ FLASH_UNLOCKCONF,(0x00D0); \
+ .equ FLASH_LOCKDOWNCONF,(0x002F); \
.equ FLASH_ERASECONF,(0x00D0); \
.equ FLASH_OP_NOT_SUPPORTED,(0x10);");
***************
*** 426,429 ****
--- 427,469 ----
/**
+ * Flash_Lockdown
+ *
+ * The function performs all the steps required to
+ * lock down a flash block. The commands and steps are defined
+ * in the memory subsystem data sheet for the processor.
+ * The Block address has to be passed as a parameter to the
+ * function.
+ *
+ * @param addr Address of the block that has to be locked.
+ *
+ * @return status The status register value.
+ */
+ uint16_t Flash_Lockdown(uint32_t addr)
+ {
+ addr = (addr / FLASH_BLOCK_SIZE) * FLASH_BLOCK_SIZE;
+
+ asm volatile(
+ "ldr r1,=FLASH_DLOCKBLOCK; \
+ ldr r2,=FLASH_READARRAY; \
+ ldr r3,=FLASH_LOCKDOWNCONF; \
+ ldr r4,=FLASH_CLEARSTATUS; \
+ b _goUnlockCacheLine1; \
+ .align 5; \
+ _goUnlockCacheLine1: \
+ strh r4,[%0]; \
+ strh r1,[%0]; \
+ strh r3,[%0]; \
+ strh r2,[%0]; \
+ ldrh r2,[%0]; \
+ nop; \
+ nop; \
+ nop;"
+ :/*no output info*/
+ :"r"(addr)
+ : "r1", "r2", "r3", "r4", "memory");
+ return SUCCESS;
+ }
+
+ /**
* Program_Buffer
*
Index: main.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/imote2/tools/src/bootloader/src/main.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** main.c 10 Oct 2006 22:34:06 -0000 1.1
--- main.c 4 May 2007 20:36:18 -0000 1.2
***************
*** 182,185 ****
--- 182,191 ----
TOSH_SET_YELLOW_LED_PIN ();
TOSH_SET_RED_LED_PIN ();
+ /*Lock down attribute tables*/
+ Flash_Lockdown(BL_ATTR_ADDRESS_TABLE);
+ Flash_Lockdown(BL_ATTR_DEF_BOOTLOADER);
+ Flash_Lockdown(BL_ATTR_BOOTLOADER);
+ /*Lock down the bootloader location*/
+ Flash_Lockdown(0x200000);
handle_jump ();
}
***************
*** 308,311 ****
--- 314,321 ----
uint32_t selftest = 0;
+ HPLInit ();
+ Leds_Init ();
+ FlashAccess_Init();
+
/* FIXME this should be done at the start of the reset
* vector. We dont have to reach till here.
***************
*** 314,320 ****
Check_OS_Validity_And_Jump ();
- HPLInit ();
- Leds_Init ();
- FlashAccess_Init();
/*Check if we have to recover from any crash.*/
--- 324,327 ----
More information about the Tinyos-contrib-commits
mailing list