Makefile 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. # This file is part of Espruino, a JavaScript interpreter for Microcontrollers
  2. #
  3. # Copyright (C) 2013 Gordon Williams <gw@pur3.co.uk>
  4. #
  5. # This Source Code Form is subject to the terms of the Mozilla Public
  6. # License, v. 2.0. If a copy of the MPL was not distributed with this
  7. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  8. #
  9. # -----------------------------------------------------------------------------
  10. # Makefile for Espruino
  11. # -----------------------------------------------------------------------------
  12. # Set ONE of the following environment variables to compile for that board:
  13. #
  14. # ESPRUINO_1V0=1 # Espruino board rev 1.0
  15. # ESPRUINO_1V1=1 # Espruino board rev 1.1 and 1.2
  16. # ESPRUINO_1V3=1 # Espruino board rev 1.3
  17. # OLIMEXINO_STM32=1 # Olimexino STM32
  18. # OLIMEXINO_STM32_BOOTLOADER=1 # Olimexino STM32 with bootloader
  19. # EMBEDDED_PI=1 # COOCOX STM32 Embedded Pi boards
  20. # HYSTM32_24=1 # HY STM32 2.4 Ebay boards
  21. # HYSTM32_28=1 # HY STM32 2.8 Ebay boards
  22. # HYSTM32_32=1 # HY STM32 3.2 VCT6 Ebay boards
  23. # STM32VLDISCOVERY=1
  24. # STM32F3DISCOVERY=1
  25. # STM32F4DISCOVERY=1
  26. # STM32F429IDISCOVERY=1
  27. # CARAMBOLA=1
  28. # RASPBERRYPI=1
  29. # LPC1768=1 # beta
  30. # LCTECH_STM32F103RBT6=1 # LC Technology STM32F103RBT6 Ebay boards
  31. # Or nothing for standard linux compile
  32. #
  33. # Also:
  34. #
  35. # DEBUG=1 # add debug symbols (-g)
  36. # RELEASE=1 # Force release-style compile (no asserts, etc)
  37. # SINGLETHREAD=1 # Compile single-threaded to make compilation errors easier to find
  38. # BOOTLOADER=1 # make the bootloader (not Espruino)
  39. # PROFILE=1 # Compile with gprof profiling info
  40. ifndef SINGLETHREAD
  41. MAKEFLAGS=-j5 # multicore
  42. endif
  43. INCLUDE=-I$(ROOT) -I$(ROOT)/targets -I$(ROOT)/src -I$(ROOT)/gen
  44. LIBS=
  45. DEFINES=
  46. CFLAGS=-Wall -Wextra -Wconversion -Werror=implicit-function-declaration -fdiagnostics-show-option
  47. OPTIMIZEFLAGS=
  48. #-fdiagnostics-show-option - shows which flags can be used with -Werror
  49. # Espruino flags...
  50. USE_MATH=1
  51. ifeq ($(shell uname -m),armv6l)
  52. RASPBERRYPI=1 # just a guess
  53. endif
  54. ifeq ($(shell uname),Darwin)
  55. MACOSX=1
  56. endif
  57. # Gordon's car ECU (extremely beta!)
  58. ifdef ECU
  59. STM32F4DISCOVERY=1
  60. #HYSTM32_32=1
  61. USE_TRIGGER=1
  62. DEFINES += -DECU
  63. endif
  64. ifdef RELEASE
  65. # force no asserts to be compiled in
  66. DEFINES += -DNO_ASSERT
  67. endif
  68. CWD = $(shell pwd)
  69. ROOT = $(CWD)
  70. PRECOMPILED_OBJS=
  71. PLATFORM_CONFIG_FILE=gen/platform_config.h
  72. BASEADDRESS=0x08000000
  73. ###################################################
  74. # When adding stuff here, also remember build_pininfo, platform_config.h, jshardware.c
  75. ifdef ESPRUINO_1V0
  76. USB=1
  77. #USE_NET=1
  78. #USE_CC3000=1
  79. USE_GRAPHICS=1
  80. USE_FILESYSTEM=1
  81. FAMILY=STM32F1
  82. CHIP=STM32F103RG
  83. BOARD=ESPRUINOBOARD_R1_0
  84. DEFINES+=-DESPRUINOBOARD
  85. STLIB=STM32F10X_XL
  86. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f1/lib/startup_stm32f10x_hd.o
  87. OPTIMIZEFLAGS+=-O3
  88. else ifdef ESPRUINO_1V1
  89. DEFINES+=-DESPRUINO_1V1
  90. USE_BOOTLOADER=1
  91. BOOTLOADER_PROJ_NAME=bootloader_espruino_1v1
  92. USB=1
  93. USE_NET=1
  94. USE_CC3000=1
  95. USE_GRAPHICS=1
  96. USE_FILESYSTEM=1
  97. FAMILY=STM32F1
  98. CHIP=STM32F103RC
  99. BOARD=ESPRUINOBOARD_R1_1
  100. DEFINES+=-DESPRUINOBOARD
  101. STLIB=STM32F10X_XL
  102. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f1/lib/startup_stm32f10x_hd.o
  103. OPTIMIZEFLAGS+=-Os # not that short on memory, but Travis compiler is old and uses more
  104. else ifdef ESPRUINO_1V3
  105. DEFINES+=-DESPRUINO_1V3
  106. USE_BOOTLOADER=1
  107. BOOTLOADER_PROJ_NAME=bootloader_espruino_1v3
  108. USB=1
  109. USE_NET=1
  110. USE_CC3000=1
  111. USE_GRAPHICS=1
  112. USE_FILESYSTEM=1
  113. FAMILY=STM32F1
  114. CHIP=STM32F103RC
  115. BOARD=ESPRUINOBOARD
  116. STLIB=STM32F10X_XL
  117. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f1/lib/startup_stm32f10x_hd.o
  118. OPTIMIZEFLAGS+=-O3
  119. else ifdef OLIMEXINO_STM32
  120. USB=1
  121. USE_FILESYSTEM=1
  122. FAMILY=STM32F1
  123. CHIP=STM32F103RB
  124. BOARD=OLIMEXINO_STM32
  125. STLIB=STM32F10X_MD
  126. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f1/lib/startup_stm32f10x_md.o
  127. OPTIMIZEFLAGS+=-Os # short on program memory
  128. else ifdef OLIMEXINO_STM32_BOOTLOADER
  129. USB=1
  130. USE_FILESYSTEM=1
  131. FAMILY=STM32F1
  132. CHIP=STM32F103RB_MAPLE
  133. DEFINES += -DSTM32F103RB
  134. SAVE_ON_FLASH=1
  135. BOARD=OLIMEXINO_STM32_BOOTLOADER
  136. STLIB=STM32F10X_MD
  137. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f1/lib/startup_stm32f10x_md.o
  138. OPTIMIZEFLAGS+=-Os # short on program memory
  139. else ifdef EMBEDDED_PI
  140. USB=1
  141. # USE_FILESYSTEM=1 # no SD-CARD READER
  142. FAMILY=STM32F1
  143. CHIP=STM32F103RB
  144. BOARD=EMBEDDED_PI
  145. STLIB=STM32F10X_MD
  146. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f1/lib/startup_stm32f10x_md.o
  147. OPTIMIZEFLAGS+=-Os # short on program memory
  148. else ifdef HYSTM32_24
  149. USB=1
  150. USE_GRAPHICS=1
  151. USE_LCD_FSMC=1
  152. USE_FILESYSTEM=1
  153. USE_FILESYSTEM_SDIO=1
  154. FAMILY=STM32F1
  155. CHIP=STM32F103VE
  156. BOARD=HYSTM32_24
  157. STLIB=STM32F10X_HD
  158. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f1/lib/startup_stm32f10x_hd.o
  159. OPTIMIZEFLAGS+=-O3
  160. else ifdef HYSTM32_28
  161. USB=1
  162. USE_GRAPHICS=1
  163. USE_LCD_FSMC=1
  164. DEFINES+=-DILI9325_BITBANG # bit-bang the LCD driver
  165. SAVE_ON_FLASH=1
  166. #USE_FILESYSTEM=1 # just normal SPI
  167. FAMILY=STM32F1
  168. CHIP=STM32F103RB
  169. BOARD=HYSTM32_28
  170. STLIB=STM32F10X_MD
  171. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f1/lib/startup_stm32f10x_md.o
  172. OPTIMIZEFLAGS+=-Os
  173. else ifdef HYSTM32_32
  174. USB=1
  175. USE_GRAPHICS=1
  176. USE_LCD_FSMC=1
  177. USE_FILESYSTEM=1
  178. USE_FILESYSTEM_SDIO=1
  179. FAMILY=STM32F1
  180. CHIP=STM32F103VC
  181. BOARD=HYSTM32_32
  182. STLIB=STM32F10X_HD
  183. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f1/lib/startup_stm32f10x_hd.o
  184. OPTIMIZEFLAGS+=-O3
  185. else ifdef STM32F4DISCOVERY
  186. USB=1
  187. #USE_NET=1
  188. #USE_CC3000=1
  189. USE_GRAPHICS=1
  190. DEFINES += -DUSE_USB_OTG_FS=1
  191. FAMILY=STM32F4
  192. CHIP=STM32F407
  193. BOARD=STM32F4DISCOVERY
  194. STLIB=STM32F4XX
  195. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f4/lib/startup_stm32f4xx.o
  196. OPTIMIZEFLAGS+=-O3
  197. else ifdef STM32F429IDISCOVERY
  198. USB=1
  199. USE_GRAPHICS=1
  200. #USE_LCD_FSMC=1
  201. DEFINES += -DUSE_USB_OTG_FS=1
  202. FAMILY=STM32F4
  203. CHIP=STM32F429
  204. BOARD=STM32F429IDISCOVERY
  205. STLIB=STM32F4XX
  206. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f4/lib/startup_stm32f4xx.o
  207. OPTIMIZEFLAGS+=-O3
  208. else ifdef SMARTWATCH
  209. DEFINES+=-DHSE_VALUE=26000000UL
  210. USB=1
  211. FAMILY=STM32F2
  212. CHIP=STM32F205RG
  213. BOARD=SMARTWATCH
  214. STLIB=STM32F2XX
  215. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f2/lib/startup_stm32f2xx.o
  216. OPTIMIZEFLAGS+=-O3
  217. else ifdef STM32F3DISCOVERY
  218. #USE_BOOTLOADER=1
  219. #BOOTLOADER_PROJ_NAME=bootloader_espruino_stm32f3discovery
  220. USB=1
  221. FAMILY=STM32F3
  222. CHIP=STM32F303
  223. BOARD=STM32F3DISCOVERY
  224. STLIB=STM32F3XX
  225. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f3/lib/startup_stm32f30x.o
  226. OPTIMIZEFLAGS+=-O3
  227. else ifdef STM32VLDISCOVERY
  228. FAMILY=STM32F1
  229. CHIP=STM32F100RB
  230. BOARD=STM32VLDISCOVERY
  231. STLIB=STM32F10X_MD_VL
  232. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f1/lib/startup_stm32f10x_md_vl.o
  233. OPTIMIZEFLAGS+=-Os # short on program memory
  234. else ifdef TINYCHIP
  235. FAMILY=STM32F1
  236. CHIP=STM32F103TB
  237. BOARD=TINYCHIP
  238. STLIB=STM32F10X_MD
  239. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f1/lib/startup_stm32f10x_md.o
  240. OPTIMIZEFLAGS+=-Os # short on program memory
  241. else ifdef LPC1768
  242. MBED=1
  243. FAMILY=LPC1768
  244. CHIP=LPC1768
  245. BOARD=LPC1768
  246. MBED_GCC_CS_DIR=$(ROOT)/targets/libmbed/LPC1768/GCC_CS
  247. PRECOMPILED_OBJS+=$(MBED_GCC_CS_DIR)/sys.o $(MBED_GCC_CS_DIR)/cmsis_nvic.o $(MBED_GCC_CS_DIR)/system_LPC17xx.o $(MBED_GCC_CS_DIR)/core_cm3.o $(MBED_GCC_CS_DIR)/startup_LPC17xx.o
  248. LIBS+=-L$(MBED_GCC_CS_DIR) -lmbed
  249. OPTIMIZEFLAGS+=-O3
  250. else ifdef CARAMBOLA
  251. BOARD=CARAMBOLA
  252. DEFINES += -DCARAMBOLA -DSYSFS_GPIO_DIR="\"/sys/class/gpio\""
  253. LINUX=1
  254. USE_FILESYSTEM=1
  255. USB=1
  256. USE_GRAPHICS=1
  257. USE_NET=1
  258. else ifdef RASPBERRYPI
  259. BOARD=RASPBERRYPI
  260. DEFINES += -DRASPBERRYPI -DSYSFS_GPIO_DIR="\"/sys/class/gpio\""
  261. LINUX=1
  262. USE_FILESYSTEM=1
  263. USB=1
  264. USE_GRAPHICS=1
  265. #USE_LCD_SDL=1
  266. USE_NET=1
  267. else ifdef LCTECH_STM32F103RBT6
  268. USB=1
  269. SAVE_ON_FLASH=1
  270. FAMILY=STM32F1
  271. CHIP=STM32F103RB
  272. BOARD=LCTECH_STM32F103RBT6
  273. STLIB=STM32F10X_MD
  274. PRECOMPILED_OBJS+=$(ROOT)/targetlibs/stm32f1/lib/startup_stm32f10x_md.o
  275. OPTIMIZEFLAGS+=-Os
  276. else
  277. BOARD=LINUX
  278. LINUX=1
  279. USE_FILESYSTEM=1
  280. USB=1
  281. USE_GRAPHICS=1
  282. #USE_LCD_SDL=1
  283. ifndef MACOSX
  284. # http libs need some tweaks before net can compile
  285. USE_NET=1
  286. endif
  287. endif
  288. PROJ_NAME=$(shell python scripts/get_binary_name.py $(BOARD) | sed -e "s/.bin$$//")
  289. ifeq ($(PROJ_NAME),)
  290. $(error Unable to work out binary name (PROJ_NAME))
  291. endif
  292. ifeq ($(BOARD),LINUX)
  293. PROJ_NAME=espruino
  294. endif
  295. ifdef DEBUG
  296. #OPTIMIZEFLAGS=-Os -g
  297. OPTIMIZEFLAGS=-g
  298. endif
  299. ifdef PROFILE
  300. OPTIMIZEFLAGS+=-pg
  301. endif
  302. WRAPPERFILE=gen/jswrapper.c
  303. WRAPPERSOURCES = \
  304. src/jswrap_pin.c \
  305. src/jswrap_functions.c \
  306. src/jswrap_modules.c \
  307. src/jswrap_process.c \
  308. src/jswrap_interactive.c \
  309. src/jswrap_json.c \
  310. src/jswrap_object.c \
  311. src/jswrap_string.c \
  312. src/jswrap_array.c \
  313. src/jswrap_arraybuffer.c \
  314. src/jswrap_serial.c \
  315. src/jswrap_spi_i2c.c \
  316. src/jswrap_onewire.c \
  317. src/jswrap_io.c
  318. # it is important that _pin comes before stuff which uses
  319. # integers (as the check for int *includes* the chek for pin)
  320. SOURCES = \
  321. src/jslex.c \
  322. src/jsvar.c \
  323. src/jsutils.c \
  324. src/jsparse.c \
  325. src/jspin.c \
  326. src/jsinteractive.c \
  327. src/jsdevices.c \
  328. $(WRAPPERFILE)
  329. CPPSOURCES =
  330. ifdef BOOTLOADER
  331. ifndef USE_BOOTLOADER
  332. $(error Using bootloader on device that is not expecting one)
  333. endif
  334. BUILD_LINKER_FLAGS+=--bootloader
  335. PROJ_NAME=$(BOOTLOADER_PROJ_NAME)
  336. WRAPPERSOURCES =
  337. SOURCES = \
  338. targets/stm32_boot/main.c \
  339. targets/stm32_boot/utils.c
  340. ifndef DEBUG
  341. OPTIMIZEFLAGS=-Os
  342. endif
  343. else # !BOOTLOADER
  344. ifdef USE_BOOTLOADER
  345. BUILD_LINKER_FLAGS+=--using_bootloader
  346. STM32LOADER_FLAGS+=-p /dev/ttyACM0
  347. BASEADDRESS=$(shell python -c "import sys;sys.path.append('scripts');import common;print hex(0x08000000+common.get_bootloader_size())")
  348. endif
  349. endif
  350. ifdef USB_PRODUCT_ID
  351. DEFINES+=-DUSB_PRODUCT_ID=$(USB_PRODUCT_ID)
  352. endif
  353. ifdef SAVE_ON_FLASH
  354. DEFINES+=-DSAVE_ON_FLASH
  355. endif
  356. ifdef USE_FILESYSTEM
  357. DEFINES += -DUSE_FILESYSTEM
  358. WRAPPERSOURCES += libs/jswrap_fat.c
  359. ifndef LINUX
  360. INCLUDE += -I$(ROOT)/libs/fat_sd
  361. SOURCES += \
  362. libs/fat_sd/fattime.c \
  363. libs/fat_sd/ff.c
  364. #libs/fat_sd/option/ccsbcs.c # for LFN support (see _USE_LFN in ff.h)
  365. ifdef USE_FILESYSTEM_SDIO
  366. DEFINES += -DUSE_FILESYSTEM_SDIO
  367. SOURCES += \
  368. libs/fat_sd/sdio_diskio.c \
  369. libs/fat_sd/sdio_sdcard.c
  370. else #USE_FILESYSTEM_SDIO
  371. SOURCES += \
  372. libs/fat_sd/spi_diskio.c
  373. endif #USE_FILESYSTEM_SDIO
  374. endif #!LINUX
  375. endif #USE_FILESYSTEM
  376. ifdef USE_MATH
  377. DEFINES += -DUSE_MATH
  378. WRAPPERSOURCES += libs/jswrap_math.c
  379. ifndef LINUX
  380. INCLUDE += -I$(ROOT)/libs/math
  381. SOURCES += \
  382. libs/math/acosh.c \
  383. libs/math/asin.c \
  384. libs/math/asinh.c \
  385. libs/math/atan.c \
  386. libs/math/atanh.c \
  387. libs/math/cbrt.c \
  388. libs/math/chbevl.c \
  389. libs/math/clog.c \
  390. libs/math/cmplx.c \
  391. libs/math/const.c \
  392. libs/math/cosh.c \
  393. libs/math/drand.c \
  394. libs/math/exp10.c \
  395. libs/math/exp2.c \
  396. libs/math/exp.c \
  397. libs/math/fabs.c \
  398. libs/math/floor.c \
  399. libs/math/isnan.c \
  400. libs/math/log10.c \
  401. libs/math/log2.c \
  402. libs/math/log.c \
  403. libs/math/mtherr.c \
  404. libs/math/polevl.c \
  405. libs/math/pow.c \
  406. libs/math/powi.c \
  407. libs/math/round.c \
  408. libs/math/setprec.c \
  409. libs/math/sin.c \
  410. libs/math/sincos.c \
  411. libs/math/sindg.c \
  412. libs/math/sinh.c \
  413. libs/math/sqrt.c \
  414. libs/math/tan.c \
  415. libs/math/tandg.c \
  416. libs/math/tanh.c \
  417. libs/math/unity.c
  418. #libs/math/mod2pi.c
  419. #libs/math/mtst.c
  420. #libs/math/dtestvec.c
  421. endif
  422. endif
  423. ifdef USE_GRAPHICS
  424. DEFINES += -DUSE_GRAPHICS
  425. WRAPPERSOURCES += libs/graphics/jswrap_graphics.c
  426. INCLUDE += -I$(ROOT)/libs/graphics
  427. SOURCES += \
  428. libs/graphics/bitmap_font_8x8.c \
  429. libs/graphics/graphics.c \
  430. libs/graphics/lcd_arraybuffer.c \
  431. libs/graphics/lcd_js.c
  432. ifdef USE_LCD_SDL
  433. DEFINES += -DUSE_LCD_SDL
  434. SOURCES += libs/graphics/lcd_sdl.c
  435. LIBS += -lSDL
  436. INCLUDE += -I/usr/include/SDL
  437. endif
  438. ifdef USE_LCD_FSMC
  439. DEFINES += -DUSE_LCD_FSMC
  440. SOURCES += libs/graphics/lcd_fsmc.c
  441. endif
  442. endif
  443. ifdef USE_NET
  444. DEFINES += -DUSE_NET
  445. WRAPPERSOURCES += libs/network/http/jswrap_http.c
  446. INCLUDE += -I$(ROOT)/libs/network/http
  447. SOURCES += \
  448. libs/network/http/httpserver.c
  449. ifdef LINUX
  450. #LIBS += -l...
  451. #INCLUDE += -I...
  452. endif
  453. endif
  454. ifdef USE_CC3000
  455. DEFINES += -DUSE_CC3000 -DSEND_NON_BLOCKING
  456. WRAPPERSOURCES += libs/network/cc3000/jswrap_cc3000.c
  457. INCLUDE += -I$(ROOT)/libs/network/cc3000
  458. SOURCES += \
  459. libs/network/cc3000/board_spi.c \
  460. libs/network/cc3000/cc3000_common.c \
  461. libs/network/cc3000/evnt_handler.c \
  462. libs/network/cc3000/hci.c \
  463. libs/network/cc3000/netapp.c \
  464. libs/network/cc3000/nvmem.c \
  465. libs/network/cc3000/security.c \
  466. libs/network/cc3000/socket.c \
  467. libs/network/cc3000/wlan.c
  468. endif
  469. ifdef USE_TRIGGER
  470. DEFINES += -DUSE_TRIGGER
  471. WRAPPERSOURCES += libs/trigger/jswrap_trigger.c
  472. INCLUDE += -I$(ROOT)/libs/trigger
  473. SOURCES += \
  474. ./libs/trigger/trigger.c
  475. endif
  476. ifdef USB
  477. DEFINES += -DUSB
  478. endif
  479. ifeq ($(FAMILY), STM32F1)
  480. ARCHFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m3 -mfix-cortex-m3-ldrd -mthumb-interwork -mfloat-abi=soft
  481. ARM=1
  482. STM32=1
  483. INCLUDE += -I$(ROOT)/targetlibs/stm32f1 -I$(ROOT)/targetlibs/stm32f1/lib
  484. DEFINES += -DSTM32F1
  485. SOURCES += \
  486. targetlibs/stm32f1/lib/misc.c \
  487. targetlibs/stm32f1/lib/stm32f10x_adc.c \
  488. targetlibs/stm32f1/lib/stm32f10x_bkp.c \
  489. targetlibs/stm32f1/lib/stm32f10x_can.c \
  490. targetlibs/stm32f1/lib/stm32f10x_cec.c \
  491. targetlibs/stm32f1/lib/stm32f10x_crc.c \
  492. targetlibs/stm32f1/lib/stm32f10x_dac.c \
  493. targetlibs/stm32f1/lib/stm32f10x_dbgmcu.c \
  494. targetlibs/stm32f1/lib/stm32f10x_dma.c \
  495. targetlibs/stm32f1/lib/stm32f10x_exti.c \
  496. targetlibs/stm32f1/lib/stm32f10x_flash.c \
  497. targetlibs/stm32f1/lib/stm32f10x_fsmc.c \
  498. targetlibs/stm32f1/lib/stm32f10x_gpio.c \
  499. targetlibs/stm32f1/lib/stm32f10x_i2c.c \
  500. targetlibs/stm32f1/lib/stm32f10x_iwdg.c \
  501. targetlibs/stm32f1/lib/stm32f10x_pwr.c \
  502. targetlibs/stm32f1/lib/stm32f10x_rcc.c \
  503. targetlibs/stm32f1/lib/stm32f10x_rtc.c \
  504. targetlibs/stm32f1/lib/stm32f10x_sdio.c \
  505. targetlibs/stm32f1/lib/stm32f10x_spi.c \
  506. targetlibs/stm32f1/lib/stm32f10x_tim.c \
  507. targetlibs/stm32f1/lib/stm32f10x_usart.c \
  508. targetlibs/stm32f1/lib/stm32f10x_wwdg.c \
  509. targetlibs/stm32f1/lib/system_stm32f10x.c
  510. ifdef USB
  511. INCLUDE += -I$(ROOT)/targetlibs/stm32f1/usblib -I$(ROOT)/targetlibs/stm32f1/usb
  512. SOURCES += \
  513. targetlibs/stm32f1/usblib/otgd_fs_cal.c \
  514. targetlibs/stm32f1/usblib/otgd_fs_dev.c \
  515. targetlibs/stm32f1/usblib/otgd_fs_int.c \
  516. targetlibs/stm32f1/usblib/otgd_fs_pcd.c \
  517. targetlibs/stm32f1/usblib/usb_core.c \
  518. targetlibs/stm32f1/usblib/usb_init.c \
  519. targetlibs/stm32f1/usblib/usb_int.c \
  520. targetlibs/stm32f1/usblib/usb_mem.c \
  521. targetlibs/stm32f1/usblib/usb_regs.c \
  522. targetlibs/stm32f1/usblib/usb_sil.c \
  523. targetlibs/stm32f1/usb/usb_desc.c \
  524. targetlibs/stm32f1/usb/usb_endp.c \
  525. targetlibs/stm32f1/usb/usb_istr.c \
  526. targetlibs/stm32f1/usb/usb_prop.c \
  527. targetlibs/stm32f1/usb/usb_pwr.c \
  528. targetlibs/stm32f1/usb/usb_utils.c
  529. endif #USB
  530. endif #STM32F1
  531. ifeq ($(FAMILY), STM32F2)
  532. ARCHFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m3 -mthumb-interwork -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
  533. ARM=1
  534. STM32=1
  535. INCLUDE += -I$(ROOT)/targetlibs/stm32f2 -I$(ROOT)/targetlibs/stm32f2/lib
  536. DEFINES += -DSTM32F2
  537. SOURCES += \
  538. targetlibs/stm32f2/lib/misc.c \
  539. targetlibs/stm32f2/lib/stm32f2xx_adc.c \
  540. targetlibs/stm32f2/lib/stm32f2xx_can.c \
  541. targetlibs/stm32f2/lib/stm32f2xx_crc.c \
  542. targetlibs/stm32f2/lib/stm32f2xx_cryp_aes.c\
  543. targetlibs/stm32f2/lib/stm32f2xx_cryp.c \
  544. targetlibs/stm32f2/lib/stm32f2xx_cryp_des.c\
  545. targetlibs/stm32f2/lib/stm32f2xx_cryp_tdes.c\
  546. targetlibs/stm32f2/lib/stm32f2xx_dac.c \
  547. targetlibs/stm32f2/lib/stm32f2xx_dbgmcu.c \
  548. targetlibs/stm32f2/lib/stm32f2xx_dcmi.c \
  549. targetlibs/stm32f2/lib/stm32f2xx_dma.c \
  550. targetlibs/stm32f2/lib/stm32f2xx_exti.c \
  551. targetlibs/stm32f2/lib/stm32f2xx_flash.c \
  552. targetlibs/stm32f2/lib/stm32f2xx_fsmc.c \
  553. targetlibs/stm32f2/lib/stm32f2xx_gpio.c \
  554. targetlibs/stm32f2/lib/stm32f2xx_hash.c \
  555. targetlibs/stm32f2/lib/stm32f2xx_hash_md5.c \
  556. targetlibs/stm32f2/lib/stm32f2xx_hash_sha1.c \
  557. targetlibs/stm32f2/lib/stm32f2xx_i2c.c \
  558. targetlibs/stm32f2/lib/stm32f2xx_iwdg.c \
  559. targetlibs/stm32f2/lib/stm32f2xx_pwr.c \
  560. targetlibs/stm32f2/lib/stm32f2xx_rcc.c \
  561. targetlibs/stm32f2/lib/stm32f2xx_rng.c \
  562. targetlibs/stm32f2/lib/stm32f2xx_rtc.c \
  563. targetlibs/stm32f2/lib/stm32f2xx_sdio.c \
  564. targetlibs/stm32f2/lib/stm32f2xx_spi.c \
  565. targetlibs/stm32f2/lib/stm32f2xx_syscfg.c \
  566. targetlibs/stm32f2/lib/stm32f2xx_tim.c \
  567. targetlibs/stm32f2/lib/stm32f2xx_usart.c \
  568. targetlibs/stm32f2/lib/stm32f2xx_wwdg.c \
  569. targetlibs/stm32f2/lib/system_stm32f2xx.c
  570. ifdef USB
  571. INCLUDE += -I$(ROOT)/targetlibs/stm32f2/usblib -I$(ROOT)/targetlibs/stm32f2/usb
  572. SOURCES += \
  573. targetlibs/stm32f2/usb/usbd_cdc_vcp.c \
  574. targetlibs/stm32f2/usb/usb_irq_handlers.c \
  575. targetlibs/stm32f2/usb/usbd_desc.c \
  576. targetlibs/stm32f2/usb/usbd_usr.c \
  577. targetlibs/stm32f2/usb/usb_bsp.c \
  578. targetlibs/stm32f2/usblib/usbd_req.c \
  579. targetlibs/stm32f2/usblib/usb_dcd_int.c \
  580. targetlibs/stm32f2/usblib/usbd_core.c \
  581. targetlibs/stm32f2/usblib/usbd_cdc_core.c \
  582. targetlibs/stm32f2/usblib/usbd_ioreq.c \
  583. targetlibs/stm32f2/usblib/usb_core.c \
  584. targetlibs/stm32f2/usblib/usb_dcd.c
  585. #targetlibs/stm32f2/usblib/usb_otg.c \
  586. #targetlibs/stm32f2/usblib/usb_bsp_template.c \
  587. #targetlibs/stm32f2/usblib/usbd_cdc_if_template.c \
  588. #targetlibs/stm32f2/usblib/usb_hcd.c \
  589. #targetlibs/stm32f2/usblib/usb_hcd_int.c
  590. endif #USB
  591. endif #STM32F2
  592. ifeq ($(FAMILY), STM32F3)
  593. ARCHFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
  594. ARM=1
  595. STM32=1
  596. INCLUDE += -I$(ROOT)/targetlibs/stm32f3 -I$(ROOT)/targetlibs/stm32f3/lib
  597. DEFINES += -DSTM32F3
  598. SOURCES += \
  599. targetlibs/stm32f3/lib/stm32f30x_adc.c \
  600. targetlibs/stm32f3/lib/stm32f30x_can.c \
  601. targetlibs/stm32f3/lib/stm32f30x_comp.c \
  602. targetlibs/stm32f3/lib/stm32f30x_crc.c \
  603. targetlibs/stm32f3/lib/stm32f30x_dac.c \
  604. targetlibs/stm32f3/lib/stm32f30x_dbgmcu.c \
  605. targetlibs/stm32f3/lib/stm32f30x_dma.c \
  606. targetlibs/stm32f3/lib/stm32f30x_exti.c \
  607. targetlibs/stm32f3/lib/stm32f30x_flash.c \
  608. targetlibs/stm32f3/lib/stm32f30x_gpio.c \
  609. targetlibs/stm32f3/lib/stm32f30x_i2c.c \
  610. targetlibs/stm32f3/lib/stm32f30x_iwdg.c \
  611. targetlibs/stm32f3/lib/stm32f30x_misc.c \
  612. targetlibs/stm32f3/lib/stm32f30x_opamp.c \
  613. targetlibs/stm32f3/lib/stm32f30x_pwr.c \
  614. targetlibs/stm32f3/lib/stm32f30x_rcc.c \
  615. targetlibs/stm32f3/lib/stm32f30x_rtc.c \
  616. targetlibs/stm32f3/lib/stm32f30x_spi.c \
  617. targetlibs/stm32f3/lib/stm32f30x_syscfg.c \
  618. targetlibs/stm32f3/lib/stm32f30x_tim.c \
  619. targetlibs/stm32f3/lib/stm32f30x_usart.c \
  620. targetlibs/stm32f3/lib/stm32f30x_wwdg.c \
  621. targetlibs/stm32f3/lib/system_stm32f30x.c
  622. ifdef USB
  623. INCLUDE += -I$(ROOT)/targetlibs/stm32f3/usblib -I$(ROOT)/targetlibs/stm32f3/usb
  624. SOURCES += \
  625. targetlibs/stm32f3/usblib/usb_core.c \
  626. targetlibs/stm32f3/usblib/usb_init.c \
  627. targetlibs/stm32f3/usblib/usb_int.c \
  628. targetlibs/stm32f3/usblib/usb_mem.c \
  629. targetlibs/stm32f3/usblib/usb_regs.c \
  630. targetlibs/stm32f3/usblib/usb_sil.c \
  631. targetlibs/stm32f3/usb/usb_desc.c \
  632. targetlibs/stm32f3/usb/usb_endp.c \
  633. targetlibs/stm32f3/usb/usb_istr.c \
  634. targetlibs/stm32f3/usb/usb_prop.c \
  635. targetlibs/stm32f3/usb/usb_pwr.c \
  636. targetlibs/stm32f3/usb/usb_utils.c
  637. endif #USB
  638. endif #STM32F3
  639. ifeq ($(FAMILY), STM32F4)
  640. ARCHFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
  641. ARM=1
  642. STM32=1
  643. INCLUDE += -I$(ROOT)/targetlibs/stm32f4 -I$(ROOT)/targetlibs/stm32f4/lib
  644. DEFINES += -DSTM32F4
  645. SOURCES += \
  646. targetlibs/stm32f4/lib/misc.c \
  647. targetlibs/stm32f4/lib/stm32f4xx_adc.c \
  648. targetlibs/stm32f4/lib/stm32f4xx_can.c \
  649. targetlibs/stm32f4/lib/stm32f4xx_crc.c \
  650. targetlibs/stm32f4/lib/stm32f4xx_cryp_aes.c \
  651. targetlibs/stm32f4/lib/stm32f4xx_cryp.c \
  652. targetlibs/stm32f4/lib/stm32f4xx_cryp_des.c \
  653. targetlibs/stm32f4/lib/stm32f4xx_cryp_tdes.c \
  654. targetlibs/stm32f4/lib/stm32f4xx_dac.c \
  655. targetlibs/stm32f4/lib/stm32f4xx_dbgmcu.c \
  656. targetlibs/stm32f4/lib/stm32f4xx_dcmi.c \
  657. targetlibs/stm32f4/lib/stm32f4xx_dma.c \
  658. targetlibs/stm32f4/lib/stm32f4xx_exti.c \
  659. targetlibs/stm32f4/lib/stm32f4xx_flash.c \
  660. targetlibs/stm32f4/lib/stm32f4xx_fsmc.c \
  661. targetlibs/stm32f4/lib/stm32f4xx_gpio.c \
  662. targetlibs/stm32f4/lib/stm32f4xx_hash.c \
  663. targetlibs/stm32f4/lib/stm32f4xx_hash_md5.c \
  664. targetlibs/stm32f4/lib/stm32f4xx_hash_sha1.c \
  665. targetlibs/stm32f4/lib/stm32f4xx_i2c.c \
  666. targetlibs/stm32f4/lib/stm32f4xx_iwdg.c \
  667. targetlibs/stm32f4/lib/stm32f4xx_pwr.c \
  668. targetlibs/stm32f4/lib/stm32f4xx_rcc.c \
  669. targetlibs/stm32f4/lib/stm32f4xx_rng.c \
  670. targetlibs/stm32f4/lib/stm32f4xx_rtc.c \
  671. targetlibs/stm32f4/lib/stm32f4xx_sdio.c \
  672. targetlibs/stm32f4/lib/stm32f4xx_spi.c \
  673. targetlibs/stm32f4/lib/stm32f4xx_syscfg.c \
  674. targetlibs/stm32f4/lib/stm32f4xx_tim.c \
  675. targetlibs/stm32f4/lib/stm32f4xx_usart.c \
  676. targetlibs/stm32f4/lib/stm32f4xx_wwdg.c \
  677. targetlibs/stm32f4/lib/system_stm32f4xx.c
  678. ifdef USB
  679. INCLUDE += -I$(ROOT)/targetlibs/stm32f4/usblib -I$(ROOT)/targetlibs/stm32f4/usb
  680. SOURCES += \
  681. targetlibs/stm32f4/usblib/usb_core.c \
  682. targetlibs/stm32f4/usblib/usbd_cdc_core.c \
  683. targetlibs/stm32f4/usblib/usb_dcd.c \
  684. targetlibs/stm32f4/usblib/usb_dcd_int.c \
  685. targetlibs/stm32f4/usblib/usbd_core.c \
  686. targetlibs/stm32f4/usblib/usbd_ioreq.c \
  687. targetlibs/stm32f4/usblib/usbd_req.c \
  688. targetlibs/stm32f4/usb/usb_bsp.c \
  689. targetlibs/stm32f4/usb/usbd_cdc_vcp.c \
  690. targetlibs/stm32f4/usb/usbd_desc.c \
  691. targetlibs/stm32f4/usb/usbd_usr.c
  692. #targetlibs/stm32f4/usblib/usb_hcd.c
  693. #targetlibs/stm32f4/usblib/usb_hcd_int.c
  694. #targetlibs/stm32f4/usblib/usb_otg.c
  695. endif #USB
  696. endif #STM32F4
  697. ifdef MBED
  698. ARCHFLAGS += -mcpu=cortex-m3 -mthumb
  699. ARM=1
  700. INCLUDE+=-I$(ROOT)/targetlibs/libmbed -I$(ROOT)/targetlibs/libmbed/$(CHIP) -I$(ROOT)/targetlibs/libmbed/$(CHIP)/GCC_CS
  701. DEFINES += -DMBED
  702. INCLUDE += -I$(ROOT)/targetlibs/mbed
  703. SOURCES += targets/mbed/main.c
  704. CPPSOURCES += targets/mbed/jshardware.cpp
  705. endif
  706. ifdef ARM
  707. LINKER_FILE = gen/linker.ld
  708. DEFINES += -DARM
  709. INCLUDE += -I$(ROOT)/targetlibs/arm
  710. OPTIMIZEFLAGS += -fno-common -fno-exceptions -fdata-sections -ffunction-sections
  711. # -flto -fuse-linker-plugin
  712. # -flto - link time optimisation - could be good for ST's libs
  713. # GCC suggests use of -fuse-linker-plugin with flto
  714. # Does not work - get errors like : `sqrt' referenced in section `.text.asin' of /tmp/ccJheOub.ltrans9.ltrans.o: defined in discarded section `.text' of libs/math/sqrt.o (symbol from plugin)
  715. # 4.6
  716. #export CCPREFIX=arm-linux-gnueabi-
  717. # 4.5
  718. #export CCPREFIX=~/sat/bin/arm-none-eabi-
  719. # 4.4
  720. export CCPREFIX=arm-none-eabi-
  721. endif # ARM
  722. PININFOFILE=$(ROOT)/gen/jspininfo
  723. ifdef PININFOFILE
  724. SOURCES += $(PININFOFILE).c
  725. endif
  726. ifdef CARAMBOLA
  727. TOOLCHAIN_DIR=$(shell cd ~/workspace/carambola/staging_dir/toolchain-*/bin;pwd)
  728. export STAGING_DIR=$(TOOLCHAIN_DIR)
  729. export CCPREFIX=$(TOOLCHAIN_DIR)/mipsel-openwrt-linux-
  730. endif
  731. ifdef RASPBERRYPI
  732. ifneq ($(shell uname -m),armv6l)
  733. # eep. let's cross compile
  734. export CCPREFIX=targetlibs/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-
  735. else
  736. # compiling in-place, so give it a normal name
  737. PROJ_NAME=espruino
  738. endif
  739. endif
  740. ifdef STM32
  741. DEFINES += -DFAKE_STDLIB
  742. # FAKE_STDLIB is for Espruino - it uses its own standard library so we don't have to link in the normal one + get bloated
  743. DEFINES += -DSTM32 -DUSE_STDPERIPH_DRIVER=1 -D$(CHIP) -D$(BOARD) -D$(STLIB)
  744. INCLUDE += -I$(ROOT)/targets/stm32
  745. ifndef BOOTLOADER
  746. SOURCES += \
  747. targets/stm32/main.c \
  748. targets/stm32/jshardware.c \
  749. targets/stm32/stm32_it.c
  750. endif
  751. endif
  752. ifdef LINUX
  753. DEFINES += -DLINUX
  754. INCLUDE += -I$(ROOT)/targets/linux
  755. SOURCES += \
  756. targets/linux/main.c \
  757. targets/linux/jshardware.c
  758. LIBS += -lm # maths lib
  759. endif
  760. SOURCES += $(WRAPPERSOURCES)
  761. SOURCEOBJS = $(SOURCES:.c=.o) $(CPPSOURCES:.cpp=.o)
  762. OBJS = $(SOURCEOBJS) $(PRECOMPILED_OBJS)
  763. # -ffreestanding -nodefaultlibs -nostdlib -fno-common
  764. # -nodefaultlibs -nostdlib -nostartfiles
  765. # -fdata-sections -ffunction-sections are to help remove unused code
  766. CFLAGS += $(OPTIMIZEFLAGS) -c $(ARCHFLAGS) $(DEFINES) $(INCLUDE)
  767. # -Wl,--gc-sections helps remove unused code
  768. # -Wl,--whole-archive checks for duplicates
  769. LDFLAGS += $(OPTIMIZEFLAGS) $(ARCHFLAGS)
  770. ifndef MACOSX
  771. LDFLAGS += -Wl,--gc-sections
  772. endif
  773. ifdef LINKER_FILE
  774. LDFLAGS += -T$(LINKER_FILE)
  775. endif
  776. export CC=$(CCPREFIX)gcc
  777. export LD=$(CCPREFIX)gcc
  778. export AR=$(CCPREFIX)ar
  779. export AS=$(CCPREFIX)as
  780. export OBJCOPY=$(CCPREFIX)objcopy
  781. export OBJDUMP=$(CCPREFIX)objdump
  782. export GDB=$(CCPREFIX)gdb
  783. .PHONY: proj
  784. all: proj
  785. ifeq ($(V),1)
  786. quiet_=
  787. Q=
  788. else
  789. quiet_=quiet_
  790. Q=@
  791. export SILENT=1
  792. endif
  793. $(WRAPPERFILE): scripts/build_jswrapper.py $(WRAPPERSOURCES)
  794. @echo Generating JS wrappers
  795. $(Q)echo WRAPPERSOURCES = $(WRAPPERSOURCES)
  796. $(Q)echo DEFINES = $(DEFINES)
  797. $(Q)python scripts/build_jswrapper.py $(WRAPPERSOURCES) $(DEFINES)
  798. ifdef PININFOFILE
  799. $(PININFOFILE).c $(PININFOFILE).h: scripts/build_pininfo.py
  800. @echo Generating pin info
  801. $(Q)python scripts/build_pininfo.py $(BOARD) $(PININFOFILE).c $(PININFOFILE).h
  802. endif
  803. $(LINKER_FILE): scripts/build_linker.py
  804. @echo Generating linker scripts
  805. $(Q)python scripts/build_linker.py $(BOARD) $(LINKER_FILE) $(BUILD_LINKER_FLAGS)
  806. $(PLATFORM_CONFIG_FILE): boards/$(BOARD).py scripts/build_platform_config.py
  807. @echo Generating platform configs
  808. $(Q)python scripts/build_platform_config.py $(BOARD)
  809. compile=$(CC) $(CFLAGS) $(DEFINES) $< -o $@
  810. link=$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
  811. obj_dump=$(OBJDUMP) -x -S $(PROJ_NAME).elf > $(PROJ_NAME).lst
  812. obj_to_bin=$(OBJCOPY) -O $1 $(PROJ_NAME).elf $(PROJ_NAME).$2
  813. quiet_compile= CC $@
  814. quiet_link= LD $@
  815. quiet_obj_dump= GEN $(PROJ_NAME).lst
  816. quiet_obj_to_bin= GEN $(PROJ_NAME).$2
  817. %.o: %.c $(PLATFORM_CONFIG_FILE) $(PININFOFILE).h
  818. @echo $($(quiet_)compile)
  819. @$(call compile)
  820. .cpp.o: $(PLATFORM_CONFIG_FILE) $(PININFOFILE).h
  821. @echo $($(quiet_)compile)
  822. @$(call compile)
  823. .s.o:
  824. @echo $($(quiet_)compile)
  825. @$(call compile)
  826. ifdef LINUX # ---------------------------------------------------
  827. proj: $(PLATFORM_CONFIG_FILE) $(PROJ_NAME)
  828. $(PROJ_NAME): $(OBJS)
  829. @echo $($(quiet_)link)
  830. @$(call link)
  831. else # embedded, so generate bin, etc ---------------------------
  832. $(PROJ_NAME).elf: $(OBJS) $(LINKER_FILE)
  833. @echo $($(quiet_)link)
  834. @$(call link)
  835. $(PROJ_NAME).lst : $(PROJ_NAME).elf
  836. @echo $($(quiet_)obj_dump)
  837. @$(call obj_dump)
  838. $(PROJ_NAME).hex: $(PROJ_NAME).elf
  839. @echo $(call $(quiet_)obj_to_bin,ihex,hex)
  840. @$(call obj_to_bin,ihex,hex)
  841. $(PROJ_NAME).srec : $(PROJ_NAME).elf
  842. @echo $(call $(quiet_)obj_to_bin,srec,srec)
  843. @$(call obj_to_bin,srec,srec)
  844. $(PROJ_NAME).bin : $(PROJ_NAME).elf
  845. @echo $(call $(quiet_)obj_to_bin,binary,bin)
  846. @$(call obj_to_bin,binary,bin)
  847. bash scripts/check_size.sh $(PROJ_NAME).bin
  848. proj: $(PROJ_NAME).lst $(PROJ_NAME).bin
  849. #proj: $(PROJ_NAME).lst $(PROJ_NAME).hex $(PROJ_NAME).srec $(PROJ_NAME).bin
  850. flash: all
  851. ifdef OLIMEXINO_STM32_BOOTLOADER
  852. echo Olimexino Serial bootloader
  853. dfu-util -a1 -d 0x1EAF:0x0003 -D $(PROJ_NAME).bin
  854. else
  855. ifdef MBED
  856. cp $(PROJ_NAME).bin /media/MBED;sync
  857. else
  858. echo ST-LINK flash
  859. ~/bin/st-flash write $(PROJ_NAME).bin $(BASEADDRESS)
  860. endif
  861. endif
  862. serialflash: all
  863. echo STM32 inbuilt serial bootloader, set BOOT0=1, BOOT1=0
  864. python scripts/stm32loader.py -b 460800 -a $(BASEADDRESS) -ew $(STM32LOADER_FLAGS) $(PROJ_NAME).bin
  865. # python scripts/stm32loader.py -b 460800 -a $(BASEADDRESS) -ewv $(STM32LOADER_FLAGS) $(PROJ_NAME).bin
  866. gdb:
  867. echo "target extended-remote :4242" > gdbinit
  868. echo "file $(PROJ_NAME).elf" >> gdbinit
  869. #echo "load" >> gdbinit
  870. echo "break main" >> gdbinit
  871. echo "break HardFault_Handler" >> gdbinit
  872. $(GDB) -x gdbinit
  873. rm gdbinit
  874. endif # ---------------------------------------------------
  875. clean:
  876. @echo Cleaning targets
  877. $(Q)find . -name *.o | grep -v libmbed | grep -v arm-bcm2708 | xargs rm -f
  878. $(Q)rm -f $(ROOT)/gen/*.c $(ROOT)/gen/*.h $(ROOT)/gen/*.ld
  879. $(Q)rm -f $(PROJ_NAME).elf
  880. $(Q)rm -f $(PROJ_NAME).hex
  881. $(Q)rm -f $(PROJ_NAME).bin
  882. $(Q)rm -f $(PROJ_NAME).srec
  883. $(Q)rm -f $(PROJ_NAME).lst