upload
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

targets.py 42KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272
  1. """
  2. mbed SDK
  3. Copyright (c) 2011-2015 ARM Limited
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. """
  14. CORE_LABELS = {
  15. "ARM7TDMI-S": ["ARM7"],
  16. "Cortex-M0" : ["M0", "CORTEX_M"],
  17. "Cortex-M0+": ["M0P", "CORTEX_M"],
  18. "Cortex-M1" : ["M1", "CORTEX_M"],
  19. "Cortex-M3" : ["M3", "CORTEX_M"],
  20. "Cortex-M4" : ["M4", "CORTEX_M"],
  21. "Cortex-M4F" : ["M4", "CORTEX_M"],
  22. "Cortex-M7" : ["M7", "CORTEX_M"],
  23. "Cortex-M7F" : ["M7", "CORTEX_M"],
  24. "Cortex-A9" : ["A9", "CORTEX_A"]
  25. }
  26. import os
  27. import binascii
  28. import struct
  29. import shutil
  30. from workspace_tools.patch import patch
  31. from paths import TOOLS_BOOTLOADERS
  32. class Target:
  33. def __init__(self):
  34. # ARM Core
  35. self.core = None
  36. # Is the disk provided by the interface chip of this board virtual?
  37. self.is_disk_virtual = False
  38. # list of toolchains that are supported by the mbed SDK for this target
  39. self.supported_toolchains = None
  40. # list of extra specific labels
  41. self.extra_labels = []
  42. # list of macros (-D)
  43. self.macros = []
  44. # Default online compiler:
  45. self.default_toolchain = "ARM"
  46. self.name = self.__class__.__name__
  47. # Code used to determine devices' platform
  48. # This code is prefix in URL link provided in mbed.htm (in mbed disk)
  49. self.detect_code = []
  50. def program_cycle_s(self):
  51. return 4 if self.is_disk_virtual else 1.5
  52. def get_labels(self):
  53. return [self.name] + CORE_LABELS[self.core] + self.extra_labels
  54. def init_hooks(self, hook, toolchain_name):
  55. pass
  56. ### NXP ###
  57. # This class implements the post-link patching step needed by LPC targets
  58. class LPCTarget(Target):
  59. def __init__(self):
  60. Target.__init__(self)
  61. def init_hooks(self, hook, toolchain_name):
  62. hook.hook_add_binary("post", self.lpc_patch)
  63. @staticmethod
  64. def lpc_patch(t_self, resources, elf, binf):
  65. t_self.debug("LPC Patch: %s" % os.path.split(binf)[1])
  66. patch(binf)
  67. class LPC11C24(LPCTarget):
  68. def __init__(self):
  69. LPCTarget.__init__(self)
  70. self.core = "Cortex-M0"
  71. self.extra_labels = ['NXP', 'LPC11XX_11CXX', 'LPC11CXX']
  72. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  73. class LPC1114(LPCTarget):
  74. def __init__(self):
  75. LPCTarget.__init__(self)
  76. self.core = "Cortex-M0"
  77. self.extra_labels = ['NXP', 'LPC11XX_11CXX', 'LPC11XX']
  78. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"]
  79. self.default_toolchain = "uARM"
  80. class LPC11U24(LPCTarget):
  81. def __init__(self):
  82. LPCTarget.__init__(self)
  83. self.core = "Cortex-M0"
  84. self.extra_labels = ['NXP', 'LPC11UXX', 'LPC11U24_401']
  85. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  86. self.default_toolchain = "uARM"
  87. self.detect_code = ["1040"]
  88. class OC_MBUINO(LPC11U24):
  89. def __init__(self):
  90. LPC11U24.__init__(self)
  91. self.core = "Cortex-M0"
  92. self.extra_labels = ['NXP', 'LPC11UXX']
  93. self.macros = ['TARGET_LPC11U24']
  94. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  95. self.default_toolchain = "uARM"
  96. class LPC11U24_301(LPCTarget):
  97. def __init__(self):
  98. LPCTarget.__init__(self)
  99. self.core = "Cortex-M0"
  100. self.extra_labels = ['NXP', 'LPC11UXX']
  101. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  102. class LPC11U34_421(LPCTarget):
  103. def __init__(self):
  104. LPCTarget.__init__(self)
  105. self.core = "Cortex-M0"
  106. self.extra_labels = ['NXP', 'LPC11UXX']
  107. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"]
  108. self.default_toolchain = "uARM"
  109. class APPNEARME_MICRONFCBOARD(LPC11U34_421):
  110. def __init__(self):
  111. LPC11U34_421.__init__(self)
  112. self.macros = ['LPC11U34_421']
  113. self.is_disk_virtual = True
  114. class LPC11U35_401(LPCTarget):
  115. def __init__(self):
  116. LPCTarget.__init__(self)
  117. self.core = "Cortex-M0"
  118. self.extra_labels = ['NXP', 'LPC11UXX']
  119. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"]
  120. self.default_toolchain = "uARM"
  121. class LPC11U35_501(LPCTarget):
  122. def __init__(self):
  123. LPCTarget.__init__(self)
  124. self.core = "Cortex-M0"
  125. self.extra_labels = ['NXP', 'LPC11UXX', 'MCU_LPC11U35_501']
  126. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR" , "IAR"]
  127. self.default_toolchain = "uARM"
  128. class LPC11U35_Y5_MBUG(LPCTarget):
  129. def __init__(self):
  130. LPCTarget.__init__(self)
  131. self.core = "Cortex-M0"
  132. self.extra_labels = ['NXP', 'LPC11UXX', 'MCU_LPC11U35_501']
  133. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR" , "IAR"]
  134. self.default_toolchain = "uARM"
  135. class LPC11U37_501(LPCTarget):
  136. def __init__(self):
  137. LPCTarget.__init__(self)
  138. self.core = "Cortex-M0"
  139. self.extra_labels = ['NXP', 'LPC11UXX']
  140. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"]
  141. self.default_toolchain = "uARM"
  142. class LPCCAPPUCCINO(LPC11U37_501):
  143. def __init__(self):
  144. LPC11U37_501.__init__(self)
  145. class ARCH_GPRS(LPCTarget):
  146. def __init__(self):
  147. LPCTarget.__init__(self)
  148. self.core = "Cortex-M0"
  149. self.extra_labels = ['NXP', 'LPC11UXX', 'LPC11U37_501']
  150. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"]
  151. self.default_toolchain = "uARM"
  152. self.supported_form_factors = ["ARDUINO"]
  153. class LPC11U68(LPCTarget):
  154. def __init__(self):
  155. LPCTarget.__init__(self)
  156. self.core = "Cortex-M0+"
  157. self.extra_labels = ['NXP', 'LPC11U6X']
  158. self.supported_toolchains = ["ARM", "uARM", "GCC_CR", "GCC_ARM", "IAR"]
  159. self.default_toolchain = "uARM"
  160. self.supported_form_factors = ["ARDUINO"]
  161. self.detect_code = ["1168"]
  162. class LPC1347(LPCTarget):
  163. def __init__(self):
  164. LPCTarget.__init__(self)
  165. self.core = "Cortex-M3"
  166. self.extra_labels = ['NXP', 'LPC13XX']
  167. self.supported_toolchains = ["ARM", "GCC_ARM","IAR"]
  168. class LPC1549(LPCTarget):
  169. def __init__(self):
  170. LPCTarget.__init__(self)
  171. self.core = "Cortex-M3"
  172. self.extra_labels = ['NXP', 'LPC15XX']
  173. self.supported_toolchains = ["uARM", "GCC_CR", "GCC_ARM", "IAR"]
  174. self.default_toolchain = "uARM"
  175. self.supported_form_factors = ["ARDUINO"]
  176. self.detect_code = ["1549"]
  177. class LPC1768(LPCTarget):
  178. def __init__(self):
  179. LPCTarget.__init__(self)
  180. self.core = "Cortex-M3"
  181. self.extra_labels = ['NXP', 'LPC176X', 'MBED_LPC1768']
  182. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CS", "GCC_CR", "IAR"]
  183. self.detect_code = ["1010"]
  184. class ARCH_PRO(LPCTarget):
  185. def __init__(self):
  186. LPCTarget.__init__(self)
  187. self.core = "Cortex-M3"
  188. self.extra_labels = ['NXP', 'LPC176X']
  189. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CS", "GCC_CR", "IAR"]
  190. self.macros = ['TARGET_LPC1768']
  191. self.supported_form_factors = ["ARDUINO"]
  192. class UBLOX_C027(LPCTarget):
  193. def __init__(self):
  194. LPCTarget.__init__(self)
  195. self.core = "Cortex-M3"
  196. self.extra_labels = ['NXP', 'LPC176X']
  197. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CS", "GCC_CR", "IAR"]
  198. self.macros = ['TARGET_LPC1768']
  199. self.supported_form_factors = ["ARDUINO"]
  200. class LPC2368(LPCTarget):
  201. def __init__(self):
  202. LPCTarget.__init__(self)
  203. self.core = "ARM7TDMI-S"
  204. self.extra_labels = ['NXP', 'LPC23XX']
  205. self.supported_toolchains = ["ARM", "GCC_ARM", "GCC_CR"]
  206. class LPC810(LPCTarget):
  207. def __init__(self):
  208. LPCTarget.__init__(self)
  209. self.core = "Cortex-M0+"
  210. self.extra_labels = ['NXP', 'LPC81X']
  211. self.supported_toolchains = ["uARM", "IAR"]
  212. self.default_toolchain = "uARM"
  213. self.is_disk_virtual = True
  214. class LPC812(LPCTarget):
  215. def __init__(self):
  216. LPCTarget.__init__(self)
  217. self.core = "Cortex-M0+"
  218. self.extra_labels = ['NXP', 'LPC81X']
  219. self.supported_toolchains = ["uARM", "IAR"]
  220. self.default_toolchain = "uARM"
  221. self.supported_form_factors = ["ARDUINO"]
  222. self.is_disk_virtual = True
  223. self.detect_code = ["1050"]
  224. class LPC824(LPCTarget):
  225. def __init__(self):
  226. LPCTarget.__init__(self)
  227. self.core = "Cortex-M0+"
  228. self.extra_labels = ['NXP', 'LPC82X']
  229. self.supported_toolchains = ["uARM", "GCC_ARM","GCC_CR", "IAR"]
  230. self.default_toolchain = "uARM"
  231. self.supported_form_factors = ["ARDUINO"]
  232. self.is_disk_virtual = True
  233. class SSCI824(LPCTarget):
  234. def __init__(self):
  235. LPCTarget.__init__(self)
  236. self.core = "Cortex-M0+"
  237. self.extra_labels = ['NXP', 'LPC82X']
  238. self.supported_toolchains = ["uARM", "GCC_ARM"]
  239. self.default_toolchain = "uARM"
  240. self.is_disk_virtual = True
  241. class LPC4088(LPCTarget):
  242. def __init__(self):
  243. LPCTarget.__init__(self)
  244. self.core = "Cortex-M4F"
  245. self.extra_labels = ['NXP', 'LPC408X']
  246. self.supported_toolchains = ["ARM", "GCC_CR", "GCC_ARM", "IAR"]
  247. self.is_disk_virtual = True
  248. def init_hooks(self, hook, toolchain_name):
  249. if toolchain_name in ['ARM_STD', 'ARM_MICRO']:
  250. hook.hook_add_binary("post", self.binary_hook)
  251. @staticmethod
  252. def binary_hook(t_self, resources, elf, binf):
  253. if not os.path.isdir(binf):
  254. # Regular binary file, nothing to do
  255. LPCTarget.lpc_patch(t_self, resources, elf, binf)
  256. return
  257. outbin = open(binf + ".temp", "wb")
  258. partf = open(os.path.join(binf, "ER_IROM1"), "rb")
  259. # Pad the fist part (internal flash) with 0xFF to 512k
  260. data = partf.read()
  261. outbin.write(data)
  262. outbin.write('\xFF' * (512*1024 - len(data)))
  263. partf.close()
  264. # Read and append the second part (external flash) in chunks of fixed size
  265. chunksize = 128 * 1024
  266. partf = open(os.path.join(binf, "ER_IROM2"), "rb")
  267. while True:
  268. data = partf.read(chunksize)
  269. outbin.write(data)
  270. if len(data) < chunksize:
  271. break
  272. partf.close()
  273. outbin.close()
  274. # Remove the directory with the binary parts and rename the temporary
  275. # file to 'binf'
  276. shutil.rmtree(binf, True)
  277. os.rename(binf + '.temp', binf)
  278. t_self.debug("Generated custom binary file (internal flash + SPIFI)")
  279. LPCTarget.lpc_patch(t_self, resources, elf, binf)
  280. class LPC4088_DM(LPC4088):
  281. pass
  282. class LPC4330_M4(LPCTarget):
  283. def __init__(self):
  284. LPCTarget.__init__(self)
  285. self.core = "Cortex-M4F"
  286. self.extra_labels = ['NXP', 'LPC43XX', 'LPC4330']
  287. self.supported_toolchains = ["ARM", "GCC_CR", "IAR", "GCC_ARM"]
  288. class LPC4330_M0(LPCTarget):
  289. def __init__(self):
  290. LPCTarget.__init__(self)
  291. self.core = "Cortex-M0"
  292. self.extra_labels = ['NXP', 'LPC43XX', 'LPC4330']
  293. self.supported_toolchains = ["ARM", "GCC_CR", "IAR"]
  294. class LPC4337(LPCTarget):
  295. def __init__(self):
  296. Target.__init__(self)
  297. self.core = "Cortex-M4F"
  298. self.extra_labels = ['NXP', 'LPC43XX', 'LPC4337']
  299. self.supported_toolchains = ["ARM"]
  300. class LPC1800(LPCTarget):
  301. def __init__(self):
  302. LPCTarget.__init__(self)
  303. self.core = "Cortex-M3"
  304. self.extra_labels = ['NXP', 'LPC43XX']
  305. self.supported_toolchains = ["ARM", "GCC_CR", "IAR"]
  306. class LPC11U37H_401(LPCTarget):
  307. def __init__(self):
  308. LPCTarget.__init__(self)
  309. self.core = "Cortex-M0"
  310. self.extra_labels = ['NXP', 'LPC11UXX']
  311. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR"]
  312. self.default_toolchain = "uARM"
  313. self.supported_form_factors = ["ARDUINO"]
  314. ### Freescale ###
  315. class KL05Z(Target):
  316. def __init__(self):
  317. Target.__init__(self)
  318. self.core = "Cortex-M0+"
  319. self.extra_labels = ['Freescale', 'KLXX']
  320. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  321. self.default_toolchain = "uARM"
  322. self.supported_form_factors = ["ARDUINO"]
  323. self.is_disk_virtual = True
  324. class KL25Z(Target):
  325. def __init__(self):
  326. Target.__init__(self)
  327. self.core = "Cortex-M0+"
  328. self.extra_labels = ['Freescale', 'KLXX']
  329. self.supported_toolchains = ["ARM", "GCC_CW_EWL", "GCC_CW_NEWLIB", "GCC_ARM","IAR"]
  330. self.supported_form_factors = ["ARDUINO"]
  331. self.is_disk_virtual = True
  332. self.detect_code = ["0200"]
  333. class KL43Z(Target):
  334. def __init__(self):
  335. Target.__init__(self)
  336. self.core = "Cortex-M0+"
  337. self.extra_labels = ['Freescale', 'KLXX']
  338. self.supported_toolchains = ["GCC_ARM", "ARM"]
  339. self.supported_form_factors = ["ARDUINO"]
  340. self.is_disk_virtual = True
  341. class KL46Z(Target):
  342. def __init__(self):
  343. Target.__init__(self)
  344. self.core = "Cortex-M0+"
  345. self.extra_labels = ['Freescale', 'KLXX']
  346. self.supported_toolchains = ["GCC_ARM", "ARM", "IAR"]
  347. self.supported_form_factors = ["ARDUINO"]
  348. self.is_disk_virtual = True
  349. self.detect_code = ["0220"]
  350. class K20D50M(Target):
  351. def __init__(self):
  352. Target.__init__(self)
  353. self.core = "Cortex-M4"
  354. self.extra_labels = ['Freescale', 'K20XX']
  355. self.supported_toolchains = ["GCC_ARM", "ARM", "IAR"]
  356. self.is_disk_virtual = True
  357. self.detect_code = ["0230"]
  358. class TEENSY3_1(Target):
  359. OUTPUT_EXT = 'hex'
  360. def __init__(self):
  361. Target.__init__(self)
  362. self.core = "Cortex-M4"
  363. self.extra_labels = ['Freescale', 'K20XX', 'K20DX256']
  364. self.supported_toolchains = ["GCC_ARM", "ARM"]
  365. self.is_disk_virtual = True
  366. self.detect_code = ["0230"]
  367. def init_hooks(self, hook, toolchain_name):
  368. if toolchain_name in ['ARM_STD', 'ARM_MICRO', 'GCC_ARM']:
  369. hook.hook_add_binary("post", self.binary_hook)
  370. @staticmethod
  371. def binary_hook(t_self, resources, elf, binf):
  372. from intelhex import IntelHex
  373. binh = IntelHex()
  374. binh.loadbin(binf, offset = 0)
  375. with open(binf.replace(".bin", ".hex"), "w") as f:
  376. binh.tofile(f, format='hex')
  377. class K22F(Target):
  378. def __init__(self):
  379. Target.__init__(self)
  380. self.core = "Cortex-M4F"
  381. self.extra_labels = ['Freescale', 'KPSDK_MCUS', 'KPSDK_CODE']
  382. self.macros = ["CPU_MK22FN512VLH12", "FSL_RTOS_MBED"]
  383. self.supported_toolchains = ["ARM", "GCC_ARM", "IAR"]
  384. self.supported_form_factors = ["ARDUINO"]
  385. self.is_disk_virtual = True
  386. self.detect_code = ["0201"]
  387. class K64F(Target):
  388. def __init__(self):
  389. Target.__init__(self)
  390. self.core = "Cortex-M4F"
  391. self.extra_labels = ['Freescale', 'KPSDK_MCUS', 'KPSDK_CODE', 'MCU_K64F', 'FRDM']
  392. self.macros = ["CPU_MK64FN1M0VMD12", "FSL_RTOS_MBED"]
  393. self.supported_toolchains = ["ARM", "GCC_ARM", "IAR"]
  394. self.supported_form_factors = ["ARDUINO"]
  395. self.is_disk_virtual = True
  396. self.default_toolchain = "ARM"
  397. self.detect_code = ["0240"]
  398. class MTS_GAMBIT(Target):
  399. def __init__(self):
  400. Target.__init__(self)
  401. self.core = "Cortex-M4F"
  402. self.extra_labels = ['Freescale', 'KPSDK_MCUS', 'KPSDK_CODE', 'MCU_K64F']
  403. self.supported_toolchains = ["ARM", "GCC_ARM"]
  404. self.macros = ["CPU_MK64FN1M0VMD12", "FSL_RTOS_MBED", "TARGET_K64F"]
  405. self.is_disk_virtual = True
  406. self.default_toolchain = "ARM"
  407. ### STMicro ###
  408. class NUCLEO_F030R8(Target):
  409. def __init__(self):
  410. Target.__init__(self)
  411. self.core = "Cortex-M0"
  412. self.extra_labels = ['STM', 'STM32F0', 'STM32F030R8']
  413. self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"]
  414. self.default_toolchain = "uARM"
  415. self.supported_form_factors = ["ARDUINO", "MORPHO"]
  416. self.detect_code = ["0725"]
  417. class NUCLEO_F070RB(Target):
  418. def __init__(self):
  419. Target.__init__(self)
  420. self.core = "Cortex-M0"
  421. self.extra_labels = ['STM', 'STM32F0', 'STM32F070RB']
  422. self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"]
  423. self.default_toolchain = "uARM"
  424. self.supported_form_factors = ["ARDUINO", "MORPHO"]
  425. self.detect_code = ["0755"]
  426. class NUCLEO_F072RB(Target):
  427. def __init__(self):
  428. Target.__init__(self)
  429. self.core = "Cortex-M0"
  430. self.extra_labels = ['STM', 'STM32F0', 'STM32F072RB']
  431. self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"]
  432. self.default_toolchain = "uARM"
  433. self.supported_form_factors = ["ARDUINO", "MORPHO"]
  434. self.detect_code = ["0730"]
  435. class NUCLEO_F091RC(Target):
  436. def __init__(self):
  437. Target.__init__(self)
  438. self.core = "Cortex-M0"
  439. self.extra_labels = ['STM', 'STM32F0', 'STM32F091RC']
  440. self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"]
  441. self.default_toolchain = "uARM"
  442. self.supported_form_factors = ["ARDUINO", "MORPHO"]
  443. self.detect_code = ["0750"]
  444. class NUCLEO_F103RB(Target):
  445. def __init__(self):
  446. Target.__init__(self)
  447. self.core = "Cortex-M3"
  448. self.extra_labels = ['STM', 'STM32F1', 'STM32F103RB']
  449. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  450. self.default_toolchain = "uARM"
  451. self.supported_form_factors = ["ARDUINO", "MORPHO"]
  452. self.detect_code = ["0700"]
  453. class NUCLEO_F302R8(Target):
  454. def __init__(self):
  455. Target.__init__(self)
  456. self.core = "Cortex-M4F"
  457. self.extra_labels = ['STM', 'STM32F3', 'STM32F302R8']
  458. self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"]
  459. self.default_toolchain = "uARM"
  460. self.supported_form_factors = ["ARDUINO", "MORPHO"]
  461. self.detect_code = ["0705"]
  462. class NUCLEO_F303RE(Target):
  463. def __init__(self):
  464. Target.__init__(self)
  465. self.core = "Cortex-M4F"
  466. self.extra_labels = ['STM', 'STM32F3', 'STM32F303RE']
  467. self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"]
  468. self.default_toolchain = "uARM"
  469. self.supported_form_factors = ["ARDUINO", "MORPHO"]
  470. self.detect_code = ["0745"]
  471. class NUCLEO_F334R8(Target):
  472. def __init__(self):
  473. Target.__init__(self)
  474. self.core = "Cortex-M4F"
  475. self.extra_labels = ['STM', 'STM32F3', 'STM32F334R8']
  476. self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"]
  477. self.default_toolchain = "uARM"
  478. self.supported_form_factors = ["ARDUINO", "MORPHO"]
  479. self.detect_code = ["0735"]
  480. class NUCLEO_F401RE(Target):
  481. def __init__(self):
  482. Target.__init__(self)
  483. self.core = "Cortex-M4F"
  484. self.extra_labels = ['STM', 'STM32F4', 'STM32F401RE']
  485. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  486. self.default_toolchain = "uARM"
  487. self.supported_form_factors = ["ARDUINO", "MORPHO"]
  488. self.detect_code = ["0720"]
  489. class NUCLEO_F411RE(Target):
  490. def __init__(self):
  491. Target.__init__(self)
  492. self.core = "Cortex-M4F"
  493. self.extra_labels = ['STM', 'STM32F4', 'STM32F411RE']
  494. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  495. self.default_toolchain = "uARM"
  496. self.supported_form_factors = ["ARDUINO", "MORPHO"]
  497. self.detect_code = ["0740"]
  498. class NUCLEO_L053R8(Target):
  499. def __init__(self):
  500. Target.__init__(self)
  501. self.core = "Cortex-M0+"
  502. self.extra_labels = ['STM', 'STM32L0', 'STM32L053R8']
  503. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  504. self.default_toolchain = "uARM"
  505. self.supported_form_factors = ["ARDUINO", "MORPHO"]
  506. self.detect_code = ["0715"]
  507. class NUCLEO_L073RZ(Target):
  508. def __init__(self):
  509. Target.__init__(self)
  510. self.core = "Cortex-M0+"
  511. self.extra_labels = ['STM', 'STM32L0', 'STM32L073RZ']
  512. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  513. self.default_toolchain = "uARM"
  514. self.supported_form_factors = ["ARDUINO", "MORPHO"]
  515. self.detect_code = ["0760"]
  516. class NUCLEO_L152RE(Target):
  517. def __init__(self):
  518. Target.__init__(self)
  519. self.core = "Cortex-M3"
  520. self.extra_labels = ['STM', 'STM32L1', 'STM32L152RE']
  521. self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"]
  522. self.default_toolchain = "uARM"
  523. self.supported_form_factors = ["ARDUINO", "MORPHO"]
  524. self.detect_code = ["0710"]
  525. class STM32F3XX(Target):
  526. def __init__(self):
  527. Target.__init__(self)
  528. self.core = "Cortex-M4"
  529. self.extra_labels = ['STM', 'STM32F3XX']
  530. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"]
  531. self.default_toolchain = "uARM"
  532. class STM32F407(Target):
  533. def __init__(self):
  534. Target.__init__(self)
  535. self.core = "Cortex-M4F"
  536. self.extra_labels = ['STM', 'STM32F4', 'STM32F4XX']
  537. self.supported_toolchains = ["ARM", "GCC_ARM", "IAR"]
  538. class ARCH_MAX(Target):
  539. def __init__(self):
  540. Target.__init__(self)
  541. self.core = "Cortex-M4F"
  542. self.extra_labels = ['STM', 'STM32F4', 'STM32F407', 'STM32F407VG']
  543. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"]
  544. self.supported_form_factors = ["ARDUINO"]
  545. self.macros = ['LSI_VALUE=32000']
  546. def program_cycle_s(self):
  547. return 2
  548. class DISCO_F051R8(Target):
  549. def __init__(self):
  550. Target.__init__(self)
  551. self.core = "Cortex-M0"
  552. self.extra_labels = ['STM', 'STM32F0', 'STM32F051', 'STM32F051R8']
  553. self.supported_toolchains = ["GCC_ARM"]
  554. self.default_toolchain = "uARM"
  555. class DISCO_F100RB(Target):
  556. def __init__(self):
  557. Target.__init__(self)
  558. self.core = "Cortex-M3"
  559. self.extra_labels = ['STM', 'STM32F1', 'STM32F100RB']
  560. self.supported_toolchains = ["GCC_ARM"]
  561. self.default_toolchain = "uARM"
  562. class DISCO_F303VC(Target):
  563. def __init__(self):
  564. Target.__init__(self)
  565. self.core = "Cortex-M4F"
  566. self.extra_labels = ['STM', 'STM32F3', 'STM32F303', 'STM32F303VC']
  567. self.supported_toolchains = ["GCC_ARM"]
  568. self.default_toolchain = "uARM"
  569. class DISCO_F334C8(Target):
  570. def __init__(self):
  571. Target.__init__(self)
  572. self.core = "Cortex-M4F"
  573. self.extra_labels = ['STM', 'STM32F3', 'STM32F334C8']
  574. self.supported_toolchains = ["GCC_ARM",]
  575. self.default_toolchain = "GCC_ARM"
  576. self.detect_code = ["0735"]
  577. class DISCO_F407VG(Target):
  578. def __init__(self):
  579. Target.__init__(self)
  580. self.core = "Cortex-M4F"
  581. self.extra_labels = ['STM', 'STM32F4', 'STM32F407', 'STM32F407VG']
  582. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"]
  583. class DISCO_F429ZI(Target):
  584. def __init__(self):
  585. Target.__init__(self)
  586. self.core = "Cortex-M4F"
  587. self.extra_labels = ['STM', 'STM32F4', 'STM32F429', 'STM32F429ZI']
  588. self.supported_toolchains = ["GCC_ARM", "IAR"]
  589. self.default_toolchain = "GCC_ARM"
  590. class DISCO_L053C8(Target):
  591. def __init__(self):
  592. Target.__init__(self)
  593. self.core = "Cortex-M0+"
  594. self.extra_labels = ['STM', 'STM32L0', 'STM32L053C8']
  595. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM"]
  596. self.default_toolchain = "uARM"
  597. class MTS_MDOT_F405RG(Target):
  598. def __init__(self):
  599. Target.__init__(self)
  600. self.core = "Cortex-M4F"
  601. self.extra_labels = ['STM', 'STM32F4', 'STM32F405RG']
  602. self.macros = ['HSE_VALUE=26000000', 'OS_CLOCK=48000000']
  603. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  604. self.is_disk_virtual = True
  605. self.default_toolchain = "ARM"
  606. class MTS_MDOT_F411RE(Target):
  607. def __init__(self):
  608. Target.__init__(self)
  609. self.core = "Cortex-M4F"
  610. self.extra_labels = ['STM', 'STM32F4', 'STM32F411RE']
  611. self.macros = ['HSE_VALUE=26000000', 'OS_CLOCK=96000000', 'USE_PLL_HSE_EXTC=0', 'VECT_TAB_OFFSET=0x00010000']
  612. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  613. self.default_toolchain = "uARM"
  614. def init_hooks(self, hook, toolchain_name):
  615. if toolchain_name in ['GCC_ARM', 'ARM_STD', 'ARM_MICRO']:
  616. hook.hook_add_binary("post", self.combine_bins)
  617. # combine application binary with bootloader
  618. # bootloader + padding to 64kB + application + md5sum (16 bytes)
  619. @staticmethod
  620. def combine_bins(t_self, resources, elf, binf):
  621. loader = os.path.join(TOOLS_BOOTLOADERS, "MTS_MDOT_F411RE", "bootloader.bin")
  622. target = binf + ".tmp"
  623. if not os.path.exists(loader):
  624. print "Can't find bootloader binary: " + loader
  625. return
  626. outbin = open(target, 'w+b')
  627. part = open(loader, 'rb')
  628. data = part.read()
  629. outbin.write(data)
  630. outbin.write('\xFF' * (64*1024 - len(data)))
  631. part.close()
  632. part = open(binf, 'rb')
  633. data = part.read()
  634. outbin.write(data)
  635. part.close()
  636. outbin.seek(0, 0)
  637. data = outbin.read()
  638. outbin.seek(0, 1)
  639. crc = struct.pack('<I', binascii.crc32(data) & 0xFFFFFFFF)
  640. outbin.write(crc)
  641. outbin.close()
  642. os.remove(binf)
  643. os.rename(target, binf)
  644. class MTS_DRAGONFLY_F411RE(Target):
  645. def __init__(self):
  646. Target.__init__(self)
  647. self.core = "Cortex-M4F"
  648. self.extra_labels = ['STM', 'STM32F4', 'STM32F411RE']
  649. self.macros = ['HSE_VALUE=26000000', 'VECT_TAB_OFFSET=0x08010000']
  650. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  651. self.default_toolchain = "ARM"
  652. def init_hooks(self, hook, toolchain_name):
  653. if toolchain_name in ['GCC_ARM', 'ARM_STD', 'ARM_MICRO']:
  654. hook.hook_add_binary("post", self.combine_bins)
  655. # combine application binary with bootloader
  656. # bootloader + padding to 64kB + application + md5sum (16 bytes)
  657. @staticmethod
  658. def combine_bins(t_self, resources, elf, binf):
  659. loader = os.path.join(TOOLS_BOOTLOADERS, "MTS_DRAGONFLY_F411RE", "bootloader.bin")
  660. target = binf + ".tmp"
  661. if not os.path.exists(loader):
  662. print "Can't find bootloader binary: " + loader
  663. return
  664. outbin = open(target, 'w+b')
  665. part = open(loader, 'rb')
  666. data = part.read()
  667. outbin.write(data)
  668. outbin.write('\xFF' * (64*1024 - len(data)))
  669. part.close()
  670. part = open(binf, 'rb')
  671. data = part.read()
  672. outbin.write(data)
  673. part.close()
  674. outbin.seek(0, 0)
  675. data = outbin.read()
  676. outbin.seek(0, 1)
  677. crc = struct.pack('<I', binascii.crc32(data) & 0xFFFFFFFF)
  678. outbin.write(crc)
  679. outbin.close()
  680. os.remove(binf)
  681. os.rename(target, binf)
  682. class MOTE_L152RC(Target):
  683. def __init__(self):
  684. Target.__init__(self)
  685. self.core = "Cortex-M3"
  686. self.extra_labels = ['STM', 'STM32L1', 'STM32L152RC']
  687. self.supported_toolchains = ["ARM", "uARM", "IAR", "GCC_ARM"]
  688. self.default_toolchain = "uARM"
  689. self.detect_code = ["4100"]
  690. class DISCO_F401VC(Target):
  691. def __init__(self):
  692. Target.__init__(self)
  693. self.core = "Cortex-M4F"
  694. self.extra_labels = ['STM', 'STM32F4', 'STM32F401', 'STM32F401VC']
  695. self.supported_toolchains = ["GCC_ARM"]
  696. self.default_toolchain = "GCC_ARM"
  697. class UBLOX_C029(Target):
  698. def __init__(self):
  699. Target.__init__(self)
  700. self.core = "Cortex-M4F"
  701. self.extra_labels = ['STM', 'STM32F4', 'STM32F439', 'STM32F439ZI']
  702. self.macros = ['HSE_VALUE=24000000', 'HSE_STARTUP_TIMEOUT=5000']
  703. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "IAR"]
  704. self.default_toolchain = "uARM"
  705. self.supported_form_factors = ["ARDUINO"]
  706. ### Nordic ###
  707. class NRF51822(Target):
  708. # the following is a list of possible Nordic softdevices in decreasing order
  709. # of preference.
  710. EXPECTED_SOFTDEVICES_WITH_OFFSETS = [
  711. {
  712. 'name' : 's110_nrf51822_8.0.0_softdevice.hex',
  713. 'offset' : 0x18000
  714. },
  715. {
  716. 'name' : 's110_nrf51822_7.1.0_softdevice.hex',
  717. 'offset' : 0x16000
  718. },
  719. {
  720. 'name' : 's110_nrf51822_7.0.0_softdevice.hex',
  721. 'offset' : 0x16000
  722. },
  723. {
  724. 'name' : 's110_nrf51822_6.0.0_softdevice.hex',
  725. 'offset' : 0x14000
  726. }
  727. ]
  728. EXPECTED_BOOTLOADER_FILENAME = "nrf51822_bootloader.hex"
  729. OUTPUT_EXT = 'hex'
  730. MERGE_SOFT_DEVICE = True
  731. MERGE_BOOTLOADER = False
  732. def __init__(self):
  733. Target.__init__(self)
  734. self.core = "Cortex-M0"
  735. self.extra_labels = ["NORDIC", "NRF51822_MKIT", "MCU_NRF51822", "MCU_NORDIC_16K"]
  736. self.common_macros = ['NRF51']
  737. self.macros = self.common_macros
  738. self.supported_toolchains = ["ARM", "GCC_ARM", "IAR"]
  739. self.is_disk_virtual = True
  740. self.detect_code = ["1070"]
  741. def program_cycle_s(self):
  742. return 6
  743. def init_hooks(self, hook, toolchain_name):
  744. if toolchain_name in ['ARM_STD', 'ARM_MICRO', 'GCC_ARM', 'IAR']:
  745. hook.hook_add_binary("post", self.binary_hook)
  746. @staticmethod
  747. def binary_hook(t_self, resources, elf, binf):
  748. # Scan to find the actual paths of soft device and bootloader files
  749. sdf = None
  750. blf = None
  751. for hexf in resources.hex_files:
  752. if hexf.find(t_self.target.EXPECTED_BOOTLOADER_FILENAME) != -1:
  753. blf = hexf
  754. else:
  755. for softdeviceAndOffsetEntry in t_self.target.EXPECTED_SOFTDEVICES_WITH_OFFSETS:
  756. if hexf.find(softdeviceAndOffsetEntry['name']) != -1:
  757. sdf = hexf
  758. break
  759. if sdf is None:
  760. t_self.debug("Hex file not found. Aborting.")
  761. return
  762. # Merge user code with softdevice
  763. from intelhex import IntelHex
  764. binh = IntelHex()
  765. binh.loadbin(binf, offset=softdeviceAndOffsetEntry['offset'])
  766. if t_self.target.MERGE_SOFT_DEVICE is True:
  767. t_self.debug("Merge SoftDevice file %s" % softdeviceAndOffsetEntry['name'])
  768. sdh = IntelHex(sdf)
  769. binh.merge(sdh)
  770. if t_self.target.MERGE_BOOTLOADER is True and blf is not None:
  771. t_self.debug("Merge BootLoader file %s" % t_self.target.EXPECTED_BOOTLOADER_FILENAME)
  772. blh = IntelHex(blf)
  773. binh.merge(blh)
  774. with open(binf.replace(".bin", ".hex"), "w") as f:
  775. binh.tofile(f, format='hex')
  776. class NRF51822_BOOT(NRF51822):
  777. def __init__(self):
  778. NRF51822.__init__(self)
  779. self.core = "Cortex-M0"
  780. self.extra_labels = ["NORDIC", "NRF51822_MKIT", "MCU_NRF51822", "MCU_NORDIC_16K", "NRF51822"]
  781. self.macros = ['TARGET_NRF51822', 'TARGET_OTA_ENABLED']
  782. self.macros += self.common_macros
  783. self.supported_toolchains = ["ARM", "GCC_ARM"]
  784. self.MERGE_SOFT_DEVICE = True
  785. self.MERGE_BOOTLOADER = True
  786. class NRF51822_OTA(NRF51822):
  787. def __init__(self):
  788. NRF51822.__init__(self)
  789. self.core = "Cortex-M0"
  790. self.extra_labels = ["NORDIC", "NRF51822_MKIT", "MCU_NRF51822", "MCU_NORDIC_16K", "NRF51822"]
  791. self.macros = ['TARGET_NRF51822', 'TARGET_OTA_ENABLED']
  792. self.macros += self.common_macros
  793. self.supported_toolchains = ["ARM", "GCC_ARM"]
  794. self.MERGE_SOFT_DEVICE = False
  795. class NRF51_DK(NRF51822):
  796. def __init__(self):
  797. NRF51822.__init__(self)
  798. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_32K']
  799. self.macros = ['TARGET_NRF51822']
  800. self.macros += self.common_macros
  801. self.supported_form_factors = ["ARDUINO"]
  802. class NRF51_DK_BOOT(NRF51822):
  803. def __init__(self):
  804. NRF51822.__init__(self)
  805. self.core = "Cortex-M0"
  806. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_32K', 'NRF51_DK']
  807. self.macros = ['TARGET_NRF51822', 'TARGET_NRF51_DK', 'TARGET_OTA_ENABLED']
  808. self.macros += self.common_macros
  809. self.supported_toolchains = ["ARM", "GCC_ARM"]
  810. self.MERGE_SOFT_DEVICE = True
  811. self.MERGE_BOOTLOADER = True
  812. class NRF51_DK_OTA(NRF51822):
  813. def __init__(self):
  814. NRF51822.__init__(self)
  815. self.core = "Cortex-M0"
  816. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_32K', 'NRF51_DK']
  817. self.macros = ['TARGET_NRF51822', 'TARGET_NRF51_DK', 'TARGET_OTA_ENABLED']
  818. self.macros += self.common_macros
  819. self.supported_toolchains = ["ARM", "GCC_ARM"]
  820. self.MERGE_SOFT_DEVICE = False
  821. class NRF51_DONGLE(NRF51822):
  822. def __init__(self):
  823. NRF51822.__init__(self)
  824. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_32K']
  825. self.macros = ['TARGET_NRF51822']
  826. self.macros += self.common_macros
  827. class ARCH_BLE(NRF51822):
  828. def __init__(self):
  829. NRF51822.__init__(self)
  830. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_16K']
  831. self.macros = ['TARGET_NRF51822']
  832. self.macros += self.common_macros
  833. self.supported_form_factors = ["ARDUINO"]
  834. class SEEED_TINY_BLE(NRF51822):
  835. def __init__(self):
  836. NRF51822.__init__(self)
  837. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_16K']
  838. self.macros = ['TARGET_NRF51822']
  839. self.macros += self.common_macros
  840. class SEEED_TINY_BLE_BOOT(NRF51822):
  841. def __init__(self):
  842. NRF51822.__init__(self)
  843. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_16K', 'SEEED_TINY_BLE']
  844. self.macros = ['TARGET_NRF51822', 'TARGET_SEEED_TINY_BLE', 'TARGET_OTA_ENABLED']
  845. self.macros += self.common_macros
  846. self.MERGE_SOFT_DEVICE = True
  847. self.MERGE_BOOTLOADER = True
  848. class SEEED_TINY_BLE_OTA(NRF51822):
  849. def __init__(self):
  850. NRF51822.__init__(self)
  851. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_16K', 'SEEED_TINY_BLE']
  852. self.macros = ['TARGET_NRF51822', 'TARGET_SEEED_TINY_BLE', 'TARGET_OTA_ENABLED']
  853. self.macros += self.common_macros
  854. self.MERGE_SOFT_DEVICE = False
  855. class HRM1017(NRF51822):
  856. def __init__(self):
  857. NRF51822.__init__(self)
  858. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_16K']
  859. self.macros = ['TARGET_NRF51822']
  860. self.macros += self.common_macros
  861. class RBLAB_NRF51822(NRF51822):
  862. def __init__(self):
  863. NRF51822.__init__(self)
  864. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_16K']
  865. self.macros = ['TARGET_NRF51822']
  866. self.macros += self.common_macros
  867. self.supported_form_factors = ["ARDUINO"]
  868. class RBLAB_BLENANO(NRF51822):
  869. def __init__(self):
  870. NRF51822.__init__(self)
  871. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_16K']
  872. self.macros = ['TARGET_NRF51822']
  873. self.macros += self.common_macros
  874. class NRF51822_Y5_MBUG(NRF51822):
  875. def __init__(self):
  876. NRF51822.__init__(self)
  877. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_16K']
  878. self.macros = ['TARGET_NRF51822']
  879. self.macros += self.common_macros
  880. class XADOW_M0(LPCTarget):
  881. def __init__(self):
  882. LPCTarget.__init__(self)
  883. self.core = "Cortex-M0"
  884. self.extra_labels = ['NXP', 'LPC11UXX', 'MCU_LPC11U35_501']
  885. self.supported_toolchains = ["ARM", "uARM", "GCC_ARM", "GCC_CR", "IAR"]
  886. self.default_toolchain = "uARM"
  887. class WALLBOT_BLE(NRF51822):
  888. def __init__(self):
  889. NRF51822.__init__(self)
  890. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_16K']
  891. self.macros = ['TARGET_NRF51822']
  892. self.macros += self.common_macros
  893. class DELTA_DFCM_NNN40(NRF51822):
  894. def __init__(self):
  895. NRF51822.__init__(self)
  896. self.core = "Cortex-M0"
  897. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_16K']
  898. self.macros = ['TARGET_NRF51822']
  899. self.macros += self.common_macros
  900. class DELTA_DFCM_NNN40_OTA(NRF51822):
  901. def __init__(self):
  902. NRF51822.__init__(self)
  903. self.core = "Cortex-M0"
  904. self.extra_labels = ['NORDIC', 'MCU_NRF51822', 'MCU_NORDIC_16K', 'DELTA_DFCM_NNN40']
  905. self.MERGE_SOFT_DEVICE = False
  906. self.macros += self.common_macros
  907. ### ARM ###
  908. class ARM_MPS2_M0(Target):
  909. def __init__(self):
  910. Target.__init__(self)
  911. self.core = "Cortex-M0"
  912. self.extra_labels = ['ARM_SSG', 'MPS2_M0']
  913. self.macros = ['CMSDK_CM0']
  914. self.supported_toolchains = ["ARM", "GCC_ARM"]
  915. self.default_toolchain = "ARM"
  916. class ARM_MPS2_M0P(Target):
  917. def __init__(self):
  918. Target.__init__(self)
  919. self.core = "Cortex-M0+"
  920. self.extra_labels = ['ARM_SSG', 'MPS2_M0P']
  921. self.macros = ['CMSDK_CM0plus']
  922. self.supported_toolchains = ["ARM", "GCC_ARM"]
  923. self.default_toolchain = "ARM"
  924. class ARM_MPS2_M1(Target):
  925. def __init__(self):
  926. Target.__init__(self)
  927. self.core = "Cortex-M1"
  928. self.extra_labels = ['ARM_SSG', 'MPS2_M1']
  929. self.macros = ['CMSDK_CM1']
  930. self.supported_toolchains = ["ARM", "GCC_ARM"]
  931. self.default_toolchain = "ARM"
  932. class ARM_MPS2_M3(Target):
  933. def __init__(self):
  934. Target.__init__(self)
  935. self.core = "Cortex-M3"
  936. self.extra_labels = ['ARM_SSG', 'MPS2_M3']
  937. self.macros = ['CMSDK_CM3']
  938. self.supported_toolchains = ["ARM", "GCC_ARM"]
  939. self.default_toolchain = "ARM"
  940. class ARM_MPS2_M4(Target):
  941. def __init__(self):
  942. Target.__init__(self)
  943. self.core = "Cortex-M4F"
  944. self.extra_labels = ['ARM_SSG', 'MPS2_M4']
  945. self.macros = ['CMSDK_CM4']
  946. self.supported_toolchains = ["ARM", "GCC_ARM"]
  947. self.default_toolchain = "ARM"
  948. class ARM_MPS2_M7(Target):
  949. def __init__(self):
  950. Target.__init__(self)
  951. self.core = "Cortex-M7F"
  952. self.extra_labels = ['ARM_SSG', 'MPS2_M7']
  953. self.macros = ['CMSDK_CM7']
  954. self.supported_toolchains = ["ARM", "GCC_ARM"]
  955. self.default_toolchain = "ARM"
  956. class ARM_MPS2(ARM_MPS2_M4):
  957. pass
  958. ### Renesas ###
  959. class RZ_A1H(Target):
  960. def __init__(self):
  961. Target.__init__(self)
  962. self.core = "Cortex-A9"
  963. self.extra_labels = ['RENESAS', 'MBRZA1H']
  964. self.supported_toolchains = ["ARM", "GCC_ARM"]
  965. self.supported_form_factors = ["ARDUINO"]
  966. self.default_toolchain = "ARM"
  967. def program_cycle_s(self):
  968. return 2
  969. ### Maxim Integrated ###
  970. class MAXWSNENV(Target):
  971. def __init__(self):
  972. Target.__init__(self)
  973. self.core = "Cortex-M3"
  974. self.extra_labels = ['Maxim', 'MAX32610']
  975. self.macros = ['__SYSTEM_HFX=24000000']
  976. self.supported_toolchains = ["GCC_ARM", "IAR", "ARM"]
  977. self.default_toolchain = "ARM"
  978. class MAX32600MBED(Target):
  979. def __init__(self):
  980. Target.__init__(self)
  981. self.core = "Cortex-M3"
  982. self.extra_labels = ['Maxim', 'MAX32600']
  983. self.macros = ['__SYSTEM_HFX=24000000']
  984. self.supported_toolchains = ["GCC_ARM", "IAR", "ARM"]
  985. self.default_toolchain = "ARM"
  986. # Get a single instance for each target
  987. TARGETS = [
  988. ### NXP ###
  989. LPC11C24(),
  990. LPC11U24(),
  991. OC_MBUINO(), # LPC11U24
  992. LPC11U24_301(),
  993. LPC11U34_421(),
  994. APPNEARME_MICRONFCBOARD(), #LPC11U34_421
  995. LPC11U35_401(),
  996. LPC11U35_501(),
  997. XADOW_M0(), # LPC11U35_501
  998. LPC11U35_Y5_MBUG(),
  999. LPC11U37_501(),
  1000. LPCCAPPUCCINO(),# LPC11U37_501
  1001. ARCH_GPRS(), # LPC11U37_501
  1002. LPC11U68(),
  1003. LPC1114(),
  1004. LPC1347(),
  1005. LPC1549(),
  1006. LPC1768(),
  1007. ARCH_PRO(), # LPC1768
  1008. UBLOX_C027(), # LPC1768
  1009. LPC2368(),
  1010. LPC810(),
  1011. LPC812(),
  1012. LPC824(),
  1013. SSCI824(), # LPC824
  1014. LPC4088(),
  1015. LPC4088_DM(),
  1016. LPC4330_M4(),
  1017. LPC4330_M0(),
  1018. LPC4337(),
  1019. LPC11U37H_401(),
  1020. ### Freescale ###
  1021. KL05Z(),
  1022. KL25Z(),
  1023. KL43Z(),
  1024. KL46Z(),
  1025. K20D50M(),
  1026. TEENSY3_1(),
  1027. K22F(),
  1028. K64F(),
  1029. MTS_GAMBIT(), # FRDM K64F
  1030. ### STMicro ###
  1031. NUCLEO_F030R8(),
  1032. NUCLEO_F070RB(),
  1033. NUCLEO_F072RB(),
  1034. NUCLEO_F091RC(),
  1035. NUCLEO_F103RB(),
  1036. NUCLEO_F302R8(),
  1037. NUCLEO_F303RE(),
  1038. NUCLEO_F334R8(),
  1039. NUCLEO_F401RE(),
  1040. NUCLEO_F411RE(),
  1041. NUCLEO_L053R8(),
  1042. NUCLEO_L073RZ(),
  1043. NUCLEO_L152RE(),
  1044. STM32F3XX(),
  1045. STM32F407(),
  1046. DISCO_F051R8(),
  1047. DISCO_F100RB(),
  1048. DISCO_F303VC(),
  1049. DISCO_F334C8(),
  1050. DISCO_F407VG(), # STM32F407
  1051. ARCH_MAX(), # STM32F407
  1052. DISCO_F429ZI(),
  1053. DISCO_L053C8(),
  1054. MTS_MDOT_F405RG(),
  1055. MTS_MDOT_F411RE(),
  1056. MOTE_L152RC(),
  1057. MTS_DRAGONFLY_F411RE(),
  1058. DISCO_F401VC(),
  1059. UBLOX_C029(), # STM32F439
  1060. ### Nordic ###
  1061. NRF51822(),
  1062. NRF51822_BOOT(), # nRF51822
  1063. NRF51822_OTA(), # nRF51822
  1064. NRF51_DK(),
  1065. NRF51_DK_BOOT(), # nRF51822
  1066. NRF51_DK_OTA(), # nRF51822
  1067. NRF51_DONGLE(),
  1068. ARCH_BLE(), # nRF51822
  1069. SEEED_TINY_BLE(), # nRF51822
  1070. SEEED_TINY_BLE_BOOT(),# nRF51822
  1071. SEEED_TINY_BLE_OTA(),# nRF51822
  1072. HRM1017(), # nRF51822
  1073. RBLAB_NRF51822(),# nRF51822
  1074. RBLAB_BLENANO(),# nRF51822
  1075. NRF51822_Y5_MBUG(),#nRF51822
  1076. WALLBOT_BLE(), # nRF51822
  1077. DELTA_DFCM_NNN40(), # nRF51822
  1078. DELTA_DFCM_NNN40_OTA(), # nRF51822
  1079. ### ARM ###
  1080. ARM_MPS2_M0(),
  1081. ARM_MPS2_M0P(),
  1082. ARM_MPS2_M1(),
  1083. ARM_MPS2_M3(),
  1084. ARM_MPS2_M4(),
  1085. ARM_MPS2_M7(),
  1086. ARM_MPS2(),
  1087. ### Renesas ###
  1088. RZ_A1H(),
  1089. ### Maxim Integrated ###
  1090. MAXWSNENV(),
  1091. MAX32600MBED(),
  1092. ]
  1093. # Map each target name to its unique instance
  1094. TARGET_MAP = {}
  1095. for t in TARGETS:
  1096. TARGET_MAP[t.name] = t
  1097. TARGET_NAMES = TARGET_MAP.keys()
  1098. # Some targets with different name have the same exporters
  1099. EXPORT_MAP = { }
  1100. # Detection APIs
  1101. def get_target_detect_codes():
  1102. """ Returns dictionary mapping detect_code -> platform_name
  1103. """
  1104. result = {}
  1105. for target in TARGETS:
  1106. for detect_code in target.detect_code:
  1107. result[detect_code] = target.name
  1108. return result