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
  • If you change the foundations the code was written based on, then you need to modify the code to make it compatible.

    You don't have the code? Then that should be an indication that you are running in the wrong direction. Other people aren't stuck with this issue because they aren't fighting with wind mills.

    You have gotten a bad idea in your head. The idea will not be good because you invest more time on it. The idea _could_ have been better if you had owned the source code for the CRTL + the OS, allowing you to redesign the code for the changed use case.

    Yes, cars can have the engine back. But they are normally designed from the start to have the engine at the back.

    You don't take an Opel from the street and just move the engine to the back. You'll have lots of very interesting problems to solve. And you'll have lots of interesting paperwork to handle.

    Your current idea is like taking a three-story building and splitting it up and then reconnect the pieces again so the bottom floor is now on the top, and the top floor is on the bottom. Most other people would instead just move between the top and bottom apartments without trying to rip the building to pieces.

Reply
  • If you change the foundations the code was written based on, then you need to modify the code to make it compatible.

    You don't have the code? Then that should be an indication that you are running in the wrong direction. Other people aren't stuck with this issue because they aren't fighting with wind mills.

    You have gotten a bad idea in your head. The idea will not be good because you invest more time on it. The idea _could_ have been better if you had owned the source code for the CRTL + the OS, allowing you to redesign the code for the changed use case.

    Yes, cars can have the engine back. But they are normally designed from the start to have the engine at the back.

    You don't take an Opel from the street and just move the engine to the back. You'll have lots of very interesting problems to solve. And you'll have lots of interesting paperwork to handle.

    Your current idea is like taking a three-story building and splitting it up and then reconnect the pieces again so the bottom floor is now on the top, and the top floor is on the bottom. Most other people would instead just move between the top and bottom apartments without trying to rip the building to pieces.

Children
No data