mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-24 22:13:52 +01:00
Merge pull request #7739 from kYc0o/factorise_sam0_ldscripts
ld: refactor sam0 ldscripts
This commit is contained in:
commit
f6d7e54228
@ -16,8 +16,9 @@ ifeq ($(PROGRAMMER),jlink)
|
||||
include $(RIOTMAKE)/tools/jlink.inc.mk
|
||||
else
|
||||
# by default, we use BOSSA to flash this board and take into account the
|
||||
# preinstalled Arduino bootloader.
|
||||
export LINKER_SCRIPT ?= $(RIOTCPU)/sam0_common/ldscripts/$(CPU_MODEL)_arduino_bootloader.ld
|
||||
# preinstalled Arduino bootloader. ROM_OFFSET skips the space taken by
|
||||
# such bootloader.
|
||||
ROM_OFFSET ?= 0x2000
|
||||
include $(RIOTMAKE)/tools/bossa.inc.mk
|
||||
endif
|
||||
|
||||
|
||||
@ -16,8 +16,9 @@ ifeq ($(PROGRAMMER),jlink)
|
||||
include $(RIOTMAKE)/tools/jlink.inc.mk
|
||||
else
|
||||
# by default, we use BOSSA to flash this board to take into account the
|
||||
# pre-flashed Arduino bootloader
|
||||
export LINKER_SCRIPT ?= $(RIOTCPU)/sam0_common/ldscripts/$(CPU_MODEL)_arduino_bootloader.ld
|
||||
# pre-flashed Arduino bootloader. ROM_OFFSET skips the space taken by
|
||||
# such bootloader.
|
||||
ROM_OFFSET ?= 0x2000
|
||||
include $(RIOTMAKE)/tools/bossa.inc.mk
|
||||
endif
|
||||
|
||||
|
||||
@ -1,3 +1,14 @@
|
||||
# include module specific includes
|
||||
INCLUDES += -I$(RIOTCPU)/cortexm_common/include
|
||||
INCLUDES += -I$(RIOTCPU)/cortexm_common/include/vendor
|
||||
|
||||
ifneq (,$(ROM_OFFSET))
|
||||
LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_rom_offset=$(ROM_OFFSET)
|
||||
endif
|
||||
|
||||
ifneq (,$(ROM_START_ADDR)$(RAM_START_ADDR)$(ROM_LEN)$(RAM_LEN))
|
||||
LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_rom_start_addr=$(ROM_START_ADDR)
|
||||
LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_ram_start_addr=$(RAM_START_ADDR)
|
||||
LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_rom_length=$(ROM_LEN)
|
||||
LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_ram_length=$(RAM_LEN)
|
||||
endif
|
||||
|
||||
29
cpu/cortexm_common/ldscripts/cortexm.ld
Normal file
29
cpu/cortexm_common/ldscripts/cortexm.ld
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Inria
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup cpu_cortexm_common
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Memory definitions for the Cortex-M family
|
||||
*
|
||||
* @author Francisco Acosta <francisco.acosta@inria.fr>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
_boot_offset = DEFINED( _rom_offset ) ? _rom_offset : 0x0 ;
|
||||
|
||||
MEMORY
|
||||
{
|
||||
rom (rx) : ORIGIN = _rom_start_addr + _boot_offset, LENGTH = _rom_length - _boot_offset
|
||||
ram (rwx) : ORIGIN = _ram_start_addr, LENGTH = _ram_length
|
||||
}
|
||||
|
||||
INCLUDE cortexm_base.ld
|
||||
@ -1,11 +1,20 @@
|
||||
# Define the CPU family so we can differentiate between them in the code
|
||||
CFLAGS += -DCPU_FAM_$(shell echo $(CPU_FAM) | tr 'a-z-' 'A-Z_')
|
||||
|
||||
# Set ROM and RAM lengths according to CPU model
|
||||
ifneq (,$(filter samd21g18a samd21j18a saml21j18b saml21j18a samr21g18a,$(CPU_MODEL)))
|
||||
ROM_LEN ?= 0x40000
|
||||
RAM_LEN ?= 0x8000
|
||||
endif
|
||||
|
||||
ROM_START_ADDR ?= 0x00000000
|
||||
RAM_START_ADDR ?= 0x20000000
|
||||
|
||||
# this CPU implementation doesn't use CMSIS initialization
|
||||
export CFLAGS += -DDONT_USE_CMSIS_INIT
|
||||
|
||||
# for the sam[drl] CPUs we hold all linkerscripts in the sam0 common folder
|
||||
export LINKFLAGS += -L$(RIOTCPU)/sam0_common/ldscripts
|
||||
# For Cortex-M cpu we use the common cortexm.ld linker script
|
||||
LINKER_SCRIPT ?= cortexm.ld
|
||||
|
||||
# use common periph functions
|
||||
USEMODULE += periph_common
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
### Atmel SAM0 linker scripts notes
|
||||
|
||||
This folder contains SAM0 CPU specific linker scripts that are used to generate
|
||||
the final binary firmware.
|
||||
|
||||
There are 2 kinds of scripts:
|
||||
|
||||
* <name of cpu>.ld: used to generate a firmware that starts at the
|
||||
beginning of the flash memory. The firmware is copied to the flash memory
|
||||
using [OpenOCD](https://github.com/ntfreak/openocd).
|
||||
|
||||
* <name of cpu>\_arduino\_bootloader.ld: used to generate a firmware
|
||||
that starts after a preflashed Arduino bootloader. The firmware is copied to
|
||||
the flash memory using [Bossa](https://github.com/shumatech/BOSSA).
|
||||
This is the kind of configuration used with Arduino MKR and Adafruit Feather
|
||||
M0 boards.
|
||||
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015, 2016 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup cpu_samd21
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Memory definitions for the SAMD21DG18A
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
rom (rx) : ORIGIN = 0x00000000, LENGTH = 256K
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
|
||||
}
|
||||
|
||||
INCLUDE cortexm_base.ld
|
||||
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2017 Freie Universität Berlin
|
||||
* 2017 Inria
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup cpu_samd21
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Memory definitions for the SAMD21DG18A when used with a
|
||||
* preinstalled bootloader.
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
rom (rx) : ORIGIN = 0x00002000, LENGTH = 256K-0x2000
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
|
||||
}
|
||||
|
||||
INCLUDE cortexm_base.ld
|
||||
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015, 2016 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup cpu_samd21
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Memory definitions for the SAMD21J18A
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
rom (rx) : ORIGIN = 0x00000000, LENGTH = 256K
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
|
||||
}
|
||||
|
||||
INCLUDE cortexm_base.ld
|
||||
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup cpu_saml21
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Memory definitions for the SAML21J18A
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
rom (rx) : ORIGIN = 0x00000000, LENGTH = 256K
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
|
||||
}
|
||||
|
||||
INCLUDE cortexm_base.ld
|
||||
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015, 2016 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup cpu_samd21
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Memory definitions for the SAMR21E18A
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
rom (rx) : ORIGIN = 0x00000000, LENGTH = 256K
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
|
||||
}
|
||||
|
||||
INCLUDE cortexm_base.ld
|
||||
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015, 2016 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup cpu_samd21
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Memory definitions for the SAMR21G18A
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
rom (rx) : ORIGIN = 0x00000000, LENGTH = 256K
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
|
||||
}
|
||||
|
||||
INCLUDE cortexm_base.ld
|
||||
Loading…
x
Reference in New Issue
Block a user