This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/MSP430F5438A: How to configure the TI-RTOS to generate MSP-EXP430F5438-A2_pr430XS with __pic (position independent code) runtime

Part Number: MSP430F5438A

Tool/software: TI-RTOS

Hello,

I am trying to build my project with PIC enabled in the IAR(7.11.1). 

During the linking phase, there is an error message:

Error[e117]: Incompatible runtime models. Module MSP-EXP430F5438-A2_pr430XS specifies that '__pic' must be 'no', but module adc has the value 'ropi'.

I am wondering how can I add the --ropi option to the generated module MSP-EXP430F5438-A2_pr430XS?

xdctool version: xdctools_3_32_00_06.

tirtos version: tirtos_msp43x_2_20_00_06

Thanks in advance.

Allen

  • Hello Allen,

    You may find it helpful to search for "__pic" in the IAR C/C++ Compiler Reference Guide for Texas Instruments’ MSP430 Microcontroller. It seems that for the Runtime model attribute "__pic", you can specify either "ropi" or "no" for the value.

    Also, I found another related thread where the Debug versus Release configurations affected this behavior. According to Anders, enabling "ropi" made the code much harder to read.

    Release hex created in IAR MSP430 does not work?

    Regards,

    James

    MSP Customer Applications

  • Hi James,

    Thanks for the document.

    I have checked that the --ropi is enabled if I checked the box of Position-independence for all .c files (checked the .r43 file) except the MSP-EXP430F5438-A2_pr430XS.or430XS file.

    And I am working in the debug target.

    My question is why this MSP-EXP430F5438-A2_pr430XS.or430XS file is not position independent? And how to enable it?

    Shall we rebuild the library with some special parameters in the make file? Or shall we add some settings in the .cfg file to the TI-RTOS?

    I do a lot of search on the internet but fails to find any useful information yet.

    Or a more general question, does the TI-RTOS support PIC?

    Thanks in advance.


    Allen
  • This post has the similar question.
    e2e.ti.com/.../220811
  • Hi Allen,

    Just fyi I found in an IAR release note that --ropi is a deprecated link option.

    supp.iar.com/.../icc430.ENU.html

    As for general pic support for TI-RTOS, I would guess that it shouldn't be a problem but I will get back to you after I ask around.

    Thanks,

    Sean
  • Thanks Sean,

    Yesterday I tried to rebuild the TI-RTOS by modifying the build configuration files (bios.bld and drivers.bld).

    var ccOpts = {
    ......

    "iar.targets.msp430.MSP430X_small" : "--ropi",     // --ropi is noe added

    ......
    };

    However, the build stops with some error messages shown below. It seems the compiler option key words "--ropi", "__pic", or "__ropi" are not supported.

    Is it correct to add compiler option in that two .bld file? If yes, what is the key word?? 

    Thanks very much.

    Allen

  •  Another possible solution is to reconfigure the BIOS by a proper compiler options, but I was not able to find the right option for PIC or ROPI yet.

  • Hi Allen,

    I've recreated your link issue.

    I think you need to rebuild driverlib/drivers with that option.
    I think the easiest way to do this would be to add the files (driverlib and driver files) directly into your project so that the linker doesn't need to go looking for the symbols. It will take a while to build but it is the lowest effort way to see if that is the issue.

    Sean
  • Hi Sean,

    Thanks for the feedback.

    1) For you first suggestion of rebuilding driverlib/drivers, I have successfully rebuilt the bios.o with the --ropi option, by adding this compiler option in the .cfg file.

    BIOS.libType = BIOS.LibType_Custom;

    BIOS.customCCOpts += "--ropi";

    However, another file xxx_pr430XS.or430XS (locates in the folder xxx\configPkg\package\cfg) is still not 'ropi' enabled.

    It seems this file is built automatically, how can we add the "--ropi" to this file as well?

    2) How to add the files (driverlib and driver files) directly into the project?

    Thanks

    Allen

  • Allen,

    I haven't had luck rebuilding those libraries with that option thus far, have you tried adding '-ropi' to the 'profiles' section of this file:?

    C:\ti\tirtos_msp43x_2_20_00_06\products\bios_6_46_00_23\packages\iar\targets\msp430\MSP430X_small.xdc

    But maybe we could get around needing those libraries at all if we added the source/header files directly to your project.

    For adding the files, you'd have to know which drivers your application was using as well as the driverlib files that those drivers were using and add them into your IAR project. Then those files would be compiled locally with your project's compile flags and so the library wouldn't be necessary at link time.

    Thanks,

    Sean

  • Hi Sean,

    Thanks, I just tried to add the "--ropi" option in the file MSP430X_small.xdc in the folder C:\ti\tirtos_msp43x_2_20_00_06\products\bios_6_46_00_23\packages\iar\targets\msp430\.

    /*!
    * ======== cc ========
    * The command used to compile C/C++ source files into object files
    *
    * Defaults:
    * @p(dlist)
    * -`-e`
    * enable compiler extensions so it's possible to get segment
    * start addresses in C, via:
    * @p(code)
    * #pragma segment = "CSTACK"
    * isrStack = __segment_begin("CSTACK");
    * @p
    * -`--core=430X`
    * MSP430X architecture
    * -`--data_model`
    * Small data model for MSP430X architecture
    * -`--save_reg20`
    * All 20 bits of registers are preserved in all interrupt functions
    * @p
    */
    override readonly config Command cc = {
    cmd: "icc430",
    opts: "-e --core=430X --data_model=small --save_reg20 --ropi"
    };

    But the build log still indicates as follows:

    "Error[e117]: Incompatible runtime models. Module MSP-EXP430F5438-A2_pr430XS specifies that '__pic' must be 'no', but module adc has the value 'ropi'

    "

    I have not got chance to add the library files to the project directly, did you successfully try this method?

  • Hi Sean,

    In the link below which says "There is no way to use SYS/BIOS without XDCtools. To replace XDCtools, you would need another tool to read a CFG script and then generate a source file that's compiled and linked with SYS/BIOS libraries and the app. I don't know of any such tool."

    https://e2e.ti.com/support/embedded/tirtos/f/355/t/189232?DSP-SYS-BIOS-without-using-the-XDC

    So how could we manage to use the BIOS and library without the config file and XDCTool in your opinion?

    Thanks

    Allen

  • Hi Sean,

    In the link below which says "There is no way to use SYS/BIOS without XDCtools. To replace XDCtools, you would need another tool to read a CFG script and then generate a source file that's compiled and linked with SYS/BIOS libraries and the app. I don't know of any such tool."

    e2e.ti.com/.../189232

    So how could we manage to use the BIOS and library without the config file and XDCTool in your opinion?

    Thanks

    Allen
  • Hi Allen,

    Thanks again for your patience. Just a quick status update. After some debugging with engineers more familiar with XDCtools, we've determined that the IAR xdc tooling does not pass the flag properly and lacks the option to specify a custom config bld file. Overwriting the xdc target is also not sufficient unless the package is rebuilt on our end. We are exploring alternate solutions for this problem and hopefully I will have better news for you early next week.

    Thanks,

    Sean

  • Thanks Sean for the update.

    Hope the alternate solution will be found for this problem.

    Besides adding "ropi" to the IAR_MSP430X_SMALL target, do we need to rebuild the library with the --ropi option as well? 

    If so, where shall we add the option?

      

    Thanks

    Allen

  • Hi Allen,

    So we were able to pin down the bug in configuro and we have a work around to pass the flag properly. The work around is to modify the getCompileOpts function in Main.xs on the path: \ti\tirtos_msp43x_2_20_00_06\products\bios_6_46_00_23\packages\iar\tools\configuro\

    This function was dropping all non -D/-I options. You need to allow the ropi flag to be returned, which can be as simple as adding:
    // Hardcode ropi flag
    cOpts += " --ropi";
    return (cOpts);
    }

    Unfortunately the kernel was not designed to be position independent and so this causes several compilation errors like this:
    the address of this object cannot be used in static initialization
    __FAR__ const xdc_runtime_Types_Base xdc_runtime_ISystemSupport_Interface__BASE__C = {(void*)&xdc_runtime_IModule_Interface__BASE__C};

    I was advised that it probably makes more sense to compile the kernel normally with a small app that jumps into the separate position independent code app. We'd need to know more about your design to help further.

    Sean
  • Thanks Sean,

    I will try your solutions in the following days and I will let you know how it works. 

    For you last suggestion, "compile the kernel normally with a small app that jumps into the separate position independent code app", if I understand correct, the small app has the RTOS enabled and the other app code which supports the independent code will not use the RTOS? 

    Do I understand correctly?

    Thanks

    Allen

  • Hi Allen,

    Yes you can create a library file containing your position independent code and link it into your separate TI-RTOS project.

    Different compilers have different ways of handling libraries but I think you will need to refer to IAR documentation for this. I found some good starting points here:

    ftp.iar.se/.../EWARM_DevelopmentGuide.ENU.pdf
    ftp.iar.se/.../EWARM_IDEGuide.ENU.pdf

    Thanks,

    Sean
  • Hi Sean,

    Sorry for the late reply.

    I was busy developing the Bootloader for this project.

    Your suggestion about compile the TI-RTOS normally and jumps to the app with another app which compiled with the position independent option may not be suitable for our requirement.
    The reason is that, we will compile the Application project(which uses the TI-RTOS) with the option(position independent) together in a IAR project (TI-RTOS is compiled and configured using the .cfg file), and upload the output image to the products. Looks like it is not possible to separate the Application to two (one is with TI-RTOS and the other is without).

    However, good news is that the Bootloader works fine as well as the FW update over UART.
    Instead of directly jumping to the new APP image in the flash (preferable option is the TI-RTOS supports the position independent, the feature), the Bootloader copies the new APP image to the address of the original APP. (This is the reason why we want the TI-RTOS can support the feature).

    It is a pity that the TI-RTOS does not support this feature. So is there any plan to support the feature in the future?
    I am sure other customers would have similar requirements.

    BTW. your links of documents are for the ARM processor, but still be useful generally. Thanks.
  • Hi Allen,

    No worries, glad to hear you found a work around.

    So if I understand correctly, you wanted your TIRTOS app to be PIC so that you could jump directly into your new FW no matter where you placed it? That's an interesting use case, I believe most bootloaders overwrite the old application at a fixed location like yours does now. Although in theory, you could place the application somewhere else provided you compiled the app ahead of time for that location new location.

    Unfortunately I don't think the kernel will be supporting PIC as this would likely require large parts of it to be re-written or even re-architected. I also was not able to find a competing RTOS solution that supports PIC (at least explicitly) or even shared libraries which is what PIC is usually for.

    Anyways, thank you for checking back in with us and sorry that we didn't have the feature you wanted. Good luck!

    Sean

**Attention** This is a public forum