summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-04-27 15:33:04 -0700
committerKeith Packard <keithp@keithp.com>2013-05-07 21:30:27 -0700
commit4a90eec4b8ee4a35711aa74c13b3f30d12c0fe08 (patch)
tree150ac4133334ba7a6a75bbdff2f74a1af82e8587
parentb131c5ac59bbd339a724892586023a43f97c7f90 (diff)
altos/stm: Create per-product flash loaders
Split the flash loader prototype into pieces so that each product can build a custom flash loader with very little code. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/Makefile7
-rw-r--r--src/megadongle-v0.1/flash-loader/Makefile7
-rw-r--r--src/megadongle-v0.1/flash-loader/ao_pins.h34
-rw-r--r--src/product/ao_flash_pins.h40
-rw-r--r--src/product/ao_flash_task.c (renamed from src/stm-flash/ao_stm_flash.c)31
-rw-r--r--src/product/ao_flash_task.h24
-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
-rw-r--r--src/telegps-v0.1/flash-loader/Makefile8
-rw-r--r--src/telegps-v0.1/flash-loader/ao_pins.h34
-rw-r--r--src/telemega-v0.1/flash-loader/Makefile7
-rw-r--r--src/telemega-v0.1/flash-loader/ao_pins.h34
-rw-r--r--src/telemega-v0.3/flash-loader/Makefile8
-rw-r--r--src/telemega-v0.3/flash-loader/ao_pins.h34
19 files changed, 434 insertions, 38 deletions
diff --git a/src/Makefile b/src/Makefile
index 90a74166..5ae61a00 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -29,7 +29,12 @@ AVRDIRS=\
telescience-v0.1 telescience-pwm telepyro-v0.1 micropeak
ARMDIRS=\
- telemega-v0.1 telemega-v0.3 megadongle-v0.1 stm-bringup stm-demo telelco-v0.1 \
+ telemega-v0.1 telemega-v0.1/flash-loader \
+ telemega-v0.3 telemega-v0.3/flash-loader \
+ megadongle-v0.1 megadongle-v0.1/flash-loader \
+ telegps-v0.1 telegps-v0.1/flash-loader \
+ stm-bringup stm-demo telelco-v0.1 \
+ telelco-v0.2 telelco-v0.2/flash-loader \
telescience-v0.2
ifneq ($(shell which sdcc),)
diff --git a/src/megadongle-v0.1/flash-loader/Makefile b/src/megadongle-v0.1/flash-loader/Makefile
new file mode 100644
index 00000000..adea5786
--- /dev/null
+++ b/src/megadongle-v0.1/flash-loader/Makefile
@@ -0,0 +1,7 @@
+#
+# AltOS flash loader build
+#
+
+TOPDIR=../..
+HARDWARE=megadongle-v0.1
+include $(TOPDIR)/stm/Makefile-flash.defs
diff --git a/src/megadongle-v0.1/flash-loader/ao_pins.h b/src/megadongle-v0.1/flash-loader/ao_pins.h
new file mode 100644
index 00000000..1af92f13
--- /dev/null
+++ b/src/megadongle-v0.1/flash-loader/ao_pins.h
@@ -0,0 +1,34 @@
+/*
+ * 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_PINS_H_
+#define _AO_PINS_H_
+
+/* External crystal at 8MHz */
+#define AO_HSE 8000000
+
+#include <ao_flash_stm_pins.h>
+
+/* Companion port cs_companion0 PD0 */
+
+#define AO_BOOT_PIN 1
+#define AO_BOOT_APPLICATION_GPIO stm_gpiod
+#define AO_BOOT_APPLICATION_PIN 0
+#define AO_BOOT_APPLICATION_VALUE 1
+#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP
+
+#endif /* _AO_PINS_H_ */
diff --git a/src/product/ao_flash_pins.h b/src/product/ao_flash_pins.h
new file mode 100644
index 00000000..b774df6d
--- /dev/null
+++ b/src/product/ao_flash_pins.h
@@ -0,0 +1,40 @@
+/*
+ * 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_PINS_H_
+#define _AO_FLASH_PINS_H_
+
+/* Common definitions for the USB flash loader */
+
+#define HAS_TASK_QUEUE 0
+
+#define HAS_USB 1
+#define USE_USB_STDIO 0
+#define HAS_BEEP 0
+#define HAS_TASK 0
+#define HAS_ECHO 0
+#define HAS_TICK 0
+
+#define PACKET_HAS_SLAVE 0
+
+#define HAS_TASK_INFO 0
+#define HAS_VERSION 0
+
+#define AO_BOOT_CHAIN 1
+#define AO_BOOT_PIN 1
+
+#endif /* _AO_FLASH_PINS_H_ */
diff --git a/src/stm-flash/ao_stm_flash.c b/src/product/ao_flash_task.c
index f8580735..fdc4d0aa 100644
--- a/src/stm-flash/ao_stm_flash.c
+++ b/src/product/ao_flash_task.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2011 Keith Packard <keithp@keithp.com>
+ * 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
@@ -18,12 +18,12 @@
#include "ao.h"
#include <ao_exti.h>
#include <ao_boot.h>
-#include <ao_flash_stm.h>
+#include <ao_flash.h>
+#include <ao_flash_task.h>
void
ao_panic(uint8_t reason)
{
- for (;;);
}
void
@@ -37,7 +37,7 @@ ao_put_string(__code char *s)
}
}
-void
+static void
ao_application(void)
{
ao_boot_reboot(AO_BOOT_APPLICATION_BASE);
@@ -69,7 +69,7 @@ ao_get_hex32(void)
return v;
}
-void
+static void
ao_block_erase(void)
{
uint32_t addr = ao_get_hex32();
@@ -78,7 +78,7 @@ ao_block_erase(void)
ao_flash_erase_page(p);
}
-void
+static void
ao_block_write(void)
{
uint32_t addr = ao_get_hex32();
@@ -98,7 +98,7 @@ ao_block_write(void)
ao_flash_page(p, u.data32);
}
-void
+static void
ao_block_read(void)
{
uint32_t addr = ao_get_hex32();
@@ -122,7 +122,7 @@ ao_show_version(void)
ao_put_string("\n");
}
-static void
+void
ao_flash_task(void) {
for (;;) {
ao_usb_flush();
@@ -135,18 +135,3 @@ ao_flash_task(void) {
}
}
}
-
-
-int
-main(void)
-{
- ao_clock_init();
-
-// ao_timer_init();
-// ao_dma_init();
-// ao_exti_init();
- ao_usb_init();
-
- ao_flash_task();
- return 0;
-}
diff --git a/src/product/ao_flash_task.h b/src/product/ao_flash_task.h
new file mode 100644
index 00000000..0a2fbb35
--- /dev/null
+++ b/src/product/ao_flash_task.h
@@ -0,0 +1,24 @@
+/*
+ * 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_TASK_H_
+#define _AO_FLASH_TASK_H_
+
+void
+ao_flash_task(void);
+
+#endif /* _AO_FLASH_TASK_H_ */
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_ */
diff --git a/src/telegps-v0.1/flash-loader/Makefile b/src/telegps-v0.1/flash-loader/Makefile
new file mode 100644
index 00000000..efc98d14
--- /dev/null
+++ b/src/telegps-v0.1/flash-loader/Makefile
@@ -0,0 +1,8 @@
+#
+# AltOS flash loader build
+#
+#
+
+TOPDIR=../..
+HARDWARE=telegps-v0.1
+include $(TOPDIR)/stm/Makefile-flash.defs
diff --git a/src/telegps-v0.1/flash-loader/ao_pins.h b/src/telegps-v0.1/flash-loader/ao_pins.h
new file mode 100644
index 00000000..564e84de
--- /dev/null
+++ b/src/telegps-v0.1/flash-loader/ao_pins.h
@@ -0,0 +1,34 @@
+/*
+ * 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_PINS_H_
+#define _AO_PINS_H_
+
+/* External crystal at 8MHz */
+#define AO_HSE 8000000
+
+#include <ao_flash_stm_pins.h>
+
+/* Telemetry TX pin PB6 */
+
+#define AO_BOOT_PIN 1
+#define AO_BOOT_APPLICATION_GPIO stm_gpiob
+#define AO_BOOT_APPLICATION_PIN 6
+#define AO_BOOT_APPLICATION_VALUE 1
+#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP
+
+#endif /* _AO_PINS_H_ */
diff --git a/src/telemega-v0.1/flash-loader/Makefile b/src/telemega-v0.1/flash-loader/Makefile
new file mode 100644
index 00000000..7aa8549f
--- /dev/null
+++ b/src/telemega-v0.1/flash-loader/Makefile
@@ -0,0 +1,7 @@
+#
+# AltOS flash loader build
+#
+
+TOPDIR=../..
+HARDWARE=telemega-v0.1
+include $(TOPDIR)/stm/Makefile-flash.defs
diff --git a/src/telemega-v0.1/flash-loader/ao_pins.h b/src/telemega-v0.1/flash-loader/ao_pins.h
new file mode 100644
index 00000000..1af92f13
--- /dev/null
+++ b/src/telemega-v0.1/flash-loader/ao_pins.h
@@ -0,0 +1,34 @@
+/*
+ * 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_PINS_H_
+#define _AO_PINS_H_
+
+/* External crystal at 8MHz */
+#define AO_HSE 8000000
+
+#include <ao_flash_stm_pins.h>
+
+/* Companion port cs_companion0 PD0 */
+
+#define AO_BOOT_PIN 1
+#define AO_BOOT_APPLICATION_GPIO stm_gpiod
+#define AO_BOOT_APPLICATION_PIN 0
+#define AO_BOOT_APPLICATION_VALUE 1
+#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP
+
+#endif /* _AO_PINS_H_ */
diff --git a/src/telemega-v0.3/flash-loader/Makefile b/src/telemega-v0.3/flash-loader/Makefile
new file mode 100644
index 00000000..8fda18cd
--- /dev/null
+++ b/src/telemega-v0.3/flash-loader/Makefile
@@ -0,0 +1,8 @@
+#
+# AltOS flash loader build
+#
+#
+
+TOPDIR=../..
+HARDWARE=telemega-v0.3
+include $(TOPDIR)/stm/Makefile-flash.defs
diff --git a/src/telemega-v0.3/flash-loader/ao_pins.h b/src/telemega-v0.3/flash-loader/ao_pins.h
new file mode 100644
index 00000000..1af92f13
--- /dev/null
+++ b/src/telemega-v0.3/flash-loader/ao_pins.h
@@ -0,0 +1,34 @@
+/*
+ * 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_PINS_H_
+#define _AO_PINS_H_
+
+/* External crystal at 8MHz */
+#define AO_HSE 8000000
+
+#include <ao_flash_stm_pins.h>
+
+/* Companion port cs_companion0 PD0 */
+
+#define AO_BOOT_PIN 1
+#define AO_BOOT_APPLICATION_GPIO stm_gpiod
+#define AO_BOOT_APPLICATION_PIN 0
+#define AO_BOOT_APPLICATION_VALUE 1
+#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP
+
+#endif /* _AO_PINS_H_ */