TMS320F28375S: Strange issue with bootloader

Part Number: TMS320F28375S

Tool/software:

Hello

This is a follow up on this issue. The previous thread is now locked, so I had to create this one.

I debugged the issue and in the cases that the bootloader is not coming up, DSP stops somewhere inside the c_int00 assembly instructions. It reaches the GET_DATA and GET_ADDR loops, but somewhere something goes wrong. It doesn't reach DO_BINIT. I'm not sure how this can help me to find the cause.

I have a first stage bootloader (Bl0) + a second stage BL + the main application. (Bl0 + BL + APP), each with a dedicated range in Flash. Bl0 runs from flash, at the end it jumps to BL, and Bl will jump to the APP. (BL and APP run from RAM)

The strange thing is that the same code for BL0 runs when alone (the APP is not flashed), but stops working when the APP is present. A small insignificant change in the code can make it run again. Sometimes a change makes it run, but not normally. In one case for example, it runs, but I see that a static variable that I initialized, has a different value from the beginning by itself !. In another case, the BL0 and BL run normally, but later inside the application something goes wrong with the communication for example. I don't understand, how can something in BL0 affect the APP later, after DSP has jumped to the APP. BTW, the APP is 100% sure, so nothing is wron there.

Here are some examples. The changes that I make in the BL0 code between different cases are really insignificant, it could be anything anywhere, changing the value of a macro, which isn't even used, or adding some dummy lines of code, or changing some debug messages. So whatever this is, it's not about the content of my changes. The different versions of BL0 that I wrote here are essentially the same.

BL0_version1 + BL + APP >> runs, normal
BL0_version2 + BL + APP >> doen't run
BL0_version2 + BL            >> runs
BL0_version3 + BL + APP >> runs, but not normal, strange behaviour in BL0
BL0_version4 + BL + APP >> runs, but not normal, strange behaviour later in the APP


