nutsetup 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. #! /bin/sh
  2. if [ "x`uname`" != "xLinux" ]; then
  3. if [ "x`uname`" != "xFreeBSD" ]; then
  4. if [ "x`uname`" != "xDarwin" ]; then
  5. if [ "x`uname -o`" != "xCygwin" ]; then
  6. echo "This is not a Cygwin, FreeBSD, Linux or Mac OS X system."
  7. echo "I'm so confused!"
  8. exit 1
  9. fi
  10. fi
  11. fi
  12. fi
  13. # Ask user which device to target
  14. unset HWDEF
  15. unset DEV
  16. while [ "x$DEV" = "x" ]
  17. do
  18. echo "Select a target device:"
  19. echo ""
  20. echo " 1) Atmel ATmega128"
  21. echo " 2) Atmel ATmega103"
  22. echo " 3) Atmel AT90CAN128"
  23. echo " 4) Renesas H8/3068F"
  24. echo " 5) UNIX Emulation"
  25. # echo " 6) Renesas H8/3069F" # just an example
  26. # echo " 7) Renesas H8S/2676F" # just an example
  27. # echo " 8) OKI ML67Q5003" # just an example
  28. echo " a) Atmel AT91R40008"
  29. echo " b) Atmel AT91SAM7X(C)256"
  30. echo " c) Atmel AT91SAM9260"
  31. echo ""
  32. echo -n "Selection -> "
  33. read answ
  34. case "$answ" in
  35. 1) DEV=atmega128; ARCH=avr; CPU=m128 ;;
  36. 2) DEV=atmega103; ARCH=avr; CPU=m103 ;;
  37. 3) DEV=at90can128; ARCH=avr; CPU=c128; HWDEF="-DMCU_AT90CAN128 -DNUTMEM_STACKHEAP=4096" ;;
  38. 4) DEV=H8/3068F; ARCH=h8300h ;;
  39. 5) DEV=mac; ARCH=unix ;;
  40. # 6) DEV=H8/3069F; ARCH=h8300h ;; # just an example
  41. # 7) DEV=H8S/2676F; ARCH=h8300s ;; # just an example
  42. # 8) DEV=ML67Q5003; ARCH=arm ;; # just an example
  43. a) DEV=AT91R40008; ARCH=arm; CPU=arm7tdmi ;;
  44. b) DEV=AT91SAM7X256; ARCH=arm; CPU=arm7tdmi ;;
  45. c) DEV=AT91SAM9260; ARCH=arm; CPU=arm9 ;;
  46. *)
  47. echo "invalid choice" ;;
  48. esac
  49. done
  50. # Set up environment for AVR microcontrollers
  51. if [ "$ARCH" = "avr" ]; then
  52. # Verify that avr-gcc is in the users PATH
  53. if ! avr-gcc --version >/dev/null 2>&1
  54. then
  55. echo "Can't find avr-gcc. :-("
  56. echo ""
  57. echo "This could mean either of the following:"
  58. echo " 1: You don't have avr-gcc installed."
  59. echo " 2: You don't have your PATH environment variable set right."
  60. echo "Here is your PATH variable:"
  61. echo ""
  62. echo $PATH
  63. echo ""
  64. exit 1
  65. fi
  66. # Make links to included make fragments
  67. ln -s -f Makedefs.avr-gcc Makedefs
  68. ln -s -f Makerules.avr-gcc Makerules
  69. ln -s -f Makedefs.avr-gcc app/Makedefs
  70. ln -s -f Makerules.avr-gcc app/Makerules
  71. # Ask which target board is being used
  72. unset PLATFORM
  73. while [ "x$PLATFORM" = "x" ]
  74. do
  75. echo "Do you use a standard Ethernut board?"
  76. echo ""
  77. echo " 0) No standard"
  78. echo " 1) Ethernut 1 (10 Mbit Realtek RTL8019AS)"
  79. echo " 2) Ethernut 2 (10/100 Mbit SMSC LAN91C111)"
  80. echo ""
  81. echo -n "Selection -> "
  82. read answ
  83. case "$answ" in
  84. 0) ;;
  85. 1) PLATFORM=ETHERNUT1 ;;
  86. 2) PLATFORM=ETHERNUT2 ;;
  87. *)
  88. echo "invalid choice" ;;
  89. esac
  90. done
  91. # Ask which crystal is being used
  92. unset CRYSTAL
  93. while [ "x$CLOCKSEL" = "x" ]
  94. do
  95. echo "Do you want to set a fixed cpu clock?"
  96. echo ""
  97. echo " 1) don't set clock"
  98. echo " 2) 7.3728 Mhz"
  99. echo " 3) 8.0000 Mhz"
  100. echo " 4) 12.0000 Mhz"
  101. echo " 5) 14.7456 Mhz"
  102. echo " 6) 16.0000 Mhz"
  103. echo ""
  104. echo -n "Selection -> "
  105. read answ
  106. case "$answ" in
  107. 1) CLOCKSEL=1 ;;
  108. 2) CLOCKSEL=2 ; CLOCK=-DNUT_CPU_FREQ=7372800 ;;
  109. 3) CLOCKSEL=3 ; CLOCK=-DNUT_CPU_FREQ=8000000 ;;
  110. 4) CLOCKSEL=4 ; CLOCK=-DNUT_CPU_FREQ=12000000 ;;
  111. 5) CLOCKSEL=5 ; CLOCK=-DNUT_CPU_FREQ=14745600 ;;
  112. 6) CLOCKSEL=6 ; CLOCK=-DNUT_CPU_FREQ=16000000 ;;
  113. *)
  114. echo "invalid choice" ;;
  115. esac
  116. done
  117. # Ask which isp programmer is being used
  118. unset UISP_PROG
  119. while [ "x$UISP_PROG" = "x" ]
  120. do
  121. echo "Which isp programmer are you using?"
  122. echo ""
  123. echo " 1) stk200, stk300 or compatible"
  124. echo " 2) skt500"
  125. echo " 3) usbasp"
  126. echo ""
  127. echo -n "Selection -> "
  128. read answ
  129. case "$answ" in
  130. 1) UISP_PROG=stk200 ;;
  131. 2) UISP_PROG=stk500 ;;
  132. 3) UISP_PROG=usbasp ;;
  133. *)
  134. echo "invalid choice" ;;
  135. esac
  136. done
  137. unset PROGRAMMER
  138. while [ "x$PROGRAMMER" = "x" ]
  139. do
  140. echo "Which programming software are you using?"
  141. echo ""
  142. echo " 1) uisp"
  143. echo " 2) avrdude"
  144. echo " 9) mine is not listed here"
  145. echo ""
  146. echo -n "Selection -> "
  147. read answ
  148. case "$answ" in
  149. 1) PROGRAMMER=usip ; BURNFLAGS="-dprog=$UISP_PROG --erase --upload --verify if=\$(TARG)" ;;
  150. 2) PROGRAMMER=avrdude
  151. if [ "$UISP_PROG" = "usbasp" ]; then
  152. BURNFLAGS="-p $CPU -c $UISP_PROG -U flash:w:\$(TARG)"
  153. else
  154. BURNFLAGS="-p $CPU -c $UISP_PROG -U flash:w:\$(TARG) -E noreset"
  155. fi
  156. ;;
  157. 9) PROGRAMMER="echo" ; BURNFLAGS="See UserConf.mk" ;;
  158. *)
  159. echo "invalid choice" ;;
  160. esac
  161. done
  162. # Generate the config file
  163. cat <<EOF > UserConf.mk
  164. PLATFORM=$PLATFORM
  165. MCU=$DEV
  166. ARCH=$ARCH
  167. HWDEF=-D__HARVARD_ARCH__ $CLOCK -D\$(PLATFORM) $HWDEF
  168. BURN=$PROGRAMMER
  169. BURNFLAGS=$BURNFLAGS
  170. CRUROM=crurom
  171. EOF
  172. echo "Your system is now configured to build for $DEV."
  173. echo "Change to subdirectory lib and type \`make clean\` "
  174. echo "and \`make install\` to build the system."
  175. exit 0
  176. fi
  177. # Set up environment for H8/300H and H8S microcontrollers
  178. if [ "$ARCH" = "h8300h" -o "$ARCH" = "h8300s" ]; then
  179. # Verify if h8300-elf-gcc is in the users PATH
  180. if ! h8300-elf-gcc --version >/dev/null 2>&1
  181. then
  182. echo "Can't find H8 gcc. :-("
  183. echo ""
  184. echo "This could mean either of the following:"
  185. echo " 1: You don't have H8 gcc installed. Go to http://www.kpitgnutools.com"
  186. echo " 2: You don't have your PATH environment variable set right."
  187. echo "Here is your PATH variable:"
  188. echo ""
  189. echo $PATH
  190. echo ""
  191. exit 1
  192. fi
  193. # Set up device dependant compiler flags
  194. if [ "$ARCH" = "h8300h" ]; then
  195. # flags for H8/300H micros
  196. MCUOPTS="-mh -mint32"
  197. else
  198. # flags for H8S micros
  199. MCUOPTS="-ms -mint32"
  200. fi
  201. # Setup paths to libc and libgcc for linker
  202. GCCVER=`h8300-elf-gcc --version|grep h8300-elf-gcc|cut -d ' ' -f 3`
  203. GCCDIR=`dirname \`which h8300-elf-gcc\``
  204. LIBGCCDIR="lib/gcc-lib/h8300-elf/$GCCVER/$ARCH/int32"
  205. LIBCDIR="h8300-elf/lib/$ARCH/int32"
  206. LDDIRS="-L $GCCDIR/../$LIBGCCDIR -L $GCCDIR/../$LIBCDIR"
  207. # Select whether code is to be executed from ROM or RAM
  208. CODEMEM="rom"
  209. unset RUNFLAG
  210. echo "Ethernut code can be run from RAM. This is useful when you are"
  211. echo "debugging your application. Remember that your hardware must"
  212. echo "have enough RAM to store data and program code."
  213. echo ""
  214. echo -n "Should Ethernut be executed from RAM (default=No)? Y(es)/N(o) "
  215. read answ
  216. if [ "$answ" = "y" -o "$answ" = "Y" ]; then
  217. RUNFLAG="-DTEXT_IN_RAM"
  218. CODEMEM="ram"
  219. fi
  220. echo ""
  221. # Choose appropriate linker script
  222. case "$DEV" in
  223. # H8/300H micros
  224. H8/3068F) LDSCRIPT=nut-h8-3068f-$CODEMEM.ld ;;
  225. H8/3069F) LDSCRIPT=nut-h8-3069f-$CODEMEM.ld ;; # just an example
  226. # H8S micros
  227. H8S/2676F) LDSCRIPT=nut-h8s-2676f-$CODEMEM.ld ;; # just an example
  228. esac
  229. # Make links to included make fragments
  230. ln -s -f Makedefs.h8-gcc Makedefs
  231. ln -s -f Makerules.h8-gcc Makerules
  232. ln -s -f Makedefs.h8-gcc app/Makedefs
  233. ln -s -f Makerules.h8-gcc app/Makerules
  234. # Generate config file
  235. cat <<EOF > UserConf.mk
  236. DEVICE=$DEV # for future use
  237. MCU=$ARCH
  238. ARCH=$ARCH
  239. MCUOPTS=$MCUOPTS
  240. RUNFLAG=$RUNFLAG
  241. LDSCRIPT=\$(top_srcdir)/arch/$ARCH/ldscripts/$LDSCRIPT
  242. LDDIRS=$LDDIRS
  243. BURN=h8write
  244. BURNFLAGS=-3068 \$(TARG)
  245. CRUROM = \$(top_srcdir)/tools/crurom/crurom
  246. EOF
  247. echo "Your system is now configured to build for $DEV."
  248. echo "Type \`make\` to build the system."
  249. exit 0
  250. fi
  251. # Set up environment for ARM microcontrollers ======================================================
  252. if [ "$ARCH" = "arm" ]; then
  253. # Verify if arm-elf-gcc is in the users PATH
  254. if ! arm-elf-gcc --version >/dev/null 2>&1
  255. then
  256. echo "Can't find ARM gcc. :-("
  257. echo ""
  258. echo "This could mean either of the following:"
  259. echo " 1: You don't have ARM GCC installed."
  260. echo " 2: You don't have your PATH environment variable set right."
  261. echo "Here is your PATH variable:"
  262. echo ""
  263. echo $PATH
  264. echo ""
  265. exit 1
  266. fi
  267. # Set up device dependant compiler flags
  268. # if [ "$ARCH" = "h8300h" ]; then
  269. # # flags for H8/300H micros
  270. # MCUOPTS="-mh -mint32"
  271. # else
  272. # # flags for H8S micros
  273. # MCUOPTS="-ms -mint32"
  274. # fi
  275. MCUOPTS="-mcpu=$CPU"
  276. # Setup paths to libc and libgcc for linker
  277. # GCCVER=`arm-elf-gcc --version|grep arm-elf-gcc|cut -d ' ' -f 3`
  278. # GCCDIR=`dirname \`which arm-elf-gcc\``
  279. # LIBGCCDIR="lib/gcc-lib/arm-elf/$GCCVER/$ARCH"
  280. # LIBCDIR="arm-elf/lib/$ARCH"
  281. # LDDIRS="-L $GCCDIR/../$LIBGCCDIR -L $GCCDIR/../$LIBCDIR"
  282. # Ask which target board is being used
  283. unset PLATFORM
  284. while [ "x$PLATFORM" = "x" ]
  285. do
  286. echo "Do you use a standard board?"
  287. echo ""
  288. echo " 0) No standard"
  289. if [ "$DEV" = "AT91R40008" ]; then
  290. echo " 1) Ethernut 3"
  291. fi
  292. if [ "$DEV" = "AT91SAM7X256" ]; then
  293. echo " 2) Atmel AT91SAM7X Evaluation Kit"
  294. fi
  295. if [ "$DEV" = "AT91SAM9260" ]; then
  296. echo " 3) Atmel AT91SAM9260 Evaluation Kit"
  297. fi
  298. echo ""
  299. echo -n "Selection -> "
  300. read answ
  301. case "$answ" in
  302. 0) ;;
  303. 1) PLATFORM=ETHERNUT3 ;;
  304. 2) PLATFORM=AT91SAM7X_EK ;;
  305. 3) PLATFORM=AT91SAM9260_EK ;;
  306. *)
  307. echo "invalid choice" ;;
  308. esac
  309. done
  310. # Select linker script
  311. if [ "$DEV" = "AT91SAM7X256" ]; then
  312. LDNAME="at91sam7x256_rom"
  313. else
  314. echo "Nut/OS can be run from RAM. This is useful when you are"
  315. echo "using a TFTP bootloader or debugging your application."
  316. echo "Remember that your hardware must have enough RAM"
  317. echo "to store data and program code."
  318. echo ""
  319. echo -n "Should Nut/OS be executed from RAM (default=Yes)? Y(es)/N(o) "
  320. read answ
  321. if [ "$answ" = "n" -o "$answ" = "N" ]; then
  322. if [ "$DEV" = "AT91SAM9260" ]; then
  323. LDNAME="at91sam9260_ram"
  324. else
  325. LDNAME="at91_boot"
  326. fi
  327. else
  328. if [ "$DEV" = "AT91SAM9260" ]; then
  329. LDNAME="at91sam9260_ram"
  330. else
  331. LDNAME="at91_ram"
  332. fi
  333. fi
  334. fi
  335. echo ""
  336. # Make links to included make fragments
  337. ln -s -f Makedefs.arm-gcc Makedefs
  338. ln -s -f Makerules.arm-gcc Makerules
  339. ln -s -f Makedefs.arm-gcc app/Makedefs
  340. ln -s -f Makerules.arm-gcc app/Makerules
  341. # Generate config file
  342. cat <<EOF > UserConf.mk
  343. PLATFORM=$PLATFORM
  344. HWDEF+=-D\$(PLATFORM)
  345. DEVICE=$DEV
  346. MCU=$CPU
  347. ARCH=$ARCH
  348. MCUOPTS=$MCUOPTS
  349. RUNFLAG=$RUNFLAG
  350. LDNAME=$LDNAME
  351. LDSCRIPT=\$(top_srcdir)/arch/arm/ldscripts/\$(LDNAME).ld
  352. #LDDIRS=$LDDIRS
  353. #BURN=jtagomat
  354. #BURNFLAGS=\$(TARG)
  355. CRUROM=crurom
  356. EOF
  357. echo "Your system is now configured to build for $DEV."
  358. echo "Change to subdirectory lib and type \`make clean\` "
  359. echo "and \`make install\` to build the system."
  360. exit 0
  361. fi
  362. if [ "$ARCH" = "unix" ]; then
  363. # Verify that gcc is in the users PATH
  364. if ! gcc --version >/dev/null 2>&1
  365. then
  366. echo "Can't find gcc. :-("
  367. echo ""
  368. echo "This could mean either of the following:"
  369. echo " 1: You don't have gcc installed."
  370. echo " 2: You don't have your PATH environment variable set right."
  371. echo "Here is your PATH variable:"
  372. echo ""
  373. echo $PATH
  374. echo ""
  375. exit 1
  376. fi
  377. # Make links to included make fragments
  378. ln -s -f Makedefs.unix-gcc Makedefs
  379. ln -s -f Makerules.unix-gcc Makerules
  380. ln -s -f Makedefs.unix-gcc app/Makedefs
  381. ln -s -f Makerules.unix-gcc app/Makerules
  382. # Generate the config file
  383. cat <<EOF > UserConf.mk
  384. CRUROM = \$(top_srcdir)/tools/crurom/crurom
  385. ARCH=$ARCH
  386. MCU=$ARCH
  387. EOF
  388. # Get system include paths for stdio.h, errno.h, sys/types.h, fcntl.h
  389. echo "#include <stdio.h>" > include_test.c
  390. echo "#include <fcntl.h>" >> include_test.c
  391. echo "#include <errno.h>" >> include_test.c
  392. echo "#include <unistd.h>" >> include_test.c
  393. echo "#include <netdb.h>" >> include_test.c
  394. echo "#include <netinet/in.h>" >> include_test.c
  395. echo "#include <sys/types.h>" >> include_test.c
  396. echo "#include <sys/socket.h>" >> include_test.c
  397. gcc -E include_test.c | grep stdio | head -1 | \
  398. sed 's/#....\(\/.*\/stdio.h\).*/#include "\1"/' > include/stdio_orig.h
  399. gcc -E include_test.c | grep unistd | head -1 | \
  400. sed 's/#....\(\/.*\/unistd.h\).*/#include "\1"/' > include/unistd_orig.h
  401. gcc -E include_test.c | grep fcntl | head -1 | \
  402. sed 's/#....\(\/.*\/fcntl.h\).*/#include "\1"/' > include/fcntl_orig.h
  403. gcc -E include_test.c | grep errno | head -1 | \
  404. sed 's/#....\(\/.*\/errno.h\).*/#include "\1"/' > include/errno_orig.h
  405. gcc -E include_test.c | grep "sys/types.h" | head -1 | \
  406. sed 's/#....\(\/.*\/sys\/types.h\).*/#include "\1"/' > include/sys/types_orig.h
  407. gcc -E include_test.c | grep "sys/socket" | head -1 | \
  408. sed 's/#....\(\/.*\/sys\/socket.h\).*/#include "\1"/' > include/sys/socket_orig.h
  409. gcc -E include_test.c | grep netdb | head -1 | \
  410. sed 's/#....\(\/.*\/netdb.h\).*/#include "\1"/' > include/netdb_orig.h
  411. gcc -E include_test.c | grep "netinet/in" | head -1 | \
  412. sed 's/#....\(\/.*\/netinet\/in.h\).*/#include "\1"/' > include/netinet/in_orig.h
  413. rm include_test.c
  414. # assert lib dirs
  415. mkdir -p lib/gcc/$ARCH
  416. # ready
  417. echo "Your system is now configured to build for your native system."
  418. echo "Change to lib and type \`make\` to build the system."
  419. exit 0
  420. fi