Flash and EEPROM protection in MC9S08DZ60

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flash and EEPROM protection in MC9S08DZ60

980 Views
Lodhart
Contributor I

Hi, I don't know how to use protection. Exactly where can I change NVPROT.

If I understand, I can write to NVPROT. And after reset NVPROT is loaded to FPROT. So, for example, if I send message to MCU to change protection (through USB or CAN). And some function in MCU change the NVPROT. I must restart the MCU to update FPROT?

Labels (1)
0 Kudos
3 Replies

393 Views
kef
Specialist I

On S12 devices FPROT register is writeable at runtime. It is made so that you can write protect more than already protected and can't remove write protection from already protected memory. NVPROT byte in flash defines reset-default value of FPROT register.

On S08D FPROT register is not writeable at all. You can only program NVPROT byte, which can be done only once at runtime, since minimum level of flash write protection will write protect NVPROT byte. Of course you can keep flash not write protected, then you may change EEPROM protection as many times as you wish. Yes, you must rest to apply new protection setting.

My bootloader for S12 defines NVPROT byte to write protect only bootloader code. At startup I write to FPROT to protect all flash that is not supposed to be modified from the code. This allows bootloading and also allows to keep all code write protected. Unfortunately this doesn't work on S08D, where I can protect only bootloader.

 

0 Kudos

393 Views
bigmac
Specialist III

Hello,


kef wrote:

On S12 devices FPROT register is writeable at runtime. It is made so that you can write protect more than already protected and can't remove write protection from already protected memory. NVPROT byte in flash defines reset-default value of FPROT register.

On S08D FPROT register is not writeable at all. You can only program NVPROT byte, which can be done only once at runtime, since minimum level of flash write protection will write protect NVPROT byte. Of course you can keep flash not write protected, then you may change EEPROM protection as many times as you wish. Yes, you must rest to apply new protection setting.

 


Here is an extract from the 'DZ60 datasheet -

 

4.5.11.4 Flash and EEPROM Protection Register (FPROT and NVPROT)

.

The FPROT register defines which Flash and EEPROM sectors are protected against program and erase

operations.

During the reset sequence, the FPROT register is loaded from the nonvolatile location NVPROT. To

change the protection that will be loaded during the reset sequence, the sector containing NVPROT must

be unprotected and erased, then NVPROT can be reprogrammed.

FPROT bits are readable at any time and writable as long as the size of the protected region is being

increased. Any write to FPROT that attempts to decrease the size of the protected memory will be ignored.

.

It would seem that the 'DZ60 may operate similarly to the S12 devices, in this respect.  Maybe a new FPROT setting could be stored in EEPROM, and then written to FPROT register during the user program initialisation process, following each reset.

 

Regards,

Mac


 

0 Kudos

393 Views
kef
Specialist I

Thanks Mac and SORRY, indeed FPROT is writeable at runtime, please disregard my previous post. I'm getting old, my bad memory, I wonder how could I misinterpret an issue, I had with S08DZ>=128 vs S08DZ<=60 compatibility. The issue I had is that bits in FPROT on these parts have different meanings, so that compatible DZ128/DZ60 bootloader binary should not have NVPROT defined in bootloader binary, but reprogram NVPROT at runtime depending on what is read from SDID register. Sorry for misleading message.

0 Kudos