samd21: Configure ROM/RAM values per device and provide linker scripts for each
authorKeith Packard <keithp@keithp.com>
Sun, 6 Nov 2022 04:05:13 +0000 (21:05 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 6 Nov 2022 04:05:13 +0000 (21:05 -0700)
SAMD21 has 4-32k of RAM and 32-256K of ROM

Signed-off-by: Keith Packard <keithp@keithp.com>
src/samd21/Makefile.defs
src/samd21/altos-128-16.ld [new file with mode: 0644]
src/samd21/altos-256-32.ld [new file with mode: 0644]
src/samd21/altos-loader.ld
src/samd21/altos.ld [deleted file]
src/snekboard/Makefile
src/telemetrum-v4.0/Makefile

index eb6a267d56ff579717d68347ecf6a6088a2c7b96..d58db93469161d88099d7cab5f04390eef7e2655 100644 (file)
@@ -4,6 +4,8 @@ endif
 
 include $(TOPDIR)/samd21/Makefile-samd21.defs
 
-LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/samd21 -Taltos.ld -n
+SAMD21_LINKER_SCRIPT=altos-$(SAMD21_ROM)-$(SAMD21_RAM).ld 
+
+LDFLAGS=-nostartfiles $(CFLAGS) -L$(TOPDIR)/samd21 -T$(SAMD21_LINKER_SCRIPT) -n
 
 .DEFAULT_GOAL=all
diff --git a/src/samd21/altos-128-16.ld b/src/samd21/altos-128-16.ld
new file mode 100644 (file)
index 0000000..e07a6a4
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright © 2022 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ */
+
+__flash = 0x00001000;
+__flash_size = 128K - 4K;
+__ram = 0x20000000;
+__ram_size = 16k;
+__stack_size = 256;
+
+INCLUDE registers.ld
+INCLUDE picolibc.ld
diff --git a/src/samd21/altos-256-32.ld b/src/samd21/altos-256-32.ld
new file mode 100644 (file)
index 0000000..4be7d67
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright © 2022 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ */
+
+__flash = 0x00001000;
+__flash_size = 256 - 4K;
+__ram = 0x20000000;
+__ram_size = 32k;
+__stack_size = 256;
+
+INCLUDE registers.ld
+INCLUDE picolibc.ld
index 7715aa5026f588bfe3225808ce816b28fe467881..a06d28b221cf23e9bb8b8420354b1334b0c7b7a0 100644 (file)
@@ -19,7 +19,7 @@
 __flash = 0x00000000;
 __flash_size = 4K;
 __ram = 0x20000000;
-__ram_size = 32k;
+__ram_size = 4k;
 __stack_size = 256;
 
 INCLUDE registers.ld
diff --git a/src/samd21/altos.ld b/src/samd21/altos.ld
deleted file mode 100644 (file)
index 40d9e4a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright © 2022 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; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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.
- */
-
-__flash = 0x00001000;
-__flash_size = 128K - 4K;
-__ram = 0x20000000;
-__ram_size = 32k;
-__stack_size = 256;
-
-INCLUDE registers.ld
-INCLUDE picolibc.ld
index 53a37c682aa06863531bd27cd09ccd4eca95dfea..44c712d68e9e4de58be657f5a236d863b66f9a7a 100644 (file)
@@ -31,6 +31,11 @@ ALTOS_SRC = \
        ao_usb_samd21.c \
        ao_spi_samd21.c
 
+# SAMD21G18A
+
+SAMD21_ROM=256
+SAMD21_RAM=32
+
 PRODUCT=SnekBoard
 PRODUCT_DEF=-DSNEKBOARD
 IDPRODUCT=0x000a
@@ -46,7 +51,7 @@ OBJ=$(SRC:.c=.o)
 
 all: $(PROG) $(HEX)
 
-$(PROG): Makefile $(OBJ) altos.ld
+$(PROG): Makefile $(OBJ) 
        $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS)
 
 $(OBJ): $(INC)
index 5733a9d0482fea954954cf4b861971f039974b1e..e1b627b954e06c4ab78c3035e632238acb052449 100644 (file)
@@ -28,6 +28,11 @@ INC = \
        samd21.h \
        Makefile
 
+# SAMD21G17D
+
+SAMD21_ROM=128
+SAMD21_RAM=32
+
 #PROFILE=ao_profile.c
 #PROFILE_DEF=-DAO_PROFILE=1