winIDEA SDK
Loading...
Searching...
No Matches
test_storage_erase.py
# This script is licensed under BSD License, see file LICENSE.txt, or search for `License` in the SDK online help.
#
# (c) TASKING Germany GmbH, 2023
import isystem.connect as ic
winidea_id = ''
def test_erase():
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
ideCtrl = ic.CIDEController(connMgr)
devName = "ST STM32F4xxxG_1024KB"
#Erase size equals size on one flash sector for this specific example target "ST STM32F4xxxG_1024KB"
eraseSize = 0x4000
optCtrl = ic.COptionController(connMgr, "/iOPEN/Data.UMI.Devices.Devices")
devIndex = optCtrl.index_of("Name",devName)
print("Index of the item whose 'Name' attribute has value " + devName + f": {devIndex}")
storageCtrl = ic.CStorageDeviceFactory.makeDevice(connMgr, ic.EStorageDevice_EmbeddedFlashDevice, devIndex)
print(f"Erasing entire device with index {devIndex}...")
storageCtrl.erase(ic.IConnectUMI.wProgDevice)
print(f"Erasing first {int(eraseSize)} bytes of a device with index {devIndex}...")
addUrl = f"/iOPEN/Data.UMI.Devices.Devices[{devIndex}].DeviceAddress"
add = ideCtrl.getOptionInt(addUrl)
storageCtrl.erase(ic.IConnectUMI.wProgDevice, add, int(eraseSize))
if __name__ == "__main__":
test_erase()