diff --git a/conf/Makefile.chibios b/conf/Makefile.chibios index c0524a0f8d..7e96ec1879 100644 --- a/conf/Makefile.chibios +++ b/conf/Makefile.chibios @@ -30,7 +30,28 @@ BOARD_DIR ?= $(BOARD)/chibios CHIBIOS_BOARD_DIR = $(PAPARAZZI_SRC)/sw/airborne/boards/$(BOARD_DIR) # chibos linker scripts directory +# to keep backwards compatibility with Luftboot (Lia/Lisa M) +# and possibly other bootloaders (like PX4 bootloader) +# we need to keep a separate linker script with a memory offset +# because it is not possible to pass it dynamicaly to the linker +# hence we have two destinations for linker scripts +CHIBIOS_BOOTLOADER_SCRIPT = +# check if we used 1 to define presence of luftboot +ifeq ($(HAS_LUFTBOOT),1) + CHIBIOS_BOOTLOADER_SCRIPT = 1 +endif +# check if we used TRUE to define presence of luftboot +ifeq ($(HAS_LUFTBOOT),TRUE) + CHIBIOS_BOOTLOADER_SCRIPT = 1 +endif + +ifdef CHIBIOS_BOOTLOADER_SCRIPT +# we use the modified linker script +CHIBIOS_LINKER_DIR ?= $(PAPARAZZI_SRC)/sw/airborne/arch/chibios/ +else +# we use the original linker script CHIBIOS_LINKER_DIR ?= $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/ld +endif # Launch with "make Q=''" to get full command display Q=@ diff --git a/conf/boards/lia_1.1_chibios.makefile b/conf/boards/lia_1.1_chibios.makefile index bf6919bd4b..d01c3b20ac 100644 --- a/conf/boards/lia_1.1_chibios.makefile +++ b/conf/boards/lia_1.1_chibios.makefile @@ -28,7 +28,7 @@ PROJECT = $(TARGET) # Project specific files and paths (see Makefile.chibios for details) CHIBIOS_BOARD_PLATFORM = STM32F1xx/platform.mk -CHIBIOS_BOARD_LINKER = STM32F107xC.ld +# CHIBIOS_BOARD_LINKER script depends on whether we use a bootloader or not, see below CHIBIOS_BOARD_STARTUP = startup_stm32f1xx.mk ############################################################################## @@ -42,7 +42,10 @@ FLASH_MODE ?= DFU HAS_LUFTBOOT ?= 1 ifeq (,$(findstring $(HAS_LUFTBOOT),0 FALSE)) -$(TARGET).CFLAGS+=-DLUFTBOOT -DCORTEX_VTOR_INIT=0x00002000 +$(TARGET).CFLAGS+=-DLUFTBOOT -DCORTEX_VTOR_INIT=0x00002000 -Tflash=0x8002000 +CHIBIOS_BOARD_LINKER = STM32F107xC_luftboot.ld +else +CHIBIOS_BOARD_LINKER = STM32F107xC.ld endif # diff --git a/conf/flash_modes.xml b/conf/flash_modes.xml index 55c9a1f0dc..57ba383740 100644 --- a/conf/flash_modes.xml +++ b/conf/flash_modes.xml @@ -47,6 +47,7 @@ + diff --git a/sw/airborne/arch/chibios/STM32F107xC_luftboot.ld b/sw/airborne/arch/chibios/STM32F107xC_luftboot.ld new file mode 100644 index 0000000000..d6e900613f --- /dev/null +++ b/sw/airborne/arch/chibios/STM32F107xC_luftboot.ld @@ -0,0 +1,50 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + * ST32F107xC memory setup. + */ +MEMORY +{ + flash : org = 0x08002000, len = 256k + ram0 : org = 0x20000000, len = 64k + ram1 : org = 0x00000000, len = 0 + ram2 : org = 0x00000000, len = 0 + ram3 : org = 0x00000000, len = 0 + ram4 : org = 0x00000000, len = 0 + ram5 : org = 0x00000000, len = 0 + ram6 : org = 0x00000000, len = 0 + ram7 : org = 0x00000000, len = 0 +} + +/* RAM region to be used for Main stack. This stack accommodates the processing + of all exceptions and interrupts*/ +REGION_ALIAS("MAIN_STACK_RAM", ram0); + +/* RAM region to be used for the process stack. This is the stack used by + the main() function.*/ +REGION_ALIAS("PROCESS_STACK_RAM", ram0); + +/* RAM region to be used for data segment.*/ +REGION_ALIAS("DATA_RAM", ram0); + +/* RAM region to be used for BSS segment.*/ +REGION_ALIAS("BSS_RAM", ram0); + +/* RAM region to be used for the default heap.*/ +REGION_ALIAS("HEAP_RAM", ram0); + +INCLUDE rules.ld