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

Generate a single Hex file from four different projects

Hello Everyone,

I am working on STM32F4.I have four Single Project(P1,P2,P3,P4), each project have their own start-up file, library files & main function. I am able to compile each of the project individually to generate its respective hex files.

Now I want to combine these four projects in to a single multi-project that would generate a single hex file for all of them.

I want to execute the projects in the following sequence:
1. Start-up file of P1 will get executed 1st followed by its main function.
2. Then the control will jump to the start-up file of P2 followed by its main function.
3. Then the control will jump to the start-up file of P3 followed by its main function.

when an system reset is encountered then the control again jumps to P1 & the sequence starts all over again.
I want to call functions of P4 from main functions of P2 & P3 respectively.

So please help me out I am stuck.

Thanks,
Amit

Parents
  • Why you are stuck?

    Because you got an idea that doesn't match your abilities.

    Maybe you should reconsider your idea instead, and modify it until it is simple enough that you understands how to make it work.

    Note that it isn't hard to write

    void main(void) {
        do_something1();
        do_something2();
        do_something3();
        for (;;) {
            do_something4();
        }
    }
    

Reply
  • Why you are stuck?

    Because you got an idea that doesn't match your abilities.

    Maybe you should reconsider your idea instead, and modify it until it is simple enough that you understands how to make it work.

    Note that it isn't hard to write

    void main(void) {
        do_something1();
        do_something2();
        do_something3();
        for (;;) {
            do_something4();
        }
    }
    

Children
  • All the pieces need to be compiled for their own address space. The start up code will need to modify the vector table address to reflect the base of the module.

    The only thing that will boot is the module situated at the base of flash 0x08000000, you will need to hand off control from there.

    Review some of the IAP examples (USART, ETHERNET, etc) to understand the transfer of control via the Reset_Handler vector in each module. It will call SystemInit() to configure the hardware, and then __main to initialize the C run time environment, and in turn it will call your main() function. Consider if the clocks and other hardware need to keep getting reinitialized, and if the code is robust enough to be used in non-reset conditions.

    It's not clear what P4 is, if it's a collection of library or API functions, you'll need to create a jump table, or export the addresses of the functions, and pass that to the linker via a definition file or something similar.

    You can combine .HEX files with tools like NOTEPAD, generally just remove the last line in all but the last file as you merge the data. Perhaps get a Hex Editor, review tools like Srecord, or the documentation for the format itself.

    The lack of any real grasp of this suggests the wrong guy was picked for this job.. Consider finding someone at your school/employer with some experience in embedded, or micro processor development work.