Skip to content

Commit c3ff199

Browse files
committed
otbox.py: when flashing binary files only check CCA region is not overwritten
1 parent 5e6f0f0 commit c3ff199

File tree

1 file changed

+43
-21
lines changed

1 file changed

+43
-21
lines changed

otbox.py

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646

4747
IMAGE_THREAD_NAME = 'image_thread'
4848
HEARTBEAT_THREAD_NAME = 'heartbeat_thread'
49+
50+
OPENMOTE_B_FLASHSIZE = 512*1024
51+
CC2538_FLASHPAGE_SIZE = 2048
52+
4953
#============================ classes =========================================
5054

5155
def _getThreadsName():
@@ -90,27 +94,45 @@ def bootload_mote(self, serialport, firmware_file):
9094

9195
bootloader_backdoor_enabled = False
9296
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+
114136
assert bootloader_backdoor_enabled
115137

116138
return subprocess.Popen(

0 commit comments

Comments
 (0)