|
9 | 9 | bl = dai.DeviceBootloader(info) |
10 | 10 | print(f'Version: {bl.getVersion()}') |
11 | 11 |
|
12 | | - for mem in (dai.DeviceBootloader.Memory.FLASH, dai.DeviceBootloader.Memory.EMMC): |
13 | | - memInfo = bl.getMemoryInfo(mem) |
14 | | - if not memInfo.available: continue # Memory is not available, skip |
15 | | - print(f"Memory '{mem}' size: {memInfo.size}, info: {memInfo.info}") |
| 12 | + supportedMemTypes = [dai.DeviceBootloader.Memory.FLASH, dai.DeviceBootloader.Memory.EMMC] |
| 13 | + if bl.getType() == dai.DeviceBootloader.Type.USB: |
| 14 | + print("USB Bootloader - supports only Flash memory") |
| 15 | + supportedMemTypes = [dai.DeviceBootloader.Memory.FLASH]; |
| 16 | + else: |
| 17 | + print("NETWORK Bootloader") |
16 | 18 |
|
17 | | - appInfo = bl.readApplicationInfo(mem) |
18 | | - if appInfo.hasApplication: |
19 | | - print(f"Application name: {appInfo.applicationName}, firmware version: {appInfo.firmwareVersion}") |
| 19 | + try: |
| 20 | + for mem in supportedMemTypes: |
| 21 | + memInfo = bl.getMemoryInfo(mem) |
| 22 | + if memInfo.available: |
| 23 | + print(f"Memory '{mem}' size: {memInfo.size}, info: {memInfo.info}") |
| 24 | + appInfo = bl.readApplicationInfo(mem) |
| 25 | + if appInfo.hasApplication: |
| 26 | + print(f"Application name: {appInfo.applicationName}, firmware version: {appInfo.firmwareVersion}") |
| 27 | + else: |
| 28 | + print(f"Memory '{mem.name}' not available...") |
| 29 | + except Exception as ex: |
| 30 | + print(f"Couldn't retrieve memory details: {ex}") |
20 | 31 | else: |
21 | 32 | print('No devices found') |
0 commit comments