From e247afaa81a6011b61ea4a7cfdbd84fadbe29b4b Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 May 2022 22:11:08 +0200 Subject: CMake: Extend debug configuration Enable debug output for InfiniTime, Nimble and the NRF SDK via SEGGER RTT on debug builds. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index f6aaf62a..acd48698 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,7 @@ cmake_minimum_required(VERSION 3.10) + +set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose Debug or Release") + project(pinetime VERSION 1.9.0 LANGUAGES C CXX ASM) set(CMAKE_C_STANDARD 99) @@ -70,8 +73,10 @@ string(STRIP "${PROJECT_GIT_COMMIT_HASH}" PROJECT_GIT_COMMIT_HASH) message("PROJECT_GIT_COMMIT_HASH_SUCCESS? " ${PROJECT_GIT_COMMIT_HASH_SUCCESS}) +message("") message("BUILD CONFIGURATION") message("-------------------") +message(" * Mode : " ${CMAKE_BUILD_TYPE}) message(" * Version : " ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) message(" * Toolchain : " ${ARM_NONE_EABI_TOOLCHAIN_PATH}) message(" * GitRef(S) : " ${PROJECT_GIT_COMMIT_HASH}) -- cgit v1.2.3-70-g09d2 From 8b0559c4812d74b6307757135622975523c5a88d Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 May 2022 21:46:36 +0200 Subject: Add basic hardware configuration options for P8 This enables the configuration of the LFCLK source, as well as the target hardware board pin configuration. --- CMakeLists.txt | 9 ++------- doc/buildAndProgram.md | 2 +- src/CMakeLists.txt | 29 +++++++++++++++++++++++++++++ src/drivers/PinMap.h | 4 ++-- src/main.cpp | 14 ++++++++++++++ 5 files changed, 48 insertions(+), 10 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index acd48698..f49a9929 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,13 +54,8 @@ if(BUILD_DFU) set(BUILD_DFU true) endif() -option(WATCH_COLMI_P8 "Build for the Colmi P8" OFF) -set(TARGET_DEVICE "PineTime") - -if(WATCH_COLMI_P8) - set(TARGET_DEVICE "Colmi P8") - add_definitions(-DWATCH_P8) -endif() +set(TARGET_DEVICE "PINETIME" CACHE STRING "Target device") +set_property(CACHE TARGET_DEVICE PROPERTY STRINGS PINETIME MOY-TFK5 MOY-TIN5 MOY-TON5 MOY-UNK) set(PROJECT_GIT_COMMIT_HASH "") diff --git a/doc/buildAndProgram.md b/doc/buildAndProgram.md index 71022bcd..42d6d390 100644 --- a/doc/buildAndProgram.md +++ b/doc/buildAndProgram.md @@ -39,7 +39,7 @@ CMake configures the project according to variables you specify the command line **GDB_CLIENT_BIN_PATH**|Path to arm-none-eabi-gdb executable. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_BIN_PATH=/home/jf/nrf52/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gdb` **GDB_CLIENT_TARGET_REMOTE**|Target remote connection string. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_TARGET_REMOTE=/dev/ttyACM0` **BUILD_DFU (\*\*)**|Build DFU files while building (needs [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-DBUILD_DFU=1` -**WATCH_COLMI_P8**|Use pin configuration for Colmi P8 watch|`-DWATCH_COLMI_P8=1` +**TARGET_DEVICE**|Target device, used for hardware configuration. Allowed: `PINETIME, MOY-TFK5, MOY-TIN5, MOY-TON5, MOY-UNK`|`-DTARGET_DEVICE=PINETIME` (Default) ####(**) Note about **CMAKE_BUILD_TYPE**: By default, this variable is set to *Release*. It compiles the code with size and speed optimizations. We use this value for all the binaries we publish when we [release](https://github.com/InfiniTimeOrg/InfiniTime/releases) new versions of InfiniTime. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index db0612ff..3b7503fd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -779,6 +779,35 @@ add_definitions(-DFREERTOS) add_definitions(-D__STACK_SIZE=1024) add_definitions(-D__HEAP_SIZE=4096) +# Note: Only use this for debugging +# Derive the low frequency clock from the main clock (SYNT) +# add_definitions(-DCLOCK_CONFIG_LF_SRC=2) + +# Target hardware configuration options +add_definitions(-DTARGET_DEVICE_${TARGET_DEVICE}) +if(TARGET_DEVICE STREQUAL "PINETIME") + add_definitions(-DDRIVER_PINMAP_PINETIME) + add_definitions(-DCLOCK_CONFIG_LF_SRC=1) # XTAL +elseif(TARGET_DEVICE STREQUAL "MOY-TFK5") # P8a + add_definitions(-DDRIVER_PINMAP_P8) + add_definitions(-DCLOCK_CONFIG_LF_SRC=1) # XTAL +elseif(TARGET_DEVICE STREQUAL "MOY-TIN5") # P8a variant 2 + add_definitions(-DDRIVER_PINMAP_P8) + add_definitions(-DCLOCK_CONFIG_LF_SRC=1) # XTAL +elseif(TARGET_DEVICE STREQUAL "MOY-TON5") # P8b + add_definitions(-DDRIVER_PINMAP_P8) + add_definitions(-DCLOCK_CONFIG_LF_SRC=0) # RC + add_definitions(-DMYNEWT_VAL_BLE_LL_SCA=500) + add_definitions(-DCLOCK_CONFIG_LF_CAL_ENABLED=1) +elseif(TARGET_DEVICE STREQUAL "MOY-UNK") # P8b mirrored + add_definitions(-DDRIVER_PINMAP_P8) + add_definitions(-DCLOCK_CONFIG_LF_SRC=0) # RC + add_definitions(-DMYNEWT_VAL_BLE_LL_SCA=500) + add_definitions(-DCLOCK_CONFIG_LF_CAL_ENABLED=1) +else() + message(FATAL_ERROR "Invalid TARGET_DEVICE") +endif() + # Debug configuration if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") add_definitions(-DDEBUG) diff --git a/src/drivers/PinMap.h b/src/drivers/PinMap.h index 833c6477..a70cfc41 100644 --- a/src/drivers/PinMap.h +++ b/src/drivers/PinMap.h @@ -4,8 +4,8 @@ namespace Pinetime { namespace PinMap { -#ifdef WATCH_P8 - // COLMI P8 +#if defined(DRIVER_PINMAP_P8) + // COLMI P8 and variants static constexpr uint8_t Charging = 19; static constexpr uint8_t Cst816sReset = 13; static constexpr uint8_t Button = 17; diff --git a/src/main.cpp b/src/main.cpp index 3d70af49..98d8cafb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -300,10 +300,24 @@ void nimble_port_ll_task_func(void* args) { } } +void calibrate_lf_clock_rc(nrf_drv_clock_evt_type_t event) { + // 16 * 0.25s = 4s calibration cycle + // Not recursive, call is deferred via internal calibration timer + nrf_drv_clock_calibration_start(16, calibrate_lf_clock_rc); +} + int main(void) { logger.Init(); nrf_drv_clock_init(); + nrf_drv_clock_lfclk_request(NULL); + +// The RC source for the LF clock has to be calibrated +#if (CLOCK_CONFIG_LF_SRC == NRF_CLOCK_LFCLK_RC) + while (!nrf_clock_lf_is_running()) { + } + nrf_drv_clock_calibration_start(0, calibrate_lf_clock_rc); +#endif // Unblock i2c? nrf_gpio_cfg(Pinetime::PinMap::TwiScl, -- cgit v1.2.3-70-g09d2 From 8a14038324ace6b899520575381b35e69450726b Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Wed, 29 Jun 2022 18:05:06 +0200 Subject: Set version to 1.10 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index f49a9929..be8ef41f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10) set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose Debug or Release") -project(pinetime VERSION 1.9.0 LANGUAGES C CXX ASM) +project(pinetime VERSION 1.10.0 LANGUAGES C CXX ASM) set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 14) -- cgit v1.2.3-70-g09d2 From e2a3d9f0c7a531d129501325e793fdd634babba8 Mon Sep 17 00:00:00 2001 From: Jean-François Milants Date: Sun, 11 Sep 2022 12:43:30 +0200 Subject: Small improvement in generate-fonts.py following code review. Add lv_img_conf in Docker image to build resources at build time. --- CMakeLists.txt | 9 +++++++++ docker/Dockerfile | 10 ++++++++++ docker/build.sh | 7 ++++++- docker/post_build.sh.in | 2 ++ src/CMakeLists.txt | 12 +++++++++++- src/resources/generate-fonts.py | 2 +- 6 files changed, 39 insertions(+), 3 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index be8ef41f..1da460c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,10 @@ if(BUILD_DFU) set(BUILD_DFU true) endif() +if(BUILD_RESOURCES) + set(BUILD_RESOURCES true) +endif() + set(TARGET_DEVICE "PINETIME" CACHE STRING "Target device") set_property(CACHE TARGET_DEVICE PROPERTY STRINGS PINETIME MOY-TFK5 MOY-TIN5 MOY-TON5 MOY-UNK) @@ -98,6 +102,11 @@ if(BUILD_DFU) else() message(" * Build DFU (using adafruit-nrfutil) : Disabled") endif() +if(BUILD_RESOURCES) + message(" * Build resources : Enabled") +else() + message(" * Build resources : Disabled") +endif() set(VERSION_EDIT_WARNING "// Do not edit this file, it is automatically generated by CMAKE!") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/Version.h) diff --git a/docker/Dockerfile b/docker/Dockerfile index f2d187d0..927160db 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -22,6 +22,12 @@ RUN apt-get update -qq \ python3-dev \ git \ apt-utils \ + pkg-config \ + libpixman-1-dev \ + libcairo2-dev \ + libpango-1.0-0 \ + ibpango1.0-dev \ + libpangocairo-1.0-0 \ && curl -sL https://deb.nodesource.com/setup_18.x | bash - \ && apt-get install -y nodejs \ && rm -rf /var/cache/apt/* /var/lib/apt/lists/*; @@ -33,6 +39,10 @@ RUN pip3 install -Iv cryptography==3.3 RUN pip3 install cbor RUN npm i lv_font_conv@1.5.2 -g +RUN npm i ts-node@10.9.1 -g +RUN npm i @swc/core -g +RUN npm i lv_img_conv@0.3.0 -g + # build.sh knows how to compile COPY build.sh /opt/ diff --git a/docker/build.sh b/docker/build.sh index 663390c4..58dcccc1 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -11,6 +11,10 @@ export SOURCES_DIR="${SOURCES_DIR:=/sources}" export BUILD_DIR="${BUILD_DIR:=$SOURCES_DIR/build}" export OUTPUT_DIR="${OUTPUT_DIR:=$SOURCES_DIR/build/output}" +# Specify a folder with read/write access to NPM +export NPM_DIR="$BUILD_DIR/npm" +export npm_config_cache="${NPM_DIR}" + export BUILD_TYPE=${BUILD_TYPE:=Release} export GCC_ARM_VER=${GCC_ARM_VER:="10.3-2021.10"} export NRF_SDK_VER=${NRF_SDK_VER:="nRF5_SDK_15.3.0_59ac345"} @@ -62,7 +66,8 @@ CmakeGenerate() { -DUSE_OPENOCD=1 \ -DARM_NONE_EABI_TOOLCHAIN_PATH="$TOOLS_DIR/$GCC_ARM_PATH" \ -DNRF5_SDK_PATH="$TOOLS_DIR/$NRF_SDK_VER" \ - -DBUILD_DFU=1 + -DBUILD_DFU=1 \ + -DBUILD_RESOURCES=1 } CmakeBuild() { diff --git a/docker/post_build.sh.in b/docker/post_build.sh.in index 8c94471a..5d82f3be 100755 --- a/docker/post_build.sh.in +++ b/docker/post_build.sh.in @@ -15,6 +15,8 @@ cp "$BUILD_DIR/src/pinetime-mcuboot-app-dfu-$PROJECT_VERSION.zip" "$OUTPUT_DIR/p cp "$BUILD_DIR/src/pinetime-mcuboot-recovery-loader-image-$PROJECT_VERSION.bin" "$OUTPUT_DIR/pinetime-mcuboot-recovery-loader-image-$PROJECT_VERSION.bin" cp "$BUILD_DIR/src/pinetime-mcuboot-recovery-loader-dfu-$PROJECT_VERSION.zip" "$OUTPUT_DIR/pinetime-mcuboot-recovery-loader-dfu-$PROJECT_VERSION.zip" +cp "$BUILD_DIR/src/resources/infinitime-resources-$PROJECT_VERSION.zip" "$OUTPUT_DIR/infinitime-resources-$PROJECT_VERSION.zip" + mkdir -p "$OUTPUT_DIR/src" cp $BUILD_DIR/src/*.bin "$OUTPUT_DIR/src/" cp $BUILD_DIR/src/*.hex "$OUTPUT_DIR/src/" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f81e7026..92f309a1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -940,6 +940,10 @@ add_custom_command(TARGET ${EXECUTABLE_NAME} COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_FILE_NAME}.out "${EXECUTABLE_FILE_NAME}.hex" COMMENT "post build steps for ${EXECUTABLE_FILE_NAME}") +if(BUILD_RESOURCES) + add_dependencies(${EXECUTABLE_NAME} GenerateResources) +endif() + # Build binary intended to be used by bootloader set(EXECUTABLE_MCUBOOT_NAME "pinetime-mcuboot-app") set(EXECUTABLE_MCUBOOT_FILE_NAME ${EXECUTABLE_MCUBOOT_NAME}-${pinetime_VERSION_MAJOR}.${pinetime_VERSION_MINOR}.${pinetime_VERSION_PATCH}) @@ -973,6 +977,10 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME} COMMENT "post build steps for ${EXECUTABLE_MCUBOOT_FILE_NAME}" ) +if(BUILD_RESOURCES) + add_dependencies(${EXECUTABLE_MCUBOOT_NAME} GenerateResources) +endif() + if(BUILD_DFU) add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME} POST_BUILD @@ -1127,7 +1135,9 @@ if(BUILD_DFU) ) endif() -add_subdirectory(resources) +if(BUILD_RESOURCES) + add_subdirectory(resources) +endif() # FLASH diff --git a/src/resources/generate-fonts.py b/src/resources/generate-fonts.py index d6b47ab2..20408166 100755 --- a/src/resources/generate-fonts.py +++ b/src/resources/generate-fonts.py @@ -20,7 +20,7 @@ class Source(object): def gen_lvconv_line(lv_font_conv: str, dest: str, size: int, bpp: int, format: str, sources: typing.List[Source], compress:bool=False): if format != "lvgl" and format != "bin": - format = "lvgl" + format = "bin" if dest.lower().endswith(".bin") else "lvgl" args = [lv_font_conv, '--size', str(size), '--output', dest, '--bpp', str(bpp), '--format', format] if not compress: -- cgit v1.2.3-70-g09d2