Cart New Account Login

HomeAbout usProductsSupportForumsBlogCustomer Service

search inside this forum
Kinetis ERROR 51 during programming!
Jon W. Apr 25, 2016 at 05:12 PM (17:12 hours)
Staff: Gerardo R.

  • I am using a Kinetis KL04Z32 with CodeWarrior for MCU version 10.6.  I'm using a P&E Micro Multilink Universal debugger.

    I have a project that has been working for many months. In this project all code is linked to flash memory. I have recently had the need to run some code out of RAM. I changed my linker command file to add a new, user-defined, section to the .data section. The .data section now includes my new RAM functions along with constant data that has been there all along. At startup all of this data is copied from the load address in flash to the run address in RAM. When I invoke a debug session in CodeWarrior the flash in the KL04 is erased and programmed as usual. After the program phase there is a CRC verify phase. With my new code, that links some functions into RAM, this verify phase fails. Here is the console output from CodeWarrior.

    CMD>RE
    INF: Initializing.
    INF: Target has been RESET and is active.
    INF: CMD>CM C:\Freescale\CW MCU v10.6\MCU\bin\Plugins\support\arm\gdi\P&E\kl04z32m4_pflash_pipeline.arp
    INF: Initializing.
    INF: Initialized.
    INF: ;version 1.03, 07/17/2013, Copyright P&E Microcomputer Systems, www.pemicro.com [mk_32k_n_pflash_m0]
    INF: ;device freescale, kl04z32m4, 1x32x8k, desc=pflash_pipeline
    INF: ;begin_cs device=$00000000, length=$00008000, ram=$20000000
    INF: Loading programming algorithm ...
    INF: Done.
    INF: CMD>EM
    INF: Erasing.
    INF: Module has been erased.
    INF: Initializing.
    INF: Initialized.
    INF: ;version 1.03, 07/17/2013, Copyright P&E Microcomputer Systems, www.pemicro.com [mk_32k_n_pflash_m0]
    INF: ;device freescale, kl04z32m4, 1x32x8k, desc=pflash_pipeline
    INF: ;begin_cs device=$00000000, length=$00008000, ram=$20000000
    INF: Loading programming algorithm ...
    INF: Done.
    INF: CMD>PM
    INF: Programming.
    INF: Processing Object File Data ...
    INF: .
    INF: Programmed.
    INF: CMD>VC
    INF: Verifying object file CRC-16 to device ranges ...
    INF: block 00000000-000000BF ...
    INF: Ok.
    INF: block 00000400-0000040F ...
    INF: Ok.
    INF: block 00000800-00004FFF ...
    INF: CRC-16 Error in block. (File = $1905, Device = $806F)

    After this the debug session terminates. It seems, however, that the code did program successfully into flash. If I power cycle the board it comes up running, including my function that is now running out of RAM. It seems that something went wrong with the VC command that is doing the CRC check. So, while it seems I can create and download code, I can no longer debug.

    Jon




    Comments

  • We run our flash programming routines out of RAM so it doesn't surprise me that this use case would give you a lot of weird issues. I'm not exactly sure how you'd need to setup the project right now, but for this to work you'd need to load the RAM data some other way after the flash has been programmed and debug without reflashing the part. I'll let you know if I can find a workaround for you.

  • Gerardo,

    Thanks for getting back to me so quickly!

    I believe, the way I have the code being linked, nothing should be copied to RAM until AFTER I start running my code. That should happen in some low-level code just before the call to main(). It is not my intent to load anything directly into RAM when the debugger is loading code. Do you think that's what is happening since the function's run address is in RAM withing the .elf file?

    Thanks,
    Jon

  • Gerardo,

    I think I've found a potential solution. Your comment got me thinking about what sections may be getting downloaded when I launch a debug session. If you don't mind please let me know if this makes sense.

    In CodeWarrior I went into the settings for my Debug Configuration. On the Debug tab I went to the Download sub-tab. Here I can choose what sections get downloaded. If I un-check Uninitialized Data everything seems to work.

    Thanks,
    Jon

  • It's a bit difficult for me to verify this setup without the project in front of me. I can't quite explain exactly why this works for you, but it likely has to do with the order of how CodeWarrior performs these operations. I'll have to look into this in more detail, but we don't have too much control over it if that turns out to be the case.

  • Hi,

    I'd just like to say that I have had the same problem, and Jon's solution worked for me too. I had added a new section in the initialised data area with some code to run from ram (for flash programming routines). Turning off the uninitialised data from the download options for the debug session fixed things. I can't think why uninitialised data should be downloaded in the first place, nor why it should cause problems here - but the workaround works.

    I have used the same sort of code-in-data arrangement in KDS projects too, and there was no problem then. So I suppose the default settings are fixed. This is a modification to an old project, so it uses the old CodeWarrior tools rather than KDS.

Add comment


   Want to comment? Please login or create a new PEMicro account.







© 2017 P&E Microcomputer Systems Inc.
Website Terms of Use and Sales Agreement