winIDEA SDK
test_storage_write.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import isystem.connect as ic
6
7
8winidea_id = ''
9
10
11def test_write():
12 connMgr = ic.ConnectionMgr()
13 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
14
15 # Another way to get device name is to check Hardware->Options->Programming or with
16 # `CStorageDeviceFactory.getDeviceNames()` method. See test_storage_get_devices_names.py
17 # for usage example.
18 devName = "ST STM32F4xxxG_1024KB"
19 optCtrl = ic.COptionController(connMgr, ic.CStorageDeviceFactory.DEVICES_OPT_URL)
20 devIndex = optCtrl.index_of("Name", devName)
21 print("Index of the item whose 'Name' attribute has value " + devName + f": {devIndex}")
22
23 storageCtrl = ic.CStorageDeviceFactory.makeDevice(connMgr, ic.EStorageDevice_EmbeddedFlashDevice, devIndex)
24
25 print(f"Writing configured data to device with index: {devIndex}")
26 storageCtrl.write(ic.IConnectUMI.wProgDevice)
27
28 print(f"Writing data from a specific file to device with index: {devIndex}")
29 storageCtrl.write(ic.IConnectUMI.wProgDevice,
30 ic.IConnectUMI.wFileFormatAuto,
31 0,
32 "CORE0/Debug/sdk_test.elf")
33
34 print(f"Writing specific data (16 bytes) to a device with index: {devIndex}")
35 data = ic.VectorBYTE()
36 for index in range(16):
37 data.append(index)
38 storageCtrl.write(ic.IConnectUMI.wProgDevice, 0x08000000, 16, data)
39
40
41if __name__ == "__main__":
42 test_write()