We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
question 1: This is the original reset handler that is in the startup file (*.s)
Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT __main LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP
which i modify to
Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT OSInit IMPORT __main LDR R0, =SystemInit BLX R0 LDR R0, =OSInit BLX R0 LDR R0, =__main BX R0 ENDP
Here the OSInit is a function. This works fine.
But when i modify the original to following, I get a hard fault.
Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT main IMPORT OSInit LDR R0, =SystemInit BLX R0 LDR R0, =main BLX R0 ;getting hardfault here LDR R0, =OSInit BX R0 ENDP
Irrespective of whether the OSInit is a function or a task, i get Hardfault.
question 2: does the '__' (two underscores) before 'main' have any significance. Because when i write __OSInit, the compiler is unable to locate OSInit function (Error L6218E: undefined symbol). but for '__main' the function name is always 'main' and compiler locates it.
OK.
__main function is an initialization file in the C runtime library. which means i cannot change __main to return back.
Can you tell me why you don't want to have main() perform the reset of the initialization?
if OSInit is a task, then too i get a hardfault. I want OSInit to be the master task, which initializes other tasks and then deletes itself.
I have nothing to do with main. Want to initialize the RTOS before main. (prior to your reply, was thinking of doing it after main.)
I am unable to call a task from the asm reset handler. it generates a hardfault error.
Also if i call function OSInit, from asm, and if i initialize the tasks in that function, the tasks never get executed. none of them. I dont understand, why the tasks are not initializing.
Why doesn't the car function as expected, if I put the engine in the back seat and have the passenger sitting under the hood?
Note that code normally is written based on a number of assumptions. You are breaking these assumptions when you try to do things differently.
Have you seen any example code where tasks are started before main()?
Another thing - you obviously can't do anything after main(), since main() is never intended to return.
@Dhaval Solanki,
This ain't gonna work, OK? You have to execute __main BEFORE you setup your kernel !