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.

package close, module$use, and platform packages

Other Parts Discussed in Thread: SYSBIOS

Hello,

I think I'm running into an order of operations issue in the configuration process with my build.

I have a module which is used in my platforms module$use. When the module's package close function is called, it claims that the module has not been used yet.

I have not been able to get any clarification here: http://rtsc.eclipse.org/docs-tip/Creating_Configurable_Content

I assume there is a better place to look.

The platform must be applied after the user's config script? It seemed like a logical place to put HW specific modules / instances. Perhaps not?

Thanks!

  • So when does the platform make it's way into the configuration process?

    And should runtime modules be used / called / instances created in a platform?

  • Here is a very much unfinished guide about creating platforms: http://rtsc.eclipse.org/docs-tip/Creating_Platform_Packages. The figure on that page shows when are the various Platform functions invoked. Platform modules are special in the sense that they have some additional functions that are invoked by the config shell (getExeContext for example), however their standard module and package functions are invoked in the same way and in the same time as for other modules. There is no any other doc that describes these standard functions and their order of invocation other than http://rtsc.eclipse.org/docs-tip/Creating_Configurable_Content, so I'll have to use that one to explain what could be happening.

    The first thing to mention is that all package.close and module$use functions are invoked after the user's script. For each package in turn, all its module$use functions are invoked first and then package.close is invoked. Then the next package is selected, and so on. Packages are ordered only to the extent that if package A references package B in any of its XDC spec files, or in any of the functions that can run in Phase 2, package A's module$use and close functions will be invoked first. If there are no references established that way, these two packages can be closed in any order. Note that if a reference is established in module$use, it's too late to affect ordering because B.close may have already run by the time module$use in package A makes a reference to package B. That could be caused by a third package or the user's script calling xdc.useModule for a module from B. I suspect that the platform package is package A and your other module is in package B in that scenario.
    If your platform unconditionally uses a module from package B, you should than call xdc.useModule for your other module in the platform's instance$meta$init function.
    That should fix the problem if my assumpions are correct. You can add some debug print statements in the relevant functions and see in which order those debug messages are displayed.

    Let me know if you have more questions. I know this aspect of RTSC is little bit tricky, and I can see that some important facts are not documented, so I'll update the docs along with answering this and any further questions.

  • That certainly sounds like the issue at hand. and I tried moving the useModule call into the module$meta$init, and now i get a new error:

    TIME=02:07:12.013 PM -- xdc: xdc.useModule called on prog.drivers.MCP23009 from prog.catalog.arm.cortexm4.progArmM4init (useModule, all)
    js: "/home/Norton256/p4/tidsp/ti_rtsc/bios_6_34_01_14_extra_arm_targets/packages/ti/sysbios/family/arm/Settings.xs", line 416: TypeError: Cannot read property "catalogName" from undefined (/home/Norton256/p4/tidsp/ti_rtsc/bios_6_34_01_14_extra_arm_targets/packages/ti/sysbios/family/arm/Settings.xs#416)
        "/home/Norton256/p4/tidsp/ti_rtsc/bios_6_34_01_14_extra_arm_targets/packages/ti/sysbios/family/arm/Settings.xs", line 568
        "/home/Norton256/p4/tidsp/ti_rtsc/bios_6_34_01_14_extra_arm_targets/packages/ti/sysbios/family/Settings.xs", line 209
        "/home/Norton256/p4/tidsp/ti_rtsc/bios_6_34_01_14_extra_arm_targets/packages/ti/sysbios/family/Settings.xs", line 121
        "/home/Norton256/p4/prog/dev/MCU_RTOS_DEV/program_common/rtsc_common/prog/catalog/arm/cortexm4/progArmM4init/BoardAMaint.xs", line 10
        "/home/Norton256/p4/prog/dev/MCU_RTOS_DEV/program_common/rtsc_common/prog/platforms/BoardAMaintPlatform/Platform.xs", line 11
        "./package/cfg/BoardAmaint_pm4g.cfg", line 135

    It seems that this is happening so early now, that it is killing the sysbios family settings code.

    Using a requires statement to the platform module produces the same error.

    Thanks

  • it looks like my problem may be that I'm trying to do too much before getExeContext is called?

  • You will certainly hit fewer issues if you use that other module at the very end of getExeContext, and it's still early enough.

  • I added the module right before the return statement in getExeContext and it is still producing the same error. It looks like something slightly after getExeContext must be using the return value to initialize the pieces which are giving me trouble.

  • My next attempt was to move the offending useModule in my platform.xs file into the platform's package.xs close function. I then added requires statements to the package.xdc files to help resolve the packages being closed in the correct order. I suspect the requires statements cause it to crash even sooner, since the platforms module$meta$init function does not even execute (my print statement did not show up).


    This is turning into a tough nut to crack. I really like xdc and what it has to offer for re-use. And BIOS is a really nice small OS. I really want this to catch on more at my company, but If i have a tough time making these hardware platforms running it easy to set up, it is going to make things more difficult.

  • norton256 said:

    My next attempt was to move the offending useModule in my platform.xs file into the platform's package.xs close function. I then added requires statements to the package.xdc files to help resolve the packages being closed in the correct order. I suspect the requires statements cause it to crash even sooner, since the platforms module$meta$init function does not even execute (my print statement did not show up).

    When you add a require statement to package.xdc, you are then loading that other package at the earliest possible time, before even module$meta$init is invoked for the platform. I looked more carefully into the error message, and I suspect that your problem is basically caused by invoking SYS/BIOS code that references Program.cpu, and Program.cpu is defined after the call to Platform.getExeContext(). The line that most likely fails is
    catalogName = Program.cpu.catalogName;
    in function deviceSupportCheck(). Can you confirm that?

    All the code in SYS/BIOS is written with the assumption that SYS/BIOS modules are loaded within a user's script or later, and that's what always happens. In a way, it's expected. When you write the code for a platform, you are describing the hardware, memory map, etc, not establishing what the operating system should run on it.

    All that theory aside, there is a chain of events that you want to happen that seems to look like this:
    BoardAMaintPlatform is loaded->progArmM4init.BoardAMaint is used->MCP23009 is used->SYS/BIOS is used.
    Is this correct?
    All this is happening at the same time, and if it happens before the user's script, SYS/BIOS fails. If it all happens at the closing time, progArmM4init package gets closed before BoardAMaintPlatform.Platform had a chance to use progArmM4init.BoardAMaint.
    That chain has to be broken somewhere. Ideally, in BoardAMaintPlatform.Platform's module$meta$init you would load progArmM4init.BoardAMaint because BoardAMaint seems to be a catalog module that describes hardware and all that should happen before the user's CFG script. Then, the user's script should declare which drivers and which OS should be used by loading MCP23009 and SYS/BIOS.
    If is not an acceptable solution, can you tell me in which function does MSP23009 load SYS/BIOS and what's being done there? Can't that code be split into something that must happen early so you put it in MCP23009.module$meta$init, and then the code that triggers SYS/BIOS happens in MCP23009.module$use?

  • Your order of operations of what I would like to occur is correct. I think my fundamental problem is that I'm trying to use the Platform package in a manner in which it was never intended.

    I'm attempting to configure all of the hardware for the board. From configuring GPIO to loading the drivers for all the peripherals which are present on that board. I attempted to associate a "Platform" with a specific piece of silicon on a specific PCB. More than just a memory map and a way to stuff device specific boot code into the process.


    Maybe I just need to add a meta function to the platform which just needs to be called in the users script.

    It is in device support check that it is dying.