-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from JohnK1987/master
Update the custom target example
- Loading branch information
Showing
10 changed files
with
149 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,76 @@ | ||
cmake_minimum_required(VERSION 3.19) | ||
cmake_policy(VERSION 3.19) | ||
|
||
# Initialize Mbed OS build system. | ||
# Note: This block must be before the include of app.cmake | ||
set(MBED_APP_JSON_PATH mbed_app.json) | ||
set(CUSTOM_TARGETS_JSON_PATH custom_targets.json) # This activates the custom targets in custom_targets.json | ||
#### Initialize Mbed OS build system. #### | ||
###################################################################################################### | ||
### Block of including .json5 files. Files of this block must be included before the app.cmake | ||
|
||
#[[ Set path of mbed_app.json (necessary everytime if mbed_app.json5 is in project) ]] | ||
set(MBED_APP_JSON_PATH mbed_app.json5) | ||
|
||
###--------------------------------------------------------------------------------------------------- | ||
#[[ This part is dedicated for custom targets only! Settings below activate targets from | ||
custom_targets.json5 and upload method config, otherwise functions below should be commented. ]] | ||
|
||
#[[ Here set path for custom_targets.json5 (this is our default) ]] | ||
set(CUSTOM_TARGETS_JSON_PATH custom_targets/custom_targets.json5) | ||
|
||
#[[ Here you can set path for custom upload config .cmake (optional example) ]] | ||
# set(CUSTOM_UPLOAD_CFG_PATH ${CMAKE_SOURCE_DIR}/${MBED_TARGET}/${MBED_TARGET}.cmake) | ||
|
||
#[[ Note: For custom target you need also an upload method and we have few options how you can do that | ||
- use the variable CUSTOM_UPLOAD_CFG_PATH above | ||
- use default expected path for custom targets upload methods where you create your own config | ||
MY_PROJECT/custom_targets/upload_method_cfg | ||
- of course you can do it by yourself directly via cmake in this file | ||
For more visit https://github.com/mbed-ce/mbed-os/wiki/Upload-Methods ]] | ||
|
||
### End of block | ||
###################################################################################################### | ||
|
||
### include app.cmake (necessary everytime) ### | ||
include(mbed-os/tools/cmake/app.cmake) | ||
|
||
# Include folder with the custom targets. | ||
# This needs to be done before add_subdirectory(mbed-os). | ||
###################################################################################################### | ||
### Block of including project folders | ||
|
||
#[[ If using a custom target, the subdirectory containing the custom target must be included before | ||
the mbed-os subdir, otherwise the next line should be commented]] | ||
add_subdirectory(custom_targets) | ||
|
||
###-------------------------------------------------------------------------------------------------- | ||
## Add mbed-os subdirectory (necessary everytime) | ||
add_subdirectory(mbed-os) | ||
|
||
###-------------------------------------------------------------------------------------------------- | ||
## Add another subdirectory, for example subdirectory of a library (if needed) | ||
#add_subdirectory(YourLibrary) | ||
|
||
### End of block | ||
###################################################################################################### | ||
|
||
### Set up your project name (necessary everytime) | ||
project(mbed-ce-custom-targets) | ||
|
||
# add subdirectories and build targets here | ||
|
||
mbed_finalize_build() | ||
### add executable (necessary everytime) | ||
add_executable(main main.cpp) | ||
|
||
### Set post build (necessary everytime) | ||
mbed_set_post_build(main) | ||
|
||
###################################################################################################### | ||
### Link libraries block | ||
#[[For more about this configuraion visit wiki page MbedOS-configuration ]] | ||
|
||
#[[link MbedOS and its libraries (necessary everytime)]] | ||
target_link_libraries(main mbed-os) | ||
|
||
### link user library (if needed) | ||
#target_link_libraries(main YourLibrary) | ||
|
||
### End of block | ||
###################################################################################################### | ||
|
||
### Build finalize does necessary configuration for debug in most cases (necessary everytime) | ||
mbed_finalize_build() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
buildType: | ||
default: Develop | ||
choices: | ||
Develop: | ||
short: Develop | ||
long: Emit debug information but also optimize | ||
buildType: Develop | ||
Debug: | ||
short: Debug | ||
long: Emit debug information and don't optimize | ||
buildType: Debug | ||
Release: | ||
short: Release | ||
long: Optimize generated code | ||
buildType: Release | ||
board: | ||
# Fill name of your targer which has to corespond to | ||
# target name in custom_targets.json5 file | ||
default: L452RE_SIMPLE | ||
choices: | ||
YOUR_MBED_TARGET: | ||
short: L452RE_SIMPLE | ||
settings: | ||
MBED_TARGET: L452RE_SIMPLE | ||
# Fill your upload method according to variants below | ||
# - universal: NONE, MBED, JLINK, PYOCD, OPENOCD | ||
# - target specific: STLINK, STM32CUBE, LINKSERVER, PICOTOOL, ARDUINO_BOSSAC | ||
# For more visit - https://github.com/mbed-ce/mbed-os/wiki/Upload-Methods#upload-method-list | ||
UPLOAD_METHOD: STM32CUBE |
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
custom_targets/upload_method_cfg/L452RE_CUSTOM_CLOCK.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
## Example of custom uploud method for L452RE_CUSTOM_CLOCK | ||
|
||
|
||
# General config parameters | ||
# ------------------------------------------------------------- | ||
set(UPLOAD_METHOD_DEFAULT OPENOCD) | ||
|
||
# Config options for OPENOCD | ||
# ------------------------------------------------------------- | ||
# We set TRUE to enable OpenOCD | ||
set(OPENOCD_UPLOAD_ENABLED TRUE) | ||
# Here set a path to requested OpenOCD config. In this case we use already implemented one. | ||
set(OPENOCD_CHIP_CONFIG_COMMANDS | ||
-f ${CMAKE_SOURCE_DIR}/mbed-os/targets/upload_method_cfg/openocd_cfgs/s/stm32l452re.cfg) |
13 changes: 13 additions & 0 deletions
13
custom_targets/upload_method_cfg/L452RE_CUSTOM_PINMAP.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Example of custom uploud method for L452RE_CUSTOM_PINMAP | ||
|
||
|
||
# General config parameters | ||
# ------------------------------------------------------------- | ||
set(UPLOAD_METHOD_DEFAULT STM32CUBE) | ||
|
||
# Config options for STM32Cube | ||
# ------------------------------------------------------------- | ||
|
||
set(STM32CUBE_UPLOAD_ENABLED TRUE) | ||
set(STM32CUBE_CONNECT_COMMAND -c port=SWD reset=HWrst) | ||
set(STM32CUBE_GDBSERVER_ARGS --swd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Example of custom uploud method for L452RE_SIMPLE | ||
|
||
|
||
# General config parameters | ||
# ------------------------------------------------------------- | ||
set(UPLOAD_METHOD_DEFAULT STM32CUBE) | ||
|
||
# Config options for STM32Cube | ||
# ------------------------------------------------------------- | ||
|
||
set(STM32CUBE_UPLOAD_ENABLED TRUE) | ||
set(STM32CUBE_CONNECT_COMMAND -c port=SWD reset=HWrst) | ||
set(STM32CUBE_GDBSERVER_ARGS --swd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "mbed.h" | ||
|
||
DigitalOut led(LED1); // fill your pin | ||
|
||
int main(){ | ||
printf("mbed-ce-custom-targets\n"); | ||
while(1){ | ||
led = !led; | ||
thread_sleep_for(500); | ||
} | ||
} |
Submodule mbed-os
updated
3433 files
File renamed without changes.