CodeWarrior 8- & 16-bit tools: Securing MC9S12A64?

Showing results for 
Search instead for 
Did you mean: 

CodeWarrior 8- & 16-bit tools: Securing MC9S12A64?

Contributor V
To help you find solutions to problems that have already been solved, we have posted this message. It contains an entire topic ported from a separate forum. The original message and all replies are in this single message.

Posted: Oct 19, 2005 - 01:44 PM   

To enable the security feature of the MC9S12A64, I put this line in my code:

const unsigned char securitybyte @0xFF0F = 0x00;

When I now click on "Debug", Hi-WAVE successfully loads the program to the flash, and securing seems to work because i can't debug anymore.

But the program doesn't run anymore! Well, at least not as it should. I've checked many things now:

small test programs still work correctly (e.g. blinking LED's, changing PWM's, ...)

"unsecure..." from HI-WAVE works too. I can then load another program to the device

I also tried to 'unsecure' the device in SW after startup by writing the password words to 0xFF00-0xFF06, didn't work either.

I'm not sure if the secure feature prevents the device from accessing external components on the data/address bus or if the *whole* program gets written to the flash (I can't use the debugger to find out).

Does anyone here have experience with this feature? Could it be that HI-WAVE doesn't write the flash location 0xFF00-0xFF0F last but in between other blocks so that other blocks can't even be written to anymore? If yes, how could I prevent it from doing so? 
Posted: Oct 20, 2005 - 06:30 AM   

Some more information:

The reason the program doesn't work anymore is that all data/address signals usually going out to the external chip we have mapped to address 0x1000-0x1080 don't work anymore. There just aren't any signals anymore!

I know that the IVIS-bit doesn't work in secure mode, but we don't have that set in non-secure mode either and the signals appear there.

Any ideas what I can do to force those signals to appear again when non-flash addresses are read/written to? 

Posted: Oct 21, 2005 - 11:31 AM   

The HI-WAVE flash programming algorithm should not be an issue here. The chip will only be secured the next time when the board is reset.

That means it does not matter when the flash programming algorithm is setting the security bit. The application will be programmed to the end and the chip will be secured only upon next reset.

Can you please check to see if the application is working as expected in stand alone (i.e. without securing the chip and without debugger connected).

You just need to load your application in flash, close debugger and apply a power on reset to your board. The application should be running then.

Is the application working as expected in that case? If this is not working then you have an issue with you chip configuration.

I hope this helps.


Ron Liechty
Ombudsman for Metrowerks 
Posted: Oct 24, 2005 - 03:02 PM   

Some more research:

Seems Processor-Experts changes some settings automatically if you switch the startup mode from "Singe Chip" to "Expanded Narrow". That's why there weren't any signals anymore on the data/addressbus.

And of course, the whole program runs very well if the protection isn't activated.

But now it seems I'm screwed. The print is finished, and we have made it so that the processor starts up in single chip mode. But we must change that later to narrow-expanded so we can access the external chip. But that doesn't work when the chip is secured 

I thought I could unsecure the chip, change the mode, and then secure it again. But I can't get it secure again after doing the unsecure steps (writing the password bytes to 0xff00-0xff06). Or is there a way to secure the chip again which I haven't found yet?

I also tried to make the chip start up in expanded-narrow mode. But then the program doesn't run at all - I have the first line in main() setting a pin to high to turn on a LED, but that line is never reached! So I guess in expanded-narrow the processor expects the program in external memory?
Is there maybe a way to have the processor start up in narrow-expanded mode but still start the program from internal flash?


Labels (1)
Tags (1)
0 Kudos
0 Replies