reform

MNT Reform: Open Source Portable Computer
Log (Feed) | Files | Refs (Tags) | README

Makefile (12115B)


      1 ##########################################################################
      2 # User configuration and firmware specific object files	
      3 ##########################################################################
      4 
      5 FILENAME=firmware
      6 
      7 # See projectconfig.h for a list of valid BOARD options!
      8 BOARD=CFG_BRD_REFORM2
      9 
     10 # Set TARGET to 'lpc11u' or 'lpc13u' depending on the target MCU
     11 TARGET = lpc11u
     12 ifeq (lpc11u,$(TARGET))
     13   CORE = cortex-m0
     14   LDSCRIPT = cmsis/lpc11u24.ld
     15   # LDSCRIPT = cmsis/lpc11u37.ld
     16 else
     17   CORE = cortex-m3
     18   LDSCRIPT = cmsis/lpc1347.ld
     19 endif
     20 
     21 # Set OPTIMIZATION to '0', '1', '2', '3' or 's'
     22 OPTIMIZATION = 2
     23 
     24 ##########################################################################
     25 # Output directories
     26 ##########################################################################
     27 
     28 BIN_PATH = bin
     29 OBJ_PATH = bin/obj
     30 
     31 ##########################################################################
     32 # Source Files
     33 ##########################################################################
     34 
     35 VPATH = cmsis
     36 ifeq (lpc11u,$(TARGET))
     37   OBJS   = $(OBJ_PATH)/startup_lpc11u_gnumake.o 
     38   OBJS  += $(OBJ_PATH)/system_LPC11Uxx.o
     39 else
     40   OBJS   = $(OBJ_PATH)/startup_lpc13u_gnumake.o 
     41   OBJS  += $(OBJ_PATH)/system_LPC13Uxx.o
     42 endif
     43 OBJS  += $(OBJ_PATH)/math_helper.o
     44 OBJS  += $(OBJ_PATH)/RTX_hook.o
     45 
     46 VPATH += src
     47 OBJS  += $(OBJ_PATH)/printf-retarget.o
     48 
     49 VPATH += src/boards/lpcnfc
     50 OBJS  += $(OBJ_PATH)/board_lpcnfc.o
     51 
     52 VPATH += src/boards/reform2
     53 OBJS  += $(OBJ_PATH)/board_reform2.o
     54 
     55 VPATH += src/boards/rf1ghzusb
     56 OBJS  += $(OBJ_PATH)/board_rf1ghzusb.o
     57 
     58 VPATH += src/boards/rf1ghznode
     59 OBJS  += $(OBJ_PATH)/board_rf1ghznode.o
     60 
     61 VPATH += src/cli
     62 OBJS  += $(OBJ_PATH)/cli.o 
     63 OBJS  += $(OBJ_PATH)/commands.o
     64 
     65 VPATH += src/cli/commands
     66 OBJS  += $(OBJ_PATH)/cmd_chibi_addr.o 
     67 OBJS  += $(OBJ_PATH)/cmd_chibi_tx.o 
     68 OBJS  += $(OBJ_PATH)/cmd_dbg_memrd.o
     69 OBJS  += $(OBJ_PATH)/cmd_eeprom_read.o 
     70 OBJS  += $(OBJ_PATH)/cmd_eeprom_write.o 
     71 OBJS  += $(OBJ_PATH)/cmd_i2c_read.o
     72 OBJS  += $(OBJ_PATH)/cmd_i2c_scan.o 
     73 OBJS  += $(OBJ_PATH)/cmd_i2c_write.o 
     74 OBJS  += $(OBJ_PATH)/cmd_nfc_mfc_ndef.o
     75 OBJS  += $(OBJ_PATH)/cmd_nfc_mifareclassic_memdump.o
     76 OBJS  += $(OBJ_PATH)/cmd_nfc_mifareclassic_valueblock.o 
     77 OBJS  += $(OBJ_PATH)/cmd_nfc_mifareultralight_memdump.o 
     78 OBJS  += $(OBJ_PATH)/cmd_rtc_read.o
     79 OBJS  += $(OBJ_PATH)/cmd_rtc_write.o
     80 OBJS  += $(OBJ_PATH)/cmd_sd_dir.o
     81 OBJS  += $(OBJ_PATH)/cmd_sysinfo.o
     82 OBJS  += $(OBJ_PATH)/cmd_wifi.o
     83 
     84 VPATH += src/core/adc
     85 OBJS  += $(OBJ_PATH)/adc.o
     86 
     87 VPATH += src/core/delay
     88 OBJS  += $(OBJ_PATH)/delay.o
     89 
     90 VPATH += src/core/debug
     91 OBJS  += $(OBJ_PATH)/debug.o
     92 
     93 VPATH += src/core/eeprom
     94 OBJS  += $(OBJ_PATH)/eeprom.o
     95 
     96 VPATH += src/core/fifo
     97 OBJS  += $(OBJ_PATH)/fifo.o
     98 
     99 VPATH += src/core/gpio
    100 OBJS  += $(OBJ_PATH)/gpio.o
    101 
    102 VPATH += src/core/i2c
    103 OBJS  += $(OBJ_PATH)/i2c.o
    104 
    105 VPATH += src/core/iap
    106 OBJS  += $(OBJ_PATH)/iap.o
    107 
    108 VPATH += src/core/libc
    109 OBJS  += $(OBJ_PATH)/stdio.o 
    110 OBJS  += $(OBJ_PATH)/string.o
    111 
    112 VPATH += src/core/pmu
    113 OBJS  += $(OBJ_PATH)/pmu.o
    114 
    115 VPATH += src/core/ssp0
    116 OBJS  += $(OBJ_PATH)/ssp0.o
    117 
    118 VPATH += src/core/ssp1
    119 OBJS  += $(OBJ_PATH)/ssp1.o
    120 
    121 VPATH += src/core/timer16
    122 OBJS  += $(OBJ_PATH)/timer16.o
    123 
    124 VPATH += src/core/timer32
    125 OBJS  += $(OBJ_PATH)/timer32.o
    126 
    127 VPATH += src/core/uart
    128 OBJS  += $(OBJ_PATH)/uart.o 
    129 OBJS  += $(OBJ_PATH)/uart_buf.o
    130 
    131 VPATH += src/core/usb
    132 OBJS  += $(OBJ_PATH)/descriptors.o 
    133 OBJS  += $(OBJ_PATH)/usb_cdc.o 
    134 OBJS  += $(OBJ_PATH)/usb_custom_class.o
    135 OBJS  += $(OBJ_PATH)/usb_hid.o 
    136 OBJS  += $(OBJ_PATH)/usb_msc.o 
    137 OBJS  += $(OBJ_PATH)/usbd.o
    138 
    139 VPATH += src/drivers
    140 OBJS  += $(OBJ_PATH)/timespan.o
    141 
    142 VPATH += src/drivers/displays
    143 OBJS  += $(OBJ_PATH)/smallfonts.o
    144 
    145 VPATH += src/drivers/displays/bitmap/ssd1306
    146 OBJS  += $(OBJ_PATH)/ssd1306_i2c.o
    147 
    148 VPATH += src/drivers/displays/graphic 
    149 OBJS  += $(OBJ_PATH)/aafonts.o 
    150 OBJS  += $(OBJ_PATH)/colors.o 
    151 OBJS  += $(OBJ_PATH)/drawing.o 
    152 OBJS  += $(OBJ_PATH)/fonts.o 
    153 OBJS  += $(OBJ_PATH)/theme.o
    154 
    155 VPATH += src/drivers/displays/graphic/aafonts/aa2 
    156 OBJS  += $(OBJ_PATH)/DejaVuSansCondensed14_AA2.o 
    157 OBJS  += $(OBJ_PATH)/DejaVuSansCondensedBold14_AA2.o 
    158 OBJS  += $(OBJ_PATH)/DejaVuSansMono10_AA2.o 
    159 OBJS  += $(OBJ_PATH)/DejaVuSansMono13_AA2.o 
    160 OBJS  += $(OBJ_PATH)/DejaVuSansMono14_AA2.o 
    161 OBJS  += $(OBJ_PATH)/FontCalibri18_AA2.o 
    162 OBJS  += $(OBJ_PATH)/FontCalibriBold18_AA2.o 
    163 OBJS  += $(OBJ_PATH)/FontCalibriItalic18_AA2.o 
    164 OBJS  += $(OBJ_PATH)/FontFranklinGothicBold99_Numbers_AA2.o
    165 
    166 VPATH += src/drivers/displays/graphic/aafonts/aa4 
    167 OBJS  += $(OBJ_PATH)/FontCalibri18_AA4.o
    168 
    169 VPATH += src/drivers/displays/graphic/fonts 
    170 OBJS  += $(OBJ_PATH)/dejavusans9.o 
    171 OBJS  += $(OBJ_PATH)/dejavusansbold9.o 
    172 OBJS  += $(OBJ_PATH)/dejavusanscondensed9.o 
    173 OBJS  += $(OBJ_PATH)/dejavusansmono8.o 
    174 OBJS  += $(OBJ_PATH)/dejavusansmonobold8.o 
    175 OBJS  += $(OBJ_PATH)/veramono9.o 
    176 OBJS  += $(OBJ_PATH)/veramono11.o 
    177 OBJS  += $(OBJ_PATH)/veramonobold9.o 
    178 OBJS  += $(OBJ_PATH)/veramonobold11.o 
    179 OBJS  += $(OBJ_PATH)/verdana9.o 
    180 OBJS  += $(OBJ_PATH)/verdana14.o 
    181 OBJS  += $(OBJ_PATH)/verdanabold14.o
    182 
    183 VPATH += src/drivers/displays/graphic/hw
    184 OBJS  += $(OBJ_PATH)/hx8340b.o 
    185 # OBJS  += $(OBJ_PATH)/hx8347g.o
    186 
    187 VPATH += src/drivers/displays/segment/ht16k33
    188 OBJS  += $(OBJ_PATH)/ht16k33.o
    189 
    190 VPATH += src/drivers/filters/iir
    191 OBJS  += $(OBJ_PATH)/iir_f.o
    192 OBJS  += $(OBJ_PATH)/iir_i.o
    193 OBJS  += $(OBJ_PATH)/iir_u16.o
    194 
    195 VPATH += src/drivers/filters/ma
    196 OBJS  += $(OBJ_PATH)/sma_f.o 
    197 OBJS  += $(OBJ_PATH)/sma_i.o 
    198 OBJS  += $(OBJ_PATH)/sma_u16.o
    199 OBJS  += $(OBJ_PATH)/wma_f.o 
    200 OBJS  += $(OBJ_PATH)/wma_i.o 
    201 OBJS  += $(OBJ_PATH)/wma_u16.o
    202 
    203 VPATH += src/drivers/motor/stepper
    204 OBJS  += $(OBJ_PATH)/stepper.o
    205 
    206 VPATH += src/drivers/pwm/pca9685
    207 OBJS  += $(OBJ_PATH)/pca9685.o
    208 
    209 VPATH += src/drivers/rf/802.15.4/chibi
    210 OBJS  += $(OBJ_PATH)/chb.o 
    211 OBJS  += $(OBJ_PATH)/chb_buf.o 
    212 OBJS  += $(OBJ_PATH)/chb_drvr.o 
    213 OBJS  += $(OBJ_PATH)/chb_eeprom.o 
    214 OBJS  += $(OBJ_PATH)/chb_spi.o
    215 OBJS  += $(OBJ_PATH)/messages.o
    216 
    217 VPATH += src/drivers/rf/nfc/pn532
    218 OBJS  += $(OBJ_PATH)/pn532.o 
    219 OBJS  += $(OBJ_PATH)/pn532_bus_i2c.o 
    220 OBJS  += $(OBJ_PATH)/pn532_bus_uart.o
    221 
    222 VPATH += src/drivers/rf/nfc/pn532/helpers
    223 OBJS  += $(OBJ_PATH)/pn532_config.o 
    224 OBJS  += $(OBJ_PATH)/pn532_gpio.o 
    225 OBJS  += $(OBJ_PATH)/pn532_mifare_classic.o 
    226 OBJS  += $(OBJ_PATH)/pn532_mifare_ultralight.o 
    227 OBJS  += $(OBJ_PATH)/pn532_ndef.o 
    228 OBJS  += $(OBJ_PATH)/pn532_ndef_cards.o 
    229 
    230 VPATH += src/drivers/rf/wifi/cc3000
    231 OBJS  += $(OBJ_PATH)/spi.o 
    232 OBJS  += $(OBJ_PATH)/wifi.o 
    233 
    234 VPATH += src/drivers/rf/wifi/cc3000/hostdriver
    235 OBJS  += $(OBJ_PATH)/cc3000_common.o 
    236 OBJS  += $(OBJ_PATH)/evnt_handler.o 
    237 OBJS  += $(OBJ_PATH)/hci.o 
    238 OBJS  += $(OBJ_PATH)/netapp.o 
    239 OBJS  += $(OBJ_PATH)/nvmem.o 
    240 OBJS  += $(OBJ_PATH)/security.o 
    241 OBJS  += $(OBJ_PATH)/socket.o 
    242 OBJS  += $(OBJ_PATH)/wlan.o 
    243 
    244 VPATH += src/drivers/rf/nfc/pn532/mem_allocator
    245 OBJS  += $(OBJ_PATH)/bget.o 
    246 OBJS  += $(OBJ_PATH)/pn532_mem.o 
    247 
    248 VPATH += src/drivers/rtc
    249 OBJS  += $(OBJ_PATH)/rtc.o
    250 
    251 VPATH += src/drivers/rtc/pcf2129
    252 OBJS  += $(OBJ_PATH)/pcf2129.o
    253 
    254 VPATH += src/drivers/sensors
    255 OBJS  += $(OBJ_PATH)/sensors.o
    256 OBJS  += $(OBJ_PATH)/sensorpoll.o
    257 
    258 VPATH += src/drivers/sensors/accelerometers
    259 OBJS  += $(OBJ_PATH)/accelerometers.o
    260 OBJS  += $(OBJ_PATH)/adxl345.o
    261 OBJS  += $(OBJ_PATH)/lis3dh.o
    262 OBJS  += $(OBJ_PATH)/lsm303accel.o
    263 
    264 VPATH += src/drivers/sensors/gyroscopes
    265 OBJS  += $(OBJ_PATH)/l3gd20.o
    266 
    267 VPATH += src/drivers/sensors/light
    268 OBJS  += $(OBJ_PATH)/tsl2561.o
    269 
    270 VPATH += src/drivers/sensors/magnetometers
    271 OBJS  += $(OBJ_PATH)/magnetometers.o
    272 OBJS  += $(OBJ_PATH)/lsm303mag.o
    273 
    274 VPATH += src/drivers/sensors/pressure
    275 OBJS  += $(OBJ_PATH)/pressure.o
    276 OBJS  += $(OBJ_PATH)/bmp085.o
    277 OBJS  += $(OBJ_PATH)/mpl115a2.o
    278 
    279 VPATH += src/drivers/sensors/temperature
    280 OBJS  += $(OBJ_PATH)/lm75b.o
    281 
    282 VPATH += src/drivers/storage
    283 OBJS  += $(OBJ_PATH)/logger.o 
    284 
    285 VPATH += src/drivers/storage/fatfs
    286 OBJS  += $(OBJ_PATH)/ff.o 
    287 OBJS  += $(OBJ_PATH)/mmc.o
    288 
    289 VPATH += src/localisation
    290 OBJS  += $(OBJ_PATH)/localisation.o
    291 
    292 VPATH += src/protocol
    293 OBJS  += $(OBJ_PATH)/protocol.o
    294 
    295 VPATH += src/protocol/commands
    296 OBJS  += $(OBJ_PATH)/protocol_cmd_led.o
    297 OBJS  += $(OBJ_PATH)/protocol_cmd_sysinfo.o
    298 
    299 ##########################################################################
    300 # Include paths
    301 ##########################################################################
    302 
    303 ROOT_PATH = src
    304 INCLUDE_PATHS = -I$(ROOT_PATH) -Icmsis
    305 
    306 ##########################################################################
    307 # GNU GCC compiler prefix
    308 ##########################################################################
    309 
    310 # Use the default toolchain (based on the PATH variable, etc.)
    311 CROSS_COMPILE ?= arm-none-eabi-
    312 
    313 # OR ... use a toolchain at a specific location
    314 # CROSS_COMPILE = C:/code_red/RedSuiteNXP_5.0.12_1048/redsuite/tools/bin/arm-none-eabi-
    315 # CROSS_COMPILE = C:/arm/gnu4.7.2012.q4/bin/arm-none-eabi-
    316 
    317 AS           = $(CROSS_COMPILE)gcc
    318 CC           = $(CROSS_COMPILE)gcc
    319 LD           = $(CROSS_COMPILE)gcc
    320 SIZE         = $(CROSS_COMPILE)size
    321 OBJCOPY      = $(CROSS_COMPILE)objcopy
    322 OBJDUMP      = $(CROSS_COMPILE)objdump
    323 OUTFILE      = $(BIN_PATH)/$(FILENAME)
    324 LPCRC       ?= tools/lpcrc/lpcrc
    325 REMOVE       = rm -f
    326 MOUNT_POINT ?= /media/CRP DISABLD
    327 
    328 ##########################################################################
    329 # Compiler settings, parameters and flags
    330 ##########################################################################
    331 
    332 # Compiler Options
    333 GCFLAGS  = -c 
    334 GCFLAGS += -std=gnu99 
    335 GCFLAGS += -g 
    336 GCFLAGS += -O$(OPTIMIZATION) 
    337 GCFLAGS += $(INCLUDE_PATHS) 
    338 GCFLAGS += -Wall
    339 GCFLAGS += -mthumb 
    340 GCFLAGS += -ffunction-sections 
    341 GCFLAGS += -fdata-sections 
    342 GCFLAGS += -fmessage-length=0 
    343 GCFLAGS += -fno-builtin 
    344 GCFLAGS += -mcpu=$(CORE) 
    345 GCFLAGS += -DTARGET=$(TARGET)
    346 GCFLAGS += -D$(BOARD)
    347 # CMSIS DSP Flags
    348 ifeq (lpc11u,$(TARGET))
    349   GCFLAGS += -DARM_MATH_CM0
    350 else
    351   GCFLAGS += -DARM_MATH_CM3
    352 endif
    353 # For use with the GCC ARM Embedded toolchain
    354 # GCFLAGS += --specs=nano.specs
    355 # For use with the LPCXpresso toolchain
    356 # GCFLAGS += -D__REDLIB__ -D__CODE_RED
    357 GCFLAGS += $(REFORM_LPC_OPTIONS)
    358 
    359 # Assembler Options
    360 ASFLAGS  = -c 
    361 ASFLAGS += -g 
    362 ASFLAGS += -O$(OPTIMIZATION) 
    363 ASFLAGS += $(INCLUDE_PATHS) 
    364 ASFLAGS += -Wall 
    365 ASFLAGS += -mthumb 
    366 ASFLAGS += -ffunction-sections 
    367 ASFLAGS += -fdata-sections 
    368 ASFLAGS += -fmessage-length=0 
    369 ASFLAGS += -mcpu=$(CORE) 
    370 ASFLAGS += -D__ASSEMBLY__ 
    371 ASFLAGS += -x assembler-with-cpp
    372 
    373 # Linker Options
    374 LDFLAGS  = -nostartfiles 
    375 LDFLAGS += -mcpu=$(CORE) 
    376 LDFLAGS += -mthumb 
    377 LDFLAGS += -O$(OPTIMIZATION) 
    378 LDFLAGS += -Wl,--gc-sections 
    379 LDFLAGS += -T $(LDSCRIPT)
    380 LDFLAGS += -Xlinker -Map=bin/firmware.map
    381 # CMSIS Libraries
    382 LDFLAGS += -L./cmsis/libs
    383 ifeq (lpc11u,$(TARGET))
    384   LDLIBS   = -larm_cortexM0l_math -lRTX_CM0
    385 else
    386   LDLIBS   = -larm_cortexM3l_math -lRTX_CM3
    387 endif
    388 # External Libraries
    389 LDLIBS   += -lm
    390 # The following libraries are required with the LPCXpresso toolchain
    391 # LDLIBS  += -lcr_c -lcr_eabihelpers
    392 
    393 OCFLAGS = --strip-unneeded
    394 
    395 ##########################################################################
    396 # Rules
    397 ##########################################################################
    398 
    399 all: firmware
    400 
    401 $(OBJ_PATH)/%.o : %.c
    402 	@mkdir -p $(dir $@)
    403 	-@echo "COMPILING $(@F)"
    404 	@$(CC) $(GCFLAGS) -o $@ $<
    405 
    406 $(OBJ_PATH)/%.o : %.s
    407 	@mkdir -p $(dir $@)
    408 	-@echo "ASSEMBLING $(@F)"
    409 	@$(AS) $(ASFLAGS) -o $@ $<
    410 
    411 firmware: $(OBJS) $(SYS_OBJS)
    412 	@mkdir -p $(BIN_PATH)
    413 	-@echo ""
    414 	-@echo "LINKING $(OUTFILE).elf ($(CORE) -O$(OPTIMIZATION) $(BOARD))"
    415 	@$(LD) $(LDFLAGS) -o $(OUTFILE).elf $(LDLIBS) $(OBJS) $(LDLIBS)
    416 	-@echo ""
    417 	@$(SIZE) $(OUTFILE).elf
    418 	-@echo ""
    419 	-@echo "Generating $(OUTFILE).hex"
    420 	@$(OBJCOPY) $(OCFLAGS) -O ihex $(OUTFILE).elf $(OUTFILE).hex
    421 	-@echo "Generating $(OUTFILE).bin"
    422 	@$(OBJCOPY) $(OCFLAGS) -O binary $(OUTFILE).elf $(OUTFILE).bin
    423 	-@echo ""
    424 	@$(LPCRC) $(OUTFILE).bin
    425 
    426 flash: firmware
    427 	-@echo ""
    428 	-@echo "Flashing device ..."
    429 	-@[ -e "$(MOUNT_POINT)/firmware.bin" ] && dd if=bin/firmware.bin of="$(MOUNT_POINT)/firmware.bin" conv=nocreat,notrunc && umount "$(MOUNT_POINT)" || echo "Error, no device?!"
    430 
    431 lpcrc:
    432 	-@echo ""
    433 	-@echo "Building lpcrc (checksum tool) ..."
    434 	@make -C tools/lpcrc
    435   
    436 clean:
    437 	@$(REMOVE) $(OBJS) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex
    438 
    439 #########################################################################