From ae4d617f72ba934dc9e1bc394c87a2dd9fd70e64 Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Mon, 15 Dec 2014 15:04:22 +0100 Subject: [PATCH] Provide support for multiple applications in the same repository Single common Makefile for all existing and future apps without modifications Simple application addition Readme updated accordingly. --- .gitignore | 2 +- Makefile | 49 +++++++++++++++++++++++++++++++------------------ README | 50 +++++++++++++++++++++++++++++++------------------- 3 files changed, 63 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index 51660f5..3f3c65a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,10 +12,10 @@ *.o *.d *.bin +*.elf *.map */objs/* *.zip *.svg *.dump tags -mod_gpio diff --git a/Makefile b/Makefile index fea7b34..5cf8955 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ # Makefile for GPIO Demo Module -NAME = mod_gpio +TARGET_DIR = apps/$(NAME) + LPC = lpc1224 CPU = cortex-m0 ARCH = armv6-m @@ -11,41 +12,53 @@ FOPTS = -fno-builtin -ffunction-sections -fdata-sections -ffreestanding CFLAGS = -Wall -O2 -mthumb -mcpu=$(CPU) $(FOPTS) LINKOPTS = -static -nostartfiles -nostdlib \ -Wl,--gc-sections -Wl,--build-id=none \ - -Wl,-Map=lpc_map_$(LPC).map -Tlpc_link_$(LPC).ld - + -Wl,-Map=$(TARGET_DIR)/lpc_map_$(LPC).map -Tlpc_link_$(LPC).ld -.PHONY: all -all: $(NAME).bin -prog: CFLAGS += -DEEPROM_WRITE -prog: clean all +APPS = $(subst apps/,,$(wildcard apps/*)) +.PHONY: all $(APPS) +all: $(APPS) INCLUDES = include/ +TARGET_INCLUDES = $(TARGET_DIR)/ OBJDIR = objs -SRC = $(shell find . -name \*.c) +SRC = $(wildcard */*.c) OBJS = ${SRC:%.c=${OBJDIR}/%.o} +DEPS = ${OBJS:%.o=$(OBJDIR)/%.d} + +NAME_SRC = $(wildcard $(TARGET_DIR)/*.c) +NAME_OBJS = ${NAME_SRC:%.c=${OBJDIR}/%.o} +NAME_DEPS = ${NAME_OBJS:%.o=$(OBJDIR)/%.d} + +-include $(DEPS) $(NAME_DEPS) + +.SECONDARY: $(OBJS) $(NAME_OBJS) +.PRECIOUS: %.elf +%.elf: $(OBJS) $(NAME_OBJS) + @echo "Linking $(NAME) ..." + @$(CC) $(LINKOPTS) $(OBJS) $(NAME_OBJS) -o $@ -$(NAME).bin: $(NAME) +%.bin: %.elf @echo "Creating image : $@" @$(CROSS_COMPILE)objcopy -R .stack -R .bss -O binary $^ $@ @ls -l $@ @echo Done. -$(NAME): $(OBJS) - @echo "Linking ..." - @$(CC) $(CFLAGS) $(LINKOPTS) $(OBJS) -o $@ -I$(INCLUDES) - ${OBJDIR}/%.o: %.c @mkdir -p $(dir $@) @echo "-- compiling" $< - @$(CC) -MMD -MP -MF ${OBJDIR}/$*.d $(CFLAGS) $< -c -o $@ -I$(INCLUDES) + @$(CC) -MMD -MP -MF ${OBJDIR}/$*.d $(CFLAGS) $< -c -o $@ -I$(INCLUDES) -I$(TARGET_INCLUDES) + + +$(APPS): + @make --no-print-directory NAME=$@ apps/$@/$@.bin + +all_apps: $(APPS) clean: - find ${OBJDIR} -name "*.o" -exec rm {} \; - find ${OBJDIR} -name "*.d" -exec rm {} \; - rm -f *.map + rm -rf $(OBJDIR) mrproper: clean - rm -f $(NAME)* + rm -f apps/*/*.bin apps/*/*.elf apps/*/*.map diff --git a/README b/README index 5c0133b..211f1bd 100644 --- a/README +++ b/README @@ -4,44 +4,50 @@ Techno-Innov. It has support for the LPC1224 as used on this development module, and for the peripherals found on the development module (Led, eeprom and temperature sensor). +Support for various other cool stuff is added when we play with it. -By default, both uarts are configured to echo any received character. -The programm will send the identification found in the EEPROM once and -then send the temperature in an endless loop on UART1, while playing with -the status LED. +Example applications are created in the apps directory, with one +sub-directory for each application. These are (and must stay) independent. -More usefull stuff is up to you. +More usefull stuff is up to you. Creating an app is *very* simple. Copy +an example from apps/ to the name you want and simply change "NAME" in the +Makefile to the name of your new directory. Please, no spaces in the name ! ******************** BUID and FLASH Build has been tested using gcc, and only gcc, in the version provided by -the emdebian project, but any ARM gcc toolchain should do. +the emdebian project, and a few other binary versions available for +download on the Internet, but any ARM gcc toolchain should do. In order to get the emdebian ARM gcc cross-toolchain you should add this repository to your apt sources : deb http://www.emdebian.org/debian/ unstable main and then update and install package gcc-4.7-arm-linux-gnueabi -It may be required that you create a symlink in /usr/bin for the arm gcc - cd /usr/bin && ln -s arm-linux-gnueabi-gcc-4.7 arm-linux-gnueabi-gcc +It may be required that you update the alternatives for this compiler, with +a line like this one : + update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-4.7 60 There's no need for the related libc package here, the libc does not fit in our micro-controller memory. Instead have a look at the content of the lib/ directory, and add stuff there. Once done you should build using the provided makefile by running the -simple "make" command. - -To flash the binary (the one with .bin) to the LPC Flash you will need -our lpctool package (not yet packaged for Debian as of 2013-11-06) -available in our git repository : http://git.techno-innov.fr/lpctools +simple "make" command in the base directory, which will build all apps, or +run "make " to build a specific application. You can also run the +simple "make" command in the specific app subdirectory to compile this +application alone. + +To flash the binary (the one with .bin) to the LPC Flash you will need the +lpctool package, now packaged for Debian, starting with Jessie, or available +in our git repository : http://git.techno-innov.fr/lpctools Clone using : git clone http://gitclone.techno-innov.fr/lpctools Then build (make) and use :) Usual command lines : ./lpcprog -d /dev/ttyUSB0 -c id - ./lpcprog -d /dev/ttyUSB0 -c flash mod_gpio.bin + ./lpcprog -d /dev/ttyUSB0 -c flash app_name.bin See lpctools readme and lpcprog or isp help (-h) or manpages for more information. @@ -55,6 +61,7 @@ SUPPORTED FEATURES and INTERFACES - Interrupts - ROM based division routines - Utility functions to replace ctz and clz instructions (not present in Cortex M0) + - IAP ROM based functions (tested for user flash access only) - Bootstrap - vector table @@ -64,25 +71,31 @@ SUPPORTED FEATURES and INTERFACES - flash accelerator configuration - watchdog (stop) - clock / PLL config - - call of existing/used drivers configuration routines - systick - precise msleep and usleep functions (using systick) - counter / timers + - pio configuration - Simple C Library - memcpy and memset - strcpy, strncpy, strcmp, strncmp, strchr, strrchr, strlen, strnlen - snprintf, vsnprintf -- Interface drivers +- Integrated Interface drivers - UART (as UART or RS485) - I²C - - I²C EEPROM - - TMP101 I²C temperature sensor - ADC - GPIO - GPIO interrupts - SPI (SSP) + - PWM + +- External Device drivers + - I²C EEPROM + - TMP101 I²C temperature sensor + - DHT11 temperatur and Humidity sensor + - CC1101 Sub 1GHz RF Transceiver + - Status led ******************** @@ -94,7 +107,6 @@ TODO : - RTC Support - Comparator support - Watchdog support -- Flash IAP support - CRC engine support - Test UART IrDA mode -- 2.43.0