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

Firmware and application cohabitation on the same device

Hello,

I would like to create a firmware and an application running on the same device.

The application needs to call some functions of the firmware. The application can be updated whereas the firmware is still the same.

Therefore, i want to have 2 projects: one for the firmware (C coded) and one for the application (C coded).

I have seen that it's possible to forbid idata, xdata and code area in order to prevent the application to overwrite the firmware and its variables, but I have no clues on how to give my firmware prototype to my application.
Of course parameters and functions' addresses must map with the firmware mapping.

Does anyone have an idea how I can do this?

Thanks for your help!
Damien.

Parents
  • Damn it did not post my reply! Here it is again

    It should be obvoous that if you change the bootloader/BIOS you need to change the app as well, the below requires that.

    Yes I was aware of that :)

    write an assembler module with all global BDATA/DATA/IDATA/PDATA/XDATA that the bootloader/BIOS uses and link it with both bootloader/BIOS and app.

    That's a good idea, I'll try that! But I have some libs and I don't have its source code, so I can't define them all in my firmware ASM file. I'll have to make a new ASM file for the application including all firmware variables. Too bad :(

    There will be a requirement that all functions are declared reentrant to make them not use call tree since one will not be aware of the other. If main() can not be declared reentrant there can be no locval variables in main()

    Why do have I to set function reentrant? I'm not using any OS, so when I'm running a firmware function, the application can not perform something else. reetrant is not for functions that can be called twice at the "same time", like isr or tasks?

    Thanks!

    Damien.

Reply
  • Damn it did not post my reply! Here it is again

    It should be obvoous that if you change the bootloader/BIOS you need to change the app as well, the below requires that.

    Yes I was aware of that :)

    write an assembler module with all global BDATA/DATA/IDATA/PDATA/XDATA that the bootloader/BIOS uses and link it with both bootloader/BIOS and app.

    That's a good idea, I'll try that! But I have some libs and I don't have its source code, so I can't define them all in my firmware ASM file. I'll have to make a new ASM file for the application including all firmware variables. Too bad :(

    There will be a requirement that all functions are declared reentrant to make them not use call tree since one will not be aware of the other. If main() can not be declared reentrant there can be no locval variables in main()

    Why do have I to set function reentrant? I'm not using any OS, so when I'm running a firmware function, the application can not perform something else. reetrant is not for functions that can be called twice at the "same time", like isr or tasks?

    Thanks!

    Damien.

Children
  • That's a good idea, I'll try that! But I have some libs and I don't have its source code, so I can't define them all in my firmware ASM file. I'll have to make a new ASM file for the application including all firmware variables. Too bad :(
    If you do not have the source , you simply CAN NOT do what you want (see below)

    Why do have I to set function reentrant? I'm not using any OS, so when I'm running a firmware function, the application can not perform something else.

    let us take an example:
    BB (bootloader BIOS) is compiled and linked separately, app is compiled and linked separately, all BB global varibales are avoided by the app.

    the app
    void main (void)
    {
    U8 var1; // placed by the linker at end of globals
    U16 var2; // placed by the linker at end of globals+1
      BBfunc1()
    }
    
    void BBfunc1(void)
    (
    
    // the BB is not 'aware' that the app placed temp variables by the call tree
    
    U8 bvar1; // placed by the linker at end of globals
    U16 bvar2; // placed by the linker at end of globals+1
    }
    

    Thus you need reentranr, not for reentancy, but for no call tree.

    Erik

  • Ok! Thanks!!

    If I specify a new zone for my application's global variable (_IBIT_GROUP_, _DATA_GROUP_, _IDATA_GROUP_, _XDATA_GROUP_), then I don't need to define them as reentrant?

    BL51 linker:

    XDATA([...], _XDATA_GROUP_ (0x1806))
    

    It will use more memory, but it will be possible to call functions from my library, right?

    Damien.

  • If I specify a new zone for my application's global variable (_IBIT_GROUP_, _DATA_GROUP_, _IDATA_GROUP_, _XDATA_GROUP_), then I don't need to define them as reentrant?
    you define functions as reentrant Please read the manual as to how.

    Erik

  • I'm sorry, I don't understand "Please read the manual as to how".

    Does it mean "Read the manual to know how reentrant function works, please"?

    Then I'm sorry to disappoint you, but I did. From this article http://www.keil.com/support/docs/1854.htm , I understand that normal function use _DATA_GROUP_ for local variables.

    From this article: http://www.keil.com/support/man/docs/c51/c51_le_reentrantfuncs.htm
    Reentrant directive inform the compiler/linker to not use _DATA_GROUP_ but a separate stack (XDATA for me, because I use LARGE model).

    So I thought that if I declare two different _DATA_GROUP_, one for my firmware, and one for my application, I don't need reentrant functions. Let me explain:

    FIRMWARE

    void BBfunc1(void)
    (
       U8 bvar1;
       U16 bvar2;
    }
    


    APPLICATION

    void main (void)
    {
       U8 var1;
       U16 var2;
    
          BBfunc1()
    }
    

    I specify the _XDATA_GROUP_ (LARGE model) for application at 0xEC00

    _XDATA_GROUP_ for the firmware is placed by the linker, I do not give any specification: 0x1800 is the address of the _XDATA_GROUP_ of the firmware.

    Once complied/linked, I'll have:
    FIRMWARE

    SEGMENT                          XDATA_GROUP
      +--> CALLED SEGMENT          START    LENGTH
    ----------------------------------------------
    ?PR?BBFUNCT1?FIRMWARE_FUNC     1808H    0006H
    
    


    APPLICATION

    SEGMENT                          XDATA_GROUP
      +--> CALLED SEGMENT          START    LENGTH
    ----------------------------------------------
    ?PR?MAIN?MAIN                  EC00H    0006H
      +--> ?PR?BBFUNCT1?FIRMWARE_FUNC
    
    


    ==> var1/var2 and bvar1/bvar2 are not located at the same address because _XDATA_GROUP_ are not located at the same address.

    ==> Do I still need reentrant functions?? I don't think so. Am I wrong?

    Damien.

  • I just read up on reentrant (which I never have or would use) and saw the thing about 'stack location'. I, incorrectly, assumed it was like it was once (passing parametres on the internal st6ack) MY BAD.

    Now, for your thingy you need contact Keil support (since you use allmost 64k, you must have a license) and find out how to avoid having separate stack pointers.

    Erik