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.

SYSBIOS: PRU firmware load error

Part Number: SYSBIOS
Other Parts Discussed in Thread: AM3356, AM3359

Hello I am having issues with my software.

What I am trying to accomplish is add support for normal Ethernet via tthe AM335x build in PRUs (I already have Ethernet via CPSW running correctly). We have a board that has 2 fiber optics PHYs connected to the PRU MII interface. So I have taken the application that we have already running on our own board and started to add code from the TI example project (NIMU_ICSS_BasicExample_icev2AM335x_wSoCLib_armExampleproject) to my code. While adding the code, I can see that sometimes I get into a situation where I get the following on the debug output in CCS:

00000.500 llEnter: Illegal priority call to llEnter()

00000.506 llExit: Illegal call to llExit()

This does not seem to be related to things that I do in the code, there is some outside trigger causing this to happen and I don't know what it is.

What I have done to check that it is probably no my code that causes it, is the following:

  • From a point where I once again got the above message, I reverted back to the state of the software where I did not have this problem and nothing related to PRUs in my code
  • I ensured that my code was still running correctly and not giving me that message by cleaning the project, building it and running it on my target. Everything was working as it should work.
  • Then I started slowly adding code in 'baby steps'. After every step, I cleaned the project, then build it again and loaded it onto the target via the CCS environment. When loaded, I started the application and check that A) I did not get the message about priority and B) The software was still working correctly.
  • I kept on doing these 'baby steps' until I got to the point that nearly everyting was in my code. The only things missing were loading the PRUs with firmware (PRUICSS_pruWriteMemory) and enabling the PRUs again (PRUICSS_pruEnable)..
    Reaching this point still did not give me the 'Illegal priority' error message, 2 other things were broken though (my CPSW Ethernet interface no longer established a connection to my PC and I could no longer open the UART that we have connected to an RS-485 driver). This is something to look at later on, but not my issue for now.
  • At this point I turned off my board for a complete reset and then turned it on again. Next I started my 'Target configuration' again to connect to the board and then loaded the software (without any compiling/rebuilding -> so same binary) into the board again. However running the software now resulted in the above mentioned error message about 'Illegal priority'. And now I am unable to the software running again, rebuilding the software or restarting the hardware does not help.
  • From this point I will change back my code back to the starting position again, to find out when it will run again, but this is a time consuming process and I know that the 'illegal priority' error will pop-up again when I add PRU functionality.

So I have some questions:

  1. How is it possible that I get this error message ? Because it has nothing to do with any priority of any of my own tasks.
  2. Is it possible that the reset triggers something which caused my problem ? Or the better question might me, is it possible that my incremental building back up my software can somehow prevent this error from occuring, because there is something left behind in memroy ? And the hardware reset will ofcourse clear out the entire memory, so no settings are left behind.
  3. What can I do to prevent this issue ? Because what I have read about this error message is that it is caused by creating/running a task with a priority higher than allowed by the configuration in the .cfg file and since it is not one of my tasks, it is hard for me to change task priorities, as the tasks must be in the TI PDK.
    FYI, I have not set the maximum task priority level in my .cfg file, so it is at its default level.

My configuration is the following:

  • Code Composer Studio: Version: 8.2.0.00007
  • TI library versions:
    • EDMA3 low level driver 2.12.5
    • NDK 3.40.1.01
    • SYSBIOS 6.73.0.12
    • System Analyzer 2.30.1.02
    • am335x PDK 1.0.12
  • XDCtools version 3.50.7.20_core
  • Compiler: gcc-arm-none-eabi-6-2017-q1-update
  • Our board contains
    • an AM3356
    • DDR3 RAM
    • Flash for the bootloader
    • an SD-Card that normally contains the application, but it is now loaded by CCS
  • I am using an XDS200 debugger to interface with the hardware from CCS

Is there anyone that can help me resolve this ?

Kind regards,

   Han Hoekstra

  • Hi Han,

    You may search 'llEnter: Illegal priority call to llEnter()' in the forum, some answers may help, e.g

    Regards,

    Garrett

  • Thanks for you response Garrett !

    I have already done a search for the "llEnter: Illegal priority" phrase and the posts that I have read all seem to point to tasks with a priority higher than the maximum priority allowed.

    However, I think my problem is different from a simple task priority error. What I described in my problem description is that I start from a working source code base and in baby steps add functionality for the PRUs. In the last step that I do, I have nearly all PRU functionality in my software and when I run my software, it is still working without the error. But when I turn off my device, then turn it back on again and try to run the exact same binary image, I all of a suden get the error message. So the only change it the hardware reset of the device and this causes the error. Note: During the adding of the PRU functionality, I never power cycled the device, I just loaded the software using the JTAG debugger and ran it.

    When I power cycle the device with my 'starting point' software, there is never a problem running the software (we have already performed some qualification tests on our hardware, where the device is reset a lot for changing the setup and this is done without any problems).

    From my point of view, there might be something initialised in memory that keeps the software running while I add functionality, but as soon as I reset the device, this 'data' is no longer in memory and somehow causes the 'illegal priority' error.

    Today I will start working backwards, until I get back to a functioning software again, so that I have an idea where I should look for the fault. When I have more information, I will post it here.

    Kind regards,

    Han

  • Additional information after slowly changing back the code from the fault situation to a situation where my software is working again:

    The error:

    00000.500 llEnter: Illegal priority call to llEnter()

    00000.507 llExit: Illegal call to llExit()

    Seems to be caused by the flag BOARD_INIT_ICSS_PINMUX, which is passed by my application to the function 'Board_init'. The code for the 'Board_init' looks as follows:

    ----------------------------------------------------

        Board_initCfg   boardCfg;
        Board_STATUS    boardStatus;

        boardCfg = BOARD_INIT_PLL | BOARD_INIT_DDR | BOARD_INIT_PINMUX_CONFIG | BOARD_INIT_MODULE_CLOCK |
                    BOARD_INIT_ETH_PHY /*| BOARD_INIT_ICSS_PINMUX | BOARD_INIT_ICSS_ETH_PHY*/;
        boardStatus = Board_init (boardCfg);
        if (boardStatus == BOARD_SOK)
        {

    ----------------------------------------------------

    When I run this, my application works fine. If I uncomment only the 'BOARD_INIT_ICSS_PINMUX' flag and leave the 'BOARD_INIT_ICSS_ETH_PHY' commented out, there are 2 possible results of running my code:

    1. When I re-build the software, don't reset my board and load my image into the target, the software will run perfectly.

    2. When I re-build the software, perform a hardware reset of my board and then load my image, I get the priority related error message

    So it seems that it matters if I first run a working version of my software or that I start with a board that has just been reset for the code with the init flag 'BOARD_INIT_ICSS_PINMUX' to work or not. The code that gets called because of the 'BOARD_INIT_ICSS_PINMUX' flag is exactly the same for my board as for the AM3359 ICE V2 board.

    The only thing I can think of causing this problem is an issue with my Pinmux file. The Pinmux I use is created using the online Pinmux tool. I will have a look at it in detail to see if there is an issue with it. But I think it is a bit strange that an issue with the Pinmux can cause this kind of errors.

    So my new question is, how could the use of the flag 'BOARD_INIT_ICSS_PINMUX' cause the error with the illegal priority ?

    Kind regards,

       Han

     

  • Han,

    If you look into the Board_init() function, BOARD_INIT_ICSS_PINMUX has to be kept for the board pinmuxConfig.

    if (cfg & BOARD_INIT_ICSS_PINMUX)
    {
    icssPinMuxFlag = 1U;
    ret = Board_pinmuxConfig();

    }

    Yes, you have to look into your pinmux file more carefully. Without an incorrect pinmux file, any weird thing may happen.

    As you are working with a custom board, did you re-build the board library and step into the Board_init() function to ensure all peripherals are activated as designed? 

    Regards,
    Garrett

  • I have some more information.

    What I have done is try the TI project 'NIMU_ICSS_FtpExample_icev2AM335x_wSoCLib_armExampleproject' with my board definition. This did not give me the 'priority' error. I also checked my pinmux file with respect to the PRU pinmux against the pinmux file of the TI ICE V2 board and I could not find anything that would cause errors. The pins I use are defined the same as for the TI ICE V2 boad, I only have a few pins less, like the UART pins.

    Next I studied the source code of the NDK in more detail, to see what could be the problem. llEnter increases the current priority to 'OS_TASKPRIKERN' and compares it to the priority returned by 'TaskSetPri', so I started to look in that direction. My application .cfg file sets the priority for the NDK kernel task priority to 15 (Global.kernTaskPriLevel = 15) and I checked that it is actually set to 15 using the calls to 'CfgGetEntry' and 'CfgEntryGetData', which showed that it was really set to 15. So that should be fine, because there is no other task running at or above priority 15, which I checked by listing all tasks known in the system.

    My next step was to modify the function 'llEnter' and make it print the priority level that was wrong according to the if statement:

    if( tmpOldPriority >= OS_TASKPRIKERN )

    When teh error occurred, this showed that 'tmpOldPriority' was 9 and 'OS_TASKPRIKERN' was also 9.

    So here is my problem, somehow the 'OS_TASKPRIKERN' is wrong, maybe only in the beginning, I don't know. But it does not match the setting in my .cfg file.

    In the .c file generated by the XDCTOOL, I can see the following code:

    /* add the configuration settings for NDK kernel priority task level. */
    rc = 15;
    CfgAddEntry(hCfg, CFGTAG_OS, CFGITEM_OS_TASKPRIKERN,
                 CFG_ADDMODE_UNIQUE, sizeof(uint32_t), (unsigned char *)&rc, 0 );

    So the setting from my .cfg file is set in the NDK stack configuration. Later I discovered that 9 is the initial value for the priority.

    My question now is, is it possible that updating this setting in the NDK stack settings is somehow delayed, so that it is running for sometime with the initial value for the setting ?

    Would it be better to #define the option 'USE_LL_SEMAPHORE', so that I don't have this dependency on priority levels anymore ?

    Is the only drawback that using the Semaphore is a little slower than the priority switching ? Or are there other issues ?

    Please let me know what you think.
    Kind regards,
       Han Hoekstra

  • Hi Han,

    Yes, you can chose the 'USE_LL_SEMAPHORE' implementation for llEnter() and llExit() functions to avoid the task priority dependency.

    There is really no known drawback other than as the code commented: The priority based version is faster, but not as safe if care is not taken when setting task priorities.

    Regards,
    Garrett

  • The problem with the llEnter issue is resolved by setting the 'USE_LL_SEMAPHORE', the llEnter error no longer occures.

    But I ran into another error and decided to abandon my attempt to integrate the normal Ethernet via PRU into my code. The idea was that this would be a quick way to verify our hardware, but it turned out to be harder than expected. As normal Ethernet via PRU will not be in our software, I stopped work on this and started with the HSR application example, because we want the HSR protocol via the PRUs.

    So at this moment I am trying to integrate that in my code, which is also not going as smoothly as I would like. So I will probably come back with other issues.

    But the llEnter issue is resolved, which is what this thread is about.