nutsetup.lua 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. --
  2. -- Copyright (C) 2012 by egnite GmbH
  3. --
  4. -- All rights reserved.
  5. --
  6. -- Redistribution and use in source and binary forms, with or without
  7. -- modification, are permitted provided that the following conditions
  8. -- are met:
  9. --
  10. -- 1. Redistributions of source code must retain the above copyright
  11. -- notice, this list of conditions and the following disclaimer.
  12. -- 2. Redistributions in binary form must reproduce the above copyright
  13. -- notice, this list of conditions and the following disclaimer in the
  14. -- documentation and/or other materials provided with the distribution.
  15. -- 3. Neither the name of the copyright holders nor the names of
  16. -- contributors may be used to endorse or promote products derived
  17. -- from this software without specific prior written permission.
  18. --
  19. -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. -- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. -- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. -- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. -- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. -- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. -- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. -- AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. -- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. -- THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. -- SUCH DAMAGE.
  31. --
  32. -- For additional information see http://www.ethernut.de/
  33. --
  34. archs = {
  35. arm7tdmi = { "ARM7", "arm7tdmi" },
  36. arm9 = { "ARM9", "arm9" },
  37. armcm3 = { "ARM Cortex-M3", "cortex-m3" },
  38. armcm4 = { "ARM Cortex-M4", "cortex-m4" },
  39. avr = { "AVR 8-bit" },
  40. avr32 = { "AVR 32-bit" }
  41. }
  42. devices = {
  43. at90can128 = { name = "AT90CAN128", arch = archs.avr },
  44. at90usb1287 = { name = "AT90USB1287", arch = archs.avr },
  45. at91r40008 = { name = "AT91R40008", arch = archs.arm7tdmi },
  46. at91sam7s256 = { name = "AT91SAM7S256", arch = archs.arm7tdmi },
  47. at91sam7se512 = { name = "AT91SAM7SE512", arch = archs.arm7tdmi },
  48. at91sam7x256 = { name = "AT91SAM7X256", arch = archs.arm7tdmi },
  49. at91sam7x512 = { name = "AT91SAM7X512", arch = archs.arm7tdmi },
  50. at91sam9260 = { name = "AT91SAM9260", arch = archs.arm9 },
  51. at91sam9g45 = { name = "AT91SAM9G45", arch = archs.arm9 },
  52. at91sam9xe512 = { name = "AT91SAM9XE512", arch = archs.arm9 },
  53. atmega103 = { name = "ATMEGA103", arch = archs.avr },
  54. atmega128 = { name = "ATMEGA128", arch = archs.avr },
  55. atmega2561 = { name = "ATMEGA2561", arch = archs.avr },
  56. avr32uc3a0512 = { name = "AVR32UC3A0512", arch = archs.avr32 },
  57. avr32uc3a3256 = { name = "AVR32UC3A3256", arch = archs.avr32 },
  58. avr32uc3b0256 = { name = "AVR32UC3B0256", arch = archs.avr32 },
  59. gba = { name = "GBA", arch = archs.arm7tdmi },
  60. lm3s9b96 = { name = "LM3S9B96", arch = archs.arm_cm3 },
  61. lpc1768 = { name = "LPC1768", arch = archs.arm_cm3 },
  62. lpc1778 = { name = "LPC1778", arch = archs.arm_cm3 },
  63. lpc1788 = { name = "LPC1788", arch = archs.arm_cm3 },
  64. stm32f100 = { name = "STM32F100", arch = archs.arm_cm3 },
  65. stm32f103 = { name = "STM32F103", arch = archs.arm_cm3 },
  66. stm32f107 = { name = "STM32F107", arch = archs.arm_cm3 },
  67. stm32f205 = { name = "STM32F205", arch = archs.arm_cm3 },
  68. stm32f207 = { name = "STM32F207", arch = archs.arm_cm3 },
  69. stm32f405 = { name = "STM32F405", arch = archs.arm_cm3 },
  70. stm32l151 = { name = "STM32L151", arch = archs.arm_cm4 },
  71. zero = { name = "ZERO", arch = archs.arm7tdmi },
  72. }
  73. boards = {
  74. {
  75. name = { "Arthernet 1", "ARTHERNET1" },
  76. device = devices.atmega128,
  77. },
  78. {
  79. name = { "Atmel AT90USBKEY", "AT90USBKEY" },
  80. device = devices.at90usb1287,
  81. },
  82. {
  83. name = { "Atmel AT91EB40A", "AT91EB40A" },
  84. device = devices.at91r40008,
  85. },
  86. {
  87. name = { "Generic AT91SAM7S256", "AT91SAM7S" },
  88. device = devices.at91sam7s256,
  89. },
  90. {
  91. name = { "Atmel AT91SAM7SE-EK", "AT91SAM7SE_EK" },
  92. device = devices.at91sam7se512,
  93. },
  94. {
  95. name = { "Atmel AT91SAM7X-EK", "AT91SAM7X_EK" },
  96. device = devices.at91sam7x256,
  97. },
  98. {
  99. name = { "Atmel AT91SAM9260-EK", "AT91SAM9260_EK" },
  100. device = devices.at91sam9260,
  101. },
  102. {
  103. name = { "Atmel AT91SAM9G45-EK", "AT91SAM9G45_EK" },
  104. device = devices.at91sam9g45,
  105. },
  106. {
  107. name = { "hwgroup Charon II", "CHARON2" },
  108. device = devices.atmega128,
  109. },
  110. {
  111. name = { "Luminary DK-LM3S9B96", "DK_LM3S9B96" },
  112. device = devices.lm3s9b96,
  113. },
  114. {
  115. name = { "Elektor Internet Radio", "ELEKTOR_IR1" },
  116. device = devices.at91sam7se512,
  117. },
  118. {
  119. name = { "Embedded-IT eNet-sam7X", "ENET_SAM7X" },
  120. device = devices.at91sam7x512,
  121. },
  122. {
  123. name = { "egnite Ethernut 1", "ETHERNUT1" },
  124. device = devices.atmega128,
  125. },
  126. {
  127. name = { "egnite Ethernut 2", "ETHERNUT2" },
  128. device = devices.atmega128,
  129. },
  130. {
  131. name = { "egnite Ethernut 3", "ETHERNUT3" },
  132. device = devices.at91r40008,
  133. },
  134. {
  135. name = { "egnite Ethernut 5", "ETHERNUT5" },
  136. device = devices.at91sam9xe512,
  137. },
  138. {
  139. name = { "EVK1100", "EVK1100" },
  140. device = devices.avr32uc3a0512,
  141. },
  142. {
  143. name = { "EVK1101", "EVK1101" },
  144. device = devices.avr32uc3b0256,
  145. },
  146. {
  147. name = { "EVK1104", "EVK1104" },
  148. device = devices.avr32uc3a3256,
  149. },
  150. {
  151. name = { "EVK1105", "EVK1105" },
  152. device = devices.avr32uc3a0512,
  153. },
  154. {
  155. name = { "ST F4 Discovery", "F4_DISCOVERY" },
  156. device = devices.stm32f405,
  157. },
  158. {
  159. name = { "egnite FLECX", "FLECX1" },
  160. device = devices.lpc1768,
  161. },
  162. {
  163. name = { "Nintendo GBA", "GBAXPORT2" },
  164. device = devices.gba,
  165. },
  166. {
  167. name = { "IAR KSK-LPC1788-SK", "KSK_LPC1788_SK" },
  168. device = devices.lpc1788,
  169. },
  170. {
  171. name = { "Embedded-IT Lisa", "LISA" },
  172. device = devices.lpc1778,
  173. },
  174. {
  175. name = { "mbed NXP LPC1768", "MBED_NXP_LPC1768" },
  176. device = devices.lpc1768,
  177. },
  178. {
  179. name = { "Propox MMNET01", "MMNET01" },
  180. device = devices.atmega128,
  181. },
  182. {
  183. name = { "Propox MMNET01", "MMNET02" },
  184. device = devices.atmega128,
  185. },
  186. {
  187. name = { "Propox MMNET01", "MMNET03" },
  188. device = devices.atmega128,
  189. },
  190. {
  191. name = { "Propox MMNET01", "MMNET04" },
  192. device = devices.atmega128,
  193. },
  194. {
  195. name = { "Propox MMNET01", "MMNET101" },
  196. device = devices.atmega128,
  197. },
  198. {
  199. name = { "Propox MMNET01", "MMNET102" },
  200. device = devices.atmega128,
  201. },
  202. {
  203. name = { "Propox MMNET01", "MMNET103" },
  204. device = devices.atmega128,
  205. },
  206. {
  207. name = { "Propox MMNET01", "MMNET104" },
  208. device = devices.atmega128,
  209. },
  210. {
  211. name = { "egnite Morphoq", "MORPHOQ1" },
  212. device = devices.at91sam7x512,
  213. },
  214. {
  215. name = { "egnite SAM7ETH", "SAM7ETH" },
  216. device = devices.at91sam7x512,
  217. compilers = {
  218. { "GNU C ARM-ELF", "arm-elf" },
  219. { "GNU C ARM-EABI", "arm-none-eabi" }
  220. },
  221. linker_scripts = {
  222. { "Program in Flash", "at91sam7x512_rom" }
  223. }
  224. },
  225. {
  226. name = { "STEVAL_PCC010V2", "STEVAL_PCC010V2" },
  227. device = devices.stm32f205,
  228. },
  229. {
  230. name = { "Atmel STK501", "STK501" },
  231. device = devices.atmega128,
  232. },
  233. {
  234. name = { "STM32_CAN", "STM32_CAN" },
  235. device = devices.stm32f107,
  236. },
  237. {
  238. name = { "STM32_COMSTICK", "STM32_COMSTICK" },
  239. device = devices.stm32f107,
  240. },
  241. {
  242. name = { "STM3210C_EVAL", "STM3210C_EVAL" },
  243. device = devices.stm32f107,
  244. },
  245. {
  246. name = { "STM3210E_EVAL", "STM3210E_EVAL" },
  247. device = devices.stm32f103,
  248. },
  249. {
  250. name = { "USPS_F107C", "USPS" },
  251. device = devices.stm32f107,
  252. },
  253. {
  254. name = { "USPS_F205C", "USPS" },
  255. device = devices.stm32f205,
  256. },
  257. {
  258. name = { "USPS_F405G", "USPS" },
  259. device = devices.stm32f405,
  260. },
  261. {
  262. name = { "USPS_L151B", "USPS" },
  263. device = devices.stm32l151,
  264. },
  265. {
  266. name = { "Proconx XNUT 100", "XNUT_100" },
  267. device = devices.atmega128,
  268. },
  269. {
  270. name = { "Proconx XNUT 105", "XNUT_105" },
  271. device = devices.at90can128,
  272. },
  273. {
  274. name = { "Zero", "ZERO_EK" },
  275. device = devices.zero,
  276. },
  277. }
  278. function get_arch_list()
  279. local t
  280. t = {}
  281. for i, v in ipairs(boards) do
  282. if v.device ~= nil then
  283. local found
  284. found = false
  285. for ii, vv in pairs(t) do
  286. if vv == v.device.arch then
  287. found = true
  288. break
  289. end
  290. end
  291. if not found then
  292. t[#t + 1] = v.device.arch
  293. end
  294. end
  295. end
  296. return t
  297. end
  298. function get_device_list(arch)
  299. local t
  300. t = {}
  301. for i, v in ipairs(boards) do
  302. if v.device ~= nil and v.device.arch == arch then
  303. local found
  304. found = false
  305. for ii, vv in pairs(t) do
  306. if vv == v.device then
  307. found = true
  308. break
  309. end
  310. end
  311. if not found then
  312. t[#t + 1] = v.device
  313. end
  314. end
  315. end
  316. return t
  317. end
  318. function get_board_list(device)
  319. local t
  320. t = {}
  321. for i, v in ipairs(boards) do
  322. if v.device ~= nil and v.device == device then
  323. t[#t + 1] = v
  324. end
  325. end
  326. return t
  327. end
  328. function get_device_name(device)
  329. local t
  330. t = {}
  331. for i, v in pairs(devices) do
  332. if v == device then
  333. return i
  334. end
  335. end
  336. return nil
  337. end
  338. function get_arch_name(arch)
  339. local t
  340. t = {}
  341. for i, v in pairs(archs) do
  342. if v == arch then
  343. if v.name == nil then
  344. return i
  345. else
  346. return v.name
  347. end
  348. end
  349. end
  350. return nil
  351. end
  352. function create_ifnotexists(path, content)
  353. local f
  354. local e
  355. f,e = io.open(path, "r")
  356. if e then
  357. f = io.open(path, "w")
  358. f:write(content)
  359. end
  360. f:close()
  361. return e
  362. end
  363. sel_list = get_arch_list()
  364. io.write("Select a target architecture:\n")
  365. repeat
  366. for i, v in ipairs(sel_list) do
  367. io.write(string.format(" %d) %s\n", i, v[1]))
  368. end
  369. sel = tonumber(io.read())
  370. target_arch = sel_list[sel]
  371. io.write("\n")
  372. until target_arch ~= nil
  373. sel_list = get_device_list(target_arch)
  374. io.write("Select a target device:\n")
  375. repeat
  376. for i, v in ipairs(sel_list) do
  377. io.write(string.format(" %d) %s\n", i, v.name))
  378. end
  379. sel = tonumber(io.read())
  380. target_device = sel_list[sel]
  381. io.write("\n")
  382. until target_device ~= nil
  383. sel_list = get_board_list(target_device)
  384. io.write("Select a target board:\n")
  385. repeat
  386. for i, v in ipairs(sel_list) do
  387. io.write(string.format(" %d) %s\n", i, v.name[1]))
  388. end
  389. sel = tonumber(io.read())
  390. target_board = sel_list[sel]
  391. io.write("\n")
  392. until target_board ~= nil
  393. f = io.open("../NutConf.mk", "w")
  394. f:write("# Automatically generated by nutsetup\n")
  395. f:write("#\n")
  396. f:write("# Do not edit, modify UserConf.mk instead!\n")
  397. f:write("#\n\n")
  398. f:write("PLATFORM="..target_board.name[2].."\n")
  399. f:write("HWDEF+=-D$(PLATFORM)\n")
  400. if target_device.arch == archs.avr then
  401. f:write("HWDEF+=-D__HARVARD_ARCH__\n")
  402. end
  403. f:write("ARCH="..get_arch_name(target_arch).."\n")
  404. f:write("DEVICE="..string.upper(get_device_name(target_device)).."\n")
  405. f:write("MCU="..get_device_name(target_device).."\n")
  406. f:write("CRUROM=crurom\n")
  407. f:write("\n\n")
  408. f:write("include $(top_srcdir)/UserConf.mk\n")
  409. f:close()
  410. create_ifnotexists("../UserConf.mk", "#\n# You can use this file to modify values in NutConf.mk\n#\n")