From bb69a2feed82a380ec50b82bf3d35b1cb8fc75f4 Mon Sep 17 00:00:00 2001 From: Pat Pannuto Date: Wed, 16 Jul 2025 10:24:19 -0700 Subject: [PATCH 1/7] c23: use now-standard [[nodiscard]] in favor of compiler attribute --- libtock/tock.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libtock/tock.h b/libtock/tock.h index 061ee1f17..beaa1be4b 100644 --- a/libtock/tock.h +++ b/libtock/tock.h @@ -194,25 +194,25 @@ yield_waitfor_return_t yield_wait_for(uint32_t driver, uint32_t subscribe); void tock_exit(uint32_t completion_code) __attribute__ ((noreturn)); void tock_restart(uint32_t completion_code) __attribute__ ((noreturn)); -__attribute__ ((warn_unused_result)) +[[ nodiscard ]] syscall_return_t command(uint32_t driver, uint32_t command, int arg1, int arg2); // Pass this to the subscribe syscall as a function pointer to // be the Null Upcall. #define TOCK_NULL_UPCALL 0 -__attribute__ ((warn_unused_result)) +[[ nodiscard ]] subscribe_return_t subscribe(uint32_t driver, uint32_t subscribe, subscribe_upcall uc, void* userdata); -__attribute__ ((warn_unused_result)) +[[ nodiscard ]] allow_rw_return_t allow_readwrite(uint32_t driver, uint32_t allow, void* ptr, size_t size); -__attribute__ ((warn_unused_result)) +[[ nodiscard ]] allow_userspace_r_return_t allow_userspace_read(uint32_t driver, uint32_t allow, void* ptr, size_t size); -__attribute__ ((warn_unused_result)) +[[ nodiscard ]] allow_ro_return_t allow_readonly(uint32_t driver, uint32_t allow, const void* ptr, size_t size); // Call the memop syscall. From f4abc4d206744e4e8a2ce7c38ce35b2237255102 Mon Sep 17 00:00:00 2001 From: Leon Schuermann Date: Mon, 6 Jan 2025 05:40:33 -0500 Subject: [PATCH 2/7] workflows/ci: disable wget progress output spamming CI logs --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 215198482..7f9e67037 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,11 +37,18 @@ jobs: - uses: actions/checkout@v2 with: submodules: recursive + - uses: carlosperate/arm-none-eabi-gcc-action@v1 - run: arm-none-eabi-gcc --version - name: setup-riscv-toolchain run: sudo apt-get install -y gcc-riscv64-unknown-elf + + - name: Disable wget progress output + run: | + echo "verbose = off" >> $HOME/.wgetrc + - name: ci-build run: pushd examples; ./build_all.sh || exit; popd + - name: ci-debug-build run: pushd examples/blink; make debug RAM_START=0x20004000 FLASH_INIT=0x30051 || exit; popd From 4d9d6fe5fd34ed3ec40cdaaad86696610dd4efde Mon Sep 17 00:00:00 2001 From: Pat Pannuto Date: Wed, 23 Jul 2025 10:57:25 -0700 Subject: [PATCH 3/7] ci: update to latest LTS --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f9e67037..92922b127 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: ci-format: strategy: matrix: - os: [ubuntu-22.04] + os: [ubuntu-24.04] # The type of runner that the job will run on runs-on: ${{ matrix.os }} @@ -28,7 +28,7 @@ jobs: ci-build: strategy: matrix: - os: [ubuntu-22.04] + os: [ubuntu-24.04] # The type of runner that the job will run on runs-on: ${{ matrix.os }} From 48041b0a3432d1a02a866b86e499a3b17d34c2d4 Mon Sep 17 00:00:00 2001 From: Pat Pannuto Date: Wed, 23 Jul 2025 10:56:05 -0700 Subject: [PATCH 4/7] build: check compiler version and enforce >= 13 --- Configuration.mk | 15 +++++++++++++++ Helpers.mk | 20 -------------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Configuration.mk b/Configuration.mk index f5d135e28..d28954dfc 100644 --- a/Configuration.mk +++ b/Configuration.mk @@ -18,6 +18,9 @@ CONFIGURATION_MAKEFILE = 1 MAKEFLAGS += -r MAKEFLAGS += -R +# Enforce a minimum complier version +MINIMUM_GCC_MAJOR := 13 + # Toolchain programs. AR := -ar AS := -as @@ -260,6 +263,12 @@ ifneq ($(findstring rv32i,$(TOCK_ARCH_FAMILIES)),) CC_rv32_version_major := $(shell echo $(CC_rv32_version) | cut -f1 -d.) endif +# Validate the the toolchain is new enough +ifneq (1,$(shell [ $(CC_rv32_version_major) -ge $(MINIMUM_GCC_MAJOR) ] && echo "1")) + $(info $(TOOLCHAIN_rv32)$(CC_rv32) -dumpfullversion: $(CC_rv32_version)) + $(error Your compiler is too old. Need gcc version >= $(MINIMUM_GCC_MAJOR)) +endif + # Match compiler version to support libtock-newlib versions. ifeq ($(CC_rv32_version_major),10) NEWLIB_VERSION_rv32 := 4.2.0.20211231 @@ -406,6 +415,12 @@ ifneq ($(findstring cortex-m,$(TOCK_ARCH_FAMILIES)),) CC_cortex-m_version_major := $(shell echo $(CC_cortex-m_version) | cut -f1 -d.) endif +# Validate the the toolchain is new enough +ifneq (1,$(shell [ $(CC_cortex-m_version_major) -ge $(MINIMUM_GCC_MAJOR) ] && echo "1")) + $(info $(TOOLCHAIN_cortex-m)$(CC_cortex-m) -dumpfullversion: $(CC_cortex-m_version)) + $(error Your compiler is too old. Need gcc version >= $(MINIMUM_GCC_MAJOR)) +endif + # Match compiler version to support libtock-newlib versions. ifeq ($(CC_cortex-m_version_major),10) NEWLIB_VERSION_cortex-m := 4.2.0.20211231 diff --git a/Helpers.mk b/Helpers.mk index a1f13bd16..076e6aac0 100644 --- a/Helpers.mk +++ b/Helpers.mk @@ -40,26 +40,6 @@ ifdef TOCK_USERLAND_BASE_DIR endif endif -# # Validate the the toolchain is new enough (known not to work for gcc <= 5.1) -# CC_VERSION_MAJOR := $(shell $(CC) -dumpversion | cut -d '.' -f1) -# ifeq (1,$(shell expr $(CC_VERSION_MAJOR) \>= 6)) -# # Opportunistically turn on gcc 6.0+ warnings since we're already version checking: -# override CPPFLAGS += -Wduplicated-cond # if (p->q != NULL) { ... } else if (p->q != NULL) { ... } -# override CPPFLAGS += -Wnull-dereference # deref of NULL (thought default if -fdelete-null-pointer-checks, in -Os, but no?) -# else -# ifneq (5,$(CC_VERSION_MAJOR)) -# $(info CC=$(CC)) -# $(info $$(CC) -dumpversion: $(shell $(CC) -dumpversion)) -# $(error Your compiler is too old. Need gcc version > 5.1) -# endif -# CC_VERSION_MINOR := $(shell $(CC) -dumpversion | cut -d '.' -f2) -# ifneq (1,$(shell expr $(CC_VERSION_MINOR) \> 1)) -# $(info CC=$(CC)) -# $(info $$(CC) -dumpversion: $(shell $(CC) -dumpversion)) -# $(error Your compiler is too old. Need gcc version > 5.1) -# endif -# endif - # Format check rule .PHONY: _format_check_unstaged From 7b3350368c31468a2f687c0eb77ec9bc0612c22f Mon Sep 17 00:00:00 2001 From: Pat Pannuto Date: Wed, 23 Jul 2025 11:42:00 -0700 Subject: [PATCH 5/7] build: add option to opt-out of compiler version check --- .github/workflows/ci.yml | 2 ++ Configuration.mk | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92922b127..aa2f13c78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,8 @@ jobs: with: submodules: false # LVGL makefile manually installs the submodule - name: ci-format + env: + TOCK_SUPPRESS_CC_VERSION_CHECK: "true" run: pushd examples; ./format_all.sh || exit; popd ci-build: diff --git a/Configuration.mk b/Configuration.mk index d28954dfc..94325959b 100644 --- a/Configuration.mk +++ b/Configuration.mk @@ -264,10 +264,12 @@ ifneq ($(findstring rv32i,$(TOCK_ARCH_FAMILIES)),) endif # Validate the the toolchain is new enough +ifeq ($(TOCK_SUPPRESS_CC_VERSION_CHECK),) ifneq (1,$(shell [ $(CC_rv32_version_major) -ge $(MINIMUM_GCC_MAJOR) ] && echo "1")) $(info $(TOOLCHAIN_rv32)$(CC_rv32) -dumpfullversion: $(CC_rv32_version)) $(error Your compiler is too old. Need gcc version >= $(MINIMUM_GCC_MAJOR)) endif +endif # Match compiler version to support libtock-newlib versions. ifeq ($(CC_rv32_version_major),10) @@ -416,10 +418,12 @@ ifneq ($(findstring cortex-m,$(TOCK_ARCH_FAMILIES)),) endif # Validate the the toolchain is new enough +ifeq ($(TOCK_SUPPRESS_CC_VERSION_CHECK),) ifneq (1,$(shell [ $(CC_cortex-m_version_major) -ge $(MINIMUM_GCC_MAJOR) ] && echo "1")) $(info $(TOOLCHAIN_cortex-m)$(CC_cortex-m) -dumpfullversion: $(CC_cortex-m_version)) $(error Your compiler is too old. Need gcc version >= $(MINIMUM_GCC_MAJOR)) endif +endif # Match compiler version to support libtock-newlib versions. ifeq ($(CC_cortex-m_version_major),10) From f0d623590506ba82fd228956bd4e3218ae28435e Mon Sep 17 00:00:00 2001 From: Pat Pannuto Date: Wed, 23 Jul 2025 11:52:21 -0700 Subject: [PATCH 6/7] fix type-pun alias warning --- .../thread_tutorials/temperature_sensor/10_screen_ipc/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/thread_tutorials/temperature_sensor/10_screen_ipc/main.c b/examples/tutorials/thread_tutorials/temperature_sensor/10_screen_ipc/main.c index d14653ba6..2b194ac67 100644 --- a/examples/tutorials/thread_tutorials/temperature_sensor/10_screen_ipc/main.c +++ b/examples/tutorials/thread_tutorials/temperature_sensor/10_screen_ipc/main.c @@ -83,7 +83,7 @@ static void sensor_callback(__attribute__ ((unused)) int pid, __attribute__ ((unused)) int arg2, __attribute__ ((unused)) void* ud) { // update measured temperature - measured_temperature = *((int*) &temperature_buffer[0]); + memcpy(&measured_temperature, temperature_buffer, sizeof(measured_temperature)); // Indicate that we have received a callback. callback_event = true; @@ -99,7 +99,7 @@ static void openthread_callback(__attribute__ ((unused)) int pid, network_up = true; // update setpoint temperature - global_temperature_setpoint = *((int*) &openthread_buffer[0]); + memcpy(&global_temperature_setpoint, openthread_buffer, sizeof(global_temperature_setpoint)); // Indicate that we have received a callback. callback_event = true; From ea0ab80e7d1c84b88c55b6f64a112cbc6238c607 Mon Sep 17 00:00:00 2001 From: Pat Pannuto Date: Wed, 23 Jul 2025 12:23:31 -0700 Subject: [PATCH 7/7] build: only validate compiler version for used arches --- Configuration.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Configuration.mk b/Configuration.mk index 94325959b..83368d793 100644 --- a/Configuration.mk +++ b/Configuration.mk @@ -265,11 +265,13 @@ endif # Validate the the toolchain is new enough ifeq ($(TOCK_SUPPRESS_CC_VERSION_CHECK),) +ifneq ($(CC_rv32_version),) ifneq (1,$(shell [ $(CC_rv32_version_major) -ge $(MINIMUM_GCC_MAJOR) ] && echo "1")) $(info $(TOOLCHAIN_rv32)$(CC_rv32) -dumpfullversion: $(CC_rv32_version)) $(error Your compiler is too old. Need gcc version >= $(MINIMUM_GCC_MAJOR)) endif endif +endif # Match compiler version to support libtock-newlib versions. ifeq ($(CC_rv32_version_major),10) @@ -419,11 +421,13 @@ endif # Validate the the toolchain is new enough ifeq ($(TOCK_SUPPRESS_CC_VERSION_CHECK),) +ifneq ($(CC_cortex-m_version),) ifneq (1,$(shell [ $(CC_cortex-m_version_major) -ge $(MINIMUM_GCC_MAJOR) ] && echo "1")) $(info $(TOOLCHAIN_cortex-m)$(CC_cortex-m) -dumpfullversion: $(CC_cortex-m_version)) $(error Your compiler is too old. Need gcc version >= $(MINIMUM_GCC_MAJOR)) endif endif +endif # Match compiler version to support libtock-newlib versions. ifeq ($(CC_cortex-m_version_major),10)