@@ -470,6 +470,7 @@ def lpc_patch(t_self, resources, elf, binf):
470
470
t_self .notify .debug ("LPC Patch: %s" % os .path .split (binf )[1 ])
471
471
patch (binf )
472
472
473
+
473
474
class MTSCode (object ):
474
475
"""Generic MTS code"""
475
476
@staticmethod
@@ -505,6 +506,53 @@ def combine_bins_mts_dragonfly(t_self, resources, elf, binf):
505
506
MTSCode ._combine_bins_helper ("MTS_DRAGONFLY_F411RE" , binf )
506
507
507
508
509
+ class LPC4088Code (object ):
510
+ """Code specific to the LPC4088"""
511
+ @staticmethod
512
+ def binary_hook (t_self , resources , elf , binf ):
513
+ """Hook to be run after an elf file is built"""
514
+ if not os .path .isdir (binf ):
515
+ # Regular binary file, nothing to do
516
+ LPCTargetCode .lpc_patch (t_self , resources , elf , binf )
517
+ return
518
+ outbin = open (binf + ".temp" , "wb" )
519
+ partf = open (os .path .join (binf , "ER_IROM1" ), "rb" )
520
+ # Pad the fist part (internal flash) with 0xFF to 512k
521
+ data = partf .read ()
522
+ outbin .write (data )
523
+ outbin .write (b'\xFF ' * (512 * 1024 - len (data )))
524
+ partf .close ()
525
+ # Read and append the second part (external flash) in chunks of fixed
526
+ # size
527
+ chunksize = 128 * 1024
528
+ partf = open (os .path .join (binf , "ER_IROM2" ), "rb" )
529
+ while True :
530
+ data = partf .read (chunksize )
531
+ outbin .write (data )
532
+ if len (data ) < chunksize :
533
+ break
534
+ partf .close ()
535
+ outbin .close ()
536
+ # Remove the directory with the binary parts and rename the temporary
537
+ # file to 'binf'
538
+ shutil .rmtree (binf , True )
539
+ os .rename (binf + '.temp' , binf )
540
+ t_self .notify .debug (
541
+ "Generated custom binary file (internal flash + SPIFI)"
542
+ )
543
+ LPCTargetCode .lpc_patch (t_self , resources , elf , binf )
544
+
545
+
546
+ class TEENSY3_1Code (object ):
547
+ """Hooks for the TEENSY3.1"""
548
+ @staticmethod
549
+ def binary_hook (t_self , resources , elf , binf ):
550
+ """Hook that is run after elf is generated"""
551
+ # This function is referenced by old versions of targets.json and
552
+ # should be kept for backwards compatibility.
553
+ pass
554
+
555
+
508
556
class MCU_NRF51Code (object ):
509
557
"""NRF51 Hooks"""
510
558
@staticmethod
0 commit comments