Skip to content

Commit

Permalink
Allow to build for Mbed LPC1768 using 'make build-mbed' and 'make upl…
Browse files Browse the repository at this point in the history
…oad-mbed'

Requires the official GCC ARM toolchain.
  • Loading branch information
jonnor committed Feb 7, 2014
1 parent 6035406 commit f847050
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -4,3 +4,6 @@
[submodule "thirdparty/node-serialport"]
path = thirdparty/node-serialport
url = ../node-serialport.git
[submodule "thirdparty/mbed"]
path = thirdparty/mbed
url = https://github.com/mbedmicro/mbed.git
14 changes: 13 additions & 1 deletion Makefile
Expand Up @@ -2,6 +2,8 @@
GRAPH=examples/blink.fbp
MODEL=uno
AVRMODEL=at90usb1287
MBED_GRAPH=examples/blink-mbed.fbp
UPLOAD_DIR=/mnt

# SERIALPORT=/dev/somecustom
# ARDUINO=/home/user/Arduino-1.0.5
Expand Down Expand Up @@ -67,9 +69,16 @@ build-avr: install
cd build/avr && $(AVROBJCOPY) -j .text -j .data -O ihex firmware.elf firmware.hex
$(AVRSIZE) -A build/avr/firmware.elf

build-mbed:
cd thirdparty/mbed && python2 workspace_tools/build.py -t GCC_ARM -m LPC1768
mkdir -p build/mbed
node microflo.js generate $(MBED_GRAPH) build/mbed/main.cpp mbed
cp Makefile.mbed build/mbed/Makefile
cd build/mbed && make ROOT_DIR=./../../

build: build-arduino build-avr

upload: build
upload: build-arduino
cd build/arduino && ino upload $(INOUPLOADOPTIONS) $(INOOPTIONS)

upload-dfu: build-avr
Expand All @@ -78,6 +87,9 @@ upload-dfu: build-avr
cd build/avr && sudo $(DFUPROGRAMMER) $(AVRMODEL) flash firmware.hex || sudo $(DFUPROGRAMMER) $(AVRMODEL) flash firmware.hex || sudo $(DFUPROGRAMMER) $(AVRMODEL) flash firmware.hex || sudo $(DFUPROGRAMMER) $(AVRMODEL) flash firmware.hex || sudo $(DFUPROGRAMMER) $(AVRMODEL) flash firmware.hex
sudo $(DFUPROGRAMMER) $(AVRMODEL) start

upload-mbed: build-mbed
cd build/mbed && sudo cp firmware.bin $(UPLOAD_DIR)

clean:
git clean -dfx --exclude=node_modules

Expand Down
51 changes: 51 additions & 0 deletions Makefile.mbed
@@ -0,0 +1,51 @@
# This file was automagically generated by mbed.org. For more information,
# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded

ROOT_DIR:=./
SOURCE_DIR:=$(ROOT_DIR)/microflo
MBED_DIR:=$(ROOT_DIR)/thirdparty/mbed/build/mbed

MBED_OBJDIR=$(MBED_DIR)/TARGET_LPC1768/TOOLCHAIN_GCC_ARM
GCC_BIN =
PROJECT = firmware
OBJECTS = ./main.o
SYS_OBJECTS = $(MBED_OBJDIR)/cmsis_nvic.o $(MBED_OBJDIR)/system_LPC17xx.o $(MBED_OBJDIR)/startup_LPC17xx.o
INCLUDE_PATHS = -I. -I$(SOURCE_DIR) -I$(MBED_DIR) -I$(MBED_DIR)/TARGET_LPC1768 -I$(MBED_OBJDIR)
LIBRARY_PATHS = -L$(MBED_OBJDIR)
LIBRARIES = -lmbed
LINKER_SCRIPT = ./$(MBED_OBJDIR)/LPC1768.ld

###############################################################################
AS = $(GCC_BIN)arm-none-eabi-as
CC = $(GCC_BIN)arm-none-eabi-gcc
CPP = $(GCC_BIN)arm-none-eabi-g++
LD = $(GCC_BIN)arm-none-eabi-gcc
OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy

CPU = -mcpu=cortex-m3 -mthumb
CC_FLAGS = $(CPU) -c -Os -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections
CC_SYMBOLS = -DTARGET_LPC1768 -DTARGET_M3 -DTARGET_NXP -DTARGET_LPC176X -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M3 -DARM_MATH_CM3

LD_FLAGS = -mcpu=cortex-m3 -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float
LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys

all: $(PROJECT).bin

clean:
rm -f $(PROJECT).bin $(PROJECT).elf $(OBJECTS)

.s.o:
$(AS) $(CPU) -o $@ $<

.c.o:
$(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $<

.cpp.o:
$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 $(INCLUDE_PATHS) -o $@ $<


$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
$(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS)

$(PROJECT).bin: $(PROJECT).elf
$(OBJCOPY) -O binary $< $@
19 changes: 1 addition & 18 deletions microflo/main.hpp
Expand Up @@ -21,22 +21,6 @@ void loadFromEEPROM(HostCommunication *controller) {
}
}
#else
const unsigned char graph[] = {
0x75,0x43,0x2f,0x46,0x6c,0x6f,0x30,0x31,
0xa,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0xf,0x1,0x0,0x0,0x0,0x0,0x0,0x0,
0xb,0x7,0x0,0x0,0x0,0x0,0x0,0x0,
0xb,0xb,0x0,0x0,0x0,0x0,0x0,0x0,
0xb,0x5,0x0,0x0,0x0,0x0,0x0,0x0,
0xb,0x34,0x0,0x0,0x0,0x0,0x0,0x0,
0xc,0x1,0x2,0x0,0x0,0x0,0x0,0x0,
0xc,0x2,0x3,0x0,0x0,0x0,0x0,0x0,
0xc,0x4,0x3,0x0,0x1,0x0,0x0,0x0,
0xd,0x1,0x0,0x7,0x2c,0x1,0x0,0x0,
0xe,0x0,0x0,0x0,0x0,0x0,0x0,0x0
};
#define MICROFLO_EMBED_GRAPH

void loadFromEEPROM(HostCommunication *controller) {
for (unsigned int i=0; i<sizeof(graph); i++) {
unsigned char c = graph[i];
Expand Down Expand Up @@ -79,17 +63,16 @@ void setup()

void loop()
{
// io.DigitalWrite(LED1, true);
transport.runTick();
network.runTick();
}

#ifndef ARDUINO
#ifndef TARGET_LPC1768
#include "microflo.hpp"
#include <stddef.h>
#include <stdlib.h>
#endif
#endif

#ifndef ARDUINO
void * operator new(size_t n)
Expand Down
1 change: 1 addition & 0 deletions thirdparty/mbed
Submodule mbed added at bbbd86

0 comments on commit f847050

Please sign in to comment.