[En-Nut-Discussion] ASM Branch

Janusz U. nopsoft at poczta.onet.pl
Fri Nov 17 17:39:32 CET 2006

my soft-reset solution for AT91SAM7S256:

#define WITH_SAMBA   0
 #define RESET_ADDR  "0x00108000"
 #define RESET_ADDR  "0x00100000"

void kReset() {
 kprintf("Reset demand!\n");
 vPortEnterCritical();  // halt the OS
 AT91F_WDTSetMode(AT91C_BASE_WDTC, AT91C_WDTC_WDDIS); // disable watchdog
 AT91C_BASE_AIC->AIC_IDCR = 0xffffffff;     // mask all interrupts
 asm volatile (
  // remap again
  "LDR R1, .MC_BASE \n\t"
  "MOV R2, #1   \n\t"
  "STR R2, [R1]  \n\t"

  // go to Reset vector
  "BIC R0, R0   \n\t"
  "LDR R0, .STARTUP \n\t" // optional but I can't reload the SAM-BA now, 
with my program sometimes crashed with free heap kernel panic
  "BX  R0    \n\t" // Thumb to ARM mode

  ".align 2    \n\t"
  ".STARTUP:    \n\t"
  ".word "RESET_ADDR"  \n\t"
  ".MC_BASE:    \n\t"
  ".word 0xFFFFFF00  \n\t"
 AT91F_WDTRestart(AT91C_BASE_WDTC);      // restart watchdog
 AT91F_WDTSetMode(AT91C_BASE_WDTC, AT91C_WDTC_WDRSTEN); // enable watchdog
 while (1);     // halt until reset

best regards
Janusz U.

More information about the En-Nut-Discussion mailing list