Change directory structure to align with Atmel softpack

This way we can easily check with 'diff' for differences in our code and
Atmel softpack.  Also, this layout is more suitable for building various
different firmware images (e.g. factory-test, dfu-loader, main
application) for a variety of different boards (simtrace, owhw, qmod).
diff --git a/firmware/Makefile b/firmware/Makefile
index 6092e8c..da92ce3 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -70,9 +70,11 @@
 #		Tools
 #-------------------------------------------------------------------------------
 
-AT91LIB_USB_COMMON_CORE_PATH = atmel_softpack_libraries/usb/common/core
-AT91LIB_USB_CORE_PATH = atmel_softpack_libraries/usb/device/core
-AT91LIB_USB_DFU_PATH = atmel_softpack_libraries/usb/device/dfu
+AT91LIB = ./atmel_softpack_libraries
+
+AT91LIB_USB_COMMON_CORE_PATH = $(AT91LIB)/usb/common/core
+AT91LIB_USB_CORE_PATH = $(AT91LIB)/usb/device/core
+AT91LIB_USB_DFU_PATH = $(AT91LIB)/usb/device/dfu
 
 # Tool suffix when cross-compiling
 CROSS_COMPILE = arm-none-eabi-
@@ -92,15 +94,16 @@
 GIT_VERSION=$(shell $(TOP)/git-version-gen $(TOP)/.tarvers)
 
 # Flags
-INCLUDES_USB = -Iatmel_softpack_libraries/usb/include -Iatmel_softpack_libraries
+INCLUDES_USB = -I$(AT91LIB)/usb/include -I$(AT91LIB)
 
-INCLUDES  = -Iinclude_board -Iinclude_sam3s -Iinclude -Isrc_simtrace -Iinclude_libosmocore
-
-# FIXME: This must be made configurable!
-INCLUDES += -Iinclude_board/$(BOARD)
-
-INCLUDES += -Icmsis
-INCLUDES += $(INCLUDES_USB)
+INCLUDES = $(INCLUDES_USB)
+INCLUDES += -I$(AT91LIB)/libchip_sam3s -I$(AT91LIB)/libchip_sam3s/include
+INCLUDES += -I$(AT91LIB)/libchip_sam3s/cmsis
+INCLUDES += -Ilibboard/common/include -Ilibboard/$(BOARD)/include
+INCLUDES += -Ilibcommon/include
+INCLUDES += -Ilibosmocore/include
+INCLUDES += -Iinclude_board
+INCLUDES += -Isrc_simtrace -Iinclude
 
 CFLAGS += -Wall -Wchar-subscripts -Wcomment -Wimplicit-int #-Wformat=2
 CFLAGS += -Werror-implicit-function-declaration -Wmain -Wparentheses
@@ -141,7 +144,12 @@
 # Directories where source files can be found
 
 USB_PATHS = $(AT91LIB_USB_CORE_PATH) $(AT91LIB_USB_DFU_PATH) $(AT91LIB_USB_COMMON_CORE_PATH)
-VPATH += src_board src_sam3s cmsis $(USB_PATHS) src_simtrace src_libosmocore
+
+VPATH += $(USB_PATHS)
+VPATH += $(AT91LIB)/libchip_sam3s/source/ $(AT91LIB)/libchip_sam3s/cmsis
+VPATH += libboard/common/source libboard/$(BOARD)/source
+VPATH += libcommon/source
+VPATH += libosmocore/source src_board src_simtrace
 
 # Objects built from C source files
 C_CMSIS    = core_cm3.o
