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

How to put program to specify address using startup.s

Hi!
I am using ADUC7026 and Keil Arm Tools. I need to put all program to specify address(for example 0x8C800). I need to do this in startup.s, because I want MCU to jump to this address only on specially condition(for example GPIO pin low). In all other cases program must start from defaul address(0x80000). Thanks in advance

  • (I don't know much about this.)

    I think you may have to re-implement __main. (__main is not your main().)

    The relative documentation on KEIL's web is gone. So I am not able to provide an URL for you.
    Please check the documentation installed with your KEIL toolchain.

    
    RealView Libraries and Floating Point Support Guide
    
    Home > The C and C++ Libraries >
    Tailoring the C library to a new execution environment >
    How C and C++ programs use the library functions
    
    Initializing the execution environment and executing the application
    
    The entry point of a program is at __main in the C library where library code does the following:
    
      1. Copies non root (RO and RW) execution regions from their load addresses to their execution addresses.
    Also, if any data sections are compressed, they are decompressed from the load address to the
    execution address. See the Linker Guide for more information.
    
      2. Zeroes ZI regions.
    
      3. Branches to __rt_entry.
    
    If you do not want the library to perform these actions, you can define your own __main that branches
    to __rt_entry as shown in Example 2.1.
    
    

    (Actually, I don't know how to re-implement __main. I had read the documentation for other purposes.)

  • Just call a simple C function via the assembly of the startup file. then test the return value to decide. remember the limitations on code placed in startup (heap, stack etc.)

  • oops, sorry, that was a mistake. can't you jump to a different location once arriving in main? must the decision be placed in the startup?

  • The problem is: I put program to 0x8C800 address via uVision
    Target Options->LA Locate
    DATA (0x10000-0x11FFF),
    CODE (0x8C800-0x8F7FF), CONST (0x8C800-0x8F7FF))
    But uVision put this program to 0x8DA69(I checked in Disassebmly window) so if jump to 0x8C800 nothing happened.
    I need to know hot to put start of main program to exactly 0x8C800 address. I think there are must be assembler operand to do this.

  • I checked in Disassebmly window

    And you checked ... what?

    I need to know hot to put start of main program to exactly 0x8C800 address.

    No, you quite certainly don't need to know that. You need to learn why the address of main() is irrelevant to what you're trying to do there.

  • And you checked ... what?
    I used debugger to check where PC goes after startup

    No, you quite certainly don't need to know that. You need to learn why the address of main() is irrelevant to what you're trying to do there.

    I need to know this for make jump to this address. I tried to make jump after initialization in startup.c to address 0x8C800, but nothing happened because program starts at 0x8DA69 address.
    I need to do this because I want to start two different programs on different address on different condition.

  • I need to do this because I want to start two different programs on different address on different condition.

    sounds like a bootloader to me.

  • sounds like a bootloader to me
    Exactly I need to make bootloader.I want to put this bootloader to 0x8C800 address and main program to 0x80000. And call bootloader on condition.

  • what you need is a bootloader at the entry point into flash, e.g. 0x0. decide where you need to branch to in the main function of the bootloader itself. it should not "be called on condition"...