summaryrefslogtreecommitdiff
path: root/src/stm
diff options
context:
space:
mode:
Diffstat (limited to 'src/stm')
-rw-r--r--src/stm/Makefile-flash.defs92
-rw-r--r--src/stm/altos-loader.ld31
-rw-r--r--src/stm/ao_arch.h4
-rw-r--r--src/stm/ao_flash.h (renamed from src/stm/ao_flash_stm.h)0
-rw-r--r--src/stm/ao_flash_loader_stm.c32
-rw-r--r--src/stm/ao_flash_stm.c2
-rw-r--r--src/stm/ao_flash_stm_pins.h43
7 files changed, 190 insertions, 14 deletions
diff --git a/src/stm/Makefile-flash.defs b/src/stm/Makefile-flash.defs
new file mode 100644
index 00000000..016bb7e7
--- /dev/null
+++ b/src/stm/Makefile-flash.defs
@@ -0,0 +1,92 @@
+vpath % $(TOPDIR)/stm:$(TOPDIR)/product:$(TOPDIR)/drivers:$(TOPDIR)/core:$(TOPDIR)/util:$(TOPDIR)
+vpath ao-make-product.5c $(TOPDIR)/util
+
+.SUFFIXES: .elf .ihx
+
+.elf.ihx:
+ objcopy -O ihex $*.elf $@
+
+CC=arm-none-eabi-gcc
+SAT=/opt/cortex
+SAT_CLIB=$(SAT)/lib/pdclib-cortex-m3.a
+SAT_CFLAGS=-I$(SAT)/include
+
+ifndef VERSION
+include $(TOPDIR)/Version
+endif
+
+AO_CFLAGS=-I. -I$(TOPDIR)/stm -I$(TOPDIR)/core -I$(TOPDIR)/drivers -I$(TOPDIR)/product -I$(TOPDIR)
+STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m3 -mthumb -ffreestanding -nostdlib $(AO_CFLAGS) $(SAT_CFLAGS)
+
+LDFLAGS=-L$(TOPDIR)/stm -Wl,-Taltos-loader.ld
+
+NICKLE=nickle
+
+V=0
+# The user has explicitly enabled quiet compilation.
+ifeq ($(V),0)
+quiet = @printf " $1 $2 $@\n"; $($1)
+endif
+# Otherwise, print the full command line.
+quiet ?= $($1)
+
+.c.o:
+ $(call quiet,CC) -c $(CFLAGS) -o $@ $<
+
+INC = \
+ ao.h \
+ ao_arch.h \
+ ao_arch_funcs.h \
+ ao_flash_pins.h \
+ ao_flash_stm_pins.h \
+ ao_flash_task.h \
+ ao_pins.h \
+ ao_product.h \
+ Makefile
+
+#
+# Common AltOS sources
+#
+SRC = \
+ ao_interrupt.c \
+ ao_romconfig.c \
+ ao_boot_chain.c \
+ ao_boot_pin.c \
+ ao_product.c \
+ ao_notask.c \
+ ao_timer.c \
+ ao_usb_stm.c \
+ ao_flash_stm.c \
+ ao_flash_task.c \
+ ao_flash_loader_stm.c
+
+OBJ=$(SRC:.c=.o)
+
+PRODUCT=AltosFlash-$(VERSION)
+PRODUCT_DEF=-DALTOS_FLASH
+IDPRODUCT=0x000a
+
+CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) -g -Os
+
+PROGNAME=altos-flash
+PROG=$(HARDWARE)-$(PROGNAME)-$(VERSION).elf
+
+$(PROG): Makefile $(OBJ) altos-loader.ld
+ $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(SAT_CLIB) -lgcc
+
+ao_product.h: ao-make-product.5c $(TOPDIR)/Version
+ $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
+
+$(OBJ): $(INC)
+
+all: $(PROG)
+
+distclean: clean
+
+clean:
+ rm -f *.o $(PROG)
+ rm -f ao_product.h
+
+install:
+
+uninstall:
diff --git a/src/stm/altos-loader.ld b/src/stm/altos-loader.ld
index 5e10e5ba..2be964f2 100644
--- a/src/stm/altos-loader.ld
+++ b/src/stm/altos-loader.ld
@@ -32,19 +32,16 @@ SECTIONS {
.text : {
__text_start__ = .;
*(.interrupt) /* Interrupt vectors */
- *(.romconfig*)
- *(.text) /* Executable code */
- . = ALIGN(4);
- *(.rodata*) /* Constants */
- . = ALIGN(4);
- } > rom
- .ARM.exidx : {
- . = ALIGN(4);
+ . = ORIGIN(rom) + 0x100;
+
+ ao_romconfig.o(.romconfig*)
+ ao_product.o(.romconfig*)
+ *(.text) /* Executable code */
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
- . = ALIGN(4);
+ *(.rodata*) /* Constants */
+ __text_end__ = .;
} > rom
- __text_end__ = .;
/* Boot data which must live at the start of ram so that
* the application and bootloader share the same addresses.
@@ -53,12 +50,20 @@ SECTIONS {
.boot (NOLOAD) : {
__boot_start__ = .;
*(.boot)
- . = ALIGN(4);
__boot_end__ = .;
} >ram
- /* Functions placed in RAM (required for flashing) */
- .textram : {
+ /* Functions placed in RAM (required for flashing)
+ *
+ * Align to 8 bytes as that's what the ARM likes text
+ * segment alignments to be, and if we don't, then
+ * we end up with a mismatch between the location in
+ * ROM and the desired location in RAM. I don't
+ * entirely understand this, but at least this appears
+ * to work...
+ */
+
+ .textram BLOCK(8): {
__data_start__ = .;
__text_ram_start__ = .;
*(.text.ram)
diff --git a/src/stm/ao_arch.h b/src/stm/ao_arch.h
index 757b5251..adc288c3 100644
--- a/src/stm/ao_arch.h
+++ b/src/stm/ao_arch.h
@@ -88,6 +88,10 @@ extern const uint32_t ao_radio_cal;
* For now, we're running at a weird frequency
*/
+#ifndef AO_HSE
+#error High speed frequency undefined
+#endif
+
#if AO_HSE
#define AO_PLLSRC AO_HSE
#else
diff --git a/src/stm/ao_flash_stm.h b/src/stm/ao_flash.h
index 09ca5ac1..09ca5ac1 100644
--- a/src/stm/ao_flash_stm.h
+++ b/src/stm/ao_flash.h
diff --git a/src/stm/ao_flash_loader_stm.c b/src/stm/ao_flash_loader_stm.c
new file mode 100644
index 00000000..2ab548cf
--- /dev/null
+++ b/src/stm/ao_flash_loader_stm.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2013 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "ao.h"
+#include <ao_exti.h>
+#include <ao_boot.h>
+#include <ao_flash_task.h>
+
+int
+main(void)
+{
+ ao_clock_init();
+
+ ao_usb_init();
+
+ ao_flash_task();
+ return 0;
+}
diff --git a/src/stm/ao_flash_stm.c b/src/stm/ao_flash_stm.c
index b4d47024..d7a85582 100644
--- a/src/stm/ao_flash_stm.c
+++ b/src/stm/ao_flash_stm.c
@@ -16,7 +16,7 @@
*/
#include <ao.h>
-#include <ao_flash_stm.h>
+#include <ao_flash.h>
static uint8_t
ao_flash_pecr_is_locked(void)
diff --git a/src/stm/ao_flash_stm_pins.h b/src/stm/ao_flash_stm_pins.h
new file mode 100644
index 00000000..d157a226
--- /dev/null
+++ b/src/stm/ao_flash_stm_pins.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2013 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#ifndef _AO_FLASH_STM_PINS_H_
+#define _AO_FLASH_STM_PINS_H_
+
+#include <ao_flash_pins.h>
+
+/* PLLVCO = 96MHz (so that USB will work) */
+#define AO_PLLMUL 12
+#define AO_RCC_CFGR_PLLMUL (STM_RCC_CFGR_PLLMUL_12)
+
+/* SYSCLK = 32MHz */
+#define AO_PLLDIV 3
+#define AO_RCC_CFGR_PLLDIV (STM_RCC_CFGR_PLLDIV_3)
+
+/* HCLK = 32MHZ (CPU clock) */
+#define AO_AHB_PRESCALER 1
+#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1
+
+/* Run APB1 at HCLK/1 */
+#define AO_APB1_PRESCALER 1
+#define AO_RCC_CFGR_PPRE1_DIV STM_RCC_CFGR_PPRE2_DIV_1
+
+/* Run APB2 at HCLK/1 */
+#define AO_APB2_PRESCALER 1
+#define AO_RCC_CFGR_PPRE2_DIV STM_RCC_CFGR_PPRE2_DIV_1
+
+#endif /* _AO_FLASH_STM_PINS_H_ */