diff --git a/firmware/include_sam3s/chip.h b/firmware/atmel_softpack_libraries/libchip_sam3s/chip.h
similarity index 100%
rename from firmware/include_sam3s/chip.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/chip.h
diff --git a/firmware/cmsis/CMSIS_Core.htm b/firmware/atmel_softpack_libraries/libchip_sam3s/cmsis/CMSIS_Core.htm
similarity index 100%
rename from firmware/cmsis/CMSIS_Core.htm
rename to firmware/atmel_softpack_libraries/libchip_sam3s/cmsis/CMSIS_Core.htm
diff --git a/firmware/cmsis/core_cm3.c b/firmware/atmel_softpack_libraries/libchip_sam3s/cmsis/core_cm3.c
similarity index 100%
rename from firmware/cmsis/core_cm3.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/cmsis/core_cm3.c
diff --git a/firmware/cmsis/core_cm3.h b/firmware/atmel_softpack_libraries/libchip_sam3s/cmsis/core_cm3.h
similarity index 100%
rename from firmware/cmsis/core_cm3.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/cmsis/core_cm3.h
diff --git a/firmware/include_sam3s/SAM3S.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/SAM3S.h
similarity index 100%
rename from firmware/include_sam3s/SAM3S.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/SAM3S.h
diff --git a/firmware/include_sam3s/USBD_Config.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/USBD_Config.h
similarity index 100%
rename from firmware/include_sam3s/USBD_Config.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/USBD_Config.h
diff --git a/firmware/include_sam3s/efc.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/efc.h
similarity index 100%
rename from firmware/include_sam3s/efc.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/efc.h
diff --git a/firmware/include_sam3s/exceptions.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/exceptions.h
similarity index 100%
rename from firmware/include_sam3s/exceptions.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/exceptions.h
diff --git a/firmware/include_sam3s/flashd.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/flashd.h
similarity index 100%
rename from firmware/include_sam3s/flashd.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/flashd.h
diff --git a/firmware/include_sam3s/hsmci.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/hsmci.h
similarity index 100%
rename from firmware/include_sam3s/hsmci.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/hsmci.h
diff --git a/firmware/include_sam3s/pio.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/pio.h
similarity index 100%
rename from firmware/include_sam3s/pio.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/pio.h
diff --git a/firmware/include_sam3s/pio_capture.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/pio_capture.h
similarity index 100%
rename from firmware/include_sam3s/pio_capture.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/pio_capture.h
diff --git a/firmware/include_sam3s/pio_it.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/pio_it.h
similarity index 100%
rename from firmware/include_sam3s/pio_it.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/pio_it.h
diff --git a/firmware/include_sam3s/pmc.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/pmc.h
similarity index 100%
rename from firmware/include_sam3s/pmc.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/pmc.h
diff --git a/firmware/include_sam3s/spi.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/spi.h
similarity index 100%
rename from firmware/include_sam3s/spi.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/spi.h
diff --git a/firmware/include_sam3s/tc.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/tc.h
similarity index 100%
rename from firmware/include_sam3s/tc.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/tc.h
diff --git a/firmware/include_sam3s/trace.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/trace.h
similarity index 100%
rename from firmware/include_sam3s/trace.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/trace.h
diff --git a/firmware/include_sam3s/unique_id.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/unique_id.h
similarity index 100%
rename from firmware/include_sam3s/unique_id.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/unique_id.h
diff --git a/firmware/include_sam3s/usart.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/usart.h
similarity index 100%
rename from firmware/include_sam3s/usart.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/usart.h
diff --git a/firmware/include_sam3s/wdt.h b/firmware/atmel_softpack_libraries/libchip_sam3s/include/wdt.h
similarity index 100%
rename from firmware/include_sam3s/wdt.h
rename to firmware/atmel_softpack_libraries/libchip_sam3s/include/wdt.h
diff --git a/firmware/src_sam3s/USBD_HAL.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
similarity index 100%
rename from firmware/src_sam3s/USBD_HAL.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c
diff --git a/firmware/src_sam3s/efc.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/efc.c
similarity index 100%
rename from firmware/src_sam3s/efc.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/source/efc.c
diff --git a/firmware/src_sam3s/exceptions.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/exceptions.c
similarity index 100%
rename from firmware/src_sam3s/exceptions.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/source/exceptions.c
diff --git a/firmware/src_sam3s/flashd.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/flashd.c
similarity index 100%
rename from firmware/src_sam3s/flashd.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/source/flashd.c
diff --git a/firmware/src_sam3s/pio.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/pio.c
similarity index 100%
rename from firmware/src_sam3s/pio.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/source/pio.c
diff --git a/firmware/src_sam3s/pio_capture.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/pio_capture.c
similarity index 100%
rename from firmware/src_sam3s/pio_capture.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/source/pio_capture.c
diff --git a/firmware/src_sam3s/pio_it.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/pio_it.c
similarity index 100%
rename from firmware/src_sam3s/pio_it.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/source/pio_it.c
diff --git a/firmware/src_sam3s/pmc.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/pmc.c
similarity index 100%
rename from firmware/src_sam3s/pmc.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/source/pmc.c
diff --git a/firmware/src_sam3s/spi.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/spi.c
similarity index 100%
rename from firmware/src_sam3s/spi.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/source/spi.c
diff --git a/firmware/src_sam3s/tc.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/tc.c
similarity index 100%
rename from firmware/src_sam3s/tc.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/source/tc.c
diff --git a/firmware/src_sam3s/unique_id.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/unique_id.c
similarity index 100%
rename from firmware/src_sam3s/unique_id.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/source/unique_id.c
diff --git a/firmware/src_sam3s/usart.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/usart.c
similarity index 100%
rename from firmware/src_sam3s/usart.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/source/usart.c
diff --git a/firmware/src_sam3s/wdt.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/wdt.c
similarity index 100%
rename from firmware/src_sam3s/wdt.c
rename to firmware/atmel_softpack_libraries/libchip_sam3s/source/wdt.c
diff --git a/firmware/include_board/board_common.h b/firmware/libboard/common/include/board_common.h
similarity index 100%
rename from firmware/include_board/board_common.h
rename to firmware/libboard/common/include/board_common.h
diff --git a/firmware/include_board/board_lowlevel.h b/firmware/libboard/common/include/board_lowlevel.h
similarity index 100%
rename from firmware/include_board/board_lowlevel.h
rename to firmware/libboard/common/include/board_lowlevel.h
diff --git a/firmware/include_board/boardver_adc.h b/firmware/libboard/common/include/boardver_adc.h
similarity index 100%
rename from firmware/include_board/boardver_adc.h
rename to firmware/libboard/common/include/boardver_adc.h
diff --git a/firmware/include_board/led.h b/firmware/libboard/common/include/led.h
similarity index 100%
rename from firmware/include_board/led.h
rename to firmware/libboard/common/include/led.h
diff --git a/firmware/include_board/uart_console.h b/firmware/libboard/common/include/uart_console.h
similarity index 100%
rename from firmware/include_board/uart_console.h
rename to firmware/libboard/common/include/uart_console.h
diff --git a/firmware/libboard/common/resources/sam3s1/flash.ld b/firmware/libboard/common/resources/sam3s1/flash.ld
new file mode 100644
index 0000000..b6c5428
--- /dev/null
+++ b/firmware/libboard/common/resources/sam3s1/flash.ld
@@ -0,0 +1,140 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2009, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*------------------------------------------------------------------------------
+ *      Linker script for running in internal FLASH on the ATSAM3S1
+ *----------------------------------------------------------------------------*/
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+	rom (rx)  : ORIGIN = 0x00400000, LENGTH = 0x00010000 /* Flash, 64K */
+	ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00004000 /* sram, 16K */
+}
+
+/* Section Definitions */ 
+SECTIONS 
+{ 
+    .text : 
+    { 
+        . = ALIGN(4);
+        _sfixed = .;
+        KEEP(*(.vectors .vectors.*))
+        *(.text .text.* .gnu.linkonce.t.*) 	      
+        *(.glue_7t) *(.glue_7)		                
+        *(.rodata .rodata* .gnu.linkonce.r.*)		    	                  
+        *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+        /* Support C constructors, and C destructors in both user code
+           and the C library. This also provides support for C++ code. */
+        . = ALIGN(4);
+        KEEP(*(.init))
+        . = ALIGN(4);
+        __preinit_array_start = .;
+        KEEP (*(.preinit_array))
+        __preinit_array_end = .;
+
+        . = ALIGN(4);
+        __init_array_start = .;
+        KEEP (*(SORT(.init_array.*)))
+        KEEP (*(.init_array))
+        __init_array_end = .;
+
+        . = ALIGN(0x4);
+        KEEP (*crtbegin.o(.ctors))
+        KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+        KEEP (*(SORT(.ctors.*)))
+        KEEP (*crtend.o(.ctors))
+
+        . = ALIGN(4);
+        KEEP(*(.fini))
+
+        . = ALIGN(4);
+        __fini_array_start = .;
+        KEEP (*(.fini_array))
+        KEEP (*(SORT(.fini_array.*)))
+        __fini_array_end = .;
+
+        KEEP (*crtbegin.o(.dtors))
+        KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+        KEEP (*(SORT(.dtors.*)))
+        KEEP (*crtend.o(.dtors))
+
+        . = ALIGN(4);
+        _efixed = .;            /* End of text section */
+    } > rom
+
+    /* .ARM.exidx is sorted, so has to go in its own output section.  */
+    PROVIDE_HIDDEN (__exidx_start = .);
+    .ARM.exidx :
+    {
+      *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+    } > rom
+    PROVIDE_HIDDEN (__exidx_end = .);
+
+    . = ALIGN(4); 
+    _etext = .;
+
+    .relocate : AT (_etext)
+    {
+        . = ALIGN(4);
+        _srelocate = .;
+        *(.ramfunc .ramfunc.*);
+        *(.data .data.*);
+        . = ALIGN(4);
+        _erelocate = .;
+    } > ram
+
+    /* .bss section which is used for uninitialized data */ 
+    .bss (NOLOAD) :
+    { 
+        . = ALIGN(4);
+        _sbss = . ;
+        _szero = .;
+        *(.bss .bss.*)
+        *(COMMON)
+        . = ALIGN(4);
+        _ebss = . ;
+        _ezero = .;
+    } > ram
+
+    /* stack section */
+    .stack (NOLOAD):
+    {
+        . = ALIGN(8);
+        *(.stack .stack.*)
+    } > ram
+
+    . = ALIGN(4); 
+    _end = . ; 
+}
diff --git a/firmware/libboard/common/resources/sam3s1/sram.ld b/firmware/libboard/common/resources/sam3s1/sram.ld
new file mode 100644
index 0000000..22b170a
--- /dev/null
+++ b/firmware/libboard/common/resources/sam3s1/sram.ld
@@ -0,0 +1,140 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2009, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*------------------------------------------------------------------------------
+ *      Linker script for running in internal SRAM on the ATSAM3S1
+ *----------------------------------------------------------------------------*/
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+	rom (rx)  : ORIGIN = 0x00400000, LENGTH = 0x00010000 /* Flash, 64K */
+	ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00004000 /* sram, 16K */
+}
+
+/* Section Definitions */ 
+SECTIONS 
+{ 
+    .text : 
+    { 
+        . = ALIGN(4);
+        _sfixed = .;
+        KEEP(*(.vectors .vectors.*))
+        *(.text .text.* .gnu.linkonce.t.*) 	      
+        *(.glue_7t) *(.glue_7)		                
+        *(.rodata .rodata* .gnu.linkonce.r.*)		    	                  
+        *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+        /* Support C constructors, and C destructors in both user code
+           and the C library. This also provides support for C++ code. */
+        . = ALIGN(4);
+        KEEP(*(.init))
+        . = ALIGN(4);
+        __preinit_array_start = .;
+        KEEP (*(.preinit_array))
+        __preinit_array_end = .;
+
+        . = ALIGN(4);
+        __init_array_start = .;
+        KEEP (*(SORT(.init_array.*)))
+        KEEP (*(.init_array))
+        __init_array_end = .;
+
+        . = ALIGN(0x4);
+        KEEP (*crtbegin.o(.ctors))
+        KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+        KEEP (*(SORT(.ctors.*)))
+        KEEP (*crtend.o(.ctors))
+
+        . = ALIGN(4);
+        KEEP(*(.fini))
+
+        . = ALIGN(4);
+        __fini_array_start = .;
+        KEEP (*(.fini_array))
+        KEEP (*(SORT(.fini_array.*)))
+        __fini_array_end = .;
+
+        KEEP (*crtbegin.o(.dtors))
+        KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+        KEEP (*(SORT(.dtors.*)))
+        KEEP (*crtend.o(.dtors))
+
+        . = ALIGN(4);
+        _efixed = .;            /* End of text section */
+    } > ram
+
+    . = ALIGN(4); 
+    _etext = .;
+
+    .relocate : AT (_etext)
+    {
+        . = ALIGN(4);
+        _srelocate = .;
+        *(.ramfunc .ramfunc.*);
+        *(.data .data.*);
+        . = ALIGN(4);
+        _erelocate = .;
+    } > ram
+
+    /* .bss section which is used for uninitialized data */ 
+    .bss (NOLOAD) :
+    { 
+        . = ALIGN(4);
+        _sbss = . ;
+        _szero = .;
+        *(.bss .bss.*)
+        *(COMMON)
+        . = ALIGN(4);
+        _ebss = . ;
+        _ezero = .;
+    } > ram
+
+    /* stack section */
+    .stack (NOLOAD):
+    {
+        . = ALIGN(8);
+        *(.stack .stack.*)
+    } > ram
+
+    /* .ARM.exidx is sorted, so has to go in its own output section.  */
+    PROVIDE_HIDDEN (__exidx_start = .);
+    .ARM.exidx :
+    {
+      *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+    } > ram
+    PROVIDE_HIDDEN (__exidx_end = .);
+
+    . = ALIGN(4); 
+    _end = . ; 
+}
diff --git a/firmware/libboard/common/resources/sam3s1/sram_samba.lds b/firmware/libboard/common/resources/sam3s1/sram_samba.lds
new file mode 100644
index 0000000..0f87ad3
--- /dev/null
+++ b/firmware/libboard/common/resources/sam3s1/sram_samba.lds
@@ -0,0 +1,91 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2009, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*------------------------------------------------------------------------------
+ *      Linker script for running in internal SRAM on the AT91SAM3S1
+ *----------------------------------------------------------------------------*/
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(entry)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+    romcodesram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x0800
+    sram (W!RX) : ORIGIN = 0x20000800, LENGTH = 0x00003800 /* sram, 16K - sizeof(romcodesram) */
+}
+
+/* Entry point */
+/*ENTRY (ResetException)*/
+
+SECTIONS
+{
+    /* startup code in the .isr_vector */
+    .text :
+    {
+        . = ALIGN(4);
+        _stext = .;
+        KEEP(*(.isr_vector .isr_vector.*))
+        *(.mailbox)
+        *(.text .text.*)
+        *(.rodata .rodata.*)
+        *(.glue_7)
+        *(.glue_7t)
+        *(.gcc_except_table)
+        *(.rodata .rodata*)
+        *(.gnu.linkonce.r.*)
+        . = ALIGN(4);
+        _etext = .;
+    } > sram
+
+    /* data */
+    .data :
+    {
+        . = ALIGN(4);
+        _sidata = .;
+        _sdata = .;
+
+        *(.data)
+        *(.data.*)
+        . = ALIGN(4);
+        _edata = .;
+    } > sram
+
+    .bss (NOLOAD) : {
+        _szero = .;
+        *(.bss)
+        . = ALIGN(4);
+        _ezero = .;
+    } >sram
+
+    /* Stack in SRAM */
+    _sstack = 0x20003FFC;
+}
+end = .;
diff --git a/firmware/libboard/common/resources/sam3s2/flash.ld b/firmware/libboard/common/resources/sam3s2/flash.ld
new file mode 100644
index 0000000..22cfe59
--- /dev/null
+++ b/firmware/libboard/common/resources/sam3s2/flash.ld
@@ -0,0 +1,140 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2009, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*------------------------------------------------------------------------------
+ *      Linker script for running in internal FLASH on the ATSAM3S2
+ *----------------------------------------------------------------------------*/
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+	rom (rx)  : ORIGIN = 0x00400000, LENGTH = 0x00020000 /* flash, 128K */
+	ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* sram, 32K */
+}
+
+/* Section Definitions */ 
+SECTIONS 
+{ 
+    .text : 
+    { 
+        . = ALIGN(4);
+        _sfixed = .;
+        KEEP(*(.vectors .vectors.*))
+        *(.text .text.* .gnu.linkonce.t.*) 	      
+        *(.glue_7t) *(.glue_7)		                
+        *(.rodata .rodata* .gnu.linkonce.r.*)		    	                  
+        *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+        /* Support C constructors, and C destructors in both user code
+           and the C library. This also provides support for C++ code. */
+        . = ALIGN(4);
+        KEEP(*(.init))
+        . = ALIGN(4);
+        __preinit_array_start = .;
+        KEEP (*(.preinit_array))
+        __preinit_array_end = .;
+
+        . = ALIGN(4);
+        __init_array_start = .;
+        KEEP (*(SORT(.init_array.*)))
+        KEEP (*(.init_array))
+        __init_array_end = .;
+
+        . = ALIGN(0x4);
+        KEEP (*crtbegin.o(.ctors))
+        KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+        KEEP (*(SORT(.ctors.*)))
+        KEEP (*crtend.o(.ctors))
+
+        . = ALIGN(4);
+        KEEP(*(.fini))
+
+        . = ALIGN(4);
+        __fini_array_start = .;
+        KEEP (*(.fini_array))
+        KEEP (*(SORT(.fini_array.*)))
+        __fini_array_end = .;
+
+        KEEP (*crtbegin.o(.dtors))
+        KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+        KEEP (*(SORT(.dtors.*)))
+        KEEP (*crtend.o(.dtors))
+
+        . = ALIGN(4);
+        _efixed = .;            /* End of text section */
+    } > rom
+
+    /* .ARM.exidx is sorted, so has to go in its own output section.  */
+    PROVIDE_HIDDEN (__exidx_start = .);
+    .ARM.exidx :
+    {
+      *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+    } > rom
+    PROVIDE_HIDDEN (__exidx_end = .);
+
+    . = ALIGN(4); 
+    _etext = .;
+
+    .relocate : AT (_etext)
+    {
+        . = ALIGN(4);
+        _srelocate = .;
+        *(.ramfunc .ramfunc.*);
+        *(.data .data.*);
+        . = ALIGN(4);
+        _erelocate = .;
+    } > ram
+
+    /* .bss section which is used for uninitialized data */ 
+    .bss (NOLOAD) :
+    { 
+        . = ALIGN(4);
+        _sbss = . ;
+        _szero = .;
+        *(.bss .bss.*)
+        *(COMMON)
+        . = ALIGN(4);
+        _ebss = . ;
+        _ezero = .;
+    } > ram
+
+    /* stack section */
+    .stack (NOLOAD):
+    {
+        . = ALIGN(8);
+        *(.stack .stack.*)
+    } > ram
+
+    . = ALIGN(4); 
+    _end = . ; 
+}
diff --git a/firmware/libboard/common/resources/sam3s2/sram.ld b/firmware/libboard/common/resources/sam3s2/sram.ld
new file mode 100644
index 0000000..8c14ac6
--- /dev/null
+++ b/firmware/libboard/common/resources/sam3s2/sram.ld
@@ -0,0 +1,140 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2009, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*------------------------------------------------------------------------------
+ *      Linker script for running in internal SRAM on the ATSAM3S2
+ *----------------------------------------------------------------------------*/
+
+OUTPUT_FORMAT ("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+	rom (rx)  : ORIGIN = 0x00400000, LENGTH = 0x00020000 /* flash, 128K */
+	ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* sram, 32K */
+}
+
+/* Section Definitions */ 
+SECTIONS 
+{ 
+    .text : 
+    { 
+        . = ALIGN(4);
+        _sfixed = .;
+        KEEP(*(.vectors .vectors.*))
+        *(.text .text.* .gnu.linkonce.t.*) 	      
+        *(.glue_7t) *(.glue_7)		                
+        *(.rodata .rodata* .gnu.linkonce.r.*)		    	                  
+        *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+        /* Support C constructors, and C destructors in both user code
+           and the C library. This also provides support for C++ code. */
+        . = ALIGN(4);
+        KEEP(*(.init))
+        . = ALIGN(4);
+        __preinit_array_start = .;
+        KEEP (*(.preinit_array))
+        __preinit_array_end = .;
+
+        . = ALIGN(4);
+        __init_array_start = .;
+        KEEP (*(SORT(.init_array.*)))
+        KEEP (*(.init_array))
+        __init_array_end = .;
+
+        . = ALIGN(0x4);
+        KEEP (*crtbegin.o(.ctors))
+        KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+        KEEP (*(SORT(.ctors.*)))
+        KEEP (*crtend.o(.ctors))
+
+        . = ALIGN(4);
+        KEEP(*(.fini))
+
+        . = ALIGN(4);
+        __fini_array_start = .;
+        KEEP (*(.fini_array))
+        KEEP (*(SORT(.fini_array.*)))
+        __fini_array_end = .;
+
+        KEEP (*crtbegin.o(.dtors))
+        KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+        KEEP (*(SORT(.dtors.*)))
+        KEEP (*crtend.o(.dtors))
+
+        . = ALIGN(4);
+        _efixed = .;            /* End of text section */
+    } > ram
+
+    . = ALIGN(4); 
+    _etext = .;
+
+    .relocate : AT (_etext)
+    {
+        . = ALIGN(4);
+        _srelocate = .;
+        *(.ramfunc .ramfunc.*);
+        *(.data .data.*);
+        . = ALIGN(4);
+        _erelocate = .;
+    } > ram
+
+    /* .bss section which is used for uninitialized data */ 
+    .bss (NOLOAD) :
+    { 
+        . = ALIGN(4);
+        _sbss = . ;
+        _szero = .;
+        *(.bss .bss.*)
+        *(COMMON)
+        . = ALIGN(4);
+        _ebss = . ;
+        _ezero = .;
+    } > ram
+
+    /* stack section */
+    .stack (NOLOAD):
+    {
+        . = ALIGN(8);
+        *(.stack .stack.*)
+    } > ram
+
+    /* .ARM.exidx is sorted, so has to go in its own output section.  */
+    PROVIDE_HIDDEN (__exidx_start = .);
+    .ARM.exidx :
+    {
+      *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+    } > ram
+    PROVIDE_HIDDEN (__exidx_end = .);
+
+    . = ALIGN(4); 
+    _end = . ; 
+}
diff --git a/firmware/libboard/common/resources/sam3s2/sram_samba.lds b/firmware/libboard/common/resources/sam3s2/sram_samba.lds
new file mode 100644
index 0000000..00040c8
--- /dev/null
+++ b/firmware/libboard/common/resources/sam3s2/sram_samba.lds
@@ -0,0 +1,91 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2009, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*------------------------------------------------------------------------------
+ *      Linker script for running in internal SRAM on the AT91SAM3S2
+ *----------------------------------------------------------------------------*/
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(entry)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+    romcodesram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x0800
+    sram (W!RX) : ORIGIN = 0x20000800, LENGTH = 0x00007800 /* sram, 32K - sizeof(romcodesram) */
+}
+
+/* Entry point */
+/*ENTRY (ResetException)*/
+
+SECTIONS
+{
+    /* startup code in the .isr_vector */
+    .text :
+    {
+        . = ALIGN(4);
+        _stext = .;
+        KEEP(*(.isr_vector .isr_vector.*))
+        *(.mailbox)
+        *(.text .text.*)
+        *(.rodata .rodata.*)
+        *(.glue_7)
+        *(.glue_7t)
+        *(.gcc_except_table)
+        *(.rodata .rodata*)
+        *(.gnu.linkonce.r.*)
+        . = ALIGN(4);
+        _etext = .;
+    } > sram
+
+    /* data */
+    .data :
+    {
+        . = ALIGN(4);
+        _sidata = .;
+        _sdata = .;
+
+        *(.data)
+        *(.data.*)
+        . = ALIGN(4);
+        _edata = .;
+    } > sram
+
+    .bss (NOLOAD) : {
+        _szero = .;
+        *(.bss)
+        . = ALIGN(4);
+        _ezero = .;
+    } >sram
+
+    /* Stack in SRAM */
+    _sstack = 0x20007FFC;
+}
+end = .;
diff --git a/firmware/libboard/common/resources/sam3s4/flash.ld b/firmware/libboard/common/resources/sam3s4/flash.ld
new file mode 100644
index 0000000..c47a2c5
--- /dev/null
+++ b/firmware/libboard/common/resources/sam3s4/flash.ld
@@ -0,0 +1,140 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2009, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*------------------------------------------------------------------------------
+ *      Linker script for running in internal FLASH on the ATSAM3S4
+ *----------------------------------------------------------------------------*/
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+	rom (rx)  : ORIGIN = 0x00400000, LENGTH = 0x00040000 /* flash, 256K */
+	ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x0000c000 /* sram, 48K */
+}
+
+/* Section Definitions */ 
+SECTIONS 
+{ 
+    .text : 
+    { 
+        . = ALIGN(4);
+        _sfixed = .;
+        KEEP(*(.vectors .vectors.*))
+        *(.text .text.* .gnu.linkonce.t.*) 	      
+        *(.glue_7t) *(.glue_7)		                
+        *(.rodata .rodata* .gnu.linkonce.r.*)		    	                  
+        *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+        /* Support C constructors, and C destructors in both user code
+           and the C library. This also provides support for C++ code. */
+        . = ALIGN(4);
+        KEEP(*(.init))
+        . = ALIGN(4);
+        __preinit_array_start = .;
+        KEEP (*(.preinit_array))
+        __preinit_array_end = .;
+
+        . = ALIGN(4);
+        __init_array_start = .;
+        KEEP (*(SORT(.init_array.*)))
+        KEEP (*(.init_array))
+        __init_array_end = .;
+
+        . = ALIGN(0x4);
+        KEEP (*crtbegin.o(.ctors))
+        KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+        KEEP (*(SORT(.ctors.*)))
+        KEEP (*crtend.o(.ctors))
+
+        . = ALIGN(4);
+        KEEP(*(.fini))
+
+        . = ALIGN(4);
+        __fini_array_start = .;
+        KEEP (*(.fini_array))
+        KEEP (*(SORT(.fini_array.*)))
+        __fini_array_end = .;
+
+        KEEP (*crtbegin.o(.dtors))
+        KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+        KEEP (*(SORT(.dtors.*)))
+        KEEP (*crtend.o(.dtors))
+
+        . = ALIGN(4);
+        _efixed = .;            /* End of text section */
+    } > rom
+
+    /* .ARM.exidx is sorted, so has to go in its own output section.  */
+    PROVIDE_HIDDEN (__exidx_start = .);
+    .ARM.exidx :
+    {
+      *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+    } > rom
+    PROVIDE_HIDDEN (__exidx_end = .);
+
+    . = ALIGN(4); 
+    _etext = .;
+
+    .relocate : AT (_etext)
+    {
+        . = ALIGN(4);
+        _srelocate = .;
+        *(.ramfunc .ramfunc.*);
+        *(.data .data.*);
+        . = ALIGN(4);
+        _erelocate = .;
+    } > ram
+
+    /* .bss section which is used for uninitialized data */ 
+    .bss (NOLOAD) :
+    { 
+        . = ALIGN(4);
+        _sbss = . ;
+        _szero = .;
+        *(.bss .bss.*)
+        *(COMMON)
+        . = ALIGN(4);
+        _ebss = . ;
+        _ezero = .;
+    } > ram
+
+    /* stack section */
+    .stack (NOLOAD):
+    {
+        . = ALIGN(8);
+        *(.stack .stack.*)
+    } > ram
+
+    . = ALIGN(4); 
+    _end = . ; 
+}
diff --git a/firmware/libboard/common/resources/sam3s4/sram.ld b/firmware/libboard/common/resources/sam3s4/sram.ld
new file mode 100644
index 0000000..9c68755
--- /dev/null
+++ b/firmware/libboard/common/resources/sam3s4/sram.ld
@@ -0,0 +1,140 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2009, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*------------------------------------------------------------------------------
+ *      Linker script for running in internal SRAM on the ATSAM3S4
+ *----------------------------------------------------------------------------*/
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+	rom (rx)  : ORIGIN = 0x00400000, LENGTH = 0x00040000 /* flash, 256K */
+	ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x0000c000 /* sram, 48K */
+}
+
+/* Section Definitions */ 
+SECTIONS 
+{ 
+    .text : 
+    { 
+        . = ALIGN(4);
+        _sfixed = .;
+        KEEP(*(.vectors .vectors.*))
+        *(.text .text.* .gnu.linkonce.t.*) 	      
+        *(.glue_7t) *(.glue_7)		                
+        *(.rodata .rodata* .gnu.linkonce.r.*)		    	                  
+        *(.ARM.extab* .gnu.linkonce.armextab.*)
+
+        /* Support C constructors, and C destructors in both user code
+           and the C library. This also provides support for C++ code. */
+        . = ALIGN(4);
+        KEEP(*(.init))
+        . = ALIGN(4);
+        __preinit_array_start = .;
+        KEEP (*(.preinit_array))
+        __preinit_array_end = .;
+
+        . = ALIGN(4);
+        __init_array_start = .;
+        KEEP (*(SORT(.init_array.*)))
+        KEEP (*(.init_array))
+        __init_array_end = .;
+
+        . = ALIGN(0x4);
+        KEEP (*crtbegin.o(.ctors))
+        KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+        KEEP (*(SORT(.ctors.*)))
+        KEEP (*crtend.o(.ctors))
+
+        . = ALIGN(4);
+        KEEP(*(.fini))
+
+        . = ALIGN(4);
+        __fini_array_start = .;
+        KEEP (*(.fini_array))
+        KEEP (*(SORT(.fini_array.*)))
+        __fini_array_end = .;
+
+        KEEP (*crtbegin.o(.dtors))
+        KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+        KEEP (*(SORT(.dtors.*)))
+        KEEP (*crtend.o(.dtors))
+
+        . = ALIGN(4);
+        _efixed = .;            /* End of text section */
+    } > ram
+
+    . = ALIGN(4); 
+    _etext = .;
+
+    .relocate : AT (_etext)
+    {
+        . = ALIGN(4);
+        _srelocate = .;
+        *(.ramfunc .ramfunc.*);
+        *(.data .data.*);
+        . = ALIGN(4);
+        _erelocate = .;
+    } > ram
+
+    /* .bss section which is used for uninitialized data */ 
+    .bss (NOLOAD) :
+    { 
+        . = ALIGN(4);
+        _sbss = . ;
+        _szero = .;
+        *(.bss .bss.*)
+        *(COMMON)
+        . = ALIGN(4);
+        _ebss = . ;
+        _ezero = .;
+    } > ram
+
+    /* stack section */
+    .stack (NOLOAD):
+    {
+        . = ALIGN(8);
+        *(.stack .stack.*)
+    } > ram
+
+    /* .ARM.exidx is sorted, so has to go in its own output section.  */
+    PROVIDE_HIDDEN (__exidx_start = .);
+    .ARM.exidx :
+    {
+      *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+    } > ram
+    PROVIDE_HIDDEN (__exidx_end = .);
+
+    . = ALIGN(4); 
+    _end = . ; 
+}
diff --git a/firmware/libboard/common/resources/sam3s4/sram_samba.lds b/firmware/libboard/common/resources/sam3s4/sram_samba.lds
new file mode 100644
index 0000000..16b1dc9
--- /dev/null
+++ b/firmware/libboard/common/resources/sam3s4/sram_samba.lds
@@ -0,0 +1,91 @@
+/* ----------------------------------------------------------------------------
+ *         ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2009, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*------------------------------------------------------------------------------
+ *      Linker script for running in internal SRAM on the AT91SAM3S4
+ *----------------------------------------------------------------------------*/
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(entry)
+
+/* Memory Spaces Definitions */
+MEMORY
+{
+    romcodesram (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x01000
+    sram (W!RX) : ORIGIN = 0x20001000, LENGTH = 0x0000B000 /* sram, 48K - sizeof(romcodesram) */
+}
+
+/* Entry point */
+/*ENTRY (ResetException)*/
+
+SECTIONS
+{
+    /* startup code in the .isr_vector */
+    .text :
+    {
+        . = ALIGN(4);
+        _stext = .;
+        KEEP(*(.isr_vector .isr_vector.*))
+        *(.mailbox)
+        *(.text .text.*)
+        *(.rodata .rodata.*)
+        *(.glue_7)
+        *(.glue_7t)
+        *(.gcc_except_table)
+        *(.rodata .rodata*)
+        *(.gnu.linkonce.r.*)
+        . = ALIGN(4);
+        _etext = .;
+    } > sram
+
+    /* data */
+    .data :
+    {
+        . = ALIGN(4);
+        _sidata = .;
+        _sdata = .;
+
+        *(.data)
+        *(.data.*)
+        . = ALIGN(4);
+        _edata = .;
+    } > sram
+
+    .bss (NOLOAD) : {
+        _szero = .;
+        *(.bss)
+        . = ALIGN(4);
+        _ezero = .;
+    } >sram
+
+    /* Stack in SRAM */
+    _sstack = 0x2000BFFC;
+}
+end = .;
diff --git a/firmware/libboard/common/resources/sam3s_ek_flash.gdb b/firmware/libboard/common/resources/sam3s_ek_flash.gdb
new file mode 100644
index 0000000..7d79615
--- /dev/null
+++ b/firmware/libboard/common/resources/sam3s_ek_flash.gdb
@@ -0,0 +1,31 @@
+#*******************************************************
+#
+#  Connect to J-Link and debug application in flash.
+#
+
+# define 'reset' command
+define reset
+
+# Connect to the J-Link gdb server
+target remote localhost:2331
+# Reset the chip to get to a known state
+monitor reset
+
+# Select flash device
+monitor flash device = AT91SAM3S4C
+# Enable flash download and flash breakpoints
+monitor flash download = 1
+# Load the program
+load
+
+# Reset peripheral  (RSTC_CR)
+set *0x400e1400 = 0xA5000004
+
+# Initializing PC and stack pointer
+mon reg sp=(0x400000)
+set *0x400004 = *0x400004 & 0xFFFFFFFE
+mon reg pc=(0x400004)
+info reg
+
+# end of 'reset' command
+end
diff --git a/firmware/libboard/common/resources/sam3s_ek_sram.gdb b/firmware/libboard/common/resources/sam3s_ek_sram.gdb
new file mode 100644
index 0000000..019bd0a
--- /dev/null
+++ b/firmware/libboard/common/resources/sam3s_ek_sram.gdb
@@ -0,0 +1,27 @@
+#*************************************************
+#
+#  Connect to J-Link and debug application in sram on SAM3S
+#
+# Note:
+#     First, users should modify Step1 and Step2 according to their project,
+#     then do Step3.
+
+# Step1: Connect to the J-Link gdb server
+define reset
+target remote localhost:2331
+monitor reset
+
+# Step2: Load file(eg. getting-started project)
+load
+
+# Step3: Reset peripheral  (RSTC_CR)
+set *0x400e1400 = 0xA5000004
+
+# Step4: Initializing PC and stack pointer
+# Modify pc value to even before writing pc register
+mon reg sp=(0x20000000)
+set *0x20000004 = *0x20000004 & 0xFFFFFFFE
+mon reg pc=(0x20000004)
+info reg
+
+end
diff --git a/firmware/libboard/common/resources/sam3s_vb_sram.gdb b/firmware/libboard/common/resources/sam3s_vb_sram.gdb
new file mode 100644
index 0000000..019bd0a
--- /dev/null
+++ b/firmware/libboard/common/resources/sam3s_vb_sram.gdb
@@ -0,0 +1,27 @@
+#*************************************************
+#
+#  Connect to J-Link and debug application in sram on SAM3S
+#
+# Note:
+#     First, users should modify Step1 and Step2 according to their project,
+#     then do Step3.
+
+# Step1: Connect to the J-Link gdb server
+define reset
+target remote localhost:2331
+monitor reset
+
+# Step2: Load file(eg. getting-started project)
+load
+
+# Step3: Reset peripheral  (RSTC_CR)
+set *0x400e1400 = 0xA5000004
+
+# Step4: Initializing PC and stack pointer
+# Modify pc value to even before writing pc register
+mon reg sp=(0x20000000)
+set *0x20000004 = *0x20000004 & 0xFFFFFFFE
+mon reg pc=(0x20000004)
+info reg
+
+end
diff --git a/firmware/src_board/board_cstartup_gnu.c b/firmware/libboard/common/source/board_cstartup_gnu.c
similarity index 100%
rename from firmware/src_board/board_cstartup_gnu.c
rename to firmware/libboard/common/source/board_cstartup_gnu.c
diff --git a/firmware/src_board/board_lowlevel.c b/firmware/libboard/common/source/board_lowlevel.c
similarity index 100%
rename from firmware/src_board/board_lowlevel.c
rename to firmware/libboard/common/source/board_lowlevel.c
diff --git a/firmware/src_board/boardver_adc.c b/firmware/libboard/common/source/boardver_adc.c
similarity index 100%
rename from firmware/src_board/boardver_adc.c
rename to firmware/libboard/common/source/boardver_adc.c
diff --git a/firmware/src_board/led.c b/firmware/libboard/common/source/led.c
similarity index 100%
rename from firmware/src_board/led.c
rename to firmware/libboard/common/source/led.c
diff --git a/firmware/src_board/uart_console.c b/firmware/libboard/common/source/uart_console.c
similarity index 100%
rename from firmware/src_board/uart_console.c
rename to firmware/libboard/common/source/uart_console.c
diff --git a/firmware/include_board/owhw/board.h b/firmware/libboard/owhw/include/board.h
similarity index 100%
rename from firmware/include_board/owhw/board.h
rename to firmware/libboard/owhw/include/board.h
diff --git a/firmware/src_board/owhw.c b/firmware/libboard/owhw/source/owhw.c
similarity index 100%
rename from firmware/src_board/owhw.c
rename to firmware/libboard/owhw/source/owhw.c
diff --git a/firmware/include_board/qmod/board.h b/firmware/libboard/qmod/include/board.h
similarity index 100%
rename from firmware/include_board/qmod/board.h
rename to firmware/libboard/qmod/include/board.h
diff --git a/firmware/src_simtrace/i2c.h b/firmware/libboard/qmod/include/i2c.h
similarity index 100%
rename from firmware/src_simtrace/i2c.h
rename to firmware/libboard/qmod/include/i2c.h
diff --git a/firmware/src_simtrace/wwan_led.h b/firmware/libboard/qmod/include/wwan_led.h
similarity index 100%
rename from firmware/src_simtrace/wwan_led.h
rename to firmware/libboard/qmod/include/wwan_led.h
diff --git a/firmware/src_simtrace/wwan_perst.h b/firmware/libboard/qmod/include/wwan_perst.h
similarity index 100%
rename from firmware/src_simtrace/wwan_perst.h
rename to firmware/libboard/qmod/include/wwan_perst.h
diff --git a/firmware/src_simtrace/i2c.c b/firmware/libboard/qmod/source/i2c.c
similarity index 100%
rename from firmware/src_simtrace/i2c.c
rename to firmware/libboard/qmod/source/i2c.c
diff --git a/firmware/src_simtrace/wwan_led.c b/firmware/libboard/qmod/source/wwan_led.c
similarity index 100%
rename from firmware/src_simtrace/wwan_led.c
rename to firmware/libboard/qmod/source/wwan_led.c
diff --git a/firmware/src_simtrace/wwan_perst.c b/firmware/libboard/qmod/source/wwan_perst.c
similarity index 100%
rename from firmware/src_simtrace/wwan_perst.c
rename to firmware/libboard/qmod/source/wwan_perst.c
diff --git a/firmware/include_board/simtrace/board.h b/firmware/libboard/simtrace/include/board.h
similarity index 100%
rename from firmware/include_board/simtrace/board.h
rename to firmware/libboard/simtrace/include/board.h
diff --git a/firmware/src_simtrace/iso7816_fidi.h b/firmware/libcommon/include/iso7816_fidi.h
similarity index 100%
rename from firmware/src_simtrace/iso7816_fidi.h
rename to firmware/libcommon/include/iso7816_fidi.h
diff --git a/firmware/src_simtrace/llist_irqsafe.h b/firmware/libcommon/include/llist_irqsafe.h
similarity index 100%
rename from firmware/src_simtrace/llist_irqsafe.h
rename to firmware/libcommon/include/llist_irqsafe.h
diff --git a/firmware/src_simtrace/req_ctx.h b/firmware/libcommon/include/req_ctx.h
similarity index 100%
rename from firmware/src_simtrace/req_ctx.h
rename to firmware/libcommon/include/req_ctx.h
diff --git a/firmware/src_simtrace/ringbuffer.h b/firmware/libcommon/include/ringbuffer.h
similarity index 100%
rename from firmware/src_simtrace/ringbuffer.h
rename to firmware/libcommon/include/ringbuffer.h
diff --git a/firmware/include_board/syscalls.h b/firmware/libcommon/include/syscalls.h
similarity index 100%
rename from firmware/include_board/syscalls.h
rename to firmware/libcommon/include/syscalls.h
diff --git a/firmware/src_simtrace/utils.h b/firmware/libcommon/include/utils.h
similarity index 100%
rename from firmware/src_simtrace/utils.h
rename to firmware/libcommon/include/utils.h
diff --git a/firmware/src_simtrace/iso7816_fidi.c b/firmware/libcommon/source/iso7816_fidi.c
similarity index 100%
rename from firmware/src_simtrace/iso7816_fidi.c
rename to firmware/libcommon/source/iso7816_fidi.c
diff --git a/firmware/src_simtrace/req_ctx.c b/firmware/libcommon/source/req_ctx.c
similarity index 100%
rename from firmware/src_simtrace/req_ctx.c
rename to firmware/libcommon/source/req_ctx.c
diff --git a/firmware/src_simtrace/ringbuffer.c b/firmware/libcommon/source/ringbuffer.c
similarity index 100%
rename from firmware/src_simtrace/ringbuffer.c
rename to firmware/libcommon/source/ringbuffer.c
diff --git a/firmware/src_board/syscalls.c b/firmware/libcommon/source/syscalls.c
similarity index 100%
rename from firmware/src_board/syscalls.c
rename to firmware/libcommon/source/syscalls.c
diff --git a/firmware/include_libosmocore/osmocom/core/linuxlist.h b/firmware/libosmocore/include/osmocom/core/linuxlist.h
similarity index 100%
rename from firmware/include_libosmocore/osmocom/core/linuxlist.h
rename to firmware/libosmocore/include/osmocom/core/linuxlist.h
diff --git a/firmware/include_libosmocore/osmocom/core/linuxrbtree.h b/firmware/libosmocore/include/osmocom/core/linuxrbtree.h
similarity index 100%
rename from firmware/include_libosmocore/osmocom/core/linuxrbtree.h
rename to firmware/libosmocore/include/osmocom/core/linuxrbtree.h
diff --git a/firmware/include_libosmocore/osmocom/core/timer.h b/firmware/libosmocore/include/osmocom/core/timer.h
similarity index 100%
rename from firmware/include_libosmocore/osmocom/core/timer.h
rename to firmware/libosmocore/include/osmocom/core/timer.h
diff --git a/firmware/src_simtrace/rbtree.c b/firmware/libosmocore/source/rbtree.c
similarity index 100%
rename from firmware/src_simtrace/rbtree.c
rename to firmware/libosmocore/source/rbtree.c
diff --git a/firmware/src_libosmocore/timer.c b/firmware/libosmocore/source/timer.c
similarity index 100%
rename from firmware/src_libosmocore/timer.c
rename to firmware/libosmocore/source/timer.c