altos/stm: Use picolibc startup code
authorKeith Packard <keithp@keithp.com>
Sun, 19 Sep 2021 05:15:50 +0000 (22:15 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 19 Sep 2021 06:17:41 +0000 (23:17 -0700)
Instead of custom bits

Signed-off-by: Keith Packard <keithp@keithp.com>
src/stm/Makefile-flash.defs
src/stm/Makefile.defs
src/stm/ao_interrupt.c

index 37fad6d1638b5e59d0bfd9c8712c93986ee0c492..776811586fdfb467f91078289ee2bb88991248e9 100644 (file)
@@ -35,7 +35,7 @@ IDPRODUCT=0x000a
 
 CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS)
 
-LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/stm -Taltos-loader.ld -n
+LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stm -Taltos-loader.ld -n
 
 PROGNAME=$(HARDWARE)-altos-flash
 PROG=$(PROGNAME)-$(VERSION).elf
index d6cbe4d4921a3be1d6257146860a16e63206e3be..2ed89f7e3c4ee56b5fdebb37329c4f6fa815bf3c 100644 (file)
@@ -4,4 +4,4 @@ endif
 
 include $(TOPDIR)/stm/Makefile-stm.defs
 
-LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/stm -Taltos.ld -n
+LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stm -Taltos.ld -n
index 9a0591876348892e85dfddb6efcac07b8e68dc01..0d6e450f581b1911e4ae3e3089154c5348ef1577 100644 (file)
@@ -136,6 +136,7 @@ isr(tim7)
 extern char __stack[];
 void _start(void) __attribute__((__noreturn__));
 void main(void) __attribute__((__noreturn__));
+void ao_setup(void) __attribute__((constructor));
 
 /* This must be exactly 256 bytes long so that the configuration data
  * gets loaded at the right place
@@ -201,16 +202,7 @@ const void * const __interrupt_vector[64] = {
        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);
-
+void __attribute__((constructor)) ao_setup(void) {
 #ifdef AO_BOOT_CHAIN
        if (ao_boot_check_chain()) {
 #ifdef AO_BOOT_PIN
@@ -223,5 +215,4 @@ void _start(void) {
 #endif
        /* Set interrupt vector table offset */
        stm_nvic.vto = (uint32_t) &__interrupt_vector;
-       main();
 }