Skip to content

Commit

Permalink
🔀 Merge branch 'ladislas/feature/option-mcuboot' into develop
Browse files Browse the repository at this point in the history
* ladislas/feature/option-mcuboot:
  🔧 (bootloader): Add ENABLE_BOOTLOADER make/cmake configuration option
  • Loading branch information
ladislas committed Jul 5, 2021
2 parents fd2a652 + fc8f67f commit 52f1ee3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ add_compile_options(
set(ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
set(MBED_OS_DIR ${ROOT_DIR}/extern/mbed-os)

# Bootloader option
option(ENABLE_BOOTLOADER "Build LekaOS with bootloader" OFF)
message(STATUS "ENABLE_BOOTLOADER (Build LekaOS with bootloader) --> ${ENABLE_BOOTLOADER}")
if (ENABLE_BOOTLOADER)
set(MBED_APP_FLAGS
-DMBED_APP_START=0x08040000
-DMBED_APP_SIZE=0x180000
)
endif(ENABLE_BOOTLOADER)

# And include mbed-cmake.cmake
include(./mbed-cmake.cmake)

Expand Down
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ VERSION ?= $(shell cat $(ROOT_DIR)/.mbed_version)
BAUDRATE ?= 115200
BUILD_TYPE ?= Release
TARGET_BOARD ?= LEKA_V1_2_DEV
CODE_ANALYSIS ?= OFF

#
# MARK: - Options
#

ENABLE_CODE_ANALYSIS ?= OFF
ENABLE_BOOTLOADER ?= OFF

#
# MARK: - Build dirs
Expand Down Expand Up @@ -114,12 +120,12 @@ config_tools_target: mkdir_cmake_config
config_cmake_build: mkdir_tools_config
@echo ""
@echo "🏃 Running cmake configuration script for target $(TARGET_BOARD) 📝"
@cmake -S . -B $(TARGET_BUILD_DIR) -GNinja -DCMAKE_CONFIG_DIR="$(CMAKE_CONFIG_DIR)" -DTARGET_BOARD="$(TARGET_BOARD)" -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_CODE_ANALYSIS=$(CODE_ANALYSIS)
@cmake -S . -B $(TARGET_BUILD_DIR) -GNinja -DCMAKE_CONFIG_DIR="$(CMAKE_CONFIG_DIR)" -DTARGET_BOARD="$(TARGET_BOARD)" -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DENABLE_CODE_ANALYSIS=$(ENABLE_CODE_ANALYSIS) -DENABLE_BOOTLOADER=$(ENABLE_BOOTLOADER)

config_tools_build: mkdir_tools_config
@echo ""
@echo "🏃 Running cmake configuration script for target $(TARGET_BOARD) 📝"
@cmake -S . -B $(CMAKE_TOOLS_BUILD_DIR) -GNinja -DCMAKE_CONFIG_DIR="$(CMAKE_TOOLS_CONFIG_DIR)" -DTARGET_BOARD="$(TARGET_BOARD)" -DCMAKE_BUILD_TYPE=Debug -DENABLE_CODE_ANALYSIS=$(CODE_ANALYSIS)
@cmake -S . -B $(CMAKE_TOOLS_BUILD_DIR) -GNinja -DCMAKE_CONFIG_DIR="$(CMAKE_TOOLS_CONFIG_DIR)" -DTARGET_BOARD="$(TARGET_BOARD)" -DCMAKE_BUILD_TYPE=Debug -DENABLE_CODE_ANALYSIS=$(ENABLE_CODE_ANALYSIS)

#
# MARK: - Tests targets
Expand Down
2 changes: 1 addition & 1 deletion cmake/ToolchainGCCArmBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(PREPROCESSED_LINKER_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/${LINKER_SCRIPT_FILEN

# NOTE: clearly the linker script is not assembly! We give -x assembler-with-cpp to force GCC to try and compile the file
# as if it was assembly. It only gets to the preprocessor stage because of -E, and everything works fine.
set(PREPROCESS_ONLY_FLAGS -x assembler-with-cpp -E -Wp,-P ${CMAKE_EXE_LINKER_FLAGS})
set(PREPROCESS_ONLY_FLAGS -x assembler-with-cpp -E -Wp,-P ${MBED_APP_FLAGS} ${CMAKE_EXE_LINKER_FLAGS})

# This is kind of a hack, but without it we would have to have a seperate facility for finding the preprocessor executable.
# We also needed to pass the linker flags because they can include defines needed in the linker script
Expand Down

0 comments on commit 52f1ee3

Please sign in to comment.