From f37e717c8a5b8d5aef2c7ff4ac2e853ed7a38d91 Mon Sep 17 00:00:00 2001 From: Perry Hung Date: Thu, 16 Sep 2010 21:46:36 -0400 Subject: Fix maple linker memory map for jtag target --- support/ld/maple/jtag.ld | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'support') diff --git a/support/ld/maple/jtag.ld b/support/ld/maple/jtag.ld index 8c5ff49..435e3f0 100644 --- a/support/ld/maple/jtag.ld +++ b/support/ld/maple/jtag.ld @@ -8,8 +8,8 @@ /* Define memory spaces. */ MEMORY { - ram (rwx) : ORIGIN = 0x20000C00, LENGTH = 17K - rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K + rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K } OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") -- cgit v1.2.3 From bdb85a454917a6e875c77ae12f9fd67961aebfae Mon Sep 17 00:00:00 2001 From: Perry Hung Date: Fri, 17 Sep 2010 01:48:52 -0400 Subject: Improve reset reliability on OS X. The USB reset scheme on OS X is unreliable. Adding a little bit of sleep seems to make it much more reliable. This will probably do until we get a chance to rewrite the USB stack and redo the whole auto-reset scheme... --- support/scripts/reset.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'support') diff --git a/support/scripts/reset.py b/support/scripts/reset.py index 9be5607..ad26d10 100755 --- a/support/scripts/reset.py +++ b/support/scripts/reset.py @@ -3,6 +3,7 @@ import serial import os import sys +import time from struct import pack def get_maple_device_path(file_prefix): @@ -68,14 +69,20 @@ try: # try to toggle DTR/RTS (old scheme) ser.setRTS(0) + time.sleep(0.01) ser.setDTR(0) + time.sleep(0.01) ser.setDTR(1) + time.sleep(0.01) ser.setDTR(0) # try magic number ser.setRTS(1) + time.sleep(0.01) ser.setDTR(1) + time.sleep(0.01) ser.setDTR(0) + time.sleep(0.01) ser.write("1EAF") # ok we're done here -- cgit v1.2.3 From 2e79aafb7081a5305ee875277d26734779ca6d2f Mon Sep 17 00:00:00 2001 From: Perry Hung Date: Fri, 17 Sep 2010 03:49:14 -0400 Subject: Enable USB auto-reset in a hard fault. Redirect thread-mode execution to a fail routine which throbs the LED to indicate a hard fault. Because the fail routine runs in thread mode with interrupts on, USB auto-reset should now work. Test by executing some bogus instruction (e.g. *(volatile int*)0xf34fdaa = 0;) and check that the auto-reset continues to work. --- Makefile | 9 ++++--- libmaple/exc.c | 63 --------------------------------------------- libmaple/rules.mk | 11 +++++--- libmaple/util.c | 51 ++++++++++++++++++++++-------------- libmaple/util.h | 1 + support/make/build-rules.mk | 7 +++-- 6 files changed, 49 insertions(+), 93 deletions(-) delete mode 100644 libmaple/exc.c (limited to 'support') diff --git a/Makefile b/Makefile index bc34f9e..4fd5ade 100644 --- a/Makefile +++ b/Makefile @@ -29,11 +29,12 @@ LIBMAPLE_PATH := $(SRCROOT)/libmaple SUPPORT_PATH := $(SRCROOT)/support # Useful variables -GLOBAL_CFLAGS := -Os -g -mcpu=cortex-m3 -mthumb -march=armv7-m -nostdlib \ - -ffunction-sections -fdata-sections -Wl,--gc-sections \ - -DBOARD_$(BOARD) -DMCU_$(MCU) +GLOBAL_CFLAGS := -Os -g -mcpu=cortex-m3 -mthumb -march=armv7-m -nostdlib \ + -ffunction-sections -fdata-sections -Wl,--gc-sections \ + -DBOARD_$(BOARD) -DMCU_$(MCU) GLOBAL_CXXFLAGS := -fno-rtti -fno-exceptions -Wall -DBOARD_$(BOARD) -DMCU_$(MCU) - +GLOBAL_ASFLAGS := -mcpu=cortex-m3 -march=armv7-m -mthumb -DBOARD_$(BOARD) \ + -DMCU_$(MCU) -x assembler-with-cpp LDDIR := $(SUPPORT_PATH)/ld LDFLAGS = -T$(LDDIR)/$(LDSCRIPT) -L$(LDDIR) \ diff --git a/libmaple/exc.c b/libmaple/exc.c deleted file mode 100644 index a5c67fa..0000000 --- a/libmaple/exc.c +++ /dev/null @@ -1,63 +0,0 @@ - -/* ***************************************************************************** - * The MIT License - * - * Copyright (c) 2010 Perry Hung. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * ****************************************************************************/ - -/** - * @brief libmaple exception handlers. If DEBUG_LEVEL > DEBUG_FAULT, then these - * exceptions will ASSERT fail and call into the default _fail() light - * blinking. - */ - -#include "util.h" - -void NMIException(void) { - ASSERT_FAULT(0); - while(1) - ; -} - -void HardFaultException(void) { - ASSERT_FAULT(0); - while(1) - ; -} - -void MemManageException(void) { - ASSERT_FAULT(0); - while(1) - ; -} - -void BusFaultException(void) { - ASSERT_FAULT(0); - while(1) - ; -} - -void UsageFaultException(void) { - ASSERT_FAULT(0); - while(1) - ; -} - diff --git a/libmaple/rules.mk b/libmaple/rules.mk index 8428277..cd50495 100644 --- a/libmaple/rules.mk +++ b/libmaple/rules.mk @@ -16,7 +16,6 @@ cSRCS_$(d) := systick.c \ timers.c \ adc.c \ syscalls.c \ - exc.c \ exti.c \ gpio.c \ nvic.c \ @@ -25,8 +24,8 @@ cSRCS_$(d) := systick.c \ rcc.c \ flash.c \ spi.c \ - fsmc.c \ - dac.c \ + fsmc.c \ + dac.c \ usb/usb.c \ usb/usb_callbacks.c \ usb/usb_hardware.c \ @@ -37,12 +36,16 @@ cSRCS_$(d) := systick.c \ usb/usb_lib/usb_mem.c \ usb/usb_lib/usb_regs.c +sSRCS_$(d) := exc.S + cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) +sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%) -OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) +OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o) DEPS_$(d) := $(OBJS_$(d):%.o=%.d) $(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d)) +$(OBJS_$(d)): TGT_ASFLAGS := TGT_BIN += $(OBJS_$(d)) diff --git a/libmaple/util.c b/libmaple/util.c index a747948..3325d2b 100644 --- a/libmaple/util.c +++ b/libmaple/util.c @@ -68,7 +68,7 @@ void _fail(const char* file, int line, const char* exp) { usart_putudec(ERROR_USART_NUM, line); usart_putc(ERROR_USART_NUM, '\n'); usart_putc(ERROR_USART_NUM, '\r'); - + /* Turn on the error LED */ gpio_set_mode(ERROR_LED_PORT, ERROR_LED_PIN, GPIO_MODE_OUTPUT_PP); @@ -77,24 +77,35 @@ void _fail(const char* file, int line, const char* exp) { nvic_irq_enable(NVIC_INT_USBLP); /* Error fade */ - while (1) { - if (CC == TOP_CNT) { - slope = -1; - } else if (CC == 0) { - slope = 1; - } - - if (i == TOP_CNT) { - CC += slope; - i = 0; - } - - if (i < CC) { - gpio_write_bit(ERROR_LED_PORT, ERROR_LED_PIN, 1); - } else { - gpio_write_bit(ERROR_LED_PORT, ERROR_LED_PIN, 0); - } - i++; - } + throb(); +} + +void throb(void) { + int32 slope = 1; + uint32 CC = 0x0000; + uint32 TOP_CNT = 0x0200; + uint32 i = 0; + + gpio_set_mode(ERROR_LED_PORT, ERROR_LED_PIN, GPIO_MODE_OUTPUT_PP); + /* Error fade */ + while (1) { + if (CC == TOP_CNT) { + slope = -1; + } else if (CC == 0) { + slope = 1; + } + + if (i == TOP_CNT) { + CC += slope; + i = 0; + } + + if (i < CC) { + gpio_write_bit(ERROR_LED_PORT, ERROR_LED_PIN, 1); + } else { + gpio_write_bit(ERROR_LED_PORT, ERROR_LED_PIN, 0); + } + i++; + } } diff --git a/libmaple/util.h b/libmaple/util.h index 63e305d..be5e430 100644 --- a/libmaple/util.h +++ b/libmaple/util.h @@ -66,6 +66,7 @@ extern "C"{ #endif void _fail(const char*, int, const char*); +void throb(void); #ifdef __cplusplus } // extern "C" diff --git a/support/make/build-rules.mk b/support/make/build-rules.mk index 3892af9..4dcf00f 100644 --- a/support/make/build-rules.mk +++ b/support/make/build-rules.mk @@ -3,7 +3,7 @@ CC := arm-none-eabi-gcc CXX := arm-none-eabi-g++ LD := arm-none-eabi-ld -v AR := arm-none-eabi-ar -AS := arm-none-eabi-as +AS := arm-none-eabi-gcc OBJCOPY := arm-none-eabi-objcopy DISAS := arm-none-eabi-objdump OBJDUMP := arm-none-eabi-objdump @@ -14,10 +14,10 @@ OPENOCD := openocd # Suppress annoying output unless V is set ifndef V SILENT_CC = @echo ' [CC] ' $(@:$(BUILD_PATH)/%.o=%.c); + SILENT_AS = @echo ' [AS] ' $(@:$(BUILD_PATH)/%.o=%.S); SILENT_CXX = @echo ' [CXX] ' $(@:$(BUILD_PATH)/%.o=%.cpp); SILENT_LD = @echo ' [LD] ' $(@F); SILENT_AR = @echo ' [AR] ' - SILENT_AS = @echo ' [AS] ' SILENT_OBJCOPY = @echo ' [OBJCOPY] ' $(@F); SILENT_DISAS = @echo ' [DISAS] ' $(@:$(BUILD_PATH)/%.bin=%).disas; SILENT_OBJDUMP = @echo ' [OBJDUMP] ' $(OBJDUMP); @@ -28,6 +28,7 @@ TGT_BIN := CFLAGS = $(GLOBAL_CFLAGS) $(TGT_CFLAGS) CXXFLAGS = $(GLOBAL_CXXFLAGS) $(TGT_CXXFLAGS) +ASFLAGS = $(GLOBAL_ASFLAGS) $(TGT_ASFLAGS) # General directory independent build rules, generate dependency information $(BUILD_PATH)/%.o: %.c @@ -36,3 +37,5 @@ $(BUILD_PATH)/%.o: %.c $(BUILD_PATH)/%.o: %.cpp $(SILENT_CXX) $(CXX) $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $< +$(BUILD_PATH)/%.o: %.S + $(SILENT_AS) $(AS) $(ASFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $< -- cgit v1.2.3