@@ -49,7 +49,7 @@ def program_cycle_s(self):
49
49
50
50
def get_labels (self ):
51
51
return [self .name , CORE_LABELS [self .core ]] + self .extra_labels
52
-
52
+
53
53
def init_hooks (self , hook , toolchain_name ):
54
54
pass
55
55
@@ -123,18 +123,20 @@ def __init__(self):
123
123
124
124
self .is_disk_virtual = True
125
125
126
+
126
127
class KL46Z (Target ):
127
128
def __init__ (self ):
128
129
Target .__init__ (self )
129
130
130
131
self .core = "Cortex-M0+"
131
132
132
133
self .extra_labels = ['Freescale' , 'KLXX' ]
133
-
134
+
134
135
self .supported_toolchains = ["GCC_ARM" , "ARM" ]
135
-
136
+
136
137
self .is_disk_virtual = True
137
138
139
+
138
140
class K20D5M (Target ):
139
141
def __init__ (self ):
140
142
Target .__init__ (self )
@@ -183,13 +185,15 @@ def __init__(self):
183
185
self .extra_labels = ['NXP' , 'LPC408X' ]
184
186
185
187
self .supported_toolchains = ["ARM" , "GCC_CR" , "GCC_ARM" ]
188
+
189
+ self .is_disk_virtual = True
186
190
187
191
def init_hooks (self , hook , toolchain_name ):
188
192
if toolchain_name in ['ARM_STD' , 'ARM_MICRO' ]:
189
193
hook .hook_add_binary ("post" , self .binary_hook )
190
-
194
+
191
195
@staticmethod
192
- def binary_hook (t_self , elf , binf ):
196
+ def binary_hook (t_self , resources , elf , binf ):
193
197
if not os .path .isdir (binf ):
194
198
# Regular binary file, nothing to do
195
199
return
@@ -260,7 +264,7 @@ def __init__(self):
260
264
261
265
self .supported_toolchains = ["ARM" , "GCC_ARM" ]
262
266
263
-
267
+
264
268
class NUCLEO_F103RB (Target ):
265
269
def __init__ (self ):
266
270
Target .__init__ (self )
@@ -272,8 +276,8 @@ def __init__(self):
272
276
self .supported_toolchains = ["ARM" , "uARM" , "GCC_ARM" ]
273
277
274
278
self .binary_naming = "8.3"
275
-
276
-
279
+
280
+
277
281
class NUCLEO_L152RE (Target ):
278
282
def __init__ (self ):
279
283
Target .__init__ (self )
@@ -286,7 +290,7 @@ def __init__(self):
286
290
287
291
self .binary_naming = "8.3"
288
292
289
-
293
+
290
294
class NUCLEO_F401RE (Target ):
291
295
def __init__ (self ):
292
296
Target .__init__ (self )
@@ -299,7 +303,7 @@ def __init__(self):
299
303
300
304
self .binary_naming = "8.3"
301
305
302
-
306
+
303
307
class NUCLEO_F030R8 (Target ):
304
308
def __init__ (self ):
305
309
Target .__init__ (self )
@@ -311,17 +315,6 @@ def __init__(self):
311
315
self .supported_toolchains = ["ARM" , "uARM" , "GCC_ARM" ]
312
316
313
317
self .binary_naming = "8.3"
314
-
315
-
316
- class MBED_MCU (Target ):
317
- def __init__ (self ):
318
- Target .__init__ (self )
319
-
320
- self .core = "Cortex-M0+"
321
-
322
- self .extra_labels = ['ARM' ]
323
-
324
- self .supported_toolchains = ["ARM" ]
325
318
326
319
327
320
class LPC1347 (Target ):
@@ -378,11 +371,14 @@ def __init__(self):
378
371
379
372
self .supported_toolchains = ["ARM" , "uARM" , "GCC_ARM" , "GCC_CS" , "GCC_CR" , "IAR" ]
380
373
374
+
381
375
class NRF51822 (Target ):
382
376
EXPECTED_SOFTDEVICE = 's110_nrf51822_6.0.0_softdevice.hex'
383
377
UICR_START = 0x10001000
384
378
APPCODE_OFFSET = 0x14000
385
-
379
+
380
+ OUTPUT_EXT = '.hex'
381
+
386
382
def __init__ (self ):
387
383
Target .__init__ (self )
388
384
@@ -391,43 +387,39 @@ def __init__(self):
391
387
self .extra_labels = ["NORDIC" ]
392
388
393
389
self .supported_toolchains = ["ARM" ]
394
-
395
- self .binary_format = "hex"
396
-
390
+
397
391
def init_hooks (self , hook , toolchain_name ):
398
392
if toolchain_name in ['ARM_STD' , 'ARM_MICRO' ]:
399
393
hook .hook_add_binary ("post" , self .binary_hook )
400
-
394
+
401
395
@staticmethod
402
- def binary_hook (t_self , elf , binf ):
403
- for hexf in t_self . resources .hex_files :
396
+ def binary_hook (t_self , resources , elf , binf ):
397
+ for hexf in resources .hex_files :
404
398
if hexf .find (NRF51822 .EXPECTED_SOFTDEVICE ) != - 1 :
405
399
break
406
400
else :
407
401
t_self .debug ("Hex file not found. Aborting." )
408
402
return
409
-
403
+
410
404
# Generate hex file
411
405
# NOTE: this is temporary, it will be removed later and only the
412
406
# combined binary file (below) will be used
413
407
from intelhex import IntelHex
414
408
binh = IntelHex ()
415
409
binh .loadbin (binf , offset = NRF51822 .APPCODE_OFFSET )
416
-
410
+
417
411
sdh = IntelHex (hexf )
418
412
sdh .merge (binh )
419
- outname = binf + ".temp"
413
+
414
+ outname = binf .replace ('.bin' , '.hex' )
420
415
with open (outname , "w" ) as f :
421
416
sdh .tofile (f , format = 'hex' )
422
417
t_self .debug ("Generated SoftDevice-enabled image in '%s'" % outname )
423
-
424
- if t_self .target .binary_format == "hex" :
425
- os .rename (outname , binf )
426
- return
427
-
418
+
428
419
# Generate concatenated SoftDevice + application binary
429
420
# Currently, this is only supported for SoftDevice images that have
430
421
# an UICR area
422
+ """
431
423
sdh = IntelHex(hexf)
432
424
if sdh.maxaddr() < NRF51822.UICR_START:
433
425
t_self.error("SoftDevice image does not have UICR area. Aborting.")
@@ -438,25 +430,27 @@ def binary_hook(t_self, elf, binf):
438
430
except ValueError:
439
431
t_self.error("UICR start address not found in the SoftDevice image. Aborting.")
440
432
return
441
-
433
+
442
434
# Assume that everything up to uicr_start_index are contiguous addresses
443
435
# in the SoftDevice code area
444
436
softdevice_code_size = addrlist[uicr_start_index - 1] + 1
445
437
t_self.debug("SoftDevice code size is %d bytes" % softdevice_code_size)
446
-
438
+
447
439
# First part: SoftDevice code
448
440
bindata = sdh[:softdevice_code_size].tobinstr()
449
-
441
+
450
442
# Second part: pad with 0xFF up to APPCODE_OFFSET
451
443
bindata = bindata + '\xFF ' * (NRF51822.APPCODE_OFFSET - softdevice_code_size)
452
-
444
+
453
445
# Last part: the application code
454
446
with open(binf, 'r+b') as f:
455
447
bindata = bindata + f.read()
456
448
# Write back the binary
457
449
f.seek(0)
458
450
f.write(bindata)
459
451
t_self.debug("Generated concatenated binary of %d bytes" % len(bindata))
452
+ """
453
+
460
454
461
455
# Get a single instance for each target
462
456
TARGETS = [
@@ -477,7 +471,6 @@ def binary_hook(t_self, elf, binf):
477
471
NUCLEO_L152RE (),
478
472
NUCLEO_F401RE (),
479
473
NUCLEO_F030R8 (),
480
- MBED_MCU (),
481
474
LPC1347 (),
482
475
LPC1114 (),
483
476
LPC11C24 (),
0 commit comments