Hi, I read a lot across the web but i couldn't solve my problem using my bootloader and my RTX application on at91sam7x256. So i try to simplify my projects and these was the results: simple bootloader which just a jump to a none RTX app works Fine but when i use bootloader witha an simple RTX application it get freeze in os_sys_init() function;
The simple bootloader
#define APPL_START_ADDR 0x00109D00 int main(){ void (*init_app)(void) = (void(*)(void))APPL_START_ADDR; //================================== // AT91F_WDTRestart(WatchdogCtrl); //Disable the Interrupts AT91C_BASE_AIC->AIC_IDCR = 0xFFFFFFFF; //Undo the Remap (Set iFlash to Boot Memory) AT91F_MC_Remap(); //Do a Reset that the Exception Vectors in the Application // are correctly written into RAM and the Remap is done correct pRSTC->RSTC_RCR = 0xA5000000 | AT91C_RSTC_EXTRST; /* Wait for hardware reset */ while (!(pRSTC->RSTC_RSR & AT91C_RSTC_NRSTL)); init_app(); }
Simple RTX App
#include <AT91SAM7X256.H> #include "rtl.h" __task void init (void); __task void task1 (void); OS_TID task1ID; int main(){ int i = 0; os_sys_init(init);//Application hang, inside this function while(1){ i++; } } __task void init (void){ task1ID = os_tsk_create(task1,1); os_tsk_delete_self(); } __task void task1 (void){ int i = 0; while (1){//infinite loop i++; } }
Bootloader Target Configuration: _________Start__|___Size_____ IROM1: 0x100000 | 0x9D00 IRAM1: 0x200058 | 0xFFA8 RTX App Target Configuration: _________Start__|___Size_____ IROM1: 0x109D00 | 0x36300 IRAM1: 0x200040 | 0xFFC0
Any idea? It is really frustrating not getting the expected behavior. Please Help!
I have enabled interrupts but that didn't work.
After making a step by step inside os_sys_init assembly, I noticed that the PC goes to address 0x00100044 and throgh the bootloader MAP file it was the address of SWI_handler of bootloader!
RESET 0x00100000 Section 332 sam7.o(RESET) Undef_Handler 0x00100040 ARM Code 4 sam7.o(RESET) SWI_Handler 0x00100044 ARM Code 4 sam7.o(RESET) //<-- program counter stop here PAbt_Handler 0x00100048 ARM Code 4 sam7.o(RESET) DAbt_Handler 0x0010004c ARM Code 4 sam7.o(RESET) IRQ_Handler 0x00100050 ARM Code 4 sam7.o(RESET) FIQ_Handler 0x00100054 ARM Code 4 sam7.o(RESET) !!!main 0x0010014c Section 8 __main.o(!!!main) !!!scatter 0x00100154 Section 60
That was my mistake so i have added AT91F_MC_Remap(); the beginning of RTX application now it goes trough the correct vector from RTX application New Problem: Now going step by step inside os_sys_init assembly shows that it do lots of initialization process like : os_sys_init0, os_sys_init1, _init_box, os_init_context, swi_handler, os_init_stack, OS_TINIT(), os_init_robin, os_sys_run, os_tsk,create0, __SWI1, os_init_context, os_init_stack, os_dispatch, os_put_rdy_first but this return from os_put_rdy_first to os_dispatch and finaly it hang inside os_dispatch: and generates a Dabt exeption and goes to
0x00109D48 EAFFFFFE B DAbt_Handler(0x00109D48)
and AS i am posting here asking for helpÙˆ i tried to check stack size of tasks and "I have found it!" stack size was to low! just 20 bytes!? change it to 200 and it works