Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"env": {
// TODO: This is a duplication of the configuration set in /docker/build.sh!
"TOOLS_DIR": "/opt",
"GCC_ARM_PATH": "gcc-arm-none-eabi-10.3-2021.10"
"GCC_ARM_PATH": "arm-gnu-toolchain-15.3.rel1-x86_64-arm-none-eabi"
},
"configurations": [
{
Expand Down
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"continue"
],
// Only use armToolchainPath if your arm-none-eabi-gdb is not in your path (some GCC packages does not contain arm-none-eabi-gdb)
"armToolchainPath": "${workspaceRoot}/../gcc-arm-none-eabi-10.3-2021.10/bin",
"armToolchainPath": "${workspaceRoot}/../arm-gnu-toolchain-15.3.rel1-x86_64-arm-none-eabi/bin",
"svdFile": "${workspaceRoot}/nrf52.svd",
"configFiles": [
"interface/stlink.cfg",
Expand All @@ -68,7 +68,7 @@
"request": "launch",
"servertype": "external",
// FIXME: This is hardcoded. I have no idea how to use the values set in build.sh here
"gdbPath": "/opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb",
"gdbPath": "/opt/arm-gnu-toolchain-15.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb",
// Connect to an already running OpenOCD instance
"gdbTarget": "host.docker.internal:3333",
"svdFile": "${workspaceRoot}/nrf52.svd",
Expand Down
42 changes: 42 additions & 0 deletions AI_USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!--
SPDX-FileCopyrightText: 2025 Gusted, jeanbaptisteC, gedankenstuecke, mark9064

SPDX-License-Identifier: CC-BY-4.0
-->

# AI usage in the InfiniTime project

This document describes if and how _artificial intelligence_ can be used in the InfiniTime project by contributors, including agreements for how to use it in a transparent and responsible way. This agreement is applicable to all projects hosted under the [InfiniTime organisation](https://github.com/InfiniTimeOrg).

All contributors are expected to be aware of this agreement and to apply it in their contributions. Contributions that do not honor these agreements will not be accepted and admins will close corresponding pull requests and issues.

## Definitions & Motivations

> [!NOTE]
>This does not necessarily reflect the official or commonly used definitions.

Software and services that heavily rely on large language model technology to generate their outcomes are referred to as Artificial Intelligence (AI). Examples of products that fit this definition: GitHub Copilot, ChatGPT, Claude Sonnet, DeepSeek, Llama and Gemini.

There's a distinction between general and narrow AI, all the aforementioned examples fall under general AI as they were not trained to execute a specific well-defined task. Narrow AI is trained to be used for specific well-defined tasks where the problem space is known in advance.

Vibe coding is the practice where AI creates a code change (feature, bug fix, tests, refactor) with a human that describes what needs to be implemented.

AI agents are AIs that are configured to perform interactions or make changes with little to no human supervision.

"AI agents" and "vibe coding" typically result in the "authors" of code not having expertise in the changes they aim to contribute, thus not able to answer questions about which trade-offs were made and why. If authors were only minimally involved in how code was generated, they can't be accountable for AI's output, which is harmful to the long-term sustainability of open source projects like InfiniTime.

## Agreement

1. If content was made with the help of AI, you must convey that this is the case. This includes content that you authored but was motivated by a suggestion of AI.
2. If at any point you used AI's work in your contribution you must make an effort to verify that you can submit this under the license of the repository.
3. The accountability of using AI in a contribution lies with the person that makes that contribution.
4. All communication, that includes: **commit messages**, **pull request messages**, **documentation**, **code comments** and **issues** (and comments on issues/pull requests), that is intended to be read by people to understand your thoughts and work must not have been generated with AI. We exclude machine translation and tooling that helps with grammar and spelling check.
5. Using general AI for review is forbidden. Changes have to be approved by a human reviewer.
6. It is not allowed to use AI in an autonomous-looking way to contribute in InfiniTime (i.e. solely using 'agent mode' or 'vibe coding'). To ensure the long-term maintainability and sustainability of the project, we require authors to have read **and** understand the code they submit themselves.
7. Commit messages must not contain advertisements for AI services/agents. This includes Co-authored-by lines and similar statements within the message text.

## License

This agreement is a near verbatim copy of [the _AI Agreement_ that the _CoMaps_ project has passed in March 2026](https://codeberg.org/comaps/Governance/pulls/136) which is [licensed under a Creative Commons CC BY 4.0 license](https://creativecommons.org/licenses/by/4.0/legalcode).

That agreement was in turn adapted from the _Forgejo_ project. The InfiniTime project extends its thanks to many upstream contributors to this policy, and also releases this version under the same CC BY 4.0 license with the hope that any further adopters of this policy would consider doing the same.
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# How to contribute?

> [!WARNING]
>All contributions must adhere to the [AI policy](AI_USAGE.md)

Here are things you can do to help.

- [Report bugs or issues](https://github.com/InfiniTimeOrg/InfiniTime/issues/new/choose)
Expand Down
4 changes: 2 additions & 2 deletions doc/BLEFS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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`
Expand Down
4 changes: 2 additions & 2 deletions doc/buildAndProgram.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

To build this project, you'll need:

- A cross-compiler : [ARM-GCC (10.3-2021.10)](https://developer.arm.com/downloads/-/gnu-rm)
- A cross-compiler : [ARM-GCC 15.3-Rel1 (arm-none-eabi)](https://gitlab.arm.com/tooling/gnu-toolchains-for-arm/-/tree/releases/15.3.rel1)
- The NRF52 SDK 15.3.0 : [nRF-SDK v15.3.0](https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/sdks/nrf5/binaries/nrf5sdk153059ac345.zip)
- The Python 3 modules `cbor`, `intelhex`, `click` and `cryptography` modules for the `mcuboot` tool (see [requirements.txt](../tools/mcuboot/requirements.txt))
- To keep the system clean, you can install python modules into a python virtual environment (`venv`)
Expand Down Expand Up @@ -38,7 +38,7 @@ CMake configures the project according to variables you specify the command line

Variable | Description | Example|
----------|-------------|--------|
**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`-DARM_NONE_EABI_TOOLCHAIN_PATH=/home/jf/nrf52/gcc-arm-none-eabi-10.3-2021.10/`|
**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`-DARM_NONE_EABI_TOOLCHAIN_PATH=/home/jf/nrf52/arm-gnu-toolchain-15.3.rel1-x86_64-arm-none-eabi/`|
**NRF5_SDK_PATH**|path to the NRF52 SDK|`-DNRF5_SDK_PATH=/home/jf/nrf52/Pinetime/sdk`|
**CMAKE_BUILD_TYPE (\*)**| Build type (Release or Debug). Release is applied by default if this variable is not specified.|`-DCMAKE_BUILD_TYPE=Debug`
**BUILD_DFU (\*\*)**|Build DFU files while building (needs [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-DBUILD_DFU=1`
Expand Down
2 changes: 1 addition & 1 deletion doc/buildWithVScode.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To support as many setups as possible the VS Code configuration files expect the

Variable | Description | Example
----------|-------------|--------
**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`export ARM_NONE_EABI_TOOLCHAIN_PATH=/opt/gcc-arm-none-eabi-10.3-2021.10`
**ARM_NONE_EABI_TOOLCHAIN_PATH**|path to the toolchain directory|`export ARM_NONE_EABI_TOOLCHAIN_PATH=/opt/arm-gnu-toolchain-15.3.rel1-x86_64-arm-none-eabi`
**NRF5_SDK_PATH**|path to the NRF52 SDK|`export NRF5_SDK_PATH=/opt/nRF5_SDK_15.3.0_59ac345`

## VS Code Extensions
Expand Down
6 changes: 3 additions & 3 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ 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 GCC_ARM_VER=${GCC_ARM_VER:="15.3.rel1"}
export NRF_SDK_VER=${NRF_SDK_VER:="nRF5_SDK_15.3.0_59ac345"}
# convert to lower case and remove _ and . character
# the download URL uses the SLUG, but the extracted folder is named like the original value
Expand All @@ -26,7 +26,7 @@ export NRF_SDK_VER_SLUG=${NRF_SDK_VER_SLUG//[_.]/}
MACHINE="$(uname -m)"
[ "$MACHINE" = "arm64" ] && MACHINE="aarch64"

export GCC_ARM_PATH="gcc-arm-none-eabi-$GCC_ARM_VER"
export GCC_ARM_PATH="arm-gnu-toolchain-$GCC_ARM_VER-$MACHINE-arm-none-eabi"

main() {
local target="$1"
Expand All @@ -50,7 +50,7 @@ main() {
}

GetGcc() {
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/$GCC_ARM_VER/$GCC_ARM_PATH-$MACHINE-linux.tar.bz2 -O - | tar -xj -C $TOOLS_DIR/
wget -q https://gitlab.arm.com/api/v4/projects/tooling%2Fgnu-toolchains-for-arm/packages/generic/gnu-toolchain/$GCC_ARM_VER/$GCC_ARM_PATH.tar.xz -O - | tar -xJ -C $TOOLS_DIR/
if [ ! -d "$TOOLS_DIR/$GCC_ARM_PATH" ]; then
echo "missing GCC path: $TOOLS_DIR/$GCC_ARM_PATH"
return 1
Expand Down
12 changes: 6 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ target_compile_options(${EXECUTABLE_NAME} PUBLIC

set_target_properties(${EXECUTABLE_NAME} PROPERTIES
SUFFIX ".out"
LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_FILE_NAME}.map"
LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_FILE_NAME}.map"
)

add_custom_command(TARGET ${EXECUTABLE_NAME}
Expand Down Expand Up @@ -965,7 +965,7 @@ target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC

set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES
SUFFIX ".out"
LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_MCUBOOT_FILE_NAME}.map"
LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_MCUBOOT_FILE_NAME}.map"
)

add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME}
Expand Down Expand Up @@ -1008,7 +1008,7 @@ target_compile_options(${EXECUTABLE_RECOVERY_NAME} PUBLIC

set_target_properties(${EXECUTABLE_RECOVERY_NAME} PROPERTIES
SUFFIX ".out"
LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_RECOVERY_FILE_NAME}.map"
LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_RECOVERY_FILE_NAME}.map"
)

add_custom_command(TARGET ${EXECUTABLE_RECOVERY_NAME}
Expand Down Expand Up @@ -1040,7 +1040,7 @@ target_compile_options(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC

set_target_properties(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PROPERTIES
SUFFIX ".out"
LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_GRAPHICS_FILE_NAME}.map"
LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_GRAPHICS_FILE_NAME}.map"
)

add_custom_command(TARGET ${EXECUTABLE_RECOVERY_MCUBOOT_NAME}
Expand Down Expand Up @@ -1083,7 +1083,7 @@ add_dependencies(${EXECUTABLE_RECOVERYLOADER_NAME} ${EXECUTABLE_RECOVERY_MCUBOOT

set_target_properties(${EXECUTABLE_RECOVERYLOADER_NAME} PROPERTIES
SUFFIX ".out"
LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_RECOVERYLOADER_FILE_NAME}.map"
LINK_FLAGS "-mthumb -mabi=aapcs -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_RECOVERYLOADER_FILE_NAME}.map"
)

add_custom_command(TARGET ${EXECUTABLE_RECOVERYLOADER_NAME}
Expand Down Expand Up @@ -1118,7 +1118,7 @@ add_dependencies(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} ${EXECUTABLE_RECOVERY

set_target_properties(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PROPERTIES
SUFFIX ".out"
LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.map"
LINK_FLAGS "-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT_MCUBOOT} -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,--gc-sections -Wl,--print-memory-usage --specs=nano.specs -Wl,-Map=${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}.map"
)

add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME}
Expand Down
2 changes: 1 addition & 1 deletion src/displayapp/screens/Notifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
} else {
// don't update id, notification manager will try to fetch
// but not find it. Refresh will try to load latest message
// or dismiss to watchface
// or dismiss to previous screen
}
DismissToBlack();
return true;
Expand Down
49 changes: 48 additions & 1 deletion src/stdlib.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <string.h>
#include <FreeRTOS.h>
#include <sys/stat.h>
#include <unistd.h>

// Override malloc() and free() to use the memory manager from FreeRTOS.
// According to the documentation of libc, we also need to override
Expand Down Expand Up @@ -29,7 +31,7 @@ void __wrap_free(void* ptr) {
}

void* calloc(size_t num, size_t size) {
void *ptr = malloc(num * size);
void* ptr = malloc(num * size);
if (ptr) {
memset(ptr, 0, num * size);
}
Expand All @@ -49,3 +51,48 @@ void* realloc(void* ptr, size_t newSize) {
void* __wrap_realloc(void* ptr, size_t newSize) {
return realloc(ptr, newSize);
}

// Implement functions required by libc as stubs
// These functions aren't linked into the final binary

__attribute__((error("stub"))) void _close(__attribute__((unused)) int fp) {
__builtin_trap();
}

__attribute__((error("stub"))) void _fstat(__attribute__((unused)) int fildes, __attribute__((unused)) struct stat* buf) {
__builtin_trap();
}

__attribute__((error("stub"))) pid_t _getpid() {
__builtin_trap();
}

__attribute__((error("stub"))) int _isatty(__attribute__((unused)) int fd) {
__builtin_trap();
}

__attribute__((error("stub"))) int _kill(__attribute__((unused)) pid_t pid, __attribute__((unused)) int sig) {
__builtin_trap();
}

__attribute__((error("stub"))) off_t _lseek(__attribute__((unused)) int fd,
__attribute__((unused)) off_t offset,
__attribute__((unused)) int whence) {
__builtin_trap();
}

__attribute__((error("stub"))) ssize_t _read(__attribute__((unused)) int fd,
__attribute__((unused)) void* buf,
__attribute__((unused)) size_t count) {
__builtin_trap();
}

__attribute__((error("stub"))) ssize_t _write(__attribute__((unused)) int fd,
__attribute__((unused)) void* buf,
__attribute__((unused)) size_t count) {
__builtin_trap();
}

__attribute__((error("stub"))) void _exit(__attribute__((unused)) int status) {
__builtin_trap();
}
15 changes: 7 additions & 8 deletions src/systemtask/SystemTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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);
Expand Down