diff --git a/.gitignore b/.gitignore index d6f917cfc4..13b939a3f9 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,10 @@ src/arm-none-eabi node_modules package.json package-lock.json + +# Toolchain and External dependencies +sdk-toolchain/ + +# Developer files +CMakeUserPresets.json +compile_commands.json diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000000..8f30cc6f1a --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,23 @@ +{ + "version": 6, + "configurePresets": [ + { + "binaryDir": "build/${presetName}", + "name": "Release", + "displayName": "Release build", + "cacheVariables": { + "ARM_NONE_EABI_TOOLCHAIN_PATH": "${fileDir}/sdk-toolchain/gcc-arm-none-eabi-10.3-2021.10", + "NRF5_SDK_PATH": "${fileDir}/sdk-toolchain/nRF5_SDK_15.3.0_59ac345", + "CMAKE_BUILD_TYPE": "Release", + "BUILD_DFU": "1", + "BUILD_RESOURCES": "1" + } + } + ], + "buildPresets": [ + { + "name": "Release", + "configurePreset": "Release" + } + ] +} diff --git a/doc/BLEFS.md b/doc/BLEFS.md index 5374fd8787..3f620d7871 100644 --- a/doc/BLEFS.md +++ b/doc/BLEFS.md @@ -14,7 +14,7 @@ There are two relevant UUIDs in this protocol: the version characteristic, and t UUID: `adaf0100-4669-6c65-5472-616e73666572` -The version characteristic returns the version of the protocol to which the sender adheres. It returns a single unsigned 32-bit integer. The latest version at the time of writing this is 4. +The version characteristic returns the version of the protocol to which the sender adheres. It returns a single unsigned 16-bit integer. The latest version at the time of writing this is 4. ### Transfer @@ -71,7 +71,7 @@ To begin writing to a file, a header must first be sent. The header packet shoul - Unsigned 32-bit integer encoding the size of the file that will be sent - File path: UTF-8 encoded string that is _not_ null terminated. -To continue reading the file after this initial packet, the following packet should be sent until all the data has been sent and a response had been received with 0 free space. No close command is required after the data has been received. +To continue writing the file after this initial packet, the following packet should be sent until all the data has been sent and a response had been received with 0 free space. No close command is required after the data has been received. - Command (single byte): `0x22` - Status: `0x01` diff --git a/doc/buildAndProgram.md b/doc/buildAndProgram.md index 5d3af46ef0..2430561034 100644 --- a/doc/buildAndProgram.md +++ b/doc/buildAndProgram.md @@ -12,9 +12,9 @@ To build this project, you'll need: python -m venv .venv source .venv/bin/activate python -m pip install wheel - python -m pip install -r tools/mcuboot/requirements.txt + python -m pip install -r tools/mcuboot/requirements.txt adafruit-nrfutil ``` -- A reasonably recent version of CMake (I use 3.16.5) +- A reasonably recent version of CMake (minimum 3.10) - lv_font_conv, to generate the font .c files - see [lv_font_conv](https://github.com/lvgl/lv_font_conv#install-the-script) - install npm (commonly done via the package manager, ensure node's version is at least 12) @@ -24,7 +24,7 @@ To build this project, you'll need: ### Clone the repo -``` +```sh git clone https://github.com/InfiniTimeOrg/InfiniTime.git cd InfiniTime git submodule update --init @@ -34,6 +34,40 @@ cd build ### Project generation using CMake +#### CMakePresets + +Note that this requires CMake 3.19 or later to be installed. +This project provides a `CMakePresets.json` file, enabling easy and fast development with modern editors such as VSCode, neovim or CLion. +The `CMakePresets.json` file looks for the arm-gcc toolchain and NRF52 SDK in the `sdk-toolchain` directory. +So to download and extract these in the correct directory, do the following: + +```sh +mkdir -p sdk-toolchain + +# Get the nRF5 SDK +wget https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/sdks/nrf5/binaries/nrf5sdk153059ac345.zip +mv nrf5sdk153059ac345.zip sdk-toolchain/ +cd sdk-toolchain +unzip nrf5sdk153059ac345.zip +cd - + +# Get the arm cross compiler (There's probably a more linux-y way of doing this though...) +wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 +mv gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 sdk-toolchain/ +cd sdk-toolchain +tar xjf gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 +cd - +``` + +To use the presets, simply call `cmake` like so (make sure you have activated the python virtual environment as described [above](##dependencies)): + +```sh +cmake --preset Release +cmake --build build/Release +``` + +#### CMake Variables + CMake configures the project according to variables you specify the command line. The variables are: Variable | Description | Example| diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 9feeadedd9..826474a068 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -310,14 +310,14 @@ void SystemTask::Work() { if (state != SystemTaskState::GoingToSleep) { break; } - if (BootloaderVersion::IsValid()) { - // First versions of the bootloader do not expose their version and cannot initialize the SPI NOR FLASH - // if it's in sleep mode. Avoid bricked device by disabling sleep mode on these versions. - spiNorFlash.Sleep(); - } - // Must keep SPI awake when still updating the display for always on + // Must keep SPI and flash awake when still updating the display for always on if (msg == Messages::OnDisplayTaskSleeping) { + if (BootloaderVersion::IsValid()) { + // First versions of the bootloader do not expose their version and cannot initialize the SPI NOR FLASH + // if it's in sleep mode. Avoid bricked device by disabling sleep mode on these versions. + spiNorFlash.Sleep(); + } spi.Sleep(); } @@ -409,14 +409,13 @@ void SystemTask::GoToRunning() { // SPI only switched off when entering Sleeping, not AOD or GoingToSleep if (state == SystemTaskState::Sleeping) { spi.Wakeup(); + spiNorFlash.Wakeup(); } // Double Tap needs the touch screen to be in normal mode if (!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) { touchPanel.Wakeup(); } - - spiNorFlash.Wakeup(); } displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToRunning);