altos/stm: Create per-product flash loaders
authorKeith Packard <keithp@keithp.com>
Sat, 27 Apr 2013 22:33:04 +0000 (15:33 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 8 May 2013 04:30:27 +0000 (21:30 -0700)
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>
21 files changed:
src/Makefile
src/megadongle-v0.1/flash-loader/Makefile [new file with mode: 0644]
src/megadongle-v0.1/flash-loader/ao_pins.h [new file with mode: 0644]
src/product/ao_flash_pins.h [new file with mode: 0644]
src/product/ao_flash_task.c [new file with mode: 0644]
src/product/ao_flash_task.h [new file with mode: 0644]
src/stm-flash/ao_stm_flash.c [deleted file]
src/stm/Makefile-flash.defs [new file with mode: 0644]
src/stm/altos-loader.ld
src/stm/ao_arch.h
src/stm/ao_flash.h [new file with mode: 0644]
src/stm/ao_flash_loader_stm.c [new file with mode: 0644]
src/stm/ao_flash_stm.c
src/stm/ao_flash_stm.h [deleted file]
src/stm/ao_flash_stm_pins.h [new file with mode: 0644]
src/telegps-v0.1/flash-loader/Makefile [new file with mode: 0644]
src/telegps-v0.1/flash-loader/ao_pins.h [new file with mode: 0644]
src/telemega-v0.1/flash-loader/Makefile [new file with mode: 0644]
src/telemega-v0.1/flash-loader/ao_pins.h [new file with mode: 0644]
src/telemega-v0.3/flash-loader/Makefile [new file with mode: 0644]
src/telemega-v0.3/flash-loader/ao_pins.h [new file with mode: 0644]

index 90a74166d8a15b62f88e3f118036c802598b4469..5ae61a007f7778f94d971ffc4f85df9405e2899f 100644 (file)
@@ -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 (file)
index 0000000..adea578
--- /dev/null
@@ -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 (file)
index 0000000..1af92f1
--- /dev/null
@@ -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 (file)
index 0000000..b774df6
--- /dev/null
@@ -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/product/ao_flash_task.c b/src/product/ao_flash_task.c
new file mode 100644 (file)
index 0000000..fdc4d0a
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * 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.h>
+#include <ao_flash_task.h>
+
+void
+ao_panic(uint8_t reason)
+{
+}
+
+void
+ao_put_string(__code char *s)
+{
+       char    c;
+       while ((c = *s++)) {
+               if (c == '\n')
+                       ao_usb_putchar('\r');
+               ao_usb_putchar(c);
+       }
+}
+
+static void
+ao_application(void)
+{
+       ao_boot_reboot(AO_BOOT_APPLICATION_BASE);
+}
+
+static uint32_t
+ao_get_hex32(void)
+{
+       int8_t  n;
+       uint32_t v = 0;
+
+       for (;;) {
+               n = ao_usb_getchar();
+               if (n != ' ')
+                       break;
+       }
+       for(;;) {
+               if ('0' <= n && n <= '9')
+                       n = n - '0';
+               else if ('a' <= n && n <= 'f')
+                       n = n - ('a' - 10);
+               else if ('A' <= n && n <= 'F')
+                       n = n - ('A' - 10);
+               else
+                       break;
+               v = (v << 4) | n;
+               n = ao_usb_getchar();
+       }
+       return v;
+}
+
+static void
+ao_block_erase(void)
+{
+       uint32_t        addr = ao_get_hex32();
+       uint32_t        *p = (uint32_t *) addr;
+
+       ao_flash_erase_page(p);
+}
+
+static void
+ao_block_write(void)
+{
+       uint32_t        addr = ao_get_hex32();
+       uint32_t        *p = (uint32_t *) addr;
+       union {
+               uint8_t         data8[256];
+               uint32_t        data32[64];
+       } u;
+       uint16_t        i;
+
+       if (addr < (uint32_t) AO_BOOT_APPLICATION_BASE) {
+               ao_put_string("Invalid address\n");
+               return;
+       }
+       for (i = 0; i < 256; i++)
+               u.data8[i] = ao_usb_getchar();
+       ao_flash_page(p, u.data32);
+}
+
+static void
+ao_block_read(void)
+{
+       uint32_t        addr = ao_get_hex32();
+       uint8_t         *p = (uint8_t *) addr;
+       uint16_t        i;
+       uint8_t         c;
+
+       for (i = 0; i < 256; i++) {
+               c = *p++;
+               ao_usb_putchar(c);
+       }
+}
+
+static void
+ao_show_version(void)
+{
+       ao_put_string("altos-loader");
+       ao_put_string("\nmanufacturer     "); ao_put_string(ao_manufacturer);
+       ao_put_string("\nproduct          "); ao_put_string(ao_product);
+       ao_put_string("\nsoftware-version "); ao_put_string(ao_version);
+       ao_put_string("\n");
+}
+
+void
+ao_flash_task(void) {
+       for (;;) {
+               ao_usb_flush();
+               switch (ao_usb_getchar()) {
+               case 'v': ao_show_version(); break;
+               case 'a': ao_application(); break;
+               case 'X': ao_block_erase(); break;
+               case 'W': ao_block_write(); break;
+               case 'R': ao_block_read(); break;
+               }
+       }
+}
diff --git a/src/product/ao_flash_task.h b/src/product/ao_flash_task.h
new file mode 100644 (file)
index 0000000..0a2fbb3
--- /dev/null
@@ -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-flash/ao_stm_flash.c b/src/stm-flash/ao_stm_flash.c
deleted file mode 100644 (file)
index f858073..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright © 2011 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_stm.h>
-
-void
-ao_panic(uint8_t reason)
-{
-       for (;;);
-}
-
-void
-ao_put_string(__code char *s)
-{
-       char    c;
-       while ((c = *s++)) {
-               if (c == '\n')
-                       ao_usb_putchar('\r');
-               ao_usb_putchar(c);
-       }
-}
-
-void
-ao_application(void)
-{
-       ao_boot_reboot(AO_BOOT_APPLICATION_BASE);
-}
-
-static uint32_t
-ao_get_hex32(void)
-{
-       int8_t  n;
-       uint32_t v = 0;
-
-       for (;;) {
-               n = ao_usb_getchar();
-               if (n != ' ')
-                       break;
-       }
-       for(;;) {
-               if ('0' <= n && n <= '9')
-                       n = n - '0';
-               else if ('a' <= n && n <= 'f')
-                       n = n - ('a' - 10);
-               else if ('A' <= n && n <= 'F')
-                       n = n - ('A' - 10);
-               else
-                       break;
-               v = (v << 4) | n;
-               n = ao_usb_getchar();
-       }
-       return v;
-}
-
-void
-ao_block_erase(void)
-{
-       uint32_t        addr = ao_get_hex32();
-       uint32_t        *p = (uint32_t *) addr;
-
-       ao_flash_erase_page(p);
-}
-
-void
-ao_block_write(void)
-{
-       uint32_t        addr = ao_get_hex32();
-       uint32_t        *p = (uint32_t *) addr;
-       union {
-               uint8_t         data8[256];
-               uint32_t        data32[64];
-       } u;
-       uint16_t        i;
-
-       if (addr < (uint32_t) AO_BOOT_APPLICATION_BASE) {
-               ao_put_string("Invalid address\n");
-               return;
-       }
-       for (i = 0; i < 256; i++)
-               u.data8[i] = ao_usb_getchar();
-       ao_flash_page(p, u.data32);
-}
-
-void
-ao_block_read(void)
-{
-       uint32_t        addr = ao_get_hex32();
-       uint8_t         *p = (uint8_t *) addr;
-       uint16_t        i;
-       uint8_t         c;
-
-       for (i = 0; i < 256; i++) {
-               c = *p++;
-               ao_usb_putchar(c);
-       }
-}
-
-static void
-ao_show_version(void)
-{
-       ao_put_string("altos-loader");
-       ao_put_string("\nmanufacturer     "); ao_put_string(ao_manufacturer);
-       ao_put_string("\nproduct          "); ao_put_string(ao_product);
-       ao_put_string("\nsoftware-version "); ao_put_string(ao_version);
-       ao_put_string("\n");
-}
-
-static void
-ao_flash_task(void) {
-       for (;;) {
-               ao_usb_flush();
-               switch (ao_usb_getchar()) {
-               case 'v': ao_show_version(); break;
-               case 'a': ao_application(); break;
-               case 'X': ao_block_erase(); break;
-               case 'W': ao_block_write(); break;
-               case 'R': ao_block_read(); break;
-               }
-       }
-}
-
-
-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/stm/Makefile-flash.defs b/src/stm/Makefile-flash.defs
new file mode 100644 (file)
index 0000000..016bb7e
--- /dev/null
@@ -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:
index 5e10e5bade2b4c79f1dc9b404ed800f82e7d57f1..2be964f2a7bad6bc5598ac9a249085273ace66c5 100644 (file)
@@ -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)
index 757b5251db3e0bf38d43cd8b492a483d98216a49..adc288c31bd1efc5fa5f9380f05dcb299fabb575 100644 (file)
@@ -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.h b/src/stm/ao_flash.h
new file mode 100644 (file)
index 0000000..09ca5ac
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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_H_
+#define _AO_FLASH_STM_H_
+
+void
+ao_flash_erase_page(uint32_t *page);
+
+void
+ao_flash_page(uint32_t *page, uint32_t *src);
+
+#endif /* _AO_FLASH_STM_H_ */
diff --git a/src/stm/ao_flash_loader_stm.c b/src/stm/ao_flash_loader_stm.c
new file mode 100644 (file)
index 0000000..2ab548c
--- /dev/null
@@ -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;
+}
index b4d47024b0a1870a7cb8ca2ea2037cbcc240022d..d7a855827723cbee2ce3bc226e99860bca9ac74d 100644 (file)
@@ -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.h b/src/stm/ao_flash_stm.h
deleted file mode 100644 (file)
index 09ca5ac..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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_H_
-#define _AO_FLASH_STM_H_
-
-void
-ao_flash_erase_page(uint32_t *page);
-
-void
-ao_flash_page(uint32_t *page, uint32_t *src);
-
-#endif /* _AO_FLASH_STM_H_ */
diff --git a/src/stm/ao_flash_stm_pins.h b/src/stm/ao_flash_stm_pins.h
new file mode 100644 (file)
index 0000000..d157a22
--- /dev/null
@@ -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 (file)
index 0000000..efc98d1
--- /dev/null
@@ -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 (file)
index 0000000..564e84d
--- /dev/null
@@ -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 (file)
index 0000000..7aa8549
--- /dev/null
@@ -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 (file)
index 0000000..1af92f1
--- /dev/null
@@ -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 (file)
index 0000000..8fda18c
--- /dev/null
@@ -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 (file)
index 0000000..1af92f1
--- /dev/null
@@ -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_ */