Tactility SDK and release build scripting (#122)

* Implement release scripting and SDK building process
* Fix for CYD display colors
* Various improvements and fixes
* Made build scripts more modular
This commit is contained in:
Ken Van Hoeylandt 2024-12-14 21:50:02 +01:00 committed by GitHub
parent 43714b2355
commit a18221db08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 324 additions and 53 deletions

2
.gitignore vendored
View File

@ -7,6 +7,8 @@ cmake-build-*/
CMakeCache.txt
*.cbp
release/
sdkconfig
sdkconfig.old

View File

@ -72,7 +72,7 @@ bool YellowDisplay::start() {
const esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = GPIO_NUM_NC,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR,
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
.bits_per_pixel = TWODOTFOUR_LCD_BITS_PER_PIXEL,
.flags = {
@ -123,7 +123,7 @@ bool YellowDisplay::start() {
.buff_dma = true,
.buff_spiram = false,
.sw_rotate = false,
.swap_bytes = false
.swap_bytes = true
}
};

View File

@ -0,0 +1,17 @@
idf_component_register(
INCLUDE_DIRS "Libraries/Tactility/Include" "Libraries/lvgl/Include"
)
add_prebuilt_library(Tactility Libraries/Tactility/Binary/libTactility.a)
add_prebuilt_library(TactilityC Libraries/Tactility/Binary/libTactilityC.a)
add_prebuilt_library(TactilityCore Libraries/Tactility/Binary/libTactilityCore.a)
add_prebuilt_library(TactilityHeadless Libraries/Tactility/Binary/libTactilityHeadless.a)
add_prebuilt_library(elf_loader Libraries/elf_loader/Binary/libelf_loader.a)
add_prebuilt_library(lvgl Libraries/lvgl/Binary/liblvgl.a)
target_link_libraries(${COMPONENT_LIB} INTERFACE TactilityC)
target_link_libraries(${COMPONENT_LIB} INTERFACE Tactility)
target_link_libraries(${COMPONENT_LIB} INTERFACE TactilityHeadless)
target_link_libraries(${COMPONENT_LIB} INTERFACE TactilityCore)
target_link_libraries(${COMPONENT_LIB} INTERFACE lvgl)
target_link_libraries(${COMPONENT_LIB} INTERFACE elf_loader)

View File

@ -0,0 +1,19 @@
function(tactility_project)
endfunction()
function(_tactility_project)
endfunction()
macro(tactility_project project_name)
set(TACTILITY_SKIP_SPIFFS 1)
add_definitions(-DESP_TARGET)
add_compile_definitions(ESP_TARGET)
include("${TACTILITY_SDK_PATH}/Libraries/elf_loader/elf_loader.cmake")
project_elf($project_name)
file(READ ${TACTILITY_SDK_PATH}/idf-version.txt TACTILITY_SDK_IDF_VERSION)
if (NOT "$ENV{ESP_IDF_VERSION}" STREQUAL "${TACTILITY_SDK_IDF_VERSION}")
message(FATAL_ERROR "ESP-IDF version of Tactility SDK (${TACTILITY_SDK_IDF_VERSION}) does not match current ESP-IDF version ($ENV{ESP_IDF_VERSION})")
endif()
endmacro()

View File

@ -0,0 +1,20 @@
param(
$port
)
if ((Get-Command "esptool.py" -ErrorAction SilentlyContinue) -eq $null)
{
Write-Host "Unable to find esptool.py in your path. Make sure you have Python installed and on your path. Then run `pip install esptool`."
}
# Create flash command based on partitions
$json = Get-Content .\build\flasher_args.json -Raw | ConvertFrom-Json
$jsonClean = $json.flash_files -replace '[\{\}\@\;]', ''
$jsonClean = $jsonClean -replace '[\=]', ' '
cd Binaries
$command = "esptool.py --connect-attemps 10 --port $port -b 460800 write_flash $jsonClean"
Invoke-Expression $command
cd ..

41
Buildscripts/Flashing/flash.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
# Usage:
# flash.sh [port]
#
# Arguments:
# port - the port of the device (e.g. /dev/ttyUSB0, ...)
#
# Requirements:
# jq - run 'pip install jq'
# esptool.py - run 'pip install esptool'
#
# Documentation:
# https://docs.espressif.com/projects/esptool/en/latest/esp32/
#
# Source: https://stackoverflow.com/a/53798785
function is_bin_in_path {
builtin type -P "$1" &> /dev/null
}
function require_bin {
program=$1
tip=$2
if ! is_bin_in_path $program; then
echo -e "\e[31m⚠ $program not found!\n\t$tip\e[0m"
fi
}
require_bin esptool.py "install esptool from your package manager or install python and run 'pip install esptool'"
require_bin jq "install jq from your package manager or install python and run 'pip install jq'"
if [[ $1 -eq 0 ]]; then
echo -e "\e[31m⚠ Must Specify port as argument. For example:\n\tflash.sh /dev/ttyACM0\n\tflash.sh /dev/ttyUSB0\e[0m"
exit -1
fi
cd Binaries
# Create flash command based on partitions
KEY_VALUES=`jq -r '.flash_files | keys[] as $k | "\($k) \(.[$k])"' flasher_args.json | tr "\n" " "`
esptool.py --port $1 --connect-attempts 10 -b 460800 write_flash $KEY_VALUES

View File

@ -0,0 +1,35 @@
#!/bin/bash
function build() {
Buildscripts/build.sh $1
}
function release() {
Buildscripts/release.sh $1
}
function releaseSdk() {
Buildscripts/release-sdk.sh $1
}
SECONDS=0
build lilygo_tdeck
release lilygo_tdeck
releaseSdk release/Tactility-ESP32S3-SDK/TactilitySDK
build yellow_board
release yellow_board
releaseSdk release/Tactility-ESP32-SDK/TactilitySDK
build m5stack_core2
release m5stack_core2
build m5stack_cores3
release m5stack_cores3
duration=$SECONDS
echo "Finished in $((duration / 60)) minutes and $((duration % 60)) seconds."

38
Buildscripts/build.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
#
# Usage: build.sh [boardname]
# Example: build.sh lilygo_tdeck
# Description: Makes a clean build for the specified board.
#
echoNewPhase() {
echo -e "⏳ \e[36m${1}\e[0m"
}
fatalError() {
echo -e "⚠️ \e[31m${1}\e[0m"
exit 0
}
sdkconfig_file="sdkconfig.board.${1}"
if [ $# -lt 1 ]; then
fatalError "Must pass board name as first argument. (e.g. lilygo_tdeck)"
fi
if [ ! -f $sdkconfig_file ]; then
fatalError "Board not found: ${sdkconfig_file}"
fi
echoNewPhase "Cleaning build folder"
rm -rf build
echoNewPhase "Building $sdkconfig_file"
cp $sdkconfig_file sdkconfig
if not idf.py build; then
fatalError "Failed to build esp32s3 SDK"
fi

View File

@ -1,4 +1,5 @@
#!/bin/sh
#!/bin/sh
rm -rf build
rm -rf build-sim
rm -rf cmake-*

View File

@ -0,0 +1,9 @@
#!/bin/bash
#
# Description: Releases the current build files as an SDK in the specified folder.
# This deployment is used when compiling apps in ./ExternalApps
#
./Buildscripts/release-sdk.sh release/TactilitySDK

52
Buildscripts/release-sdk.sh Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/bash
#
# Usage: release-sdk.sh [target_path]
# Example: release.sh release/TactilitySDK
# Description: Releases the current build files as an SDK in the specified folder.
#
target_path=$1
mkdir -p $target_path
build_dir=`pwd`
library_path=$target_path/Libraries
cp version.txt $target_path
# Tactility
tactility_library_path=$library_path/Tactility
mkdir -p $tactility_library_path/Binary
cp build/esp-idf/Tactility/libTactility.a $tactility_library_path/Binary/
cp build/esp-idf/TactilityCore/libTactilityCore.a $tactility_library_path/Binary/
cp build/esp-idf/TactilityHeadless/libTactilityHeadless.a $tactility_library_path/Binary/
cp build/esp-idf/TactilityC/libTactilityC.a $tactility_library_path/Binary/
mkdir -p $tactility_library_path/Include
find_target_dir=$build_dir/$tactility_library_path/Include/
cd TactilityC/Source
echo To $find_target_dir
find -name '*.h' | cpio -pdm $find_target_dir
cd -
# lvgl
lvgl_library_path=$library_path/lvgl
mkdir -p $lvgl_library_path/Binary
mkdir -p $lvgl_library_path/Include
cp build/esp-idf/lvgl/liblvgl.a $lvgl_library_path/Binary/
find_target_dir=$build_dir/$lvgl_library_path/Include/
cd Libraries/lvgl
find src/ -name '*.h' | cpio -pdm $find_target_dir
cd -
cp Libraries/lvgl/lvgl.h $find_target_dir
cp Libraries/lvgl_conf/lv_conf_kconfig.h $lvgl_library_path/Include/lv_conf.h
# elf_loader
elf_loader_library_path=$library_path/elf_loader
mkdir -p $elf_loader_library_path/Binary
cp -r Libraries/elf_loader/elf_loader.cmake $elf_loader_library_path
cp -r build/esp-idf/elf_loader/libelf_loader.a $elf_loader_library_path/Binary
cp Buildscripts/CMake/TactilitySDK.cmake $target_path/
cp Buildscripts/CMake/CMakeLists.txt $target_path/
echo -n $ESP_IDF_VERSION >> $target_path/idf-version.txt

55
Buildscripts/release.sh Executable file
View File

@ -0,0 +1,55 @@
#!/bin/bash
#
# Usage: release.sh [boardname]
# Example: release.sh lilygo_tdeck
# Description: Releases the current build labeled as a release for the specified board name.
#
echoNewPhase() {
echo -e "⏳ \e[36m${1}\e[0m"
}
fatalError() {
echo -e "⚠️ \e[31m${1}\e[0m"
exit 0
}
releaseSymbols() {
target_path=$1
echoNewPhase "Making symbols release at '$target_path'"
mkdir $target_path
cp build/*.elf $target_path/
}
release() {
target_path=$1
echoNewPhase "Making release at '$target_path'"
bin_path=$target_path/Binaries
mkdir -p $bin_path
mkdir -p $bin_path/partition_table
mkdir -p $bin_path/bootloader
cp build/*.bin $bin_path/
cp build/bootloader/*.bin $bin_path/bootloader/
cp build/partition_table/*.bin $bin_path/partition_table/
cp build/flash_args $bin_path/
cp build/flasher_args.json $bin_path/
cp Buildscripts/Flashing/* $target_path
}
board=$1
board_clean=${board/_/-}
release_path=release
if [ $# -lt 1 ]; then
fatalError "Must pass board name as first argument. (e.g. lilygo_tdeck)"
fi
if [ ! -f $sdkconfig_file ]; then
fatalError "Board not found: ${sdkconfig_file}"
fi
release "${release_path}/Tactility-${board_clean}"
releaseSymbols "${release_path}/Tactility-${board_clean}-symbols"

View File

@ -1,3 +1,5 @@
#!/bin/bash
cmake -S ./ -B build-sim
cmake --build build-sim --target build-tests -j 14
build-sim/Tests/TactilityCore/TactilityCoreTests --exit

View File

@ -57,7 +57,8 @@ if (DEFINED ENV{ESP_IDF_VERSION})
add_compile_definitions(LV_CONF_PATH=${LVGL_CONFIG_FULL_PATH}/lv_conf_kconfig.h)
idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND)
add_compile_definitions(TT_VERSION="alpha1")
file(READ version.txt TACTILITY_VERSION)
add_compile_definitions(TT_VERSION="$TACTILITY_VERSION")
else()
message("Building for sim target")
endif()

View File

@ -1,17 +1,16 @@
cmake_minimum_required(VERSION 3.20)
set(TACTILITY_SKIP_SPIFFS 1)
add_definitions(-DESP_TARGET)
add_compile_definitions(ESP_TARGET)
add_definitions(-DLV_CONF_PATH=../../../Boards/Simulator/Source/lv_conf.h)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(EXTRA_COMPONENT_DIRS "../../Libraries/elf_loader")
if (DEFINED ENV{TACTILITY_SDK_PATH})
set(TACTILITY_SDK_PATH $ENV{TACTILITY_SDK_PATH})
else()
set(TACTILITY_SDK_PATH "../../release/TactilitySDK")
message(WARNING "⚠️ TACTILITY_SDK_PATH environment variable is not set, defaulting to ${TACTILITY_PATH}")
endif()
include("${TACTILITY_SDK_PATH}/TactilitySDK.cmake")
set(EXTRA_COMPONENT_DIRS ${TACTILITY_SDK_PATH})
project(HelloWorld)
include(elf_loader)
project_elf(HelloWorld)
tactility_project(HelloWorld)

View File

@ -2,15 +2,5 @@ file(GLOB_RECURSE SOURCE_FILES Source/*.c)
idf_component_register(
SRCS ${SOURCE_FILES}
REQUIRES TactilitySDK
)
add_prebuilt_library(Tactility ../../../build/esp-idf/Tactility/libTactility.a)
add_prebuilt_library(TactilityC ../../../build/esp-idf/TactilityC/libTactilityC.a)
add_prebuilt_library(TactilityCore ../../../build/esp-idf/TactilityCore/libTactilityCore.a)
add_prebuilt_library(TactilityHeadless ../../../build/esp-idf/TactilityHeadless/libTactilityHeadless.a)
add_prebuilt_library(lvgl ../../../build/esp-idf/lvgl/liblvgl.a)
include_directories("../../../TactilityC/Source")
include_directories("../../../Libraries/lvgl/src")
target_link_libraries(${COMPONENT_LIB} PRIVATE TactilityC Tactility TactilityCore TactilityHeadless lvgl)

View File

@ -1 +1,2 @@
CONFIG_PARTITION_TABLE_SINGLE_APP=y
CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK=n

View File

@ -105,13 +105,19 @@ Copy the `sdkconfig.board.YOUR_BOARD` into `sdkconfig`. Use `sdkconfig.defaults`
### Building firmware
You can run `idf.py flash monitor`, but there are some helpers available too:
Building for ESP32(\*) or PC:
`./build.sh` - build the ESP-IDF or the PC version of Tactility (*)
`./build.sh -p /dev/ttyACM0` - optional: you can pass on extra parameters for esp-idf builds
`./run.sh` - Does `flash` and `monitor` for ESP-IDF and simply builds and starts it for PC
```bash
idf.py build
```
The build scripts will detect if ESP-IDF is available. They will adapter if you ran `${IDF_PATH}/export.sh`.
Flashing ESP32:
```bash
idf.py flash monitor
```
(\*) The build scripts will detect if ESP-IDF is available. They will adapt if you ran `${IDF_PATH}/export.sh`
### Development

View File

@ -118,11 +118,13 @@ static void update_sdcard_icon(std::shared_ptr<ServiceData> data) {
// region power
static _Nullable const char* power_get_status_icon() {
const std::shared_ptr<hal::Power> power = getConfiguration()->hardware->power();
if (power == nullptr) {
auto get_power = getConfiguration()->hardware->power;
if (get_power == nullptr) {
return nullptr;
}
auto power = get_power();
hal::Power::MetricData charge_level;
if (!power->getMetric(hal::Power::MetricType::CHARGE_LEVEL, charge_level)) {
return nullptr;

View File

@ -1,8 +0,0 @@
#!/bin/sh
if [[ -v ESP_IDF_VERSION ]]; then
idf.py build
else
cmake -S ./ -B build-sim
cmake --build build-sim -j 12
fi

12
run.sh
View File

@ -1,12 +0,0 @@
#!/bin/sh
if [[ -v ESP_IDF_VERSION ]]; then
idf.py flash monitor $@
else
set -e
cmake -S ./ -B build-sim
cmake --build build-sim -j 12
cd Data
../build-sim/App/AppSim
cd -
fi

1
version.txt Normal file
View File

@ -0,0 +1 @@
0.1.0