Skip to content

Commit

Permalink
STM32L1 support, rebased onto upstream generalizations branch.
Browse files Browse the repository at this point in the history
Working example again.
  • Loading branch information
karlp committed Nov 7, 2012
1 parent e4f8427 commit 4941286
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 286 deletions.
43 changes: 22 additions & 21 deletions examples/stm32/l1/Makefile.include
Expand Up @@ -25,27 +25,32 @@ LD = $(PREFIX)-gcc
OBJCOPY = $(PREFIX)-objcopy
OBJDUMP = $(PREFIX)-objdump
GDB = $(PREFIX)-gdb
# If you are copying this file to use in your own project,
# You will need to change this... (Leave unset to assume installed
# in the toolchain itself)
#OPENCM3_DIR ?= /opt/libopencm3/$(PREFIX)
OPENCM3_DIR ?= ../../../../..

ARCH_FLAGS = -mcpu=cortex-m3 -mthumb -msoft-float
CFLAGS += -g -Os -Wall -Wextra \

TOOLCHAIN_DIR ?= ../../../../..
ifeq ($(wildcard ../../../../../lib/libopencm3_stm32l1.a),)
ifneq ($(strip $(shell which $(CC))),)
TOOLCHAIN_DIR := $(shell dirname `which $(CC)`)/../$(PREFIX)
endif
else
ifeq ($(V),1)
$(info We seem to be building the example in the source directory. Using local library!)
endif
endif

$(info GAHHHH toolchain: $(TOOLCHAIN_DIR))

ARCH_FLAGS = -mthumb -mcpu=cortex-m3 -msoft-float
CFLAGS += -Os -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include \
-fno-common $(ARCH_FLAGS) -MD -DSTM32L1
LDSCRIPT ?= $(BINARY).ld
LDFLAGS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group \
LDFLAGS += --static -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group \
-L$(TOOLCHAIN_DIR)/lib \
-T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections \
$(ARCH_FLAGS) -mfix-cortex-m3-ldrd

ifneq ($(OPENCM3_DIR),)
CFLAGS += -I$(OPENCM3_DIR)/include
LDFLAGS += -L$(OPENCM3_DIR)/lib -L$(OPENCM3_DIR)/lib/stm32/l1
SCRIPT_DIR = $(OPENCM3_DIR)/share
else
SCRIPT_DIR = $(shell dirname $(shell readlink -f $(shell which $(PREFIX)-gcc)))/../$(PREFIX)/share
endif
CFLAGS += -I$(TOOLCHAIN_DIR)/include
LDFLAGS += -L$(TOOLCHAIN_DIR)/lib -L$(TOOLCHAIN_DIR)/lib/stm32/l1
SCRIPT_DIR = $(TOOLCHAIN_DIR)/share

OBJS += $(BINARY).o

Expand Down Expand Up @@ -95,11 +100,7 @@ flash: $(BINARY).flash
@#printf " OBJDUMP $(*).list\n"
$(Q)$(OBJDUMP) -S $(*).elf > $(*).list

ifeq ($(OPENCM3_DIR),)
%.elf: $(OBJS) $(LDSCRIPT)
else
%.elf: $(OBJS) $(LDSCRIPT) $(OPENCM3_DIR)/lib/stm32/l1/libopencm3_stm32l1.a
endif
%.elf: $(OBJS) $(LDSCRIPT) $(TOOLCHAIN_DIR)/lib/libopencm3_stm32l1.a
@#printf " LD $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(LD) -o $(*).elf $(OBJS) -lopencm3_stm32l1 $(LDFLAGS)

Expand Down
2 changes: 1 addition & 1 deletion examples/stm32/l1/stm32l-discovery/miniblink/Makefile
Expand Up @@ -19,7 +19,7 @@

BINARY = miniblink

LDSCRIPT = ../stm32l15xxB.ld
LDSCRIPT = ../../../../../lib/stm32/l1/stm32l15xxb.ld

