Problem Occurred: Flash programming with overlapping memory

My post in “An error occurred…”: Applied Debugging Rules gives some hints about how to isolate and solve some debugging problems. But here is a case where the tips did not help: I had this dialog with “Failed to resume target process” for my HCS08 project again:

Problem occurred
Problem occurred

The issue is: there is no useful information at all, and I’m up for guessing? Yes, there is a problem, but what kind of problem? Enabling the log for the console view did not help :-(.

Hmm, “Failed to resume target process” tells me something about the debugger not getting control over the target. I *think* the debugger started the flash programming. So he had control first, but then lost it during flash programming? Background: The debugger downloads a small program to the target which executes and performs the programming. Somehow that program on the target completely failed without returning a proper error code.

So I tried to download it with the HI-WAVE debugger from the non-eclipse based CodeWarrior, and voilà, it gives me this:

Code loading overlap detected in range 0x0000FFBD..0x0000FFBD

Ah! That debugger gives me the important hint! I love the eclipse based CodeWarrior debugger, but here it is shamefully failing.

The old HI-WAVE debugger gave me the hint: I have overlapping flash ranges. What is the problem? Checking the map file, indeed I have a memory cell assigned twice in flash:

MODULE:                 -- ProcessorExpert_c.obj --
     NVPROT_INIT                               FFBD       1       1       0   .abs_section_ffbd
MODULE:                 -- Cpu_c.obj --
     NVPROT_INIT                               FFBD       1       1       0   .abs_section_ffbd

And the reason is that I have the flash protection register set up twice in my code:

static const uint8_t NVPROT_INIT @0x0000FFBDU = 0xFFU;

So the problem is: the flash programming algorithm fails dealing with overlapping memory ranges, and the debugger fails to check for it or for returning a useful error message.

So I think the linker should catch this? Well, indeed he would warn me about this, but that message is disabled in my project:

-WmsgSd1100 -WmsgSd1912
Disabled linker messages with -WmsgSd1100 -WmsgSd1912

Disabled linker messages with -WmsgSd1100 -WmsgSd1912

Changing them to a warning (using ‘w’ (warning) instead of ‘d’ (disable) in the option)

-WmsgSw1100 -WmsgSw1912


Getting Linker Warnings

Getting Linker Warnings

Ok, that would have warned me. Fixing my code, the double allocation is fixed, and everything works now again. Good.

As a result, I have that linker messages now changed in my S08 projects. That way I get appropriate warnings. Still, I expect the debugger to report me a useful error message for such a failure. “Problem Occurred” in that case does not help. This issue has been submitted to Freescale, so hopefully things get improved over time.

Happy Problem Solving 🙂

2 thoughts on “Problem Occurred: Flash programming with overlapping memory

  1. This post saved my butt. Just thought you should know.

    Where would one go about learning these sort of esoteric details like changing those d’s to w’s? Is there some big fat CodeWarrior reference manual somewhere?

    Thank you!


    • Thanks for letting me know :-). There is no such magic CodeWarrior manual telling you this kind of things. And CodeWarrior is not alone: there are many secrets like this in the world. The internet and the search machines have helped me many times with other problems. That’s exactly the reason why I write about these kind of things in this blog: If I find out something I was not able to find elsewhere, I document it in the blog with the hope that others will find it useful. So that ‘big fat manual’ in my view is the internet and all the other folks out there writing things up for the benefit of everyone else.


What do you think?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.