@@ -616,6 +616,7 @@ def __init__(self):
616
616
self .core = "Cortex-M4F"
617
617
self .extra_labels = ['STM' , 'STM32F4' , 'STM32F407' , 'STM32F407VG' ]
618
618
self .supported_toolchains = ["ARM" , "uARM" , "GCC_ARM" ]
619
+ self .supported_form_factors = ["ARDUINO" ]
619
620
620
621
def program_cycle_s (self ):
621
622
return 2
@@ -723,6 +724,7 @@ def __init__(self):
723
724
self .supported_form_factors = ["ARDUINO" ]
724
725
725
726
727
+
726
728
### Nordic ###
727
729
728
730
class NRF51822 (Target ):
@@ -742,8 +744,10 @@ class NRF51822(Target):
742
744
'offset' : 0x14000
743
745
}
744
746
]
747
+ EXPECTED_BOOTLOADER_FILENAME = "nrf51822_bootloader.hex"
745
748
OUTPUT_EXT = 'hex'
746
749
MERGE_SOFT_DEVICE = True
750
+ MERGE_BOOTLOADER = False
747
751
748
752
def __init__ (self ):
749
753
Target .__init__ (self )
@@ -762,31 +766,50 @@ def init_hooks(self, hook, toolchain_name):
762
766
763
767
@staticmethod
764
768
def binary_hook (t_self , resources , elf , binf ):
769
+ # Scan to find the actual paths of soft device and bootloader files
770
+ sdf = None
771
+ blf = None
765
772
for hexf in resources .hex_files :
766
- found = False
767
- for softdeviceAndOffsetEntry in NRF51822 .EXPECTED_SOFTDEVICES_WITH_OFFSETS :
768
- if hexf .find (softdeviceAndOffsetEntry ['name' ]) != - 1 :
769
- found = True
770
- break
771
- if found :
772
- break
773
- else :
773
+ if hexf .find (t_self .target .EXPECTED_BOOTLOADER_FILENAME ) != - 1 :
774
+ blf = hexf
775
+ else :
776
+ for softdeviceAndOffsetEntry in t_self .target .EXPECTED_SOFTDEVICES_WITH_OFFSETS :
777
+ if hexf .find (softdeviceAndOffsetEntry ['name' ]) != - 1 :
778
+ sdf = hexf
779
+ break
780
+
781
+ if sdf is None :
774
782
t_self .debug ("Hex file not found. Aborting." )
775
783
return
776
784
777
785
# Merge user code with softdevice
778
- t_self .debug ("Patching Hex file %s" % softdeviceAndOffsetEntry ['name' ])
779
786
from intelhex import IntelHex
780
787
binh = IntelHex ()
781
788
binh .loadbin (binf , offset = softdeviceAndOffsetEntry ['offset' ])
782
789
783
790
if t_self .target .MERGE_SOFT_DEVICE is True :
784
- sdh = IntelHex (hexf )
791
+ t_self .debug ("Merge SoftDevice file %s" % softdeviceAndOffsetEntry ['name' ])
792
+ sdh = IntelHex (sdf )
785
793
binh .merge (sdh )
786
794
795
+ if t_self .target .MERGE_BOOTLOADER is True and blf is not None :
796
+ t_self .debug ("Merge BootLoader file %s" % t_self .target .EXPECTED_BOOTLOADER_FILENAME )
797
+ blh = IntelHex (blf )
798
+ binh .merge (blh )
799
+
787
800
with open (binf .replace (".bin" , ".hex" ), "w" ) as f :
788
801
binh .tofile (f , format = 'hex' )
789
802
803
+ class NRF51822_BOOT (NRF51822 ):
804
+ def __init__ (self ):
805
+ NRF51822 .__init__ (self )
806
+ self .core = "Cortex-M0"
807
+ self .extra_labels = ["NORDIC" , "NRF51822_MKIT" , "MCU_NRF51822" , "MCU_NORDIC_16K" , "NRF51822" ]
808
+ self .macros = ['TARGET_NRF51822' , 'TARGET_OTA_ENABLED' ]
809
+ self .supported_toolchains = ["ARM" , "GCC_ARM" ]
810
+ self .MERGE_SOFT_DEVICE = True
811
+ self .MERGE_BOOTLOADER = True
812
+
790
813
class NRF51822_OTA (NRF51822 ):
791
814
def __init__ (self ):
792
815
NRF51822 .__init__ (self )
@@ -803,6 +826,16 @@ def __init__(self):
803
826
self .macros = ['TARGET_NRF51822' ]
804
827
self .supported_form_factors = ["ARDUINO" ]
805
828
829
+ class NRF51_DK_BOOT (NRF51822 ):
830
+ def __init__ (self ):
831
+ NRF51822 .__init__ (self )
832
+ self .core = "Cortex-M0"
833
+ self .extra_labels = ['NORDIC' , 'MCU_NRF51822' , 'MCU_NORDIC_32K' , 'NRF51_DK' ]
834
+ self .macros = ['TARGET_NRF51822' , 'TARGET_NRF51_DK' , 'TARGET_OTA_ENABLED' ]
835
+ self .supported_toolchains = ["ARM" , "GCC_ARM" ]
836
+ self .MERGE_SOFT_DEVICE = True
837
+ self .MERGE_BOOTLOADER = True
838
+
806
839
class NRF51_DK_OTA (NRF51822 ):
807
840
def __init__ (self ):
808
841
NRF51822 .__init__ (self )
@@ -831,10 +864,18 @@ def __init__(self):
831
864
self .extra_labels = ['NORDIC' , 'MCU_NRF51822' , 'MCU_NORDIC_16K' ]
832
865
self .macros = ['TARGET_NRF51822' ]
833
866
867
+ class SEEED_TINY_BLE_BOOT (NRF51822 ):
868
+ def __init__ (self ):
869
+ NRF51822 .__init__ (self )
870
+ self .extra_labels = ['NORDIC' , 'MCU_NRF51822' , 'MCU_NORDIC_16K' , 'SEEED_TINY_BLE' ]
871
+ self .macros = ['TARGET_NRF51822' , 'TARGET_SEEED_TINY_BLE' , 'TARGET_OTA_ENABLED' ]
872
+ self .MERGE_SOFT_DEVICE = True
873
+ self .MERGE_BOOTLOADER = True
874
+
834
875
class SEEED_TINY_BLE_OTA (NRF51822 ):
835
876
def __init__ (self ):
836
877
NRF51822 .__init__ (self )
837
- self .extra_labels = ['NORDIC' , 'MCU_NRF51822' , 'MCU_NORDIC_16K' ]
878
+ self .extra_labels = ['NORDIC' , 'MCU_NRF51822' , 'MCU_NORDIC_16K' , 'SEEED_TINY_BLE' ]
838
879
self .macros = ['TARGET_NRF51822' , 'TARGET_SEEED_TINY_BLE' , 'TARGET_OTA_ENABLED' ]
839
880
self .MERGE_SOFT_DEVICE = False
840
881
@@ -890,6 +931,12 @@ def __init__(self):
890
931
self .core = "Cortex-M0"
891
932
self .extra_labels = ['NORDIC' , 'MCU_NRF51822' , 'MCU_NORDIC_16K' , 'DELTA_DFCM_NNN40' ]
892
933
self .MERGE_SOFT_DEVICE = False
934
+ class DELTA_DFCM_NNN40_OTA (NRF51822 ):
935
+ def __init__ (self ):
936
+ NRF51822 .__init__ (self )
937
+ self .core = "Cortex-M0"
938
+ self .extra_labels = ['NORDIC' , 'MCU_NRF51822' , 'MCU_NORDIC_16K' , 'DELTA_DFCM_NNN40' ]
939
+ self .MERGE_SOFT_DEVICE = False
893
940
894
941
895
942
### ARM ###
@@ -1046,13 +1093,16 @@ def program_cycle_s(self):
1046
1093
1047
1094
### Nordic ###
1048
1095
NRF51822 (),
1096
+ NRF51822_BOOT (), # nRF51822
1049
1097
NRF51822_OTA (), # nRF51822
1050
1098
NRF51_DK (),
1099
+ NRF51_DK_BOOT (), # nRF51822
1051
1100
NRF51_DK_OTA (), # nRF51822
1052
1101
NRF51_DONGLE (),
1053
1102
ARCH_BLE (), # nRF51822
1054
- SEEED_TINY_BLE (),
1055
- SEEED_TINY_BLE_OTA (),
1103
+ SEEED_TINY_BLE (), # nRF51822
1104
+ SEEED_TINY_BLE_BOOT (),# nRF51822
1105
+ SEEED_TINY_BLE_OTA (),# nRF51822
1056
1106
HRM1017 (), # nRF51822
1057
1107
RBLAB_NRF51822 (),# nRF51822
1058
1108
RBLAB_BLENANO (),# nRF51822
0 commit comments