|
46 | 46 |
|
47 | 47 | IMAGE_THREAD_NAME = 'image_thread' |
48 | 48 | HEARTBEAT_THREAD_NAME = 'heartbeat_thread' |
| 49 | + |
| 50 | +OPENMOTE_B_FLASHSIZE = 512*1024 |
| 51 | +CC2538_FLASHPAGE_SIZE = 2048 |
| 52 | + |
49 | 53 | #============================ classes ========================================= |
50 | 54 |
|
51 | 55 | def _getThreadsName(): |
@@ -90,27 +94,45 @@ def bootload_mote(self, serialport, firmware_file): |
90 | 94 |
|
91 | 95 | bootloader_backdoor_enabled = False |
92 | 96 | extended_linear_address_found = False |
93 | | - |
94 | | - # make sure bootloader backdoor is configured correctly |
95 | | - with open(firmware_file,'r') as f: |
96 | | - for line in f: |
97 | | - |
98 | | - # looking for data at address 0027FFD4 |
99 | | - # refer to: https://en.wikipedia.org/wiki/Intel_HEX#Record_types |
100 | | - |
101 | | - # looking for upper 16bit address 0027 |
102 | | - if len(line)>=15 and line[:15] == ':020000040027D3': |
103 | | - extended_linear_address_found = True |
104 | | - |
105 | | - # check the lower 16bit address FFD4 |
106 | | - |
107 | | - # | 1:3 byte count | 3:7 address | 9:17 32-bit field of the lock bit page (the last byte is backdoor configuration) | |
108 | | - # 'F6' = 111 1 0 110 |
109 | | - # reserved backdoor and bootloader enable active low PA pin used for backdoor enabling (PA6) |
110 | | - if len(line)>=17 and extended_linear_address_found and line[3:7] == 'FFD4' and int(line[1:3], 16)>4 and line[9:17] == 'FFFFFFF6': |
111 | | - bootloader_backdoor_enabled = True |
112 | | - break |
113 | | - |
| 97 | + |
| 98 | + # When building RIOT with OpenWSN-fw + SUIT the Customer |
| 99 | + # Configuration Area (CCA) is not touched. The Customer |
| 100 | + # CCA holds the Bootloader Backdoor Configuration, |
| 101 | + # Application Entry Point, flashpage lock bits. |
| 102 | + # When using SUIT + cc2538 RIOT does not touch this region so |
| 103 | + # that the entry point is not changed when updating the device |
| 104 | + # with new firmware (the entry point must allways be riot's |
| 105 | + # bootloader). |
| 106 | + # The CCA field resides in the last flashpage, for cc2538 |
| 107 | + # each flashpage is 2048 bytes. Only openmote-b are present |
| 108 | + # in the testbed and the flashsize is allways 512Kb. Since |
| 109 | + # flashing at an offset is not supported only check that the |
| 110 | + # target firmware does not override the CCA region. |
| 111 | + if '.bin' in image: |
| 112 | + if os.path.getsize(image) < (OPENMOTE_B_FLASHSIZE) - CC2538_FLASHPAGE_SIZE: |
| 113 | + bootloader_backdoor_enabled = OpenTBCmdRunner |
| 114 | + bootloader_backdoor_enabled = True |
| 115 | + else: |
| 116 | + # make sure bootloader backdoor is configured correctly |
| 117 | + with open(firmware_file,'r') as f: |
| 118 | + for line in f: |
| 119 | + |
| 120 | + # looking for data at address 0027FFD4 |
| 121 | + # refer to: https://en.wikipedia.org/wiki/Intel_HEX#Record_types |
| 122 | + |
| 123 | + # looking for upper 16bit address 0027 |
| 124 | + if len(line)>=15 and line[:15] == ':020000040027D3': |
| 125 | + extended_linear_address_found = True |
| 126 | + |
| 127 | + # check the lower 16bit address FFD4 |
| 128 | + |
| 129 | + # | 1:3 byte count | 3:7 address | 9:17 32-bit field of the lock bit page (the last byte is backdoor configuration) | |
| 130 | + # 'F6' = 111 1 0 110 |
| 131 | + # reserved backdoor and bootloader enable active low PA pin used for backdoor enabling (PA6) |
| 132 | + if len(line)>=17 and extended_linear_address_found and line[3:7] == 'FFD4' and int(line[1:3], 16)>4 and line[9:17] == 'FFFFFFF6': |
| 133 | + bootloader_backdoor_enabled = True |
| 134 | + break |
| 135 | + |
114 | 136 | assert bootloader_backdoor_enabled |
115 | 137 |
|
116 | 138 | return subprocess.Popen( |
|
0 commit comments