Search code examples
embeddedcontikicontiki-ng

Contiki-NG CC2538 rom_util_program_flash problem


I am writing a service of Contiki os, that is supposed to run on a CC2538. However, I encounter a problem that I am not aware of why happens. More specifically, I want to write to consecutive pages of flash a given array (my_arr). However, after the 20th iteration, the program stops and the board reboots. Do you know why this happens? I have also encountered a similar problem with the erase function.

int8_t* my_arr= (int8_t*)malloc(2048);

for(int i=0; i<2048; i++)
    my_arr[i] = i+1;


int8_t* init_addr = (int8_t*)0x222000;

for(int i=0;i<40;i++){

     rom_util_program_flash((uint32_t *)my_arr,
           (uint32_t)(init_addr +i*2048),
           2048);

           LOG_INFO("%d\n",i);
}

Solution

  • The reboots are caused by the watchdog.

    Try adding a watchdog_periodic() before each write to avoid the reboots.