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
  • And you won't manage to fulfill that wish if you don't know exactly how that car works.

    You obviously think you're smart by posting such a statement, but your extension to the comparison of the startup code to a complete car is just rediculous. There are many changes that can be made to a car without having to know exactly how that car works. An engine can be moved without, for example, knowing the intricacies of how the ECM works. I personally know mechanics who have done such tasks without knowing how the "black boxes" work and their results have been sweet.

    What IS important is understanding the intricasies of the area involved and the associated components that might be affected.

    Here, it is fairly clear to me that the OP has little real understaning of the C runtime startup sequence. If he learns about this he might find out what he can meaningfully do.

Reply
  • And you won't manage to fulfill that wish if you don't know exactly how that car works.

    You obviously think you're smart by posting such a statement, but your extension to the comparison of the startup code to a complete car is just rediculous. There are many changes that can be made to a car without having to know exactly how that car works. An engine can be moved without, for example, knowing the intricacies of how the ECM works. I personally know mechanics who have done such tasks without knowing how the "black boxes" work and their results have been sweet.

    What IS important is understanding the intricasies of the area involved and the associated components that might be affected.

    Here, it is fairly clear to me that the OP has little real understaning of the C runtime startup sequence. If he learns about this he might find out what he can meaningfully do.

Children
  • Per, Tamir, John, Andrew, Marcelle, Hans-Bernhard
    Thank you guys.
    The discussion was really awesome. :)

    Marcelle,
    you got it correct.
    ...the OP has little real understaning of the C runtime startup sequence. If he learns about this he might find out what he can meaningfully do.
    Request all of you to give reference of good technical material, in case you know any (i m googling it already in the adjacent tab but your recommendations are priority).

    Per,
    It is after this discussion, i came to know about the __main, scatter file, CRTL, etc.
    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.
    Is there any way to get source for CRTL + the OS? Would prefer the free one.

    John,
    question, my thought is: Yes, and not only the procedures, but also the source code.
    where and How can i get the source code?