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.

RM57 Flash Programming Error

Other Parts Discussed in Thread: HALCOGEN, UNIFLASH

Hello,

I'm new to the forum, so please be patient with me. I have an RM57 HDK and I used HALCoGen to create a FREERTOS project. From inside CCS 6.0.1.00040 I compiled and setup a debug configuration using XDS100v2 USB Debug Probe_0/CortexR5. Next, I initiated a debug session and CCS seemed to program my board OK. Unfortunately the image didn't work and I tried to re-start so that I could step through the code to debug. The second time CSSS tried to program the flash upon a debug session it failed. The error output I see is:

CortexR5: GEL Output: Memory Map Setup for Flash @ Address 0x0

CortexR5: GEL Output: Memory Map Setup for Flash @ Address 0x0 due to System Reset

CortexR5: Flash Programmer: Error erasing Bank 0, Sector 0. Operation Cancelled.

CortexR5: GEL: File: C:\Users\Rlentz\workspace_v6_0\HelloWorld\Debug\HelloWorld.out: Load failed.

CortexR5: GEL Output: Memory Map Setup for Flash @ Address 0x0 due to System Reset

At this point I see a red LED lit on the board which goes away after a power cycle and some long period of time. I can't seem to do anything with the board now. I tried power cycling the board and I tried exiting and re-opneing CSS. No combination of those things seem to help. Can you help with identifying what I did wrong?

Thank you,

