Please enable JavaScript to view this site.

winIDEA Help

Version: 9.21.239

Programming the OTP memory

One-Time-Programmable (OTP) memory is present on the MPC56xx (shadow and TEST memory), MPC57xx and SPC58xx (UTEST memory) devices. This memory can only be programmed once, therefore the programming of this memory is disabled by default in order to prevent any accidental writes to these regions.

 

 

Warning_orange

You can program UTEST memory only once with Download or Target Download if:

You are absolutely sure your settings are correct,

You have EMPTY devices from production,

Device Configuration Files (DCFs) are written to the same location on ALL devices,

ALL devices are the same.

Otherwise programming via Download or Target Download is not recommended.

 

 

Enabling Shadow and TEST Memory programming

 

HW-Options-Programming

Enable desired Flash memory in Hardware / Options.

 

These memory regions need to be programmed in 8- or 16-byte memory writes, depending on the selected MCU. Please refer to the MCU's reference manual for details on OTM memory map and configuration details.

 

Warning_orange

Programming the OTP region by writing directly to the Memory Window can potentially lock the device, because the memory writes through the memory window are performed in 1-byte chunks.

 

 

Write to OTP via script

Best method to write to the OTP regions is by running a script, which uses winIDEA SDK to connect to winIDEA. Below are two basics examples of such scripts written in Python.

 

If you are unsure that your script is written correctly, you can first make a test write to the RAM memory and only after you see that the value is written exactly as you intended, you make a memory write to the OTP memory.

 

Script that programs 8 bytes

 

import isystem.connect as ic
 
cmgr = ic.ConnectionMgr()
cmgr.connectMRU('')
ideCtrl = ic.CIDEController(cmgr)
dataCtrl = ic.CDataController(cmgr)
 
memoryAreas = dataCtrl.getSystemMemoryAreas()
physicalDataMemoryArea = memoryAreas.getMemAreaDataPhysical()
valueType = ic.SType()
valueType.m_byType = ic.SType.tUnsigned  
valueType.m_byBitSize = 64
 
address = 0x400500
value = 0x123456789ABCDEF0
 
content = ic.CValueType(valueType, value)
 
try:
dataCtrl.writeValue(ic.IConnectDebug.fMonitor, physicalDataMemoryArea, address, content)
print(hex(value) + " successfully written to " + hex(address))
except Exception as exMsg:
print("Memory write not successful: " + str(exMsg))
   
ideCtrl.refreshUI()

 

 

Warning_orange

Make sure that the memory address to which you are writing is correctly aligned (e.g. for 16-byte access, the address needs to be aligned to 16 bytes) and that the size of the output buffer is correct (e.g. 16 bytes for 16-byte access). As long as these rules are followed, winIDEA will use the appropriate memory access size.

 

It can happen that you need to program a shorter value to the OTP region (e.g. you need to program an 8-byte value, but the access must be 16-byte). This is not allowed. In such case a simple workaround is to repeat the same value for upper and lower 8 bytes (as shown in the sample script above).

 

 

Script that programs 16 bytes

On SPC58xx devices OTP FLASH programming size is 128bits (or 16 bytes) that  must be programmed in single access.

 

import isystem.connect as ic

cmgr = ic.ConnectionMgr()

cmgr.connectMRU('')

debug = ic.CDebugFacade(cmgr)

 

#RAM LOCATIONS  for script test

#DCF_START_ADDR      = 0x400A8380

#REAL UTEST LOCATIONS

DCF_START_ADDR      = 0x00400A00

 

outBuffer = ic.VectorBYTE([0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF])

debug.writeMemory(ic.IConnectDebug.fMonitor, 0, DCF_START_ADDR,  len(outBuffer), 1, outBuffer)

 

ideCtrl.refreshUI()

 

 

Copyright © 2024 TASKING Germany GmbH