tools.nut 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. --
  2. -- Copyright (C) 2004-2005 by egnite Software GmbH. All rights reserved.
  3. --
  4. -- Redistribution and use in source and binary forms, with or without
  5. -- modification, are permitted provided that the following conditions
  6. -- are met:
  7. --
  8. -- 1. Redistributions of source code must retain the above copyright
  9. -- notice, this list of conditions and the following disclaimer.
  10. -- 2. Redistributions in binary form must reproduce the above copyright
  11. -- notice, this list of conditions and the following disclaimer in the
  12. -- documentation and/or other materials provided with the distribution.
  13. -- 3. Neither the name of the copyright holders nor the names of
  14. -- contributors may be used to endorse or promote products derived
  15. -- from this software without specific prior written permission.
  16. --
  17. -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. -- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  20. -- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  21. -- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  22. -- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  23. -- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  24. -- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  25. -- AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. -- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  27. -- THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. -- SUCH DAMAGE.
  29. --
  30. -- For additional information see http://www.ethernut.de/
  31. --
  32. -- Tools
  33. --
  34. -- $Log$
  35. -- Revision 1.30 2010/12/15 18:41:29 ve2yag
  36. -- Added bootloader support script for AT91SAM7S family.
  37. --
  38. -- Revision 1.29 2009/03/07 00:04:29 olereinhardt
  39. -- Added at91_bootloader_bootcrom ldscript
  40. --
  41. -- Revision 1.28 2008/09/23 07:33:53 haraldkipp
  42. -- Added support for remaining SAM7 familiy members.
  43. --
  44. -- Revision 1.27 2008/09/18 09:48:06 haraldkipp
  45. -- The old Marv_XXX do no longer work with ICCAVR 7.18B.
  46. --
  47. -- Revision 1.26 2008/08/11 11:51:20 thiagocorrea
  48. -- Preliminary Atmega2560 compile options, but not yet supported.
  49. -- It builds, but doesn't seam to run properly at this time.
  50. --
  51. -- Revision 1.25 2008/08/06 12:51:07 haraldkipp
  52. -- Added support for Ethernut 5 (AT91SAM9XE reference design).
  53. --
  54. -- Revision 1.24 2008/07/14 13:04:28 haraldkipp
  55. -- New Ethernut 3 link option with code in RAM and constant data in ROM.
  56. --
  57. -- Revision 1.23 2008/07/09 09:15:56 haraldkipp
  58. -- EIR code running in RAM, contributed by Michael Fischer.
  59. --
  60. -- Revision 1.22 2008/06/28 07:49:33 haraldkipp
  61. -- Added floating point support for stdio running on ARM.
  62. --
  63. -- Revision 1.21 2008/04/01 10:12:33 haraldkipp
  64. -- Beautified target list.
  65. --
  66. -- Revision 1.20 2008/02/15 17:04:48 haraldkipp
  67. -- Spport for AT91SAM7SE512 added.
  68. --
  69. -- Revision 1.19 2008/01/31 09:14:09 haraldkipp
  70. -- Added ability to upload AT91 flash image via HTTP. Many thanks to
  71. -- Matthias Wilde.
  72. --
  73. -- Revision 1.18 2007/10/04 20:15:26 olereinhardt
  74. -- Support for SAM7S256 added
  75. --
  76. -- Revision 1.17 2007/09/11 13:39:45 haraldkipp
  77. -- Configurable startup file for ICCAVR.
  78. --
  79. -- Revision 1.16 2007/04/12 09:20:00 haraldkipp
  80. -- ATmega2561 no longer bound to ICCAVR.
  81. --
  82. -- Revision 1.15 2006/10/05 17:14:45 haraldkipp
  83. -- Added exclusivity attribute.
  84. --
  85. -- Revision 1.14 2006/09/05 12:31:34 haraldkipp
  86. -- Added missing linker script for SAM9260 applications running in external
  87. -- RAM.
  88. --
  89. -- Revision 1.13 2006/08/01 07:34:16 haraldkipp
  90. -- New linker script and new startup file support applications running in
  91. -- flash memory.
  92. --
  93. -- Revision 1.12 2006/07/10 14:27:31 haraldkipp
  94. -- Added ARM C++ support.
  95. --
  96. -- Revision 1.11 2006/07/10 08:48:03 haraldkipp
  97. -- Distinguish between enhanced and extended AVR.
  98. --
  99. -- Revision 1.10 2006/03/02 19:54:48 haraldkipp
  100. -- First attempt to compile with ICCARM. All compile errors fixed, but not
  101. -- a finished port yet. Many things are missing.
  102. --
  103. -- Revision 1.9 2006/02/08 15:20:21 haraldkipp
  104. -- ATmega2561 Support
  105. --
  106. -- Revision 1.8 2005/10/24 10:06:21 haraldkipp
  107. -- New linker scripts added for AT91 apps running in RAM and ROM.
  108. --
  109. -- Revision 1.7 2005/06/05 16:57:00 haraldkipp
  110. -- ICC target corrected
  111. --
  112. -- Revision 1.6 2005/04/05 18:04:17 haraldkipp
  113. -- Support for ARM7 Wolf Board added.
  114. --
  115. -- Revision 1.5 2005/01/22 19:19:31 haraldkipp
  116. -- Added C++ support contributed by Oliver Schulz (MPI).
  117. --
  118. -- Revision 1.4 2004/10/03 18:37:39 haraldkipp
  119. -- GBA support
  120. --
  121. -- Revision 1.3 2004/09/07 19:12:57 haraldkipp
  122. -- Linker script support added
  123. --
  124. -- Revision 1.2 2004/08/18 16:05:13 haraldkipp
  125. -- Use consistent directory structure
  126. --
  127. -- Revision 1.1 2004/08/18 14:02:00 haraldkipp
  128. -- First check-in
  129. --
  130. --
  131. --
  132. toolchain_names = {"ARM_GCC", "ARM_GCC_NOLIBC", "AVR_GCC", "AVR32_GCC", "CM3_GCC", "CM3_GCC_NOLIBC", "LINUX_GCC", "ICCAVR", "ICCARM", "M68K_GCC_CS"}
  133. gcc_output_format = {"ARMELF", "ARMEABI"}
  134. nuttools =
  135. {
  136. options =
  137. {
  138. {
  139. brief = "GCC for ARM",
  140. description = "GNU Compiler Collection for ARM including libc.",
  141. provides = { "TOOL_CC_ARM", "TOOL_GCC", "TOOL_CXX", "TOOL_ARMLIB" },
  142. macro = "ARM_GCC",
  143. flavor = "boolean",
  144. exclusivity = toolchain_names,
  145. file = "include/cfg/arch.h"
  146. },
  147. {
  148. brief = "GCC for ARM (no libc)",
  149. description = "GNU Compiler Collection for ARM excluding libc."..
  150. "Nut/OS provides all required C standard functions.",
  151. provides = { "TOOL_CC_ARM", "TOOL_GCC", "TOOL_CXX", "TOOL_NOLIBC" },
  152. macro = "ARM_GCC_NOLIBC",
  153. flavor = "boolean",
  154. exclusivity = toolchain_names,
  155. file = "include/cfg/arch.h",
  156. makedefs = { "ADDLIBS = -lnutc" }
  157. },
  158. {
  159. brief = "GCC for CortexM",
  160. description = "GNU Compiler Collection for ARM CortexM including libc.",
  161. provides = { "TOOL_CC_CM3", "TOOL_GCC", "TOOL_CXX", "TOOL_ARMLIB" },
  162. macro = "CM3_GCC",
  163. flavor = "boolean",
  164. exclusivity = toolchain_names,
  165. file = "include/cfg/arch.h"
  166. },
  167. {
  168. brief = "GCC for CortexM (no libc)",
  169. description = "GNU Compiler Collection for ARM CortexM excluding libc."..
  170. "Nut/OS provides all required C standard functions.",
  171. provides = { "TOOL_CC_CM3", "TOOL_GCC", "TOOL_CXX", "TOOL_NOLIBC" },
  172. macro = "CM3_GCC_NOLIBC",
  173. flavor = "boolean",
  174. exclusivity = toolchain_names,
  175. file = "include/cfg/arch.h",
  176. makedefs = { "ADDLIBS = -lnutc" }
  177. },
  178. {
  179. brief = "GCC for AVR",
  180. description = "GNU Compiler Collection for ARM including avr-libc.",
  181. -- "TOOL_CXX" disabled due to problems with avr-libc eeprom.h.
  182. provides = { "TOOL_CC_AVR", "TOOL_GCC" },
  183. macro = "AVR_GCC",
  184. flavor = "boolean",
  185. exclusivity = toolchain_names,
  186. file = "include/cfg/arch.h",
  187. makedefs = { "MCU_ATMEGA2560=atmega2560", "MCU_ATMEGA2561=atmega2561", "MCU_ATMEGA128=atmega128", "MCU_ATMEGA103=atmega103" }
  188. },
  189. {
  190. brief = "GCC for AVR32",
  191. description = "GNU Compiler Collection for AVR32 including libc.",
  192. provides = { "TOOL_CC_AVR32", "TOOL_GCC", "TOOL_CXX" },
  193. macro = "AVR32_GCC",
  194. flavor = "boolean",
  195. exclusivity = toolchain_names,
  196. file = "include/cfg/arch.h",
  197. },
  198. {
  199. brief = "GCC for Linux",
  200. description = "Linux emulation.",
  201. provides = { "TOOL_CC_LINUX", "TOOL_GCC" },
  202. macro = "LINUX_GCC",
  203. flavor = "boolean",
  204. exclusivity = toolchain_names,
  205. file = "include/cfg/arch.h"
  206. },
  207. {
  208. brief = "ImageCraft for AVR",
  209. description = "www.imagecraft.com",
  210. provides = { "TOOL_CC_AVR", "TOOL_ICC" },
  211. macro = "ICCAVR",
  212. flavor = "boolean",
  213. exclusivity = toolchain_names,
  214. file = "include/cfg/arch.h",
  215. makedefs = { "MCU_ATMEGA2560=Extended", "MCU_ATMEGA2561=Extended", "MCU_ATMEGA128=Enhanced", "MCU_ATMEGA103=LongJump" }
  216. },
  217. {
  218. brief = "ImageCraft for ARM",
  219. description = "Not yet supported",
  220. provides = { "TOOL_CC_ARM", "TOOL_ICC" },
  221. macro = "ICCARM",
  222. flavor = "boolean",
  223. exclusivity = toolchain_names,
  224. file = "include/cfg/arch.h",
  225. },
  226. {
  227. brief = "Sourcery G++ for Coldfire ELF (nolibc)",
  228. description = "GNU Compiler Collection with Run-Time Libraries from CodeSourcery http://www.mentor.com/embedded-software/codesourcery/\n"..
  229. "Sourcery's Run-Time Libraries are not used.\n"..
  230. "Nut/OS provides all required C standard functions.",
  231. provides = { "TOOL_CC_M68K", "TOOL_GCC", "TOOL_NOLIBC" },
  232. macro = "M68K_GCC_CS",
  233. flavor = "boolean",
  234. exclusivity = toolchain_names,
  235. file = "include/cfg/arch.h",
  236. makedefs = { "ADDLIBS = -lnutc" }
  237. }
  238. },
  239. {
  240. name = "nuttools_gccopt",
  241. brief = "GCC Settings",
  242. requires = { "TOOL_GCC" },
  243. options =
  244. {
  245. {
  246. macro = "LDSCRIPT",
  247. brief = "Predefined Linker Script",
  248. description = function() return GetLDScriptDescription(); end,
  249. requires = { "TOOL_GCC" },
  250. flavor = "booldata",
  251. type = "enumerated",
  252. choices = function() return GetLDScripts(); end,
  253. makedefs = function() return { "LDNAME", "LDSCRIPT=$(LDNAME).ld", "LDPATH=" .. GetLDScriptsPath() }; end,
  254. exclusivity = { "LDSCRIPT", "LLDSCRIPT" },
  255. },
  256. {
  257. macro = "LLDSCRIPT",
  258. brief = "Local Linker Script",
  259. description = "Alternatively a local linker script file name can be provided.",
  260. requires = { "TOOL_GCC" },
  261. flavor = "booldata",
  262. type = "bool",
  263. makedefs = { "LDNAME", "LDSCRIPT=" .. "$(LDNAME)"},
  264. exclusivity = { "LDSCRIPT", "LLDSCRIPT" },
  265. },
  266. {
  267. brief = "arm-elf",
  268. description = "Old binary format",
  269. requires = { "TOOL_CC_ARM" },
  270. macro = "ARMELF",
  271. flavor = "boolean",
  272. exclusivity = gcc_output_format,
  273. makedefs = { "TRGT = arm-elf-" }
  274. },
  275. {
  276. brief = "arm-none-eabi",
  277. description = "New binary format",
  278. requires = { "TOOL_CC_ARM" },
  279. macro = "ARMEABI",
  280. flavor = "boolean",
  281. exclusivity = gcc_output_format,
  282. makedefs = { "TRGT = arm-none-eabi-" }
  283. }
  284. }
  285. },
  286. {
  287. name = "nuttools_iccopt",
  288. brief = "ImageCraft AVR Settings",
  289. requires = { "TOOL_CC_AVR", "TOOL_ICC" },
  290. options =
  291. {
  292. {
  293. macro = "ICCAVR_STARTUP",
  294. brief = "Startup File",
  295. description = "Select one of the following:\n\n"..
  296. "crtnut, if globals and static variables use less than 4kB.\n"..
  297. "crtenut, same as above but including EEPROM emulation.\n"..
  298. "crtnutram, if globals and static variables use more than 4kB.\n"..
  299. "crtenutram, same as above but including EEPROM emulation.\n"..
  300. "crtnutm256, for the ATmega2560 and ATmega2561.\n\n"..
  301. "Ethernut 1 up to 1.3 Rev-F and all Ethernut 2 boards as well as most "..
  302. "compatible boards require crtnutram.\n\n"..
  303. "Ethernut 1.3 Rev-G and Rev-H boards need crtenutram. This startup "..
  304. "should also work for all other boards with ATmega103/128 CPUs, but "..
  305. "requires slightly more code than crtnutram.\n\n"..
  306. "Use crtnutm256 for Ethernut and compatible boards with ATmega256 CPU.\n",
  307. type = "enumerated",
  308. choices = iccavr_startup_choice,
  309. makedefs = { "CRTNAME" }
  310. }
  311. }
  312. }
  313. --
  314. -- Intentionally no programmer or urom creator specified.
  315. -- This will be part of the application wizard.
  316. --
  317. }
  318. avr32_ld_description =
  319. {
  320. uc3a0512_rom = "AVR32UC3A0512, code running in FLASH",
  321. uc3a0512_rom_extram = "AVR32UC3A0512, code running in FLASH, data in external SDRAM",
  322. uc3a3256_rom = "AT32UC3A3256, code running in FLASH",
  323. uc3a3256_rom_extram = "AT32UC3A3256, code running in FLASH, data in external SDRAM",
  324. uc3a0256_rom = "AT32UC3A0256, code running in FLASH",
  325. uc3b164_rom = "AT32UC3B164, code running in FLASH",
  326. uc3l064_rom = "AT32UC3B164, code running in FLASH",
  327. }
  328. avr32_ld_choice =
  329. {
  330. " ",
  331. "uc3a0512_rom",
  332. "uc3a0512_rom_extram",
  333. "uc3a3256_rom",
  334. "uc3a3256_rom_extram",
  335. "uc3a0256_rom",
  336. "uc3b164_rom",
  337. "uc3l064_rom"
  338. }
  339. arm_ld_description =
  340. {
  341. at91_boot = "AT91R40008, code in ROM, copied to and running in RAM",
  342. at91_bootcrom = "AT91R40008, code in ROM copied to RAM, but constant data remains in ROM.",
  343. at91_bootloader_bootcrom = "AT91R40008, code copied to RAM, but consts remain in ROM. Started by bootloader at address 0x10000",
  344. at91_ram = "AT91R40008, code loaded in RAM (deprecated, use at91x40_ram)",
  345. at91_rom = "AT91R40008, code running in FLASH (deprecated, use at91x40_rom)",
  346. at91_httprom = "AT91R40008, code running in FLASH. Use this with boothttp.",
  347. at91sam7x128_rom = "AT91SAM7X128, code running in FLASH",
  348. at91sam7x256_rom = "AT91SAM7X256, code running in FLASH",
  349. at91sam7x256_bootrom = "AT91SAM7X256, code running in FLASH, bootloader in FLASH (code entry at offset 0xC000)",
  350. at91sam7x512_rom = "AT91SAM7X512, code running in FLASH",
  351. at91sam7x512_bootrom = "AT91SAM7X512, code running in FLASH, bootloader in FLASH (code entry at offset 0xC000)",
  352. at91sam7s16_rom = "AT91SAM7S16, code running in FLASH",
  353. at91sam7s32_rom = "AT91SAM7S32, code running in FLASH",
  354. at91sam7s64_rom = "AT91SAM7S64, code running in FLASH",
  355. at91sam7s64_bootrom = "AT91SAM7S64, code running in FLASH, bootloader in FLASH",
  356. at91sam7s128_rom = "AT91SAM7S128, code running in FLASH",
  357. at91sam7s256_rom = "AT91SAM7S256, code running in FLASH",
  358. at91sam7s256_bootrom = "AT91SAM7S256, code running in FLASH, bootloader in FLASH",
  359. at91sam7s512_rom = "AT91SAM7S512, code running in FLASH",
  360. at91sam7se32_rom = "AT91SAM7SE32, code running in FLASH, data in SDRAM",
  361. at91sam7se32_xram = "AT91SAM7SE32, code loaded into external RAM",
  362. at91sam7se256_rom = "AT91SAM7SE256, code running in FLASH, data in SDRAM",
  363. at91sam7se256_xram = "AT91SAM7SE256, code loaded into external RAM",
  364. at91sam7se512_rom = "AT91SAM7SE512, code running in FLASH, data in SDRAM",
  365. at91sam7se512_ram = "AT91SAM7SE512, code in SDRAM (deprecated, use at91sam7se512_xram)",
  366. at91sam7se512_xram = "AT91SAM7SE512, code loaded into external RAM",
  367. at91sam9260_ram = "AT91SAM9260, code running in external RAM",
  368. at91sam9G45_ram = "AT91SAM9G45, code running in external RAM",
  369. at91sam9xe512_ram = "AT91SAM9XE512, code running in external RAM",
  370. at91x40_ram = "AT91X40, code loaded in RAM by bootloader/debugger",
  371. at91x40_rom = "AT91X40, code running in FLASH",
  372. ["s3c4510b-ram"] = "Samsung's S3C4510B, code in RAM (unsupported)",
  373. eb40a_ram = "Atmel's AT91EB40A, code in RAM at 0x100",
  374. gba_xport2 = "Nintendo's Gameboy Advance"
  375. }
  376. arm_ld_choice =
  377. {
  378. " ",
  379. "at91_boot",
  380. "at91_bootcrom",
  381. "at91_bootloader_bootcrom",
  382. "at91_ram",
  383. "at91_rom",
  384. "at91_httprom",
  385. "at91sam7s16_rom",
  386. "at91sam7s32_rom",
  387. "at91sam7s64_rom",
  388. "at91sam7s64_bootrom",
  389. "at91sam7s128_rom",
  390. "at91sam7s256_rom",
  391. "at91sam7s256_bootrom",
  392. "at91sam7s512_rom",
  393. "at91sam7se32_rom",
  394. "at91sam7se32_xram",
  395. "at91sam7se256_rom",
  396. "at91sam7se256_xram",
  397. "at91sam7se512_rom",
  398. "at91sam7se512_ram",
  399. "at91sam7se512_xram",
  400. "at91sam7x128_rom",
  401. "at91sam7x256_rom",
  402. "at91sam7x256_bootrom",
  403. "at91sam7x512_rom",
  404. "at91sam7x512_bootrom",
  405. "at91sam9260_ram",
  406. "at91sam9G45_ram",
  407. "at91sam9xe512_ram",
  408. "at91x40_ram",
  409. "at91x40_rom",
  410. "s3c4510b-ram",
  411. "eb40a_ram",
  412. "eb40a_redboot_ram",
  413. "gbaxport2",
  414. "zero"
  415. }
  416. stm32f10x_ld_header = { "Select the matching predefined linker script for your chip\n\n" }
  417. stm32f100_ld_description =
  418. {
  419. stm32f100x8_flash = "STM32F100x8, code running in FLASH, data in SRAM",
  420. stm32f100xB_flash = "STM32F100xB, code running in FLASH, data in SRAM",
  421. stm32f100xC_flash = "STM32F100xC, code running in FLASH, data in SRAM",
  422. stm32f100xD_flash = "STM32F100xD, code running in FLASH, data in SRAM",
  423. stm32f100xE_flash = "STM32F100xE, code running in FLASH, data in SRAM",
  424. }
  425. stm32f101_ld_description =
  426. {
  427. stm32f101x8_flash = "STM32F101x8 and STM32F102x8, code running in FLASH, data in SRAM",
  428. stm32f101xB_flash = "STM32F101xB and STM32F102xB, code running in FLASH, data in SRAM",
  429. stm32f101xC_flash = "STM32F101xC and STM32F102xC, code running in FLASH, data in SRAM",
  430. stm32f101xD_flash = "STM32F101xD and STM32F102xD, code running in FLASH, data in SRAM",
  431. stm32f101xE_flash = "STM32F101xE and STM32F102xE, code running in FLASH, data in SRAM",
  432. }
  433. stm32f102_ld_description =
  434. {
  435. stm32f102x8_flash = "STM32F102x8 and STM32F102x8, code running in FLASH, data in SRAM",
  436. stm32f102xB_flash = "STM32F102xB and STM32F102xB, code running in FLASH, data in SRAM",
  437. }
  438. stm32f103_ld_description =
  439. {
  440. stm32f103x8_flash = "STM32F103x8 and STM32F102x8, code running in FLASH, data in SRAM",
  441. stm32f103xB_flash = "STM32F103xB and STM32F102xB, code running in FLASH, data in SRAM",
  442. stm32f103xC_flash = "STM32F103xC and STM32F102xC, code running in FLASH, data in SRAM",
  443. stm32f103xD_flash = "STM32F103xD and STM32F102xD, code running in FLASH, data in SRAM",
  444. stm32f103xE_flash = "STM32F103xE and STM32F102xE, code running in FLASH, data in SRAM",
  445. }
  446. stm32f105_ld_description =
  447. {
  448. stm32f105x8_flash = "STM32F105x8 and STM32F102x8, code running in FLASH, data in SRAM",
  449. stm32f105xB_flash = "STM32F105xB and STM32F102xB, code running in FLASH, data in SRAM",
  450. stm32f105xC_flash = "STM32F105xC and STM32F102xC, code running in FLASH, data in SRAM",
  451. }
  452. stm32f107_ld_description =
  453. {
  454. stm32f107xB_flash = "STM32F107xB and STM32F102xB, code running in FLASH, data in SRAM",
  455. stm32f107xC_flash = "STM32F107xC and STM32F102xC, code running in FLASH, data in SRAM",
  456. }
  457. stm32f2x5_ld_description =
  458. {
  459. stm32f205xB_flash = "STM32F205xB and STM32F215xB, code running in FLASH, data in SRAM",
  460. stm32f205xC_flash = "STM32F205xC and STM32F215xC, code running in FLASH, data in SRAM",
  461. stm32f205xE_flash = "STM32F205xE and STM32F215xE, code running in FLASH, data in SRAM",
  462. stm32f205xF_flash = "STM32F205xF and STM32F215xF, code running in FLASH, data in SRAM",
  463. stm32f205xG_flash = "STM32F205xG and STM32F215xG, code running in FLASH, data in SRAM",
  464. }
  465. stm32f2x7_ld_description =
  466. {
  467. stm32f207xC_flash = "STM32F207xC and STM32F217xC, code running in FLASH, data in SRAM",
  468. stm32f207xE_flash = "STM32F207xE and STM32F217xE, code running in FLASH, data in SRAM",
  469. stm32f207xF_flash = "STM32F207xF and STM32F217xF, code running in FLASH, data in SRAM",
  470. stm32f207xG_flash = "STM32F207xG and STM32F217xG, code running in FLASH, data in SRAM",
  471. }
  472. stm32l151_ld_description =
  473. {
  474. stm32f151x6_flash = "STM32L151x6 and STM32L152x6, code running in FLASH, data in SRAM",
  475. stm32f151x8_flash = "STM32L151x8 and STM32L152x8, code running in FLASH, data in SRAM",
  476. stm32f151xB_flash = "STM32L151xB and STM32L152xB, code running in FLASH, data in SRAM",
  477. }
  478. stm32f100_ld_choice =
  479. {
  480. "stm32f100x8_flash",
  481. "stm32f100xB_flash",
  482. "stm32f100xC_flash",
  483. "stm32f100xD_flash",
  484. "stm32f100xE_flash",
  485. }
  486. stm32f101_ld_choice =
  487. {
  488. "stm32f101x8_flash",
  489. "stm32f101xB_flash",
  490. "stm32f101xC_flash",
  491. "stm32f101xD_flash",
  492. "stm32f101xE_flash",
  493. }
  494. stm32f102_ld_choice =
  495. {
  496. "stm32f102x8_flash",
  497. "stm32f102xB_flash",
  498. }
  499. stm32f103_ld_choice =
  500. {
  501. "stm32f103x8_flash",
  502. "stm32f103xB_flash",
  503. "stm32f103xC_flash",
  504. "stm32f103xD_flash",
  505. "stm32f103xE_flash",
  506. }
  507. stm32f105_ld_choice =
  508. {
  509. "stm32f105x8_flash",
  510. "stm32f105xB_flash",
  511. "stm32f105xC_flash",
  512. }
  513. stm32f107_ld_choice =
  514. {
  515. "stm32f107xB_flash",
  516. "stm32f107xC_flash",
  517. }
  518. stm32f2x5_ld_choice =
  519. {
  520. "stm32f2x5xB_flash",
  521. "stm32f2x5xC_flash",
  522. "stm32f2x5xE_flash",
  523. "stm32f2x5xF_flash",
  524. "stm32f2x5xG_flash",
  525. }
  526. stm32f2x7_ld_choice =
  527. {
  528. "stm32f2x7xC_flash",
  529. "stm32f2x7xE_flash",
  530. "stm32f2x7xF_flash",
  531. "stm32f2x7xG_flash",
  532. }
  533. stm32l151_ld_choice =
  534. {
  535. "stm32l15Xx6_flash",
  536. "stm32f15Xx8_flash",
  537. "stm32f15XxB_flash",
  538. }
  539. lm3_ld_description =
  540. {
  541. lm3s9b96_flash = "LM3S9B96, code running in FLASH, data in SRAM",
  542. }
  543. lm3_ld_choice =
  544. {
  545. "lm3s9b96_flash",
  546. }
  547. lpc17xx_ld_description =
  548. {
  549. lpc1768_flash = "LPC1768, code running in FLASH, data in SRAM",
  550. lpc1778_flash = "LPC1778/LPC1788, code running in FLASH, data in SRAM",
  551. }
  552. lpc17xx_ld_choice =
  553. {
  554. "lpc1768_flash",
  555. "lpc1778_flash",
  556. }
  557. mcf51cn_ld_description = {
  558. mcf51cn_512_rom = "MCF51cn, code running in FLASH",
  559. }
  560. mcf51cn_ld_choice = {
  561. " ",
  562. "mcf51cn_128_rom",
  563. }
  564. mcf5225x_ld_description = {
  565. mcf5225x_512_rom = "MCF5225x, code running in FLASH",
  566. mcf5225x_512_rom_512_extram = "MCF5225x, code running in FLASH, data in external SDRAM",
  567. mcf5225x_512_rom_512_extram_boot = "MCF5225x, code running in FLASH, data in external SDRAM, started by bootloader at address 0x4000, vectors in external SDRAM"
  568. }
  569. mcf5225x_ld_choice = {
  570. " ",
  571. "mcf5225x_512_rom",
  572. "mcf5225x_512_rom_512_extram",
  573. "mcf5225x_512_rom_512_extram_boot"
  574. }
  575. --
  576. -- Retrieve platform specific ldscript path.
  577. --
  578. function GetLDScriptsPath()
  579. local basepath
  580. basepath = "$(top_srcdir)/arch/"
  581. if c_is_provided("TOOL_CC_AVR32") then
  582. return basepath .. "avr32/ldscripts"
  583. end
  584. if c_is_provided("TOOL_CC_ARM") then
  585. return basepath .. "arm/ldscripts"
  586. end
  587. if c_is_provided("TOOL_CC_CM3") then
  588. return basepath .. "cm3/ldscripts"
  589. end
  590. if c_is_provided("TOOL_CC_M68K") then
  591. if c_is_provided("HW_MCU_COLDFIRE") then
  592. return basepath .. "m68k/coldfire/ldscripts"
  593. end
  594. end
  595. return "Unknown Platform - Check GetLDScriptsPath in tools.nut"
  596. end
  597. --
  598. -- Return the list of ldscripts
  599. --
  600. function GetLDScripts()
  601. if c_is_provided("TOOL_CC_AVR32") then
  602. return avr32_ld_choice
  603. end
  604. if c_is_provided("TOOL_CC_ARM") then
  605. return arm_ld_choice
  606. end
  607. if c_is_provided("TOOL_CC_CM3") then
  608. if c_is_provided("MCU_STM32F100") then
  609. return stm32f100_ld_choice
  610. end
  611. if c_is_provided("MCU_STM32F101") then
  612. return stm32f101_ld_choice
  613. end
  614. if c_is_provided("MCU_STM32F102") then
  615. return stm32f102_ld_choice
  616. end
  617. if c_is_provided("MCU_STM32F103") then
  618. return stm32f103_ld_choice
  619. end
  620. if c_is_provided("MCU_STM32F105") then
  621. return stm32f105_ld_choice
  622. end
  623. if c_is_provided("MCU_STM32F107") then
  624. return stm32f107_ld_choice
  625. end
  626. if c_is_provided("MCU_STM32F205") then
  627. return stm32f2x5_ld_choice
  628. end
  629. if c_is_provided("MCU_STM32F207") then
  630. return stm32f2x7_ld_choice
  631. end
  632. if c_is_provided("MCU_STM32L151") then
  633. return stm32l151_ld_choice
  634. end
  635. if c_is_provided("HW_MCU_LM3") then
  636. return lm3_ld_choice
  637. end
  638. if c_is_provided("HW_MCU_LPC17xx") then
  639. return lpc17xx_ld_choice
  640. end
  641. end
  642. if c_is_provided("TOOL_CC_M68K") then
  643. if c_is_provided("HW_MCU_MCF5225X") then
  644. return mcf5225x_ld_choice
  645. end
  646. if c_is_provided("HW_MCU_MCF51CN") then
  647. return mcf51cn_ld_choice
  648. end
  649. end
  650. end
  651. --
  652. -- Return the ldscript description
  653. --
  654. function GetLDScriptDescription()
  655. if c_is_provided("TOOL_CC_AVR32") then
  656. return FormatLDScriptDescription(avr32_ld_description)
  657. end
  658. if c_is_provided("TOOL_CC_ARM") then
  659. return FormatLDScriptDescription(arm_ld_description)
  660. end
  661. if c_is_provided("TOOL_CC_CM3") then
  662. if c_is_provided("MCU_STM32F100") then
  663. return FormatLDScriptDescription(stm32f100_ld_description)
  664. end
  665. if c_is_provided("MCU_STM32F101") then
  666. return FormatLDScriptDescription(stm32f101_ld_description)
  667. end
  668. if c_is_provided("MCU_STM32F102") then
  669. return FormatLDScriptDescription(stm32f102_ld_description)
  670. end
  671. if c_is_provided("MCU_STM32F103") then
  672. return FormatLDScriptDescription(stm32f103_ld_description)
  673. end
  674. if c_is_provided("MCU_STM32F105") then
  675. return FormatLDScriptDescription(stm32f105_ld_description)
  676. end
  677. if c_is_provided("MCU_STM32F107") then
  678. return FormatLDScriptDescription(stm32f107_ld_description)
  679. end
  680. if c_is_provided("MCU_STM32F205") then
  681. return FormatLDScriptDescription(stm32f2x5_ld_description)
  682. end
  683. if c_is_provided("MCU_STM32F207") then
  684. return FormatLDScriptDescription(stm32f2x7_ld_description)
  685. end
  686. if c_is_provided("MCU_STM32L151") then
  687. return FormatLDScriptDescription(stm32l151_ld_description)
  688. end
  689. if c_is_provided("HW_MCU_LM3") then
  690. return FormatLDScriptDescription(lm3_ld_description)
  691. end
  692. if c_is_provided("HW_MCU_LPC17xx") then
  693. return FormatLDScriptDescription(lpc17xx_ld_description)
  694. end
  695. end
  696. if c_is_provided("TOOL_CC_M68K") then
  697. if c_is_provided("MCU_MCF5525X") then
  698. return FormatLDScriptDescription(mcf5225x_ld_description)
  699. end
  700. if c_is_provided("MCU_MCF51CN") then
  701. return FormatLDScriptDescription(mcf51cn_ld_description)
  702. end
  703. return ""
  704. end
  705. end
  706. --
  707. -- Returns pairs sorted by keys in alphabetic order
  708. --
  709. function pairsByKeys (t, f)
  710. local a = {}
  711. -- build temporary table of the keys
  712. for n in pairs (t) do
  713. table.insert (a, n)
  714. end
  715. table.sort (a, f) -- sort using supplied function, if any
  716. local i = 0 -- iterator variable
  717. return function () -- iterator function
  718. i = i + 1
  719. return a[i], t[a[i]]
  720. end -- iterator function
  721. end -- pairsByKeys
  722. --
  723. -- Return the formated ldscript description
  724. -- Note: It looks like it's impossible to properly
  725. -- format based on tabs on both nutconf and qnutconf using
  726. -- non-fixed length fonts. When we move definitively to qnutconf
  727. -- this can be made to output html, then we will get it right.
  728. --
  729. function FormatLDScriptDescription( t )
  730. local result = ""
  731. local maxKeyLen = 0;
  732. for k,v in pairs(t) do
  733. if maxKeyLen < string.len(k) then
  734. maxKeyLen = string.len(k)
  735. end
  736. end
  737. maxTabs = math.ceil( maxKeyLen / 6 + 1 );
  738. for k,v in pairsByKeys(t) do
  739. tabs = maxTabs - math.ceil( string.len(k) / 6 );
  740. result = result .. k
  741. for i = 1, tabs do
  742. result = result .. "\t"
  743. end
  744. result = result .. v .. "\n"
  745. end
  746. return result
  747. end