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.

F28M35H52C: fprintf stops working after CPU reset.

Part Number: F28M35H52C


I am executing a program from RAM in the C28x. To debug it, I use the fprintf function which now works properly (after taking into account things said in ). When I launch, connect and load the program on the target it does what it is expected to do. The problem appears when I apply a CPU reset to re-run the program. Since C28x must boot from RAM, I have a program in FLASH for the M3 to make it boot there so I have to connect and apply a CPU reset there too. This is fine, I have checked that the C28x go to the main function correctly. However, when it gets to the function fprintf, the second time since I first launched the target because this is after the reset, this message appears in the console:

[C28xx_0] Write error: Invalid File ID (3) in CIO message!

I do not understand why fprintf stop working after the reset. I have tried using fflush thinking that, since I applied the reset in any moment, there could be a problem with the buffer but it did not help. I also specified where the .cio section must be allocated in the cmd file because when I did not do this, it was placed in a space in RAM M0 reserved for the boot rom stack. This neither helped out.

I know this is not a real problem for the application development since I can terminate the debugger and relaunch it (and it will work fine, the first time) but I would like to know why this is hapenning. Could it be related to the fact that I am loading the program in RAM memory? I am not sure if I understand what happens after the CPU reset that I click within the debug view toolbar.

I am using Code Composer Studio v7.4.

Thanks in advance.

  • Hello user,

    this looks like a case of 'my program is working when I load from debugger, but doesn't work when I try to run it from reset'. We would need to do some debug to get you help with the problem.

    One thing you mentioned about .cio section using the boot ROM reserved memory, I believe you fixed this. Yes no part of the application should have any anything assumed to be initialized correctly in the boot ROM reserved memory. Application can re-purpose this part of RAM but coming out of reset the boot ROM on device uses this RAM for boot so no initialized constants will be available.

    Secondly, when you first target connect and load code onto C28x your applications with fprintf works fine, does it work fine after you do a debugger reset and restart on C28, without having to re-load the project?

    Next thing I want to make sure that we alienate the problem to fprintf inclusion, can you check if this problem happens only if your application uses fprintf, if you don't use fprintf or try with a simple blinky/loop code on C28 you don't have this problem?

    Best Regards

    Santosh Athuru

  • "One thing you mentioned about .cio section using the boot ROM reserved memory, I believe you fixed this. Yes no part of the application should have any anything assumed to be initialized correctly in the boot ROM reserved memory. Application can re-purpose this part of RAM but coming out of reset the boot ROM on device uses this RAM for boot so no initialized constants will be available."

    Yes, I have seen the .map file and there is no problem with this.

    "Secondly, when you first target connect and load code onto C28x your applications with fprintf works fine, does it work fine after you do a debugger reset and restart on C28, without having to re-load the project?"

    That is exactly what I have done and it did not work (after reseting and restarting from the debugger, of course, the first time I execute it, it does what I expect perfectly).

    "Next thing I want to make sure that we alienate the problem to fprintf inclusion, can you check if this problem happens only if your application uses fprintf, if you don't use fprintf or try with a simple blinky/loop code on C28 you don't have this problem?"

    That is right, I do not have any problem if, for example, I comment out the function that uses the fprintf.

  • Hello user,
    thanks for confirming the above.

    You mentioned that the application doesn't work, once it hits fprintf() after reset->restart->run. I'm assuming that after reset and restart, the program control reaches main() and you are able to step through the code till it reaches fprintf() and that is where you see the error.

    one thing I forgot to ask or didn't see, is that the fail occurs at the first fprintf() or fail occurs after a few?

    What happens if you do a program re-load after you hit reset ? below steps:
    1> reset
    2> program re-load
    3> reset
    4> restart
    5> run (does it execute any fprintf()s and fail after a few?)

    What happens in below sequence, second time after you reset?
    1.> reset
    2.> program re-load
    3.> program control is already at main()
    4.> run (does it execute any fprintf()s and fail after a few?)

    I'm trying to establish :- if the first run after target connect and program load is just by chance, because of the way the memory is initialized when target is connected?
    Also I'm trying to see if this is a stack/heap problem? using C I/O calls need bigger stack and heap sizes compared to applications that doesn't use the C I/O routines.

    Please go through below wiki, it might help you with your debug as well.
    processors.wiki.ti.com/.../Tips_for_using_printf



    Best Regards
    Santosh Athuru
  • Hello and thank you for answering me again. Here goes my reply:
    "You mentioned that the application doesn't work, once it hits fprintf() after reset->restart->run. I'm assuming that after reset and restart, the program control reaches main() and you are able to step through the code till it reaches fprintf() and that is where you see the error."
    You are right with this.
    "one thing I forgot to ask or didn't see, is that the fail occurs at the first fprintf() or fail occurs after a few?"
    This is kind of tricky. Now I am trying it and it always fails after the first fprintf but I remember that occasionally it failed after some executions (I could not reproduce it).
    "What happens if you do a program re-load after you hit reset ? below steps:
    1> reset
    2> program re-load
    3> reset
    4> restart
    5> run (does it execute any fprintf()s and fail after a few?)"
    I tried this sequence:
    1>click on debug icon (launch and load as far as I am concerned)
    2>execute for the first time (everything is ok)
    3> reset
    4> program re-load
    5> reset
    6> restart
    7> run (it failed at the first fprintf() call)
    Then I tried this sequence which is the same than the latter without the execution done in the second step:
    1>click on debug icon (launch and load as far as I am concerned)
    2> reset
    3> program re-load
    4> reset
    5> restart
    6> run (everything is ok).
    "What happens in below sequence, second time after you reset?
    1.> reset
    2.> program re-load
    3.> program control is already at main()
    4.> run (does it execute any fprintf()s and fail after a few?)"
    I tried this sequence:
    1>click on debug icon (launch and load as far as I am concerned)
    2>execute for the first time (everything is ok)
    3> reset
    4> program re-load
    5.> program control is already at main()
    6> run (it failed at the first fprintf() call)
    "I'm trying to establish :- if the first run after target connect and program load is just by chance, because of the way the memory is initialized when target is connected?"
    It never failed at the first execution and it always failed at the second (most of the times at the first execution of fprintf but I remember some cases in which fprintf was called a few times before the error).
    "Please go through below wiki"
    I have seen it but none of what is there helped me out with this issue. I have increased heap and stack but it was exactly the same.
  • Thanks for the steps, would you be able to dump the entire RAM memory contents after the program load, before you run first time and dump the RAM contents after a reset and restart before run.

    Would you be able to compare the two memory logs and identify the differences? You should be able to see which memory region have different values and what section of your application is mapped to that region and then answer why it is different?

    Best Regards
    Santosh Athuru
  • That is a good idea, I will see what I can find out. If I realize about something, I will write you back.
    Thank you.