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.

TM4C1294KCPDT: Issues using ROM-mapped functions in "new" code

Part Number: TM4C1294KCPDT


I'm getting the impression that one should start new firmware projects using the Flash-based Tivaware routines, and then only move to the ROM_ routines after the code has been proven.

I am writing test firmware as part of the hardware verification stage of my product development. I happened to start out using the MAP_ functions in Tivaware driverlib, assuming that Flash usage will be a concern in the future, and also assuming that downloding code changes should be quicker if the driverlib is not compiled into my image.

What I have noticed is that my firmware seems to hang at random, but only with new code that I add. At first, I looked around for all of the usual suspects like pointers and interrupts, but quickly eliminated those. The really strange part is that I'll #if out the problem code and then move on to accessing new peripherals and then after a few revisions I'm able to include the previously problematic code and it works! Only the newer sections cause problems. The fact that old code suddenly works without being rewritten (just being included verbatim to what failed before) is highly frustrating.

Eventually, I decided to stop using the ROM_ functions so that I could step into the driverlib functions to diagnose the problems. I accomplished this by removing the rom.h include, but retaining the rommap.h include. Thus, my code is written with MAP_* but I assume that none of the ROM_* functions are available without rom.h included. As soon as I did this, I started geting compiler errors. I fixed those compiler errors by adding headers for various peripherals that I am using. This seems to have banished the mysterious behavior. I haven't tested things by going back to the ROM, but I assume that the ROM_* code would now work better, now, because I've included all of the necessary headers.

In summary, it seems that the compiler may not be complaining about all of the missing headers when accessing peripherals via the MAP_* macros and when including both rom.h and rommap.h - and my hunch is that the random failures in my code were due to my firmware calling ROM_ functions that did not have proper C language declarations, and thus were perhaps sending parameters to those functions incorrectly, leading to catastrophic failures.

As a result of this experience, my recommendation is that folks creating new firmware should probably turn off the ROM option at first to make sure all of the necessary headers are in place. After comfirming functionality, it should then be safe to switch over to the ROM library and save space.

Is there something that I'm missing? I'm fairly certain that I was not getting any build errors. Code Composer Studio usually refuses to run my firmware if there are serious build errors. I was clearly getting highly suspicious behavior until I put aside the ROM, at least temporarily.

Comments welcome.

  • Interesting post - thank you.

    If indeed this is an issue - would not (many) others have had a similar experience?     (we suspect that not all would be to your level - but surely vendor staff would have detected such behavior.)

    Unfortunately - we note that "not all" vendor discoveries/finds are published or promoted.     (i.e. they remain "quiet" until that particular issue arrives/erupts...)

  • Hi Brian,
    I am sorry to hear you were having problems. I have not heard similar issues from other users. In general when we find an issue with a ROM based function, we correct the issue in the flash based version and then deprecate the ROM version by removing its definition from rom.h. I personally make extensive use of the ROM based functions by using the "MAP_" prefix. If there is a particular function you suspect, please let us know so we can check it out.

    I also encourage any other users to add to this post if they have had a similar experience.

    Also, Brian, thank you for posting such a good way to switch between ROM and Flash based functions by using the MAP_ prefix and commenting out the inclusion of "rom.h".
  • To clarify, I don't think there are actually any issues in the ROM. Observed behavior changed from one build to the next, and I believe that I've been able to get correct results from every ROM function I've used - just not with every build. My best theory is that I'm seeing compiler issues.

    My hunch is that including rom.h fools the compiler into thinking that it has a prototype for the ROM functions, even though the headers for a particular peripheral have not been included. This results in the compiler producing incorrect code for calling the ROM function. When I remove rom.h, the compiler complains about missing prototypes, and I have to include the matching headers for the given peripheral. Granted, my success merely means that the equivalent non-ROM functions are working, but I suspect that there is more to it.

    After I have spent more time filling out my firmware to exercise all of the hardware on my board, I plan to go back and add rom.h to confirm that everything still works.

    Bottom Line: My post is intended as a warning to those who are building up new firmware from scratch, as opposed to editing examples that already have all of the appropriate headers included.

    The warning is: Do not rely on the compiler to find and warn about missing function prototypes if you're using rom.h! Either turn off ROM mapping, or be very careful to include all of the appropriate headers.

    If anyone can confirm what I'm seeing, or suggest a Code Composer Studio setting that would refuse to run builds that don't have proper function prototypes, then please reply here.