include ../../Makefile.include

49 changes: 49 additions & 0 deletions include/libopencm3/stm32/l1/irq.yaml
@@ -0,0 +1,49 @@
includeguard: LIBOPENCM3_STM32_L1_NVIC_H
partname_humanreadable: STM32 L1 series
partname_doxygen: STM32L1
irqs:
- wwdg
- pvd
- tamper
- rtc
- flash
- rcc
- exti0
- exti1
- exti2
- exti3
- exti4
- dma1_channel1
- dma1_channel2
- dma1_channel3
- dma1_channel4
- dma1_channel5
- dma1_channel6
- dma1_channel7
- adc1
- usb_hp
- usb_lp
- dac
- comp
- exti9_5
- lcd
- tim9
- tim10
- tim11
- tim2
- tim3
- tim4
- i2c1_ev
- i2c1_er
- i2c2_ev
- i2c2_er
- spi1
- spi2
- usart1
- usart2
- usart3
- exti15_10
- rtc_alarm
- usb_wakeup
- tim6
- tim7
30 changes: 4 additions & 26 deletions lib/stm32/l1/Makefile
Expand Up @@ -25,34 +25,12 @@ CC = $(PREFIX)-gcc
AR = $(PREFIX)-ar
CFLAGS = -Os -g -Wall -Wextra -I../../../include -fno-common \
-mcpu=cortex-m3 -mthumb -Wstrict-prototypes \
-ffunction-sections -fdata-sections -MD -DSTM32L1
-ffunction-sections -fdata-sections -MD -DSTM32F1
# ARFLAGS = rcsv
ARFLAGS = rcs
OBJS = vector.o desig.o crc.o gpio.o rcc.o
OBJS = rcc.o gpio.o desig.o crc.o

VPATH += ../../usb:../
VPATH += ../../usb:../:../../cm3

# Be silent per default, but 'make V=1' will show all compiler calls.
ifneq ($(V),1)
Q := @
endif

all: $(LIBNAME).a

$(LIBNAME).a: $(OBJS)
@printf " AR $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(AR) $(ARFLAGS) $@ $^

%.o: %.c
@printf " CC $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(CC) $(CFLAGS) -o $@ -c $<

clean:
@printf " CLEAN lib/stm32/f1\n"
$(Q)rm -f *.o *.d
$(Q)rm -f $(LIBNAME).a

.PHONY: clean

-include $(OBJS:.o=.d)
include ../../Makefile.include

19 changes: 9 additions & 10 deletions lib/stm32/l1/libopencm3_stm32l1.ld
Expand Up @@ -30,21 +30,18 @@ ENTRY(reset_handler)
/* Define sections. */
SECTIONS
{
. = ORIGIN(rom);

.text : {
*(.vectors) /* Vector table */
*(.text*) /* Program code */
. = ALIGN(4);
*(.rodata*) /* Read-only data */
. = ALIGN(4);
_etext = .;
} >rom

/*
* Another section used by C++ stuff, appears when using newlib with
* 64bit (long long) printf support
*/
* Another section used by C++ stuff, appears when using newlib with
* 64bit (long long) printf support
*/
.ARM.extab : {
*(.ARM.extab*)
} >rom
Expand All @@ -54,21 +51,23 @@ SECTIONS
__exidx_end = .;
} >rom

. = ORIGIN(ram);
. = ALIGN(4);
_etext = .;

.data : AT (__exidx_end) {
.data : {
_data = .;
*(.data*) /* Read-write initialized data */
. = ALIGN(4);
_edata = .;
} >ram
} >ram AT >rom
_data_loadaddr = LOADADDR(.data);

.bss : {
*(.bss*) /* Read-write zero initialized data */
*(COMMON)
. = ALIGN(4);
_ebss = .;
} >ram AT >rom
} >ram

/*
* The .eh_frame section appears to be used for C++ exception handling.
Expand Down
File renamed without changes.

0 comments on commit 4941286

Please sign in to comment.