From d435d66921203b2194da372f339bc468938db574 Mon Sep 17 00:00:00 2001 From: Willow Herring <31960031+ReFil@users.noreply.github.com> Date: Wed, 28 Jan 2026 18:55:22 +0000 Subject: [PATCH 1/2] fix: Fix build errors on GCC15 --- Makefile | 4 ++-- src/usb/uf2/ghostfat.c | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 0c9ccd6..9d2d4df 100644 --- a/Makefile +++ b/Makefile @@ -393,8 +393,8 @@ endif CFLAGS += -DDFU_APP_DATA_RESERVED=$(DFU_APP_DATA_RESERVED) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 -# Fixes for gcc version 12, 13 and 14. -ifneq (,$(filter 12.% 13.% 14.%,$(shell $(CC) -dumpversion 2>$(NULL_DEVICE)))) +# Fixes for gcc version 12, 13, 14 and 15. +ifneq (,$(filter 12.% 13.% 14.% 15.%,$(shell $(CC) -dumpversion 2>$(NULL_DEVICE)))) CFLAGS += --param=min-pagesize=0 endif diff --git a/src/usb/uf2/ghostfat.c b/src/usb/uf2/ghostfat.c index d748904..0564182 100644 --- a/src/usb/uf2/ghostfat.c +++ b/src/usb/uf2/ghostfat.c @@ -40,9 +40,16 @@ // //--------------------------------------------------------------------+ +// Add nonstring attribute if supported to avoid errors in GCC 15 +#ifdef __has_attribute + #define __NONSTRING__ __attribute__((nonstring)) +#else + #define __NONSTRING__ +#endif + typedef struct { uint8_t JumpInstruction[3]; - uint8_t OEMInfo[8]; + uint8_t OEMInfo[8] __NONSTRING__; uint16_t SectorSize; uint8_t SectorsPerCluster; uint16_t ReservedSectors; @@ -59,8 +66,8 @@ typedef struct { uint8_t Reserved; uint8_t ExtendedBootSig; uint32_t VolumeSerialNumber; - uint8_t VolumeLabel[11]; - uint8_t FilesystemIdentifier[8]; + uint8_t VolumeLabel[11] __NONSTRING__; + uint8_t FilesystemIdentifier[8] __NONSTRING__; } __attribute__((packed)) FAT_BootBlock; typedef struct { @@ -81,7 +88,7 @@ typedef struct { STATIC_ASSERT(sizeof(DirEntry) == 32); struct TextFile { - char const name[11]; + char const name[11] __NONSTRING__; char const *content; }; From 6b24be5f69e03a25aacc41f06e2364a1576c8141 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 3 Feb 2026 14:14:08 +0700 Subject: [PATCH 2/2] - add GCC diagnostic ignored "-Warray-bounds" to affected code - correct usage of __has_attribute(nonstring) and rename to ATTR_NOSTRING --- Makefile | 6 ---- .../bootloader_dfu/bootloader_settings.c | 31 ++++++++++++------- src/usb/uf2/ghostfat.c | 22 ++++++------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 9d2d4df..f1fb137 100644 --- a/Makefile +++ b/Makefile @@ -392,12 +392,6 @@ endif CFLAGS += -DDFU_APP_DATA_RESERVED=$(DFU_APP_DATA_RESERVED) -# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 -# Fixes for gcc version 12, 13, 14 and 15. -ifneq (,$(filter 12.% 13.% 14.% 15.%,$(shell $(CC) -dumpversion 2>$(NULL_DEVICE)))) - CFLAGS += --param=min-pagesize=0 -endif - #------------------------------------------------------------------------------ # Linker Flags #------------------------------------------------------------------------------ diff --git a/lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.c b/lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.c index c071020..1febf3f 100644 --- a/lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.c +++ b/lib/sdk11/components/libraries/bootloader_dfu/bootloader_settings.c @@ -40,15 +40,22 @@ void bootloader_util_settings_get(const bootloader_settings_t ** pp_bootloader_s *pp_bootloader_settings = p_bootloader_settings; } -void bootloader_mbr_addrs_populate(void) -{ - if (*(const uint32_t *)MBR_BOOTLOADER_ADDR == 0xFFFFFFFF) - { - nrfx_nvmc_word_write(MBR_BOOTLOADER_ADDR, BOOTLOADER_REGION_START); - } - - if (*(const uint32_t *)MBR_PARAM_PAGE_ADDR == 0xFFFFFFFF) - { - nrfx_nvmc_word_write(MBR_PARAM_PAGE_ADDR, BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS); - } -} +void bootloader_mbr_addrs_populate(void) +{ +#if defined(__GNUC__) && (__GNUC__ >= 12) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif + if (*(const uint32_t *)MBR_BOOTLOADER_ADDR == 0xFFFFFFFF) + { + nrfx_nvmc_word_write(MBR_BOOTLOADER_ADDR, BOOTLOADER_REGION_START); + } + + if (*(const uint32_t *)MBR_PARAM_PAGE_ADDR == 0xFFFFFFFF) + { + nrfx_nvmc_word_write(MBR_PARAM_PAGE_ADDR, BOOTLOADER_MBR_PARAMS_PAGE_ADDRESS); + } +#if defined(__GNUC__) && (__GNUC__ >= 12) +#pragma GCC diagnostic pop +#endif +} diff --git a/src/usb/uf2/ghostfat.c b/src/usb/uf2/ghostfat.c index 0564182..97753ef 100644 --- a/src/usb/uf2/ghostfat.c +++ b/src/usb/uf2/ghostfat.c @@ -41,18 +41,18 @@ //--------------------------------------------------------------------+ // Add nonstring attribute if supported to avoid errors in GCC 15 -#ifdef __has_attribute - #define __NONSTRING__ __attribute__((nonstring)) +#if defined(__has_attribute) && __has_attribute(nonstring) + #define ATTR_NONSTRING __attribute__((nonstring)) #else - #define __NONSTRING__ + #define ATTR_NONSTRING #endif typedef struct { uint8_t JumpInstruction[3]; - uint8_t OEMInfo[8] __NONSTRING__; - uint16_t SectorSize; - uint8_t SectorsPerCluster; - uint16_t ReservedSectors; + uint8_t OEMInfo[8] ATTR_NONSTRING; + uint16_t SectorSize; + uint8_t SectorsPerCluster; + uint16_t ReservedSectors; uint8_t FATCopies; uint16_t RootDirectoryEntries; uint16_t TotalSectors16; @@ -66,8 +66,8 @@ typedef struct { uint8_t Reserved; uint8_t ExtendedBootSig; uint32_t VolumeSerialNumber; - uint8_t VolumeLabel[11] __NONSTRING__; - uint8_t FilesystemIdentifier[8] __NONSTRING__; + uint8_t VolumeLabel[11] ATTR_NONSTRING; + uint8_t FilesystemIdentifier[8] ATTR_NONSTRING; } __attribute__((packed)) FAT_BootBlock; typedef struct { @@ -88,8 +88,8 @@ typedef struct { STATIC_ASSERT(sizeof(DirEntry) == 32); struct TextFile { - char const name[11] __NONSTRING__; - char const *content; + const char name[11] ATTR_NONSTRING; + const char *content; };