This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

modifying the reset handler asm code

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.

Parents
  • I am clocking the controller to 100MHz, which may be quite enough for my application.
    Dont have to run LCD on the board currently (not in this version of the product atleast. a dedicated controller handles the LCD display and touch screen).
    Hence, i think that the other peripherals will operate smoothly.

    I may not go on with porting uCLinux right now. Linux is a total NO NO for the project.
    But ya, that becomes my hobby project.

    Also want to learn uCLinux structure and try to implement some good features of linux on RTOS, which is what i am trying to achieve (hence the whole discussion).

Reply
  • I am clocking the controller to 100MHz, which may be quite enough for my application.
    Dont have to run LCD on the board currently (not in this version of the product atleast. a dedicated controller handles the LCD display and touch screen).
    Hence, i think that the other peripherals will operate smoothly.

    I may not go on with porting uCLinux right now. Linux is a total NO NO for the project.
    But ya, that becomes my hobby project.

    Also want to learn uCLinux structure and try to implement some good features of linux on RTOS, which is what i am trying to achieve (hence the whole discussion).

Children
  • I am thinking of initializing os_sys_init from main() and initializing all the tasks from the master task.
    Then call 'app_entry()' at the end of main(). Create a *.lib file and add the *.lib in the projects that my colleagues can use.

    They can now add the *.lib files and start building the code from the app_entry() function which they can define in their projects. So instead of starting from main() the entry point will be app_entry().