-
-
Notifications
You must be signed in to change notification settings - Fork 83
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 #165 from dlktdr/esp_support
Re-works the build system to use Zephyr's West tool
- Loading branch information
Showing
142 changed files
with
50,181 additions
and
21,523 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 |
---|---|---|
|
@@ -79,6 +79,5 @@ Release/ | |
!/gui/bin/bossac* | ||
/gui/build* | ||
|
||
#Zephyr | ||
/firmware/src/build* | ||
# Ignore Zephyr workspace | ||
/firmware/zephyr* |
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,44 @@ | ||
# syntax=docker/dockerfile:1 | ||
FROM ubuntu:22.04 | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
SHELL [ "/bin/bash", "-c" ] | ||
ENV SHELL=/bin/bash | ||
|
||
#Update repositories | ||
RUN apt-get update | ||
|
||
#Install build dependencies | ||
RUN apt-get install -y git cmake ninja-build gperf \ | ||
ccache dfu-util device-tree-compiler wget \ | ||
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \ | ||
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 | ||
|
||
#Install zephyr-sdk. Don't include all tools | ||
RUN cd ~ && \ | ||
wget --progress=bar:force:noscroll https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.5-1/zephyr-sdk-0.16.5-1_linux-x86_64_minimal.tar.xz && \ | ||
tar xvf zephyr-sdk-0.16.5-1_linux-x86_64_minimal.tar.xz && \ | ||
rm zephyr-sdk-0.16.5-1_linux-x86_64_minimal.tar.xz && \ | ||
cd zephyr-sdk-0.16.5-1 && \ | ||
./setup.sh -t arm-zephyr-eabi -t xtensa-espressif_esp32_zephyr-elf -t riscv64-zephyr-elf -h && \ | ||
ln -s ~/zephyr-sdk-0.16.5-1/ ~/zephyr-sdk | ||
|
||
#Install west | ||
RUN pip3 install west | ||
|
||
#Install zephyr | ||
RUN west init ~/zephyr && \ | ||
cd ~/zephyr && \ | ||
west update && \ | ||
west -z ~/zephyr zephyr-export && \ | ||
pip3 install -r ~/zephyr/zephyr/scripts/requirements.txt && \ | ||
west blobs fetch hal_espressif | ||
|
||
# Always use bash as the shell | ||
RUN echo "dash dash/sh boolean false" | debconf-set-selections | ||
RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash | ||
RUN ln -sf /bin/bash /bin/sh | ||
|
||
# Set zephyr's Environment Variables | ||
RUN echo source /root/zephyr/zephyr/zephyr-env.sh >> ~/.bashrc |
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,12 @@ | ||
{ | ||
"name": "zephyr-dev", | ||
"image": "docker.io/dlktdr/zephyr:latest", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-vscode.cpptools", | ||
"trond-snekvik.devicetree" | ||
] | ||
} | ||
} | ||
} |
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,3 +1,8 @@ | ||
.pio | ||
.vscode | ||
|
||
.vscode/*.json | ||
!.vscode/c_cpp_properties.json | ||
.cortex-debug.* | ||
*.log | ||
build* | ||
!build_all* | ||
_deps* |
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,26 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Zephyr", | ||
"includePath": [ | ||
"src/**", | ||
"src/include/**", | ||
"third-party/BMI270_SensorAPI/**", | ||
"../zephyr/**" | ||
], | ||
"browse": { | ||
"limitSymbolsToIncludedHeaders": true, | ||
"path": [ | ||
"src/**", | ||
"src/include/**", | ||
"third-party/BMI270_SensorAPI/**", | ||
"../zephyr/**" | ||
] | ||
}, | ||
"cStandard": "c99", | ||
"cppStandard": "c++11", | ||
"compilerPath": "../zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe" | ||
} | ||
], | ||
"version": 4 | ||
} |
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,125 @@ | ||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
# Get the Git Revision and Most recent version tag | ||
execute_process( | ||
COMMAND git rev-parse --short HEAD | ||
OUTPUT_VARIABLE GIT_REV | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
if(ret EQUAL "1") | ||
no_git() | ||
endif() | ||
execute_process( | ||
COMMAND git describe --tags --abbrev=0 | ||
OUTPUT_VARIABLE GIT_TAG_RAW | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
if(ret EQUAL "1") | ||
no_git() | ||
endif() | ||
string(REPLACE "v" "" GIT_TAG "${GIT_TAG_RAW}") | ||
function(no_git) | ||
message( FATAL_ERROR "Unable to fetch the project GIT status, be sure GIT is installed and in your path") | ||
endfunction() | ||
message(STATUS "Git Revision ${GIT_REV}") | ||
message(STATUS "Git Tag ${GIT_TAG}") | ||
|
||
# Rebuild all the the settings for the project | ||
message(STATUS "Building the settings files (buildsettings.py) from ../settings.csv") | ||
execute_process( | ||
COMMAND ../settings/python buildsettings.py | ||
) | ||
|
||
message(STATUS "Board=${BOARD}") | ||
|
||
# NRF52 Boards | ||
if((${BOARD} STREQUAL "arduino_nano_33_ble") OR | ||
(${BOARD} STREQUAL "xiao_ble/nrf52840/sense") OR | ||
(${BOARD} STREQUAL "dtqsys_ht")) | ||
message(STATUS " Board is a NRF52 based board") | ||
|
||
# Pick the correct project file for this architecture | ||
set (CONF_FILE zephyr/nrf_prj.conf) | ||
|
||
# The sense revision 2 uses the same board file as the original | ||
# but a few different defines in the code. | ||
if(DEFINED BOARD_REV_SR2) | ||
message(STATUS " Board is a Revision 2 Nano 33 BLE Sense") | ||
set (BOARD "arduino_nano_33_ble") | ||
# SEE BELOW for defined passed to compiler | ||
endif() | ||
|
||
#DTQ Board, use local board file from /zephyr/boards | ||
if((${BOARD} STREQUAL "dtqsys_ht")) | ||
set (BOARD_ROOT "${CMAKE_SOURCE_DIR}/zephyr") | ||
endif() | ||
|
||
#ESP32C3 Boards | ||
elseif(${BOARD} STREQUAL "esp32c3_devkitm") | ||
message(STATUS " Board is a ESP32C3 based board") | ||
set (CONF_FILE zephyr/esp32c3_prj.conf) | ||
|
||
# M5Stick CPLUS1 | ||
elseif((${BOARD} STREQUAL "m5stickc_plus/esp32/procpu") OR | ||
(${BOARD} STREQUAL "m5stickc_plus")) | ||
message(STATUS " Board is a ESP32 PICO based board") | ||
set(CONF_FILE zephyr/m5stickc_plus_prj.conf) | ||
|
||
# Raspberry Pi Pico | ||
elseif((${BOARD} STREQUAL "rpi_pico/rp2040/w") OR | ||
(${BOARD} STREQUAL "rpi_pico")) | ||
message(STATUS " Board is a Raspberry Pi 2040 Pico") | ||
set(CONF_FILE zephyr/rpi_pico.conf) | ||
|
||
else() | ||
message(FATAL_ERROR "ERROR: Board is not supported") | ||
endif() | ||
|
||
# Set the output filename in release mode | ||
string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type) | ||
if(NOT build_type STREQUAL "debug") | ||
message(STATUS "Building in Release mode") | ||
string(REPLACE "." "_" output_name "${BOARD}_${GIT_TAG}_${GIT_REV}") | ||
string(REPLACE "/" "_" output_name "${output_name}") | ||
if(DEFINED BOARD_REV_SR2) | ||
set(output_name "${output_name}_SR2") | ||
endif() | ||
set(CONFIG_KERNEL_BIN_NAME "\"${output_name}\"" CACHE INTERNAL "") | ||
message(STATUS "Output File Name=${output_name}") | ||
# Set KConfig Option to disable some optimizations in debug mode | ||
# do this here so it's easy in VScode with a task to set the build type | ||
else() | ||
message(STATUS "Building in Debug mode") | ||
set(CONFIG_DEBUG_OPTIMIZATIONS "y" CACHE INTERNAL "") | ||
set(NO_BUILD_TYPE_WARNING "y") | ||
endif() | ||
|
||
|
||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(HeadTracker DESCRIPTION "HeadTracker") | ||
|
||
# Set optimization level to -O1 for debug builds -o0 casuses stack issues | ||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O1") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O1") | ||
|
||
# -DOPENOCD=/openocd-esp32/bin -DOPENOCD_DEFAULT_PATH=/openocd-esp32/share/openocd/scripts | ||
if(${BOARD} MATCHES "esp32c3") | ||
target_compile_definitions(app PUBLIC "OPENOCD=\"c:\\openocd-esp32\\bin\"") | ||
target_compile_definitions(app PUBLIC "OPENOCD_DEFAULT_PATH=\"c:\\openocd-esp32\\share\\openocd\\scripts\"") | ||
endif() | ||
|
||
# Arduino Nano Sense Rev 2 | ||
if(DEFINED BOARD_REV_SR2) | ||
target_compile_definitions(app PUBLIC BOARD_REV_SR2=1) | ||
endif() | ||
|
||
target_compile_definitions(app PUBLIC FW_GIT_REV=${GIT_REV}) | ||
target_compile_definitions(app PUBLIC FW_VER_TAG=${GIT_TAG}) | ||
target_include_directories(app PRIVATE src/include) | ||
target_include_directories(app PRIVATE src) | ||
target_include_directories(app PRIVATE third-party/ArduinoJson/src) | ||
target_include_directories(app PRIVATE third-party/BMI270_SensorAPI) | ||
|
||
FILE(GLOB_RECURSE app_sources src/*.c*) | ||
set(app_sources ${app_sources} third-party/BMI270_SensorAPI/bmi2.c) | ||
set(app_sources ${app_sources} third-party/BMI270_SensorAPI/bmi270.c) | ||
target_sources(app PRIVATE ${app_sources}) |
Binary file not shown.
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,98 @@ | ||
/ { | ||
model = "Arduino Nano 33 BLE (Sense)"; | ||
compatible = "arduino,arduino_nano_33_ble"; | ||
|
||
chosen { | ||
/delete-property/ zephyr,console; | ||
/delete-property/ zephyr,shell-uart; | ||
/delete-property/ zephyr,uart-mcumgr; | ||
/delete-property/ zephyr,bt-mon-uart; | ||
/delete-property/ zephyr,bt-c2h-uart; | ||
zephyr,sram = &sram0; | ||
zephyr,flash = &flash0; | ||
zephyr,code-partition = &code_partition; | ||
|
||
// Uncomment the below line for kernel logging to a second USB CDC port | ||
// Also uncomment the extra cdc at the bottom of the file | ||
// zephyr,console = &cdc_acm_uart1; | ||
}; | ||
|
||
aliases { | ||
adcctrl = &adc; | ||
i2csensor = &i2c1; | ||
guiuart = &cdc_acm_uart0; | ||
}; | ||
}; | ||
|
||
/* Flash Layout | ||
* Bootloader 0x00000 - 0x10000 (Size 0x10000 65536 Bytes) | ||
* Code 0x10000 - 0xFC000 (Size 0xEC000 966656 Bytes) | ||
* NVM Data 0xFC000 - 0x100000 (Size 0x4000 16384 Bytes) | ||
*/ | ||
|
||
/delete-node/ &storage_partition; | ||
|
||
&flash0 { | ||
partitions { | ||
compatible = "fixed-partitions"; | ||
#address-cells = <1>; | ||
#size-cells = <1>; | ||
|
||
code_partition: partition@10000 { | ||
label = "code"; | ||
reg = <0x10000 0xEC000>; | ||
read-only; | ||
}; | ||
|
||
storage_partition: partition@FC000 { | ||
label = "storagept"; | ||
reg = <0xFC000 0x4000>; | ||
}; | ||
}; | ||
}; | ||
|
||
&adc { | ||
status = "okay"; | ||
}; | ||
|
||
&uart0 { | ||
status = "disabled"; | ||
}; | ||
|
||
&i2c0 { | ||
status = "disabled"; | ||
}; | ||
|
||
&i2c1 { | ||
status = "okay"; | ||
clock-frequency = <I2C_BITRATE_FAST>; | ||
zephyr,flash-buf-max-size = <128>; | ||
zephyr,concat-buf-size = <128>; | ||
}; | ||
|
||
/* Disable Timer3, used by PPM output | ||
*/ | ||
&timer3 { | ||
status = "disabled"; | ||
}; | ||
|
||
/* Disable Timer4, used by PPM input | ||
*/ | ||
&timer4 { | ||
status = "disabled"; | ||
}; | ||
|
||
zephyr_udc0: &usbd { | ||
compatible = "nordic,nrf-usbd"; | ||
status = "okay"; | ||
cdc_acm_uart0: cdc_acm_uart0 { | ||
compatible = "zephyr,cdc-acm-uart"; | ||
}; | ||
|
||
// Uncomment the below lines for kernel logging to a second USB CDC port | ||
/* | ||
cdc_acm_uart1: cdc_acm_uart1 { | ||
compatible = "zephyr,cdc-acm-uart"; | ||
}; */ | ||
}; | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.