summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
Diffstat (limited to 'tool')
-rw-r--r--tool/mbed/common.mk79
-rw-r--r--tool/mbed/gcc.mk80
-rw-r--r--tool/mbed/lpc-vector-checksum.c99
-rw-r--r--tool/mbed/mbed.mk99
4 files changed, 357 insertions, 0 deletions
diff --git a/tool/mbed/common.mk b/tool/mbed/common.mk
new file mode 100644
index 0000000000..93a927a3e8
--- /dev/null
+++ b/tool/mbed/common.mk
@@ -0,0 +1,79 @@
+OBJECTS += \
+ $(OBJDIR)/common/action.o \
+ $(OBJDIR)/common/action_tapping.o \
+ $(OBJDIR)/common/action_macro.o \
+ $(OBJDIR)/common/action_layer.o \
+ $(OBJDIR)/common/action_util.o \
+ $(OBJDIR)/common/host.o \
+ $(OBJDIR)/common/keymap.o \
+ $(OBJDIR)/common/keyboard.o \
+ $(OBJDIR)/common/util.o \
+ $(OBJDIR)/common/mbed/suspend.o \
+ $(OBJDIR)/common/mbed/timer.o \
+ $(OBJDIR)/common/mbed/xprintf.o \
+ $(OBJDIR)/common/mbed/bootloader.o \
+
+INCLUDE_PATHS += \
+ -I$(TMK_DIR)/common \
+ -I$(TMK_DIR)/protocol
+
+CC_FLAGS += -include $(CONFIG_H)
+
+
+
+# Option modules
+ifdef BOOTMAGIC_ENABLE
+ $(error Not Supported)
+ OBJECTS += $(OBJDIR)/common/bootmagic.o
+ OBJECTS += $(OBJDIR)/common/mbed/eeprom.o
+ OPT_DEFS += -DBOOTMAGIC_ENABLE
+endif
+
+ifdef MOUSEKEY_ENABLE
+ OBJECTS += $(OBJDIR)/common/mousekey.o
+ OPT_DEFS += -DMOUSEKEY_ENABLE
+ OPT_DEFS += -DMOUSE_ENABLE
+endif
+
+ifdef EXTRAKEY_ENABLE
+ $(error Not Supported)
+ OPT_DEFS += -DEXTRAKEY_ENABLE
+endif
+
+ifdef CONSOLE_ENABLE
+ $(error Not Supported)
+ OPT_DEFS += -DCONSOLE_ENABLE
+else
+ OPT_DEFS += -DNO_PRINT
+ OPT_DEFS += -DNO_DEBUG
+endif
+
+ifdef COMMAND_ENABLE
+ $(error Not Supported)
+ SRC += common/command.c
+ OPT_DEFS += -DCOMMAND_ENABLE
+endif
+
+ifdef NKRO_ENABLE
+ $(error Not Supported)
+ OPT_DEFS += -DNKRO_ENABLE
+endif
+
+ifdef SLEEP_LED_ENABLE
+ $(error Not Supported)
+ SRC += common/sleep_led.c
+ OPT_DEFS += -DSLEEP_LED_ENABLE
+ OPT_DEFS += -DNO_SUSPEND_POWER_DOWN
+endif
+
+ifdef BACKLIGHT_ENABLE
+ $(error Not Supported)
+ SRC += common/backlight.c
+ OPT_DEFS += -DBACKLIGHT_ENABLE
+endif
+
+ifdef KEYMAP_SECTION_ENABLE
+ $(error Not Supported)
+ OPT_DEFS += -DKEYMAP_SECTION_ENABLE
+ EXTRALDFLAGS = -Wl,-L$(TOP_DIR),-Tldscript_keymap_avr5.x
+endif
diff --git a/tool/mbed/gcc.mk b/tool/mbed/gcc.mk
new file mode 100644
index 0000000000..032f7c6cae
--- /dev/null
+++ b/tool/mbed/gcc.mk
@@ -0,0 +1,80 @@
+###############################################################################
+GCC_BIN =
+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
+OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump
+SIZE = $(GCC_BIN)arm-none-eabi-size
+CHKSUM = $(TMK_DIR)/tool/mbed/lpc-vector-checksum
+
+CPU = -mcpu=cortex-m0 -mthumb
+
+CC_FLAGS += $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections
+CC_FLAGS += -MMD -MP
+CC_SYMBOLS = -DTARGET_LPC11U35_401 -DTARGET_M0 -DTARGET_NXP -DTARGET_LPC11UXX -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M0 -DARM_MATH_CM0 -DMBED_BUILD_TIMESTAMP=1399108688.49 -D__MBED__=1
+
+LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs
+LD_FLAGS += -Wl,-Map=$(OBJDIR)/$(PROJECT).map,--cref
+LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
+
+ifeq ($(DEBUG), 1)
+ CC_FLAGS += -DDEBUG -O0
+else
+ CC_FLAGS += -DNDEBUG -Os
+endif
+
+all: $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).hex size
+
+clean:
+ rm -f $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).elf $(OBJDIR)/$(PROJECT).hex $(OBJDIR)/$(PROJECT).map $(OBJDIR)/$(PROJECT).lst $(OBJECTS) $(DEPS)
+ rm -fr $(OBJDIR)
+
+$(OBJDIR)/%.o: %.s
+ mkdir -p $(@D)
+ $(AS) $(CPU) -o $@ $<
+
+$(OBJDIR)/%.o: %.c
+ mkdir -p $(@D)
+ $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $<
+
+$(OBJDIR)/%.o: %.cpp
+ mkdir -p $(@D)
+ $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 $(INCLUDE_PATHS) -o $@ $<
+
+
+$(OBJDIR)/$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
+ $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)
+ @echo ""
+ @echo "*****"
+ @echo "***** You must modify vector checksum value in *.bin and *.hex files."
+ @echo "*****"
+ @echo ""
+
+$(OBJDIR)/$(PROJECT).bin: $(OBJDIR)/$(PROJECT).elf
+ @$(OBJCOPY) -O binary $< $@
+ @echo "Writing vector checksum value into $@ ..."
+ @$(CHKSUM) $@
+ @echo
+
+$(OBJDIR)/$(PROJECT).hex: $(OBJDIR)/$(PROJECT).elf
+ @$(OBJCOPY) -O ihex $< $@
+
+$(OBJDIR)/$(PROJECT).lst: $(OBJDIR)/$(PROJECT).elf
+ @$(OBJDUMP) -Sdh $< > $@
+
+lst: $(OBJDIR)/$(PROJECT).lst
+
+size:
+ $(SIZE) $(OBJDIR)/$(PROJECT).elf
+
+prog: $(OBJDIR)/$(PROJECT).bin
+ @echo "Program..."
+ifneq ($(shell mount | grep 'CRP DISABLD'),)
+ umount /dev/nxpisp >/dev/null 2>&1
+endif
+ dd if=$< of=/dev/nxpisp seek=4
+
+DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d)
+-include $(DEPS)
diff --git a/tool/mbed/lpc-vector-checksum.c b/tool/mbed/lpc-vector-checksum.c
new file mode 100644
index 0000000000..316a1253a0
--- /dev/null
+++ b/tool/mbed/lpc-vector-checksum.c
@@ -0,0 +1,99 @@
+/***************************************************************************
+* https://github.com/dhylands/projects/blob/master/lpc/lpc-vector-checksum/lpc-vector-checksum.c
+*
+* Copyright (c) 2012 by Dave Hylands
+* All Rights Reserved
+*
+* Permission is granted to any individual or institution to use, copy,
+* modify, or redistribute this file so long as it is not sold for profit,
+* and that this copyright notice is retained.
+*
+***************************************************************************
+*
+* This program calculates the vector checksum used in LPC17xx binary
+* images.
+*
+* Usage: lpc-vector-checksum file
+*
+***************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <errno.h>
+#include <string.h>
+
+/***************************************************************************/
+/**
+* update_vector_checksum
+*
+* The algorithim is to write the checksum such that the checksum of the
+* first 8 words is equal to zero.
+*
+* The LPC1768 uses little-endian, and this particular routine assumes
+* that it's running on a little-endian architecture.
+*/
+static int update_vector_checksum( const char *filename )
+{
+ uint32_t sum;
+ uint32_t header[8];
+ FILE *fs;
+ int i;
+
+ if (( fs = fopen( filename, "r+b" )) == NULL )
+ {
+ fprintf( stderr, "Unable to open '%s' for reading/writing (%d): %s\n",
+ filename, errno, strerror( errno ));
+ return 0;
+ }
+
+ if ( fread( header, sizeof( header ), 1, fs ) != 1 )
+ {
+ fprintf( stderr, "Failed to read header from '%s' (perhaps the file is too small?)",
+ filename );
+ fclose( fs );
+ return 0;
+ }
+
+ sum = 0;
+ for ( i = 0; i < 7; i++ )
+ {
+ sum += header[i];
+ }
+ printf( "sum = 0x%08x, value to write = 0x%08x\n", sum, -sum );
+
+ /* write back the checksum to location 7
+ * http://sigalrm.blogspot.jp/2011/10/cortex-m3-exception-vector-checksum.html
+ */
+ fseek(fs, 0x1c, SEEK_SET);
+ sum = -sum;
+ fwrite(&sum, 4, 1, fs);
+
+ fclose( fs );
+
+ return 1;
+}
+
+/***************************************************************************/
+/**
+* main
+*/
+int main( int argc, char **argv )
+{
+ int arg;
+
+ if ( argc < 2)
+ {
+ fprintf( stderr, "Usage: lpc-vector-checksum file ...\n" );
+ exit( 1 );
+ }
+
+ for ( arg = 1; arg < argc; arg++ )
+ {
+ update_vector_checksum( argv[ arg ]);
+ }
+
+ exit( 0 );
+ return 0;
+}
+
diff --git a/tool/mbed/mbed.mk b/tool/mbed/mbed.mk
new file mode 100644
index 0000000000..0f12ee2af3
--- /dev/null
+++ b/tool/mbed/mbed.mk
@@ -0,0 +1,99 @@
+OBJECTS += \
+ $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/startup_LPC11xx.o \
+ $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/cmsis_nvic.o \
+ $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/system_LPC11Uxx.o \
+ $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/port_api.o \
+ $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/spi_api.o \
+ $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/analogin_api.o \
+ $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.o \
+ $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_irq_api.o \
+ $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/serial_api.o \
+ $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/i2c_api.o \
+ $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pwmout_api.o \
+ $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/sleep.o \
+ $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.o \
+ $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/us_ticker.o \
+ $(OBJDIR)/libraries/mbed/common/board.o \
+ $(OBJDIR)/libraries/mbed/common/mbed_interface.o \
+ $(OBJDIR)/libraries/mbed/common/exit.o \
+ $(OBJDIR)/libraries/mbed/common/rtc_time.o \
+ $(OBJDIR)/libraries/mbed/common/us_ticker_api.o \
+ $(OBJDIR)/libraries/mbed/common/pinmap_common.o \
+ $(OBJDIR)/libraries/mbed/common/error.o \
+ $(OBJDIR)/libraries/mbed/common/gpio.o \
+ $(OBJDIR)/libraries/mbed/common/semihost_api.o \
+ $(OBJDIR)/libraries/mbed/common/wait_api.o \
+ $(OBJDIR)/libraries/mbed/common/RawSerial.o \
+ $(OBJDIR)/libraries/mbed/common/Ticker.o \
+ $(OBJDIR)/libraries/mbed/common/FilePath.o \
+ $(OBJDIR)/libraries/mbed/common/I2C.o \
+ $(OBJDIR)/libraries/mbed/common/FileBase.o \
+ $(OBJDIR)/libraries/mbed/common/retarget.o \
+ $(OBJDIR)/libraries/mbed/common/Serial.o \
+ $(OBJDIR)/libraries/mbed/common/Stream.o \
+ $(OBJDIR)/libraries/mbed/common/FileSystemLike.o \
+ $(OBJDIR)/libraries/mbed/common/CallChain.o \
+ $(OBJDIR)/libraries/mbed/common/InterruptManager.o \
+ $(OBJDIR)/libraries/mbed/common/SerialBase.o \
+ $(OBJDIR)/libraries/mbed/common/BusInOut.o \
+ $(OBJDIR)/libraries/mbed/common/SPISlave.o \
+ $(OBJDIR)/libraries/mbed/common/I2CSlave.o \
+ $(OBJDIR)/libraries/mbed/common/FunctionPointer.o \
+ $(OBJDIR)/libraries/mbed/common/Timer.o \
+ $(OBJDIR)/libraries/mbed/common/SPI.o \
+ $(OBJDIR)/libraries/mbed/common/Timeout.o \
+ $(OBJDIR)/libraries/mbed/common/Ethernet.o \
+ $(OBJDIR)/libraries/mbed/common/TimerEvent.o \
+ $(OBJDIR)/libraries/mbed/common/CAN.o \
+ $(OBJDIR)/libraries/mbed/common/BusOut.o \
+ $(OBJDIR)/libraries/mbed/common/FileLike.o \
+ $(OBJDIR)/libraries/mbed/common/BusIn.o \
+ $(OBJDIR)/libraries/mbed/common/InterruptIn.o \
+ $(OBJDIR)/libraries/mbed/common/LocalFileSystem.o \
+ $(OBJDIR)/libraries/USBDevice/USBHID/USBMouse.o \
+ $(OBJDIR)/libraries/USBDevice/USBHID/USBHID.o \
+ $(OBJDIR)/libraries/USBDevice/USBHID/USBMouseKeyboard.o \
+ $(OBJDIR)/libraries/USBDevice/USBHID/USBKeyboard.o \
+ $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_KL25Z.o \
+ $(OBJDIR)/libraries/USBDevice/USBDevice/USBDevice.o \
+ $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC17.o \
+ $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC40.o \
+ $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC11U.o \
+ $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_STM32F4.o \
+ $(OBJDIR)/libraries/USBDevice/USBAudio/USBAudio.o \
+ $(OBJDIR)/libraries/USBDevice/USBSerial/USBSerial.o \
+ $(OBJDIR)/libraries/USBDevice/USBSerial/USBCDC.o \
+ $(OBJDIR)/libraries/USBDevice/USBMSD/USBMSD.o \
+ $(OBJDIR)/libraries/USBDevice/USBMIDI/USBMIDI.o
+
+INCLUDE_PATHS += \
+ -I$(MBED_DIR)/libraries/mbed/targets \
+ -I$(MBED_DIR)/libraries/mbed/targets/hal \
+ -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP \
+ -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX \
+ -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_401 \
+ -I$(MBED_DIR)/libraries/mbed/targets/cmsis \
+ -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP \
+ -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX \
+ -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM \
+ -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_401 \
+ -I$(MBED_DIR)/libraries/mbed \
+ -I$(MBED_DIR)/libraries/mbed/hal \
+ -I$(MBED_DIR)/libraries/mbed/api \
+ -I$(MBED_DIR)/libraries/mbed/common \
+ -I$(MBED_DIR)/libraries/USBDevice \
+ -I$(MBED_DIR)/libraries/USBDevice/USBHID \
+ -I$(MBED_DIR)/libraries/USBDevice/USBDevice \
+ -I$(MBED_DIR)/libraries/USBDevice/USBAudio \
+ -I$(MBED_DIR)/libraries/USBDevice/USBSerial \
+ -I$(MBED_DIR)/libraries/USBDevice/USBMSD \
+ -I$(MBED_DIR)/libraries/USBDevice/USBMIDI
+
+OBJECTS += \
+ $(OBJDIR)/protocol/mbed/mbed_driver.o \
+ $(OBJDIR)/protocol/mbed/HIDKeyboard.o \
+
+INCLUDE_PATHS += \
+ -I$(TMK_DIR)/protocol/mbed
+
+LINKER_SCRIPT = $(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_401/LPC11U35.ld