The BL0 runs from Flash. Is there anything there that could possibly explain this weird issue?
I have a separate question about that here.







  • Hi Saeed, 

    Please allow me a bit more time to look over all of the information, I will get back to you tomorrow afternoon.

    Best,

    Matt

  • Hi Saeed,

    The strange thing is that the same code for BL0 runs when alone (the APP is not flashed), but stops working when the APP is present. A small insignificant change in the code can make it run again. Sometimes a change makes it run, but not normally. In one case for example, it runs, but I see that a static variable that I initialized, has a different value from the beginning by itself !. In another case, the BL0 and BL run normally, but later inside the application something goes wrong with the communication for example. I don't understand, how can something in BL0 affect the APP later, after DSP has jumped to the APP. BTW, the APP is 100% sure, so nothing is wron there.

    This sounds like there are issues with memory. Can you check the linker command files for BL0, BL, and the main application to make sure that there are no critical overlaps in memory? 

    Best,

    Matt

  • Hi Matt

    I had checked the linker files many times, but I checked again thoroughly. 

    Regarding FLASH: there is no overlap. Each application is linked to a separate range in flash. 

    sectors 0-1
    sectors 2-3
    sector 4* 
    sectors 5-9

    * for this, I used only half of sector 4, the same size as 2+3. I left the other half unused. But this is not the reason for the issue, I checked.


    Regarding RAM: There are some overlaps. but the whole RAM is cleared before the transition to the next one.
    Either the currently running application clears it at the end, right before jumping to the next one, or it's cleared by the next application itself, first thing right after the codestart (and wddisable)


    Best
    Saeed

  • Hi Saeed,

    What is overlapping in the RAM? 

    Just to make sure I'm still on the same page, BL (the second stage bootloader, as you defined) chooses between two applications in flash to copy to the RAM. Then, it clears the RAM and branches to the next application, or branches to the next application and is then cleared by it.

    Best,

    Matt

  • Hi Matt

    Regarding the overlapping in RAM, each piece of application has an independent allocation of RAM. The bootloaders all have similar RAM allocation. The main application has another one. Just as an example, LS5 might be used for .ebss in the bootloaders, while it is used for Cla program in the application. Totally independent memory map for each one.

    We have a first stage loader, BL0, two similar bootloaders as the second stage BL, and the main application (each dedicated one of the four flash ranges I mentioned in my last post). BL0 chooses one of the two second-stage BLs, copies the selected one from Flash to RAM, then clears the whole RAM (still in BL0), then jumps to that selected BL. 

    The whole RAM is cleared once again at the beginning of the main application. Only this time, it's cleared in the application itself at the very beginning, not at the end of BL before jumping to it. So each piece of application gets a clean RAM before starting to run. 

    To sum up, when jumping from BL0 to the selected BL, RAM is cleared right before the jump by BL0, while in the transition from BL to the application, it's cleared right after the jump by the application itself.

    Regards,
    Saeed

  • Hi Saeed,

    Thank you for reclarifying your boot process, that makes sense to me.

    To sum up, when jumping from BL0 to the selected BL, RAM is cleared right before the jump by BL0, while in the transition from BL to the application, it's cleared right after the jump by the application itself.

    My one concern with "clearing" RAM as we jump from one application to another is that the RAM should not be cleared after initialization. If RAM is cleared, it needs to be cleared before copying all ramfunc (and any other output sections mapped to RAM).

    Best,

    Matt

  • Hi Matt

    Yes that's the way it is now. In the initial boot, and in the following transitions between applications. Clearing RAM is always done before copying anything to it. RAM is never cleared after initialization in the same application.

    Best,
    Saeed

  • Hi Saeed, 

    Thank you for clarifying that, I will be looping in the RAM expert to provide further insight. 

    Best,

    Matt

  • Hi Matt

    Any update from your colleague?

    Please let me know if you need any additional information from me.

    Thank you,
    Saeed

  • Sorry for late reply. I don't see what specific query we have here related to RAM functionality ? 

    Vivek Singh

  • Hi Vivek

    I'm not sure what is causing the issue, RAM or Flash. I just know that I get this random issue when running the first bootloader from Flash. I don't see it when running from RAM. I read this post about the points to consider when modifying an application for Flash. I don't see anything wrong or overlooked, and I don't see why this problem happens randomly, not always. 

    Best,
    Saeed

  • Hi Saeed,

    Can you provide some details on an issue that is repeatable? It'll be difficult to pinpoint the issue unless the behavior is repeatable and consistent. 

    BL0_version1 + BL + APP >> runs, normal
    BL0_version2 + BL + APP >> doen't run

    For example, in this BL0_version2 that doesn't run, what behavior do you see? Is a variable being initialized with an unexpected value? Is the communication not working? Do you see the same behavior with BL0_version2 every single time? If you do, what is the address associated with the issue you're seeing? When you load the APP, do you see that particular memory address change?

    Do you see any issues branching from one BL0 -> BL -> App? Are the PC and RPC set the way you expect after branching?

    Kind regards,

    Skyler

  • Hi Skyler

    For example, in this BL0_version2 that doesn't run, what behavior do you see? Is a variable being initialized with an unexpected value? Is the communication not working?

    - in those cases dsp doesn't boot anymore, even after power cycle.

    quoting from my first post: "I debugged the issue and in the cases that the bootloader is not coming up, DSP stops somewhere inside the c_int00 assembly instructions. It reaches the GET_DATA and GET_ADDR loops, but somewhere something goes wrong. It doesn't reach DO_BINIT."

    Do you see the same behavior with BL0_version2 every single time? If you do, what is the address associated with the issue you're seeing?
    - yes, if one version of BL0 produces this problem, it will be there every time for the same specific version.


    Best,

    Saeed

  • Hi Saeed,

    How are you loading BL0, the secondary BL, and the APP? Is BL0 loaded via CCS and the secondary BL/APP loaded by BL0?

    Can you send the linker .cmd files and .map files associated with these projects?

    Kind regards,

    Skyler

  • Hi Saeed,

    Is this issue resolved? If so, I will close the thread.

    Kind regards,

    Skyler

  • Hi Skyler

    Sorry for getting back to you so late. I have been very busy with other things. Actually, no the issue is not resolved, it's on hold. Please keep the thread open. I will provide more information the first chance I get.

    Best
    Saeed

  • Okay, will do.

    Kind regards,

    Skyler