@@ -387,12 +387,13 @@ def __init__(self):
387
387
388
388
389
389
class NRF51822 (Target ):
390
- OUTPUT_EXT = '.hex'
391
-
392
390
EXPECTED_SOFTDEVICE = 's110_nrf51822_6.0.0_softdevice.hex'
393
- UICR_START = 0x10001000
391
+
394
392
APPCODE_OFFSET = 0x14000
395
393
394
+ UICR_START = 0x10001000
395
+ UICR_END = 0x10001013
396
+
396
397
def __init__ (self ):
397
398
Target .__init__ (self )
398
399
@@ -401,6 +402,8 @@ def __init__(self):
401
402
self .extra_labels = ["NORDIC" ]
402
403
403
404
self .supported_toolchains = ["ARM" ]
405
+
406
+ self .is_disk_virtual = True
404
407
405
408
def init_hooks (self , hook , toolchain_name ):
406
409
if toolchain_name in ['ARM_STD' , 'ARM_MICRO' ]:
@@ -425,45 +428,11 @@ def binary_hook(t_self, resources, elf, binf):
425
428
sdh = IntelHex (hexf )
426
429
sdh .merge (binh )
427
430
428
- outname = binf .replace ('.bin' , '.hex' )
429
- with open (outname , "w" ) as f :
430
- sdh .tofile (f , format = 'hex' )
431
- t_self .debug ("Generated SoftDevice-enabled image in '%s'" % outname )
432
-
433
- # Generate concatenated SoftDevice + application binary
434
- # Currently, this is only supported for SoftDevice images that have
435
- # an UICR area
436
- """
437
- sdh = IntelHex(hexf)
438
- if sdh.maxaddr() < NRF51822.UICR_START:
439
- t_self.error("SoftDevice image does not have UICR area. Aborting.")
440
- return
441
- addrlist = sdh.addresses()
442
- try:
443
- uicr_start_index = addrlist.index(NRF51822.UICR_START)
444
- except ValueError:
445
- t_self.error("UICR start address not found in the SoftDevice image. Aborting.")
446
- return
431
+ # Remove UICR section
432
+ del sdh [NRF51822 .UICR_START :NRF51822 .UICR_END + 1 ]
447
433
448
- # Assume that everything up to uicr_start_index are contiguous addresses
449
- # in the SoftDevice code area
450
- softdevice_code_size = addrlist[uicr_start_index - 1] + 1
451
- t_self.debug("SoftDevice code size is %d bytes" % softdevice_code_size)
452
-
453
- # First part: SoftDevice code
454
- bindata = sdh[:softdevice_code_size].tobinstr()
455
-
456
- # Second part: pad with 0xFF up to APPCODE_OFFSET
457
- bindata = bindata + '\xFF ' * (NRF51822.APPCODE_OFFSET - softdevice_code_size)
458
-
459
- # Last part: the application code
460
- with open(binf, 'r+b') as f:
461
- bindata = bindata + f.read()
462
- # Write back the binary
463
- f.seek(0)
464
- f.write(bindata)
465
- t_self.debug("Generated concatenated binary of %d bytes" % len(bindata))
466
- """
434
+ with open (binf , "w" ) as f :
435
+ sdh .tofile (f , format = 'bin' )
467
436
468
437
469
438
# Get a single instance for each target
0 commit comments