Ray

  • I saw that Wonjae had a similar problem with not being able to erase flash on a custom RM57. He reported that he erased the flash with uniflash. I can't get uniflash to erase an RM57. Does someone know what I've done wrong?
  • OK, I discovered one issue over the weekend. The Uniflash application is a little finiky about how it's installed. I didn't have the right update for RM57 support because I selected all support when I installed Uniflash. I un-installed Uniflash and re-installed selecting support for the Hercules controllers and TI emulators only. After installation Uniflash updated OK and support for the RM57 appeared. Unfortunately, the board still fails to erase flash - I'm begining to suspect a hardware failure and I'm going to call TI support.

  • I replaced the RM57Lx board and tried again. This time I used the Hercules Demo App to 1st verify the new board works correctly. Next:

    1. I used Unifalsh to just erase the board (that worked OK),
    2. I used the Hercules Demo App to restore the board (that worked OK),
    3. I used CCS to download my FreeRTOS application to the board
      1. The download worked, but the image didn't behave as expected,
    4. I used CCS to debug the image
      1. Upon trying to erase the flash and re-download the image CCS failed again trying to erase flash (bank 0, sector 0),
    5. I used Uniflash to attempt to erase the flash - it failed the same way,
    6. I tried the Hercules Demo App to attempt to restore the board - it failed the same way.

    I went back and forth a couple of times between Uniflash and the Hercules Demo App and on one iterration I successfully erased flash. After that I restored the board using the Hercules Demo App again and everything works.

    Now I suspect that the Oscillator frequency is not set correctly to support the emulator flash application. I notified a field engineer (Mark Swanson) and I'm waiting to find out what the issue is. I've lost two weeks of productivity over this issue. 

  • Ray,

    It seems that you can still connect to target (CPU) via CCS. If it is true, I would would suggest you to do a system reset from CCS before loading the new image. Sometimes we saw people not being to connect to target due to errors in the application code. The CPU starts execution from address 0x0 after the reset is released. When you connect to the target, the error in your application may already occur. If the error causes something in the device to some unknown states (repeated resets, for example), the user will have a hard time to reconnect the target and reflash. To make the debugging easier, I would like to suggest you to replace the instruction at address 0x0 with the "branch to itself" instruction "b #-8". With is change, CPU will be "locked" at address 0x0 after reset. You will need to use the debugger to force CPU out. In this way, you will have full control of the CPU execution after reset. Error in the application code will be cause trouble in reflashing the image.

    Thanks and regards,

    Zhaohong
  • I apologize I could have provided more information, but I was trying to stay as brief as possible. I tried RM57 power on reset, RM57 power cycle, closing/re-opening CCS.Uniflash and none of that seemed to make a difference. I even went as far as connecting to different Windows computer with Uniflash and CCS installed and got the same result.
  • Can you connect to target (CPU) after you observed error in your application?

    Thanks and regards,

    Zhaohong
  • Zhaohong,

    I'm not sure I understand what you mean by "connect to the target CPU" after I observe an error in my application. Here is the sequence of events that happened to me:

    1. I used CCS to download an image I built to the RM57Lx HDK,
    2. Using the debugger in CCS, I launched the application,
    3. The application did not behave as I expected (I expected to see LEDs blink on the HDK),
    4. Using the debugger I stopped execution of my application, set a breakpoint, and re-started the application,
    5. The debugger tried to re-load my application, but failed to erase block 0, sector 0 of the flash,
    6. After this point there is no recovery - CCS cannot erase/restore the flash, Uniflash cannot erase/restore flash and the Hercules Demo application cannot erase/restore the flash.

    After step #5, the Hercules Demo application identified the board as an HDK, but could could not identify it as an RM57. I sent the board back and got a replacement. I executed the same steps and had the same result with one difference - the Hercules Demo app correctly identified the board as an RM57 after step #5. I tried several times to install the Hercules Demo software and was finally successful. Since then I've done nothing with the board - I've been trying to get help on this forum.

    I hope this description helps. You can call me at (321) 727-5806 to discuss if you like.

    Ray

  • Ray,

    The theory here is that the error in your application code causes the Flash programming not working correctly. The confirm this theory, we need to do flash programming when the device is in the default state. Would you please try the following.

    (1) Connect to target in CCS.
    (2) From theCCS "run" menu, select "reset", and then select "system reset". This operation will reset most of the device..
    (3) Download a working flash image and see if it works correctly.

    Thanks and regards,

    Zhaohong
  • Zhaohong,
    I tried what you suggested and had the same result. I think I understand what you're suggesting. My application may be preventing the flash programming utility from being loaded into memory, or running if it is successfully loaded into memory. However, CCS only presents the "reset" and "system reset" options in the run menu once it connects to the target. After the error I experience I cannot connect to the target because CCS is trying to re-load the flash with my image. Is there a way to tell CCS to connect without re-flashing the image? I assume I would have to point it to the ".out" file currently programmed into flash. In any event, the Hercules Demo app was able to recover again after about three tries.
  • Zhaohong,
    I forgot to mention that my application becomes unresponsive once the FreeRTOS scheduler starts to run. I tried setting a breakpoint in one of my tasks, but it appears the task is not executing. The FreeRTOS project is built directly from the HALCoGen tool - can you ask them what might be going on? I built a similar project for the RM46 and used the same tasks - it works as expected...
  • Zhaohong,
    I discovered at least one problem and have started making progress. Apparently, the FreeRTOS project does not initialize the task stack size and/or the heap size large enough to do anything interesting. I changed the stack size from 128 words to 512 words and I changed the heap size from 8192 words to 16384 words. After amkiing these two changes, the application is running properly. I have a red LED lit that I didn't expect to be lit, but that's a minor issue for now. I believe I've solved my initial problem.
  • Zhaohong,

    I can now run my application - a FreeRTOS app with two tasks running. Each task runs one of the "adapted" Hercules LED demos, then logs a message to a queue for the other task and waits for a message on its own task. A very simple adaptation just to demonstrate the ability to run two tasks and do some minimum inter-task communication. The LED demos run fine, however I still have issues.

    First, the red "error" LED on the RM57Lx HDK stays lit all the time when running my application,

    Second, I cannot re-flash my application using CCS or Uniflash directly.

    What I've done so far is:

    First, I can repeatedly re-flash by using the Hercules Demo Application to first restore the demo app, then go back to CCS and start a new debug process. This actually works only on the second attempt with the Hercules Demo app, but it works repeatedly. I know the Hercules Demo App uses Uniflash as well, but the reflash only works from the Hercules Demo app.

    Second, I used "WinDiff" to look for differences in the source and header files between my application and the Hercules Demo app. The "license wording" at the top of the files has changed and some macros have been expanded in the FreeRTOS files. There are too many differences for me to efficiently spot any issues. Can you please help debug this problem? Would it help if I zipped up my RM57Lx CCS project and get it to you?

    Thanks for your help,

    Ray

  • I couldn't find an explanation for what causes the red error LED light on the RM57Lx HDK to turn on. I may have missed it in the documentation, but I don't know how to start troubleshooting since I don't know what could be wrong. Can you point me to documentation that explains how the red error LED works - that is what drives it and under what conditions it illuminates?

    Thank you

    Ray

  • Ray,

    I would suggest you to take a look at the ESM status registers to see the type error. I am guessing that the error LED is caused by Flash or RAM ECC errors. You need to make sure that the ECC is set for ENTIRE Flash and RAM. RAM ECC is initialized when RAM is initialized. You need to have your flash image to cover the entire range of Flash (4MB). Cortex R4/R5 uses speculative fetch to minimize the the bottleneck of accessing normal memory. The speculative fetches can go beyond the memory range used by your application.

    Thanks and regards,

    Zhaohong
  • Ray,
    Please take a look at the below post to see if it matches yours.
    e2e.ti.com/.../1287789
  • Hi Ray,
    Sorry the link I sent is an internal link. Can you tell me if you are seeing the Error LED immediately after you connect to the target? If you check the ESM status register does it indicate Group2 channel 2 (CCM-R5 CPU compare error)?
  • Charles/Zhaohong,
    I'm new to the Hercules MCU and I'm not very good at navigating the tools or the specific registers. However, I found that I could export the register values once I connected to the MCU. How can I send the file to you?
  • Hi Ray,

      Can you find out the values for Stat1, Stat2, Stat3, Stat4...Stat9 registers under the ESM module in the CCS registers window as shown below. You can insert the file when you reply to the post. When you try to reply a post, make sure you click on the "Use rich formatting" at the lower right corner of the text window. You will be able to see the icon to attach file.

  • Yes, Stat1 is 0x80000000 and the others are all 0x00000000.

    7367.Registers.txt

  • Hi Ray,

      I see below two register values. The Stat2 is for the ESM Group2 error status and it indicates a CCM-R5 CPU Compare Error. This is a known issue. We will publish an updated errata which will include this problem. CCM-R5 is a module whose main function is to constantly compare the outputs between the 2 lockstep CPUs. Whenever this is mismatch, it will signal the ESM module. However, CCM-R5 should not compare the CPU's outputs when in debug mode. A halting debug event can be asynchronous to normal program flow and cause the CPU to lose lockstep. What happens is that in RM57, the CCM-R5 by mistake continues to compare the two CPUs in debug mode. This only happens when you connect to the target the first time. Afterward, there should be no more mismatch detected. What you can do right now is to clear the LED and continue with your application. To clear the LED it depends if you have done any flash programming right after you have connected to the target. Here are the options.

    1. If you just power cycle the device and connect to the target the first time and you see the LED, you can clear the LED by writing 0x5 to the ErrKey register in the ESM module.

    2. If you power cycle the device and connect to the target but you went ahead to do some flash programming while the LED is ON, then you will clear the LED by first writing 0xA to the ErrKey and then followed by another write of 0x0 to the ErrKey register in the ESM module.

    Once you clear the LED it should not turn on unless there is a "real" mismatch between the two CPUs. Also if your target is not connected to the debugger and you simply let the device free run, it should not turn on the LED.

    R Esm1_Stat1 0x0000000B 0x80000000
    R Esm1_Stat2 0x0000000B 0x00000004

  • Charles,

    I'm not sure I agree with everything in your analysis. I'm not sure how detailed you've followed this thread, but when I use the Hercules Demo software I don't have any issues with errors/faults or the red error LED. When I use the HALCoGen tool to create a project for the RM57Lx using FreeRTOS I have the error/fault issues discussed in this thread with the flash and the red error LED.

    I added to the HALCoGen project source code I borrowed from the Hercules Demo code to turn on/off the white LEDs. I used that code to show that I could have two tasks running under FreeRTOS with each doing work (in this case turning on/off the white LEDs). I'm going to try compiling the HALCoGen project without the code I borrowed from the Hercules Demo and see what happens.

    Ray

  • Charles,

    I tried the following:

    1. Comment out everything in "HL_sys_main.c" in the main routine so that only the OS is created and nothing else happens,
    2. Start un-commenting things until I could get a failure.

    When I did this I noticed I would get the red LED intermittently - either when I strated to erase flash, or immediately after my application downloaded from the CCS debugger. However, in all cases I was able to use the CCS debugger and erase/re-program flash - something I was not able to do before.

    This behavior persisted while I un-commented things:

    1. First I uncommented the creation of tasks queues - red LED behaved the same, CSS debug was able to erase/re-program flash,
    2. Next I un-commented the creation of the tasks -  red LED behaved the same, CSS debug was able to erase/re-program flash,
    3. Finally, I un-commented the start of the FreeROTS scheduler  - red LED behaved the same, CSS debug was not able to erase/re-program flash,

    I had to revert to the Hercules Demo application to successfully erase the flash again and recover the RM57Lx HDK board. It appears when I ran the LED demo code I borrowed from the Hercules Demo application I got the "hard" failure that CSS and its debugger could not recover from. That is CSS and the debugger could not erase flash. I find this interesting since it appears that the Hercules Demo application uses uniflash as well to erase the flash. The other curiosity is that the Hercules Demo application fails on the first attempt to erase flash but succeeds the second time repeatedly.

    I'm attaching my CSS project file in the case you're inclinded to investigate this behavior. I won't be at work tomorrow (my company has a 9 day 80 hour schedule), but I'll be back Monday morning.

    Thanks for all your help to date,

    Ray

    3377.HelloWorld.zip

     

  • Hello,

      For some reason I'm not able to rebuild your project. However, I simply load your .out file into the device and I'm able to see the various white LEDs blinking. I also see the red error LED. When I tried to reload the same .out, I will fail with a 'Load failed" msg.

      To continue with the flash programming I do the below steps:

      1. Reset the device. You can do this via the CCS from Run->Reset->System Reset in the Debug perspective

      2. Go to the ESM register in the Registers window

      3. First write a 0xA to the ErrKey register

      4. Second write a 0x0 to the ErrKey register again

      After you perform the above steps you will be able to clear the nERROR. Somehow the flash programming wasn't able to proceed because of the nERROR. Try to reload your code again and I think it should work.

      I suspect the root cause of the problem is in the HL_sys_startup file. I have the code snippet below. The cache is enabled via the _cacheEnable_() is called before the global variable initialization via the __TI_auto_init(). Please try to reverse the order of these two functions by calling __TI_auto_init() before _cacheEnable_(). Please let me know if it makes a difference such as allowing you to program/erase without anymore loading errors.

        _cacheEnable_();
    
    /* USER CODE BEGIN (24) */
    /* USER CODE END */
    
    
    /* USER CODE BEGIN (25) */
    /* USER CODE END */
    
            /* initialize global variable and constructors */
        __TI_auto_init();

     

  • Charles,

    After I modified HL_sys_startup.c as you recommended the RED LED light is not lit during my demo application execution. However, I still have the flash programming error issues. Your instructions for clearing the nERROR cannot be followed as you have written them. The registers can only be written to during an active debug session. Once they are written, the debug session must be exited before the image can be downloaded through CCS or Uniflash directly. When exiting the debug session, the CPU is reset and red LED light re-appears. I can still recover with the Hercules Demo application as I described before.

    Once I recover the RM57 using the Hercules Demo application and go back to CCS to re-program my image, the red LED illuminates immediately when the flash programming operation begins, but it clears as soon as my application begins execution. I'm convinced this problem is being caused by something in the HALCoGen generated project. For now, I have a work around and plan to continue with my prototyping effort. However, before I can produce a deliverable application I need this problem to be fixed. Maybe you can engage the FreeRTOS application engineers in this issue.

    Thanks for your help,

    Ray

  • Hi Ray,
    When I ran your executable, I found the nRROR was due to ECC bus error while the CPU was in the __TI_auto_init() performing global variable initialization. There was a LDR operation at the end from the address 0x1840. There is nothing wrong with the data at this location. It has proper ECC. I think the problem is that the data at this location happens to the last data in the initialization table. When the cache is enabled before __TI_auto_init(), a read from the address 0x1840 will cause the CPU to perform a cache refill of an entire cache line. One cache line is 32 bytes. Other than the data at 0x1840 the remaining bytes are in their erased state including their corresponding ECC checkwords. When the cache refill is performed these erased data are detected as uncorrectable ECC errors. This is the reason that if you reverse the order between enabling the cache and performing global initialization will remove the LED. Anothe way which is actually the recommended way to solve this problem and other potential issues is to intialize the erased regions with their proper ECC checkwords so that the CPU will not detect them as errors. Cortex-R5 has the capability to perform speculative fetch. If the speculative fetch is performed on an erased location without an initialized ECC, you will see the nERROR LED again.
  • Charles,

    I have both an RM46Lx and an RM57Lx HDK. I used HALCoGen to generate a FreeRTOS project for each target platform. The changes I made in both projects are:

    1. I changed the task stack size to 256 (from the default 128),
    2. I changed the heap size to 16384 (from the default 8192),
    3. I set the EMAC address to 0x00 0x08 0xEE 0x03 0xA6 0x6C (as recommended by TI so that I can later integrate LWIP)

    I used the exact same led_demo.c file I borrowed from TI and my sys_main.c modified to run two tasks that call methods in the led_demo.c file. This post has been all about the issues I've had with the RM57Lx HDK - flash programming and the red error LED. I've had no issues with the RM46LX - no flash programming issues, no issues with the red error LED.

    For this reason, I believe something is not right in the TI support for FreeRTOS in HALCoGen. I'm moving on to try and integrate LWIP.

    Thanks for all your help,

    Ray