From 2108da105ed9c915fc09d1251dc655bf11203d79 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 15 Sep 2019 17:05:17 -0700 Subject: [PATCH] altos: Move from newlib-nano to picolibc Use picolibc.ld, which involved some .ld file hacking, including: 1) Defining ao_boot RAM address in the .ld file and declaring it 'extern' 2) Changing how m0 interrupt vector got moved to ram 3) Using -Taltos.ld instead of -Wl,-Taltos.ld so picolibc.specs wouldn't add picolibc.ld 4) Placing romconfig vars in '.init.1' and '.init.2' sections instead of '.romconfig' 5) Place code needing to run out of RAM in section .srodata instead of .ramtext Signed-off-by: Keith Packard --- src/Makefile.defs | 9 ++- src/kernel/ao_product.c | 6 +- src/lpc/Makefile-flash.defs | 2 +- src/lpc/Makefile-lpc.defs | 4 +- src/lpc/Makefile.defs | 2 +- src/lpc/altos-loader.ld | 67 ++----------------- src/lpc/altos.ld | 77 ++-------------------- src/lpc/ao_arch.h | 3 +- src/lpc/ao_boot_chain.c | 2 +- src/lpc/ao_interrupt.c | 80 +++++++++++++---------- src/micropeak-v2.0/Makefile | 4 +- src/micropeak-v2.0/micropeak.ld | 111 +++----------------------------- src/pnpservo-v1/lambda.ld | 2 +- src/stm/Makefile-flash.defs | 4 +- src/stm/Makefile-stm.defs | 4 +- src/stm/Makefile.defs | 2 +- src/stm/altos-loader.ld | 82 ++--------------------- src/stm/altos.ld | 84 ++---------------------- src/stm/ao_arch.h | 3 +- src/stm/ao_boot_chain.c | 4 +- src/stm/ao_flash_stm.c | 4 +- src/stm/ao_interrupt.c | 66 +++++++++++-------- src/stm32f4/altos-loader.ld | 2 +- src/stmf0/Makefile-flash.defs | 4 +- src/stmf0/Makefile-stmf0.defs | 4 +- src/stmf0/Makefile.defs | 2 +- src/stmf0/altos-loader.ld | 83 ++---------------------- src/stmf0/altos.ld | 91 ++------------------------ src/stmf0/ao_arch.h | 3 +- src/stmf0/ao_boot_chain.c | 2 +- src/stmf0/ao_flash_stm.c | 4 +- src/stmf0/ao_interrupt.c | 96 ++++++++++++++------------- src/stmf0/ao_storage_stm.c | 7 +- src/telegps-v1.0/Makefile | 2 +- src/telegps-v2.0/Makefile | 2 +- src/telemetrum-v2.0/Makefile | 2 +- 36 files changed, 229 insertions(+), 697 deletions(-) diff --git a/src/Makefile.defs b/src/Makefile.defs index d6244fee..a14b8042 100644 --- a/src/Makefile.defs +++ b/src/Makefile.defs @@ -20,12 +20,11 @@ WARN_FLAGS=-Wall -Wextra -Werror -Wcast-align \ OPT=-Os -Wl,-Map=$(PROGNAME)-$(VERSION).map -NEWLIB_PRINTF_CFLAGS = -DNEWLIB_INTEGER_PRINTF_SCANF +PICOLIBC_PRINTF_CFLAGS = -DPICOLIBC_INTEGER_PRINTF_SCANF -NEWLIB_CFLAGS= \ - -ffreestanding -nostdlib \ - -isystem $(NEWLIB_NANO)/arm-none-eabi/include \ - $(NEWLIB_PRINTF_CFLAGS) +PICOLIBC_CFLAGS= \ + -specs=picolibc.specs \ + $(PICOLIBC_PRINTF_CFLAGS) AO_CFLAGS=\ -std=gnu99 \ diff --git a/src/kernel/ao_product.c b/src/kernel/ao_product.c index 72488654..eaa6c78b 100644 --- a/src/kernel/ao_product.c +++ b/src/kernel/ao_product.c @@ -60,8 +60,12 @@ const char ao_product[] = AO_iProduct_STRING; #define TOTAL_LENGTH (HEADER_LEN + AO_USB_HAS_INT * CONTROL_CLASS_LEN + DATA_LEN) #define NUM_INTERFACES (AO_USB_HAS_INT + 1) +#ifndef AO_USBCONFIG_SYMBOL +#define AO_USBCONFIG_SYMBOL AO_ROMCONFIG_SYMBOL +#endif + /* USB descriptors in one giant block of bytes */ -AO_ROMCONFIG_SYMBOL uint8_t ao_usb_descriptors [] = +AO_USBCONFIG_SYMBOL uint8_t ao_usb_descriptors [] = { /* Device descriptor */ 0x12, diff --git a/src/lpc/Makefile-flash.defs b/src/lpc/Makefile-flash.defs index 44b43bfe..1ae94c15 100644 --- a/src/lpc/Makefile-flash.defs +++ b/src/lpc/Makefile-flash.defs @@ -35,7 +35,7 @@ IDPRODUCT=0x000a CFLAGS = $(PRODUCT_DEF) $(LPC_CFLAGS) -LDFLAGS=$(CFLAGS) -L$(TOPDIR)/lpc -Wl,-Taltos-loader.ld +LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/lpc -Taltos-loader.ld PROGNAME=altos-flash PROG=$(HARDWARE)-$(PROGNAME)-$(VERSION).elf diff --git a/src/lpc/Makefile-lpc.defs b/src/lpc/Makefile-lpc.defs index 8b297351..fb3747dd 100644 --- a/src/lpc/Makefile-lpc.defs +++ b/src/lpc/Makefile-lpc.defs @@ -8,7 +8,7 @@ vpath % $(TOPDIR)/lpc:$(AO_VPATH) CC=$(ARM_CC) -LIBS=-L$(NEWLIB_NANO)/arm-none-eabi/lib/thumb/v6-m -lc -lm -lgcc +LIBS=-lm LPC_CFLAGS=-mlittle-endian -mcpu=cortex-m0 -mthumb\ - -I$(TOPDIR)/lpc $(AO_CFLAGS) $(NEWLIB_CFLAGS) + -I$(TOPDIR)/lpc $(AO_CFLAGS) $(PICOLIBC_CFLAGS) diff --git a/src/lpc/Makefile.defs b/src/lpc/Makefile.defs index 7fdcf0dc..7ea76e1c 100644 --- a/src/lpc/Makefile.defs +++ b/src/lpc/Makefile.defs @@ -4,7 +4,7 @@ endif include $(TOPDIR)/lpc/Makefile-lpc.defs -LDFLAGS=$(CFLAGS) -L$(TOPDIR)/lpc -Wl,-Taltos.ld -n +LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/lpc -Taltos.ld -n ao_serial_lpc.h: $(TOPDIR)/lpc/baud_rate ao_pins.h nickle $(TOPDIR)/lpc/baud_rate `awk '/AO_LPC_CLKOUT/{print $$3}' ao_pins.h` > $@ diff --git a/src/lpc/altos-loader.ld b/src/lpc/altos-loader.ld index be4f115d..75b527fb 100644 --- a/src/lpc/altos-loader.ld +++ b/src/lpc/altos-loader.ld @@ -16,66 +16,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -MEMORY { - rom : ORIGIN = 0x00000000, LENGTH = 4K - ram : ORIGIN = 0x10000000, LENGTH = 4k - 128 - 32 - usb (!x) : ORIGIN = 0x20004000 + 2K - 256, LENGTH = 256 - stack (!w) : ORIGIN = 0x10000000 + 4K - 128 - 32, LENGTH = 128 -} +__flash = 0x0; +__flash_size = 4K; +__ram = 0x10000000; +__ram_size = 4k; +__stack_size = 128; INCLUDE registers.ld - -EXTERN (lpc_interrupt_vector) - -SECTIONS { - /* - * Rom contents - */ - - .interrupt : { - __text_start__ = .; - *(.interrupt) /* Interrupt vectors */ - - } > rom - - .text ORIGIN(rom) + 0x100 : { - ao_romconfig.o(.romconfig*) - ao_product.o(.romconfig*) - - *(.text*) /* Executable code */ - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - *(.rodata*) /* Constants */ - __text_end__ = .; - } > rom - - /* Boot data which must live at the start of ram so that - * the application and bootloader share the same addresses. - * This must be all uninitialized data - */ - .boot ORIGIN(ram) + SIZEOF(.interrupt) (NOLOAD) : { - __boot_start__ = .; - *(.boot*) - __boot_end__ = .; - } >ram - - /* Data -- relocated to RAM, but written to ROM - */ - .data : { - _start__ = .; - *(.data*) /* initialized data */ - _end__ = .; - } >ram AT>rom - - - .bss : { - __bss_start__ = .; - *(.bss*) - *(COMMON*) - __bss_end__ = .; - } >ram - - PROVIDE(__stack__ = ORIGIN(ram) + LENGTH(ram)); - PROVIDE(end = .); -} - -ENTRY(start); +INCLUDE picolibc.ld diff --git a/src/lpc/altos.ld b/src/lpc/altos.ld index 028ad775..3e015730 100644 --- a/src/lpc/altos.ld +++ b/src/lpc/altos.ld @@ -16,76 +16,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -MEMORY { - rom (rx) : ORIGIN = 0x00001000, LENGTH = 28K - ram (!w) : ORIGIN = 0x10000000, LENGTH = 4K - 128 - usb (!x) : ORIGIN = 0x20004000 + 2K - 256, LENGTH = 256 - stack (!w) : ORIGIN = 0x10000000 + 4K - 128, LENGTH = 128 -} +__flash = 0x1000; +__flash_size = 28K; +__ram = 0x10000000; +__ram_size = 4k; +__stack_size = 128; INCLUDE registers.ld - -EXTERN (lpc_interrupt_vector) - -SECTIONS { - /* - * Rom contents - */ - - .interrupt ORIGIN(ram) : AT (ORIGIN(rom)) { - __interrupt_start__ = .; - __interrupt_rom__ = ORIGIN(rom); - *(.interrupt) /* Interrupt vectors */ - __interrupt_end__ = .; - } > ram - - .text ORIGIN(rom) + 0x100 : { - __text_start__ = .; - - ao_romconfig.o(.romconfig*) - ao_product.o(.romconfig*) - - *(.text*) /* Executable code */ - *(.rodata*) /* Constants */ - - } > rom - - .ARM.exidx : { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - __text_end__ = .; - } > rom - - /* Boot data which must live at the start of ram so that - * the application and bootloader share the same addresses. - * This must be all uninitialized data - */ - .boot : { - __boot_start__ = .; - *(.boot) - . = ALIGN(4); - __boot_end__ = .; - } >ram - - /* Data -- relocated to RAM, but written to ROM - */ - .data : AT (ADDR(.ARM.exidx) + SIZEOF (.ARM.exidx)) { - _start__ = .; - *(.data) /* initialized data */ - _end__ = .; - __bss_start__ = .; - } >ram - - .bss : { - __bss_start__ = .; - *(.bss) - *(COMMON) - __bss_end__ = .; - } >ram - PROVIDE(end = .); - - PROVIDE(__stack__ = ORIGIN(stack) + LENGTH(stack)); -} - -ENTRY(start); - - +INCLUDE picolibc.ld diff --git a/src/lpc/ao_arch.h b/src/lpc/ao_arch.h index 93676b86..c638aa22 100644 --- a/src/lpc/ao_arch.h +++ b/src/lpc/ao_arch.h @@ -53,7 +53,8 @@ * ao_romconfig.c */ -#define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const +#define AO_ROMCONFIG_SYMBOL __attribute__((section(".init.1"))) const +#define AO_USBCONFIG_SYMBOL __attribute__((section(".init.2"))) const #define ao_arch_block_interrupts() asm("cpsid i") #define ao_arch_release_interrupts() asm("cpsie i") diff --git a/src/lpc/ao_boot_chain.c b/src/lpc/ao_boot_chain.c index 0d0bb91c..0cb92a52 100644 --- a/src/lpc/ao_boot_chain.c +++ b/src/lpc/ao_boot_chain.c @@ -43,7 +43,7 @@ struct ao_boot { uint32_t check; }; -static struct ao_boot __attribute__ ((section(".boot"))) ao_boot; +struct ao_boot ao_boot __attribute__((section(".preserve.2"))); int ao_boot_check_chain(void) diff --git a/src/lpc/ao_interrupt.c b/src/lpc/ao_interrupt.c index a479ec6d..bc2848c3 100644 --- a/src/lpc/ao_interrupt.c +++ b/src/lpc/ao_interrupt.c @@ -29,15 +29,6 @@ #define RELOCATE_INTERRUPT 1 #endif -extern void main(void); -extern char __stack__; -extern char __text_start__, __text_end__; -extern char _start__, _end__; -extern char __bss_start__, __bss_end__; -#if RELOCATE_INTERRUPT -extern char __interrupt_rom__, __interrupt_start__, __interrupt_end__; -#endif - /* Interrupt functions */ void lpc_halt_isr(void) @@ -49,26 +40,6 @@ void lpc_ignore_isr(void) { } -void start(void) { -#ifdef AO_BOOT_CHAIN - if (ao_boot_check_chain()) { -#ifdef AO_BOOT_PIN - if (ao_boot_check_pin()) -#endif - { - ao_boot_chain(AO_BOOT_APPLICATION_BASE); - } - } -#endif -#if RELOCATE_INTERRUPT - memcpy(&__interrupt_start__, &__interrupt_rom__, &__interrupt_end__ - &__interrupt_start__); - lpc_scb.sysmemremap = LPC_SCB_SYSMEMREMAP_MAP_RAM << LPC_SCB_SYSMEMREMAP_MAP; -#endif - memcpy(&_start__, &__text_end__, &_end__ - &_start__); - memset(&__bss_start__, '\0', &__bss_end__ - &__bss_start__); - main(); -} - #define STRINGIFY(x) #x #define isr(name) \ @@ -122,10 +93,13 @@ isr(usb_wakeup) #define i(addr,name) [(addr)/4] = lpc_ ## name ## _isr #define c(addr,value) [(addr)/4] = (value) -__attribute__ ((section(".interrupt"))) -const void *lpc_interrupt_vector[] = { - [0] = &__stack__, - [1] = start, +extern char __stack[]; +void _start(void) __attribute__((__noreturn__)); + +__attribute__ ((section(".init"))) +const void *const __interrupt_vector[0x30] = { + [0] = __stack, + [1] = _start, i(0x08, nmi), i(0x0c, hardfault), c(0x10, 0), @@ -178,3 +152,43 @@ const void *lpc_interrupt_vector[] = { i(0xb8, usb_wakeup), i(0xbc, hardfault), }; + +/* + * Previous versions of this code had a 256 byte interupt vector. Add + * some padding to make sure the other low ROM variables land at the + * same address + */ + +__attribute__ ((section(".init.0"))) +const void *const __interrupt_pad[0x10]; + +void main(void) __attribute__((__noreturn__)); + +void *__interrupt_ram[sizeof(__interrupt_vector)/sizeof(__interrupt_vector[0])] __attribute((section(".preserve.1"))); + +extern char __data_source[]; +extern char __data_start[]; +extern char __data_size[]; +extern char __bss_start[]; +extern char __bss_size[]; + +void _start(void) { + memcpy(__data_start, __data_source, (uintptr_t) __data_size); + memset(__bss_start, '\0', (uintptr_t) __bss_size); + +#ifdef AO_BOOT_CHAIN + if (ao_boot_check_chain()) { +#ifdef AO_BOOT_PIN + if (ao_boot_check_pin()) +#endif + { + ao_boot_chain(AO_BOOT_APPLICATION_BASE); + } + } +#endif +#if RELOCATE_INTERRUPT + memcpy(__interrupt_ram, __interrupt_vector, sizeof(__interrupt_ram)); + lpc_scb.sysmemremap = LPC_SCB_SYSMEMREMAP_MAP_RAM << LPC_SCB_SYSMEMREMAP_MAP; +#endif + main(); +} diff --git a/src/micropeak-v2.0/Makefile b/src/micropeak-v2.0/Makefile index f1f57440..5949ec09 100644 --- a/src/micropeak-v2.0/Makefile +++ b/src/micropeak-v2.0/Makefile @@ -71,10 +71,10 @@ OBJ=$(SRC:.c=.o) all: $(PROG) $(HEX) -LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stmf0 -Wl,-Tmicropeak.ld -n +LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/stmf0 -Tmicropeak.ld -n $(PROG): Makefile $(OBJ) micropeak.ld - $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) + $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) -Wl,-Map=$(PROGNAME)-$(VERSION).map distclean: clean diff --git a/src/micropeak-v2.0/micropeak.ld b/src/micropeak-v2.0/micropeak.ld index a73d4c1d..b4e06a87 100644 --- a/src/micropeak-v2.0/micropeak.ld +++ b/src/micropeak-v2.0/micropeak.ld @@ -16,108 +16,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -MEMORY { - rom (rx) : ORIGIN = 0x08001000, LENGTH = 20K - flash(rx) : ORIGIN = 0x08006000, LENGTH = 8K - ram (!w) : ORIGIN = 0x20000000, LENGTH = 6k - 512 - stack (!w) : ORIGIN = 0x20000000 + 6k - 512, LENGTH = 512 -} +__flash = 0x08001000; +__flash_size = 22K; +__flash__ = __flash + __flash_size; +__flash_end__ = __flash__ + 6K; +__ram = 0x20000000; +__ram_size = 6K; +__stack_size = 512; INCLUDE registers.ld - -EXTERN (stm_interrupt_vector) - -SECTIONS { - /* - * Rom contents - */ - - .interrupt ORIGIN(ram) : AT (ORIGIN(rom)) { - __interrupt_start__ = .; - __interrupt_rom__ = ORIGIN(rom); - *(.interrupt) /* Interrupt vectors */ - __interrupt_end__ = .; - } > ram - - .text ORIGIN(rom) + 0x100 : { - __text_start__ = .; - - /* Ick. What I want is to specify the - * addresses of some global constants so - * that I can find them across versions - * of the application. I can't figure out - * how to make gnu ld do that, so instead - * we just load the two files that include - * these defines in the right order here and - * expect things to 'just work'. Don't change - * the contents of those files, ok? - */ - ao_romconfig.o(.romconfig*) - ao_product.o(.romconfig*) - - *(.text*) /* Executable code */ - } > rom - - .ARM.exidx : { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > rom - - .rodata : { - *(.rodata*) /* Constants */ - } > rom - - __text_end__ = .; - - /* Boot data which must live at the start of ram so that - * the application and bootloader share the same addresses. - * This must be all uninitialized data - */ - .boot (NOLOAD) : { - __boot_start__ = .; - *(.boot) - . = ALIGN(4); - __boot_end__ = .; - } >ram - - /* 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): { - _start__ = .; - *(.ramtext) - } >ram AT>rom - - /* Data -- relocated to RAM, but written to ROM, - * also aligned to 8 bytes to agree with textram - */ - .data BLOCK(8): { - *(.data) /* initialized data */ - _end__ = .; - } >ram AT>rom - - .bss : { - __bss_start__ = .; - *(.bss) - *(COMMON) - . = ALIGN(4); - __bss_end__ = .; - } >ram - - PROVIDE(end = .); - - PROVIDE(__flash__ = ORIGIN(flash)); - PROVIDE(__flash_end__ = ORIGIN(flash) + LENGTH(flash)); - - PROVIDE(__stack__ = ORIGIN(stack) + LENGTH(stack)); -} - -ENTRY(start); - - +INCLUDE picolibc.ld diff --git a/src/pnpservo-v1/lambda.ld b/src/pnpservo-v1/lambda.ld index d3edbe9f..20b3ace7 100644 --- a/src/pnpservo-v1/lambda.ld +++ b/src/pnpservo-v1/lambda.ld @@ -87,7 +87,7 @@ SECTIONS { .textram BLOCK(8): { _start__ = .; __text_ram_start__ = .; - *(.ramtext) + *(.srodata) __text_ram_end = .; } >ram AT>rom diff --git a/src/stm/Makefile-flash.defs b/src/stm/Makefile-flash.defs index 08a4b177..4a386431 100644 --- a/src/stm/Makefile-flash.defs +++ b/src/stm/Makefile-flash.defs @@ -35,13 +35,13 @@ IDPRODUCT=0x000a CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) -LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stm -Wl,-Taltos-loader.ld -n +LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/stm -Taltos-loader.ld -n PROGNAME=altos-flash PROG=$(HARDWARE)-$(PROGNAME)-$(VERSION).elf $(PROG): Makefile $(OBJ) altos-loader.ld - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) + $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) $(OBJ): $(INC) diff --git a/src/stm/Makefile-stm.defs b/src/stm/Makefile-stm.defs index cce28f00..f3fd9de6 100644 --- a/src/stm/Makefile-stm.defs +++ b/src/stm/Makefile-stm.defs @@ -7,7 +7,7 @@ include $(TOPDIR)/Makefile.defs vpath % $(TOPDIR)/stm:$(AO_VPATH) CC=$(ARM_CC) -LIBS=-L$(NEWLIB_NANO)/arm-none-eabi/lib/thumb/v7-m -lm -lc -lgcc +LIBS=-lm STM_CFLAGS=-mlittle-endian -mcpu=cortex-m3 -mthumb \ - -I$(TOPDIR)/stm $(AO_CFLAGS) $(NEWLIB_CFLAGS) + -I$(TOPDIR)/stm $(AO_CFLAGS) $(PICOLIBC_CFLAGS) diff --git a/src/stm/Makefile.defs b/src/stm/Makefile.defs index 26ba5824..d6cbe4d4 100644 --- a/src/stm/Makefile.defs +++ b/src/stm/Makefile.defs @@ -4,4 +4,4 @@ endif include $(TOPDIR)/stm/Makefile-stm.defs -LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stm -Wl,-Taltos.ld -n +LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/stm -Taltos.ld -n diff --git a/src/stm/altos-loader.ld b/src/stm/altos-loader.ld index 1ebbc7a2..5ef09cd2 100644 --- a/src/stm/altos-loader.ld +++ b/src/stm/altos-loader.ld @@ -16,81 +16,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -MEMORY { - rom : ORIGIN = 0x08000000, LENGTH = 4K - ram : ORIGIN = 0x20000000, LENGTH = 16K -} +__flash = 0x08000000; +__flash_size = 4K; +__ram = 0x20000000; +__ram_size = 16K; +__stack_size = 512; INCLUDE registers.ld - -EXTERN (stm_interrupt_vector) - -SECTIONS { - /* - * Rom contents - */ - - .text : { - __text_start__ = .; - *(.interrupt) /* Interrupt vectors */ - - . = ORIGIN(rom) + 0x100; - - ao_romconfig.o(.romconfig*) - ao_product.o(.romconfig*) - *(.text*) /* Executable code */ - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - *(.rodata*) /* Constants */ - } > rom - __text_end__ = .; - - /* Boot data which must live at the start of ram so that - * the application and bootloader share the same addresses. - * This must be all uninitialized data - */ - .boot (NOLOAD) : { - __boot_start__ = .; - *(.boot) - __boot_end__ = .; - } >ram - - /* 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): { - _start__ = .; - __text_ram_start__ = .; - *(.ramtext) - __text_ram_end = .; - } >ram AT>rom - - /* Data -- relocated to RAM, but written to ROM - * Also aligned to 8 bytes to agree with textram - */ - .data BLOCK(8): { - *(.data) /* initialized data */ - _end__ = .; - } >ram AT>rom - - - .bss : { - __bss_start__ = .; - *(.bss) - *(COMMON) - __bss_end__ = .; - } >ram - - PROVIDE(__stack__ = ORIGIN(ram) + LENGTH(ram)); - PROVIDE(end = .); -} - -ENTRY(start); - - +INCLUDE picolibc.ld diff --git a/src/stm/altos.ld b/src/stm/altos.ld index e352ed36..9638bb67 100644 --- a/src/stm/altos.ld +++ b/src/stm/altos.ld @@ -16,83 +16,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -MEMORY { - rom (rx) : ORIGIN = 0x08001000, LENGTH = 124K - ram (!w) : ORIGIN = 0x20000000, LENGTH = 15872 - stack (!w) : ORIGIN = 0x20003e00, LENGTH = 512 -} +__flash = 0x08001000; +__flash_size = 124K; +__ram = 0x20000000; +__ram_size = 16k; +__stack_size = 512; INCLUDE registers.ld - -EXTERN (stm_interrupt_vector) - -SECTIONS { - /* - * Rom contents - */ - - .text ORIGIN(rom) : { - __text_start__ = .; - *(.interrupt) /* Interrupt vectors */ - - . = ORIGIN(rom) + 0x100; - - - /* Ick. What I want is to specify the - * addresses of some global constants so - * that I can find them across versions - * of the application. I can't figure out - * how to make gnu ld do that, so instead - * we just load the two files that include - * these defines in the right order here and - * expect things to 'just work'. Don't change - * the contents of those files, ok? - */ - ao_romconfig.o(.romconfig*) - ao_product.o(.romconfig*) - *(.text*) /* Executable code */ - *(.rodata*) /* Constants */ - - } > rom - - .ARM.exidx : { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > rom - __text_end__ = .; - - /* Boot data which must live at the start of ram so that - * the application and bootloader share the same addresses. - * This must be all uninitialized data - */ - .boot (NOLOAD) : { - __boot_start__ = .; - *(.boot) - . = ALIGN(4); - __boot_end__ = .; - } >ram - - /* Data -- relocated to RAM, but written to ROM - */ - .data : { - _start__ = .; - *(.data) /* initialized data */ - . = ALIGN(4); - _end__ = .; - } >ram AT>rom - - .bss : { - __bss_start__ = .; - *(.bss) - *(COMMON) - . = ALIGN(4); - __bss_end__ = .; - } >ram - - PROVIDE(end = .); - - PROVIDE(__stack__ = ORIGIN(stack) + LENGTH(stack)); -} - -ENTRY(start); - - +INCLUDE picolibc.ld diff --git a/src/stm/ao_arch.h b/src/stm/ao_arch.h index e83b6bd2..e3094c6a 100644 --- a/src/stm/ao_arch.h +++ b/src/stm/ao_arch.h @@ -51,7 +51,8 @@ * ao_romconfig.c */ -#define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const +#define AO_ROMCONFIG_SYMBOL __attribute__((section(".init.1"))) const +#define AO_USBCONFIG_SYMBOL __attribute__((section(".init.2"))) const /* * For now, we're running at a weird frequency diff --git a/src/stm/ao_boot_chain.c b/src/stm/ao_boot_chain.c index 488af1e1..d91afdab 100644 --- a/src/stm/ao_boot_chain.c +++ b/src/stm/ao_boot_chain.c @@ -43,8 +43,8 @@ struct ao_boot { uint32_t check; }; -static struct ao_boot __attribute__ ((section(".boot"))) ao_boot; - +struct ao_boot ao_boot __attribute__((section(".preserve.2"))); + int ao_boot_check_chain(void) { diff --git a/src/stm/ao_flash_stm.c b/src/stm/ao_flash_stm.c index 38618bbe..77296c32 100644 --- a/src/stm/ao_flash_stm.c +++ b/src/stm/ao_flash_stm.c @@ -70,7 +70,7 @@ ao_flash_wait_bsy(void) ; } -static void __attribute__ ((section(".ramtext"),noinline)) +static void __attribute__ ((section(".sdata2.flash"), noinline)) _ao_flash_erase_page(uint32_t *page) { stm_flash.pecr |= (1 << STM_FLASH_PECR_ERASE) | (1 << STM_FLASH_PECR_PROG); @@ -93,7 +93,7 @@ ao_flash_erase_page(uint32_t *page) ao_arch_release_interrupts(); } -static void __attribute__ ((section(".ramtext"), noinline)) +static void __attribute__ ((section(".sdata2.flash"), noinline)) _ao_flash_half_page(uint32_t *dst, uint32_t *src) { uint8_t i; diff --git a/src/stm/ao_interrupt.c b/src/stm/ao_interrupt.c index 1d563532..c62870b7 100644 --- a/src/stm/ao_interrupt.c +++ b/src/stm/ao_interrupt.c @@ -22,10 +22,6 @@ #include extern void main(void); -extern char __stack__; -extern char __text_start__, __text_end__; -extern char _start__, _end__; -extern char __bss_start__, __bss_end__; /* Interrupt functions */ @@ -38,7 +34,7 @@ void stm_ignore_isr(void) { } -const void *stm_interrupt_vector[]; +void *const __interrupt_vector[]; uint32_t stm_flash_size(void) { @@ -72,25 +68,6 @@ stm_flash_size(void) { return (uint32_t) kbytes * 1024; } -void start(void) -{ -#ifdef AO_BOOT_CHAIN - if (ao_boot_check_chain()) { -#ifdef AO_BOOT_PIN - if (ao_boot_check_pin()) -#endif - { - ao_boot_chain(AO_BOOT_APPLICATION_BASE); - } - } -#endif - /* Set interrupt vector table offset */ - stm_nvic.vto = (uint32_t) &stm_interrupt_vector; - memcpy(&_start__, &__text_end__, &_end__ - &_start__); - memset(&__bss_start__, '\0', &__bss_end__ - &__bss_start__); - main(); -} - #define STRINGIFY(x) #x #define isr(name) \ @@ -158,10 +135,18 @@ isr(tim7) #define i(addr,name) [(addr)/4] = stm_ ## name ## _isr -__attribute__ ((section(".interrupt"))) -const void *stm_interrupt_vector[] = { - [0] = &__stack__, - [1] = start, +extern char __stack[]; +void _start(void) __attribute__((__noreturn__)); +void main(void) __attribute__((__noreturn__)); + +/* This must be exactly 256 bytes long so that the configuration data + * gets loaded at the right place + */ + +__attribute__ ((section(".init"))) +void * const __interrupt_vector[64] = { + [0] = &__stack, + [1] = _start, i(0x08, nmi), i(0x0c, hardfault), i(0x10, memmanage), @@ -217,3 +202,28 @@ const void *stm_interrupt_vector[] = { i(0xec, tim6), i(0xf0, tim7), }; + +extern char __data_source[]; +extern char __data_start[]; +extern char __data_size[]; +extern char __bss_start[]; +extern char __bss_size[]; + +void _start(void) { + memcpy(__data_start, __data_source, (uintptr_t) __data_size); + memset(__bss_start, '\0', (uintptr_t) __bss_size); + +#ifdef AO_BOOT_CHAIN + if (ao_boot_check_chain()) { +#ifdef AO_BOOT_PIN + if (ao_boot_check_pin()) +#endif + { + ao_boot_chain(AO_BOOT_APPLICATION_BASE); + } + } +#endif + /* Set interrupt vector table offset */ + stm_nvic.vto = (uint32_t) &__interrupt_vector; + main(); +} diff --git a/src/stm32f4/altos-loader.ld b/src/stm32f4/altos-loader.ld index 5d6e1f4b..9a46987f 100644 --- a/src/stm32f4/altos-loader.ld +++ b/src/stm32f4/altos-loader.ld @@ -68,7 +68,7 @@ SECTIONS { .textram BLOCK(8): { _start__ = .; __text_ram_start__ = .; - *(.ramtext) + *(.srodata) __text_ram_end = .; } >ram AT>rom diff --git a/src/stmf0/Makefile-flash.defs b/src/stmf0/Makefile-flash.defs index b6e44990..bbb04e77 100644 --- a/src/stmf0/Makefile-flash.defs +++ b/src/stmf0/Makefile-flash.defs @@ -35,7 +35,7 @@ IDPRODUCT=0x000a CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS) -LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stmf0 -Wl,-Taltos-loader.ld +LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/stmf0 -Taltos-loader.ld PROGNAME=altos-flash PROG=$(HARDWARE)-$(PROGNAME)-$(VERSION).elf @@ -47,7 +47,7 @@ FLASH_ADDR=0x08000000 all: $(PROG) $(BIN) $(PROG): Makefile $(OBJ) altos-loader.ld - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) + $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) $(BIN): $(PROG) $(MAKEBIN) --output=$@ --base=$(FLASH_ADDR) $(PROG) diff --git a/src/stmf0/Makefile-stmf0.defs b/src/stmf0/Makefile-stmf0.defs index 5a883adf..f3add106 100644 --- a/src/stmf0/Makefile-stmf0.defs +++ b/src/stmf0/Makefile-stmf0.defs @@ -9,6 +9,6 @@ vpath % $(TOPDIR)/stmf0:$(AO_VPATH) CC=$(ARM_CC) STMF0_CFLAGS=-mlittle-endian -mcpu=cortex-m0 -mthumb\ - -I$(TOPDIR)/stmf0 $(AO_CFLAGS) $(NEWLIB_CFLAGS) + -I$(TOPDIR)/stmf0 $(AO_CFLAGS) $(PICOLIBC_CFLAGS) -LIBS=-L$(NEWLIB_NANO)/arm-none-eabi/lib/thumb/v6-m -lc -lm -lgcc +LIBS=-lm diff --git a/src/stmf0/Makefile.defs b/src/stmf0/Makefile.defs index 2baba4f2..fb62f095 100644 --- a/src/stmf0/Makefile.defs +++ b/src/stmf0/Makefile.defs @@ -4,7 +4,7 @@ endif include $(TOPDIR)/stmf0/Makefile-stmf0.defs -LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stmf0 -Wl,-Taltos.ld -n +LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/stmf0 -Taltos.ld -n LOADER=flash-loader/$(PROGNAME)-altos-flash-$(VERSION).elf MAKEBIN=$(TOPDIR)/../ao-tools/ao-makebin/ao-makebin diff --git a/src/stmf0/altos-loader.ld b/src/stmf0/altos-loader.ld index 4d9b81ae..4ce0b704 100644 --- a/src/stmf0/altos-loader.ld +++ b/src/stmf0/altos-loader.ld @@ -16,82 +16,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -MEMORY { - rom : ORIGIN = 0x08000000, LENGTH = 4K - ram : ORIGIN = 0x20000000, LENGTH = 6K -} +__flash = 0x08000000; +__flash_size = 4K; +__ram = 0x20000000; +__ram_size = 6k; +__stack_size = 128; INCLUDE registers.ld - -EXTERN (stm_interrupt_vector) - -SECTIONS { - /* - * Rom contents - */ - - .interrupt : { - __text_start__ = .; - *(.interrupt) /* Interrupt vectors */ - } > rom - - .text ORIGIN(rom) + 0x100 : { - ao_romconfig.o(.romconfig*) - ao_product.o(.romconfig*) - - *(.text*) /* Executable code */ - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - *(.rodata*) /* Constants */ - } > rom - __text_end__ = .; - - /* Boot data which must live at the start of ram so that - * the application and bootloader share the same addresses. - * This must be all uninitialized data - */ - .boot ORIGIN(ram) + SIZEOF(.interrupt) (NOLOAD) : { - __boot_start__ = .; - *(.boot) - __boot_end__ = .; - } >ram - - /* 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): { - _start__ = .; - __text_ram_start__ = .; - *(.ramtext) - __text_ram_end = .; - } >ram AT>rom - - /* Data -- relocated to RAM, but written to ROM. - * also aligned to 8 bytes in case textram is empty - */ - .data BLOCK(8): { - *(.data) /* initialized data */ - _end__ = .; - } >ram AT>rom - - - .bss : { - __bss_start__ = .; - *(.bss) - *(COMMON) - __bss_end__ = .; - } >ram - - PROVIDE(__stack__ = ORIGIN(ram) + LENGTH(ram)); - PROVIDE(end = .); -} - -ENTRY(start); - - +INCLUDE picolibc.ld diff --git a/src/stmf0/altos.ld b/src/stmf0/altos.ld index 64e1d00c..019565cf 100644 --- a/src/stmf0/altos.ld +++ b/src/stmf0/altos.ld @@ -16,90 +16,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -MEMORY { - rom (rx) : ORIGIN = 0x08001000, LENGTH = 28K - ram (!w) : ORIGIN = 0x20000000, LENGTH = 6k - 128 - stack (!w) : ORIGIN = 0x20000000 + 6k - 128, LENGTH = 128 -} +__flash = 0x08001000; +__flash_size = 28K; +__ram = 0x20000000; +__ram_size = 6k; +__stack_size = 128; INCLUDE registers.ld - -EXTERN (stm_interrupt_vector) - -SECTIONS { - /* - * Rom contents - */ - - .interrupt ORIGIN(ram) : AT (ORIGIN(rom)) { - __interrupt_start__ = .; - __interrupt_rom__ = ORIGIN(rom); - *(.interrupt) /* Interrupt vectors */ - __interrupt_end__ = .; - } > ram - - .text ORIGIN(rom) + 0x100 : { - __text_start__ = .; - - /* Ick. What I want is to specify the - * addresses of some global constants so - * that I can find them across versions - * of the application. I can't figure out - * how to make gnu ld do that, so instead - * we just load the two files that include - * these defines in the right order here and - * expect things to 'just work'. Don't change - * the contents of those files, ok? - */ - ao_romconfig.o(.romconfig*) - ao_product.o(.romconfig*) - - *(.text*) /* Executable code */ - } > rom - - .ARM.exidx : { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > rom - - .rodata : { - *(.rodata*) /* Constants */ - } > rom - - __text_end__ = .; - - /* Boot data which must live at the start of ram so that - * the application and bootloader share the same addresses. - * This must be all uninitialized data - */ - .boot (NOLOAD) : { - __boot_start__ = .; - *(.boot) - . = ALIGN(4); - __boot_end__ = .; - } >ram - - /* Data -- relocated to RAM, but written to ROM - */ - .data : { - _start__ = .; - *(.data) /* initialized data */ - . = ALIGN(4); - _end__ = .; - } >ram AT>rom - - .bss : { - __bss_start__ = .; - *(.bss) - *(COMMON) - . = ALIGN(4); - __bss_end__ = .; - } >ram - - PROVIDE(end = .); - - PROVIDE(__stack__ = ORIGIN(stack) + LENGTH(stack)); -} - -ENTRY(start); - - +INCLUDE picolibc.ld diff --git a/src/stmf0/ao_arch.h b/src/stmf0/ao_arch.h index d70a9110..47ac7278 100644 --- a/src/stmf0/ao_arch.h +++ b/src/stmf0/ao_arch.h @@ -53,7 +53,8 @@ * ao_romconfig.c */ -#define AO_ROMCONFIG_SYMBOL __attribute__((section(".romconfig"))) const +#define AO_ROMCONFIG_SYMBOL __attribute__((section(".init.1"))) const +#define AO_USBCONFIG_SYMBOL __attribute__((section(".init.2"))) const extern const uint16_t ao_romconfig_version; extern const uint16_t ao_romconfig_check; diff --git a/src/stmf0/ao_boot_chain.c b/src/stmf0/ao_boot_chain.c index 8f850a0a..d91afdab 100644 --- a/src/stmf0/ao_boot_chain.c +++ b/src/stmf0/ao_boot_chain.c @@ -43,7 +43,7 @@ struct ao_boot { uint32_t check; }; -static struct ao_boot __attribute__ ((section(".boot"))) ao_boot; +struct ao_boot ao_boot __attribute__((section(".preserve.2"))); int ao_boot_check_chain(void) diff --git a/src/stmf0/ao_flash_stm.c b/src/stmf0/ao_flash_stm.c index 2d57eea7..896d536b 100644 --- a/src/stmf0/ao_flash_stm.c +++ b/src/stmf0/ao_flash_stm.c @@ -52,7 +52,7 @@ ao_flash_lock(void) #define ao_flash_wait_bsy() do { while (stm_flash.sr & (1 << STM_FLASH_SR_BSY)); } while (0) -static void __attribute__ ((section(".ramtext"),noinline)) +static void __attribute__ ((section(".sdata2.flash"), noinline)) _ao_flash_erase_page(uint32_t *page) { stm_flash.cr |= (1 << STM_FLASH_CR_PER); @@ -103,7 +103,7 @@ ao_flash_erase_page(uint32_t *page) ao_arch_release_interrupts(); } -static void __attribute__ ((section(".ramtext"), noinline)) +static void __attribute__ ((section(".sdata2.flash"), noinline)) _ao_flash_page(uint16_t *dst, uint16_t *src) { uint8_t i; diff --git a/src/stmf0/ao_interrupt.c b/src/stmf0/ao_interrupt.c index 1ee6e720..3d7dc7a8 100644 --- a/src/stmf0/ao_interrupt.c +++ b/src/stmf0/ao_interrupt.c @@ -32,15 +32,6 @@ #endif #endif -extern void main(void); -extern char __stack__; -extern char __text_start__, __text_end__; -extern char _start__, _end__; -extern char __bss_start__, __bss_end__; -#if RELOCATE_INTERRUPT -extern char __interrupt_rom__, __interrupt_start__, __interrupt_end__; -#endif - /* Interrupt functions */ void stm_halt_isr(void) @@ -52,8 +43,6 @@ void stm_ignore_isr(void) { } -const void *stm_interrupt_vector[]; - uint32_t stm_flash_size(void) { uint16_t dev_id = stm_dev_id(); @@ -67,35 +56,6 @@ stm_flash_size(void) { return (uint32_t) kbytes * 1024; } -void start(void) -{ -#if AO_BOOT_CHAIN - if (ao_boot_check_chain()) { -#if AO_BOOT_PIN - if (ao_boot_check_pin()) -#endif - { - ao_boot_chain(AO_BOOT_APPLICATION_BASE); - } - } -#endif - /* Turn on syscfg */ - stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_SYSCFGCOMPEN); - -#if RELOCATE_INTERRUPT - memcpy(&__interrupt_start__, &__interrupt_rom__, &__interrupt_end__ - &__interrupt_start__); - stm_syscfg.cfgr1 = (stm_syscfg.cfgr1 & ~(STM_SYSCFG_CFGR1_MEM_MODE_MASK << STM_SYSCFG_CFGR1_MEM_MODE)) | - (STM_SYSCFG_CFGR1_MEM_MODE_SRAM << STM_SYSCFG_CFGR1_MEM_MODE); -#else - /* Switch to Main Flash mode (DFU loader leaves us in System mode) */ - stm_syscfg.cfgr1 = (stm_syscfg.cfgr1 & ~(STM_SYSCFG_CFGR1_MEM_MODE_MASK << STM_SYSCFG_CFGR1_MEM_MODE)) | - (STM_SYSCFG_CFGR1_MEM_MODE_MAIN_FLASH << STM_SYSCFG_CFGR1_MEM_MODE); -#endif - memcpy(&_start__, &__text_end__, &_end__ - &_start__); - memset(&__bss_start__, '\0', &__bss_end__ - &__bss_start__); - main(); -} - #define STRINGIFY(x) #x #define isr(name) \ @@ -153,10 +113,14 @@ isr(usb) #define i(addr,name) [(addr)/4] = stm_ ## name ## _isr -__attribute__ ((section(".interrupt"))) -const void *stm_interrupt_vector[] = { - [0] = &__stack__, - [1] = start, +extern char __stack[]; +void _start(void) __attribute__((__noreturn__)); +void main(void) __attribute__((__noreturn__)); + +__attribute__ ((section(".init"))) +const void * const __interrupt_vector[0x30] = { + [0] = __stack, + [1] = _start, i(0x08, nmi), i(0x0c, hardfault), i(0x2c, svc), @@ -196,3 +160,47 @@ const void *stm_interrupt_vector[] = { i(0xb8, cec_can), i(0xbc, usb), }; + +/* + * Previous versions of this code had a 256 byte interupt vector. Add + * some padding to make sure the other low ROM variables land at the + * same address + */ + +__attribute__ ((section(".init.0"))) +const void *const __interrupt_pad[0x10]; + +void *__interrupt_ram[sizeof(__interrupt_vector)/sizeof(__interrupt_vector[0])] __attribute__((section(".preserve.1"))); + +extern char __data_source[]; +extern char __data_start[]; +extern char __data_size[]; +extern char __bss_start[]; +extern char __bss_size[]; + +void _start(void) +{ + memcpy(__data_start, __data_source, (uintptr_t) __data_size); + memset(__bss_start, '\0', (uintptr_t) __bss_size); + +#if AO_BOOT_CHAIN + if (ao_boot_check_chain()) { +#if AO_BOOT_PIN + ao_boot_check_pin(); +#endif + } +#endif + /* Turn on syscfg */ + stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_SYSCFGCOMPEN); + +#if RELOCATE_INTERRUPT + memcpy(__interrupt_ram, __interrupt_vector, sizeof(__interrupt_ram)); + stm_syscfg.cfgr1 = (stm_syscfg.cfgr1 & ~(STM_SYSCFG_CFGR1_MEM_MODE_MASK << STM_SYSCFG_CFGR1_MEM_MODE)) | + (STM_SYSCFG_CFGR1_MEM_MODE_SRAM << STM_SYSCFG_CFGR1_MEM_MODE); +#else + /* Switch to Main Flash mode (DFU loader leaves us in System mode) */ + stm_syscfg.cfgr1 = (stm_syscfg.cfgr1 & ~(STM_SYSCFG_CFGR1_MEM_MODE_MASK << STM_SYSCFG_CFGR1_MEM_MODE)) | + (STM_SYSCFG_CFGR1_MEM_MODE_MAIN_FLASH << STM_SYSCFG_CFGR1_MEM_MODE); +#endif + main(); +} diff --git a/src/stmf0/ao_storage_stm.c b/src/stmf0/ao_storage_stm.c index c6f1defe..111db04a 100644 --- a/src/stmf0/ao_storage_stm.c +++ b/src/stmf0/ao_storage_stm.c @@ -70,7 +70,7 @@ stm_flash_page_size(void) #define ao_flash_wait_bsy() do { while (stm_flash.sr & (1 << STM_FLASH_SR_BSY)); } while (0) -static void __attribute__ ((section(".ramtext"),noinline)) +static void __attribute__ ((section(".sdata2.flash"), noinline)) _ao_flash_erase_page(uint16_t *page) { stm_flash.cr |= (1 << STM_FLASH_CR_PER); @@ -86,7 +86,8 @@ _ao_flash_erase_page(uint16_t *page) #define _ao_flash_addr(pos) ((uint16_t *) (void *) ((uint8_t *) __flash__ + (pos))) -static void __attribute ((section(".ramtext"), noinline)) _ao_flash_byte(uint32_t pos, uint8_t b) +static void __attribute__ ((section(".sdata2.flash"), noinline)) +_ao_flash_byte(uint32_t pos, uint8_t b) { uint16_t v; uint16_t *a = _ao_flash_addr(pos & ~1); @@ -99,7 +100,7 @@ static void __attribute ((section(".ramtext"), noinline)) _ao_flash_byte(uint32_ ao_flash_wait_bsy(); } -static void __attribute__ ((section(".ramtext"), noinline)) +static void __attribute__ ((section(".sdata2.flash"), noinline)) _ao_flash_write(uint32_t pos, void *sv, uint16_t len) { uint8_t *s = sv; diff --git a/src/telegps-v1.0/Makefile b/src/telegps-v1.0/Makefile index fc1b1f28..aa644298 100644 --- a/src/telegps-v1.0/Makefile +++ b/src/telegps-v1.0/Makefile @@ -71,7 +71,7 @@ OBJ=$(SRC:.c=.o) all: $(PROG) $(HEX) $(PROG): Makefile $(OBJ) altos.ld - $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) + $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) -Wl,-Map=$(PROGNAME)-$(VERSION).map $(OBJ): $(INC) diff --git a/src/telegps-v2.0/Makefile b/src/telegps-v2.0/Makefile index 7ce28471..24410e0d 100644 --- a/src/telegps-v2.0/Makefile +++ b/src/telegps-v2.0/Makefile @@ -73,7 +73,7 @@ OBJ=$(SRC:.c=.o) all: $(PROG) $(HEX) $(PROG): Makefile $(OBJ) altos.ld - $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) + $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) -Wl,-Map=$(PROGNAME)-$(VERSION).map $(OBJ): $(INC) diff --git a/src/telemetrum-v2.0/Makefile b/src/telemetrum-v2.0/Makefile index c1e220e3..9b66c518 100644 --- a/src/telemetrum-v2.0/Makefile +++ b/src/telemetrum-v2.0/Makefile @@ -105,7 +105,7 @@ OBJ=$(SRC:.c=.o) all: $(PROG) $(HEX) $(PROG): Makefile $(OBJ) altos.ld - $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) + $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) -Wl,-Map=$(PROGNAME)-$(VERSION).map $(OBJ): $(INC) -- 2.30.2