From 14dabf523ac382ddc7c17f65f79440993edc47c5 Mon Sep 17 00:00:00 2001 From: hedger Date: Mon, 12 Feb 2024 02:04:12 +0000 Subject: [PATCH] New toolchain with gcc 12 (#3254) * changes for xPack 12.3 * support for gcc 13.2 * Update tools name * Add new linux toolchain * Fixed copro submodule * Fix gdb-py * Fixes for c++ apps * Fix gdb-py3, add udev rules * Fixed udev rules location * Add MacOS arm, fix fbt toolchain download * Fixed downloading error file * fbt: fixed linker warnings; removed gcc 10 from list of supported toolchains * ufbt: fixed supported toolchain versions * nfc: replaced local malloc with calloc * restored code with Warray-bounds to older state * Update fbtenv.cmd * Suppressing warnings * Bump to 25 * Bump to 26 * lint: reformatted macros for new clang-format * Bump to 27 * Fix m type word * Bump to 28 * furi: added FURI_DEPRECATED macro * scripts: toolchain download on Windows: fixing partially extracted cases Co-authored-by: DrunkBatya --- .../debug/unit_tests/furi/furi_memmgr_test.c | 1 + .../main/nfc/scenes/nfc_scene_set_type.c | 2 +- ...subghz_frequency_analyzer_log_item_array.h | 3 + applications/services/dolphin/dolphin.c | 2 +- applications/services/gui/canvas.c | 1 - applications/services/gui/canvas_i.h | 4 +- applications/services/rpc/rpc_storage.c | 3 + fbt_options.py | 3 +- furi/core/common_defines.h | 4 ++ furi/core/core_defines.h | 6 +- furi/core/dangerous_defines.h | 31 +++++----- furi/core/string.h | 20 ++++--- lib/digital_signal/digital_signal.h | 6 +- .../iso14443_3a/iso14443_3a_poller_i.h | 2 +- lib/nfc/protocols/mf_classic/crypto1.c | 2 +- lib/pulse_reader/pulse_reader.c | 4 +- lib/u8g2/u8x8.h | 4 +- scripts/debug/41-udev.rules | 10 ++++ scripts/fbt_tools/gdb.py | 2 +- scripts/toolchain/fbtenv.cmd | 4 +- scripts/toolchain/fbtenv.sh | 56 +++++-------------- .../toolchain/windows-toolchain-download.ps1 | 9 ++- scripts/ufbt/SConstruct | 4 +- site_scons/cc.scons | 2 + site_scons/extapps.scons | 1 - site_scons/firmwareopts.scons | 1 - targets/f18/api_symbols.csv | 14 +++-- targets/f7/api_symbols.csv | 14 +++-- targets/f7/ble_glue/gap.c | 2 +- targets/f7/furi_hal/furi_hal_flash.c | 2 +- targets/f7/furi_hal/furi_hal_memory.c | 4 +- targets/f7/furi_hal/furi_hal_os.c | 4 +- .../f7/platform_specific/cxx_virtual_stub.c | 6 ++ .../f7/platform_specific/cxx_virtual_stub.h | 13 +++++ 34 files changed, 141 insertions(+), 105 deletions(-) create mode 100644 scripts/debug/41-udev.rules create mode 100644 targets/f7/platform_specific/cxx_virtual_stub.c create mode 100644 targets/f7/platform_specific/cxx_virtual_stub.h diff --git a/applications/debug/unit_tests/furi/furi_memmgr_test.c b/applications/debug/unit_tests/furi/furi_memmgr_test.c index a28632cf4..9012eed78 100644 --- a/applications/debug/unit_tests/furi/furi_memmgr_test.c +++ b/applications/debug/unit_tests/furi/furi_memmgr_test.c @@ -2,6 +2,7 @@ #include #include #include +#include void test_furi_memmgr() { void* ptr; diff --git a/applications/main/nfc/scenes/nfc_scene_set_type.c b/applications/main/nfc/scenes/nfc_scene_set_type.c index b5102f801..fc5f90f0c 100644 --- a/applications/main/nfc/scenes/nfc_scene_set_type.c +++ b/applications/main/nfc/scenes/nfc_scene_set_type.c @@ -10,7 +10,7 @@ enum SubmenuIndex { static void nfc_scene_set_type_init_edit_data(Iso14443_3aData* data, size_t uid_len) { // Easiest way to create a zero'd buffer of given length - uint8_t* uid = malloc(uid_len); + uint8_t* uid = calloc(1, uid_len); iso14443_3a_set_uid(data, uid, uid_len); free(uid); } diff --git a/applications/main/subghz/helpers/subghz_frequency_analyzer_log_item_array.h b/applications/main/subghz/helpers/subghz_frequency_analyzer_log_item_array.h index 2fa70284a..6e6b553e0 100644 --- a/applications/main/subghz/helpers/subghz_frequency_analyzer_log_item_array.h +++ b/applications/main/subghz/helpers/subghz_frequency_analyzer_log_item_array.h @@ -40,6 +40,8 @@ ARRAY_DEF(SubGhzFrequencyAnalyzerLogItemArray, SubGhzFrequencyAnalyzerLogItem_t) ARRAY_OPLIST(SubGhzFrequencyAnalyzerLogItemArray, M_OPL_SubGhzFrequencyAnalyzerLogItem_t()) ALGO_DEF(SubGhzFrequencyAnalyzerLogItemArray, SubGhzFrequencyAnalyzerLogItemArray_t) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" FUNC_OBJ_INS_DEF( SubGhzFrequencyAnalyzerLogItemArray_compare_by /* name of the instance */, SubGhzFrequencyAnalyzerLogItemArray_cmp_obj /* name of the interface */, @@ -76,3 +78,4 @@ FUNC_OBJ_INS_DEF( (order_by, SubGhzFrequencyAnalyzerLogOrderBy)) #define M_OPL_SubGhzFrequencyAnalyzerLogItemArray_compare_by_t() \ FUNC_OBJ_INS_OPLIST(SubGhzFrequencyAnalyzerLogItemArray_compare_by, M_DEFAULT_OPLIST) +#pragma GCC diagnostic pop diff --git a/applications/services/dolphin/dolphin.c b/applications/services/dolphin/dolphin.c index bef7c4a28..520a01978 100644 --- a/applications/services/dolphin/dolphin.c +++ b/applications/services/dolphin/dolphin.c @@ -8,7 +8,7 @@ #define DOLPHIN_LOCK_EVENT_FLAG (0x1) #define TAG "Dolphin" -#define HOURS_IN_TICKS(x) ((x)*60 * 60 * 1000) +#define HOURS_IN_TICKS(x) ((x) * 60 * 60 * 1000) static void dolphin_update_clear_limits_timer_period(Dolphin* dolphin); diff --git a/applications/services/gui/canvas.c b/applications/services/gui/canvas.c index 897f0ae13..9c9457123 100644 --- a/applications/services/gui/canvas.c +++ b/applications/services/gui/canvas.c @@ -1,5 +1,4 @@ #include "canvas_i.h" -#include "icon_i.h" #include "icon_animation_i.h" #include diff --git a/applications/services/gui/canvas_i.h b/applications/services/gui/canvas_i.h index 73502b719..0982830c9 100644 --- a/applications/services/gui/canvas_i.h +++ b/applications/services/gui/canvas_i.h @@ -122,7 +122,7 @@ void canvas_draw_u8g2_bitmap( uint8_t width, uint8_t height, const uint8_t* bitmap, - uint8_t rotation); + IconRotation rotation); /** Add canvas commit callback. * @@ -147,4 +147,4 @@ void canvas_remove_framebuffer_callback( #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/applications/services/rpc/rpc_storage.c b/applications/services/rpc/rpc_storage.c index a934d1c31..151d73d61 100644 --- a/applications/services/rpc/rpc_storage.c +++ b/applications/services/rpc/rpc_storage.c @@ -395,9 +395,12 @@ static void rpc_system_storage_read_process(const PB_Main* request, void* contex response->has_next = fs_operation_success && (size_left > 0); } else { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" response->content.storage_read_response.file.data = malloc(PB_BYTES_ARRAY_T_ALLOCSIZE(0)); response->content.storage_read_response.file.data->size = 0; +#pragma GCC diagnostic pop response->content.storage_read_response.has_file = true; response->has_next = false; fs_operation_success = true; diff --git a/fbt_options.py b/fbt_options.py index 277790a40..9e4d821a4 100644 --- a/fbt_options.py +++ b/fbt_options.py @@ -38,7 +38,8 @@ COPRO_STACK_ADDR = "0x0" COPRO_STACK_BIN_DIR = posixpath.join(COPRO_CUBE_DIR, "firmware") # Supported toolchain versions -FBT_TOOLCHAIN_VERSIONS = (" 10.3.",) +# Also specify in scripts/ufbt/SConstruct +FBT_TOOLCHAIN_VERSIONS = (" 12.3.", " 13.2.") OPENOCD_OPTS = [ "-f", diff --git a/furi/core/common_defines.h b/furi/core/common_defines.h index 2fc12dedb..820297863 100644 --- a/furi/core/common_defines.h +++ b/furi/core/common_defines.h @@ -13,6 +13,10 @@ extern "C" { #define FURI_WARN_UNUSED __attribute__((warn_unused_result)) #endif +#ifndef FURI_DEPRECATED +#define FURI_DEPRECATED __attribute__((deprecated)) +#endif + #ifndef FURI_WEAK #define FURI_WEAK __attribute__((weak)) #endif diff --git a/furi/core/core_defines.h b/furi/core/core_defines.h index 4309c20c5..732a90cb5 100644 --- a/furi/core/core_defines.h +++ b/furi/core/core_defines.h @@ -84,9 +84,9 @@ extern "C" { #endif #ifndef REVERSE_BYTES_U32 -#define REVERSE_BYTES_U32(x) \ - ((((x)&0x000000FF) << 24) | (((x)&0x0000FF00) << 8) | (((x)&0x00FF0000) >> 8) | \ - (((x)&0xFF000000) >> 24)) +#define REVERSE_BYTES_U32(x) \ + ((((x) & 0x000000FF) << 24) | (((x) & 0x0000FF00) << 8) | (((x) & 0x00FF0000) >> 8) | \ + (((x) & 0xFF000000) >> 24)) #endif #ifndef FURI_BIT diff --git a/furi/core/dangerous_defines.h b/furi/core/dangerous_defines.h index b477710ac..683df2f61 100644 --- a/furi/core/dangerous_defines.h +++ b/furi/core/dangerous_defines.h @@ -26,19 +26,20 @@ *tmp_x = y; \ *tmp_x; \ }) -#define FURI_CONST_ASSIGN(x, y) \ - _Generic((x), signed char \ - : FURI_CONST_ASSIGN_(signed char, x, y), unsigned char \ - : FURI_CONST_ASSIGN_(unsigned char, x, y), short \ - : FURI_CONST_ASSIGN_(short, x, y), unsigned short \ - : FURI_CONST_ASSIGN_(unsigned short, x, y), int \ - : FURI_CONST_ASSIGN_(int, x, y), unsigned \ - : FURI_CONST_ASSIGN_(unsigned, x, y), long \ - : FURI_CONST_ASSIGN_(long, x, y), unsigned long \ - : FURI_CONST_ASSIGN_(unsigned long, x, y), long long \ - : FURI_CONST_ASSIGN_(long long, x, y), unsigned long long \ - : FURI_CONST_ASSIGN_(unsigned long long, x, y), float \ - : FURI_CONST_ASSIGN_(float, x, y), double \ - : FURI_CONST_ASSIGN_(double, x, y), long double \ - : FURI_CONST_ASSIGN_(long double, x, y)) +#define FURI_CONST_ASSIGN(x, y) \ + _Generic( \ + (x), \ + signed char: FURI_CONST_ASSIGN_(signed char, x, y), \ + unsigned char: FURI_CONST_ASSIGN_(unsigned char, x, y), \ + short: FURI_CONST_ASSIGN_(short, x, y), \ + unsigned short: FURI_CONST_ASSIGN_(unsigned short, x, y), \ + int: FURI_CONST_ASSIGN_(int, x, y), \ + unsigned: FURI_CONST_ASSIGN_(unsigned, x, y), \ + long: FURI_CONST_ASSIGN_(long, x, y), \ + unsigned long: FURI_CONST_ASSIGN_(unsigned long, x, y), \ + long long: FURI_CONST_ASSIGN_(long long, x, y), \ + unsigned long long: FURI_CONST_ASSIGN_(unsigned long long, x, y), \ + float: FURI_CONST_ASSIGN_(float, x, y), \ + double: FURI_CONST_ASSIGN_(double, x, y), \ + long double: FURI_CONST_ASSIGN_(long double, x, y)) #endif diff --git a/furi/core/string.h b/furi/core/string.h index 7529deacd..0e3e6a88e 100644 --- a/furi/core/string.h +++ b/furi/core/string.h @@ -568,26 +568,30 @@ void furi_string_utf8_decode(char c, FuriStringUTF8State* state, FuriStringUnico /** * @brief Select for 1 argument */ -#define FURI_STRING_SELECT1(func1, func2, a) \ - _Generic((a), char* : func2, const char* : func2, FuriString* : func1, const FuriString* : func1)(a) +#define FURI_STRING_SELECT1(func1, func2, a) \ + _Generic((a), char*: func2, const char*: func2, FuriString*: func1, const FuriString*: func1)( \ + a) /** * @brief Select for 2 arguments */ -#define FURI_STRING_SELECT2(func1, func2, a, b) \ - _Generic((b), char* : func2, const char* : func2, FuriString* : func1, const FuriString* : func1)(a, b) +#define FURI_STRING_SELECT2(func1, func2, a, b) \ + _Generic((b), char*: func2, const char*: func2, FuriString*: func1, const FuriString*: func1)( \ + a, b) /** * @brief Select for 3 arguments */ -#define FURI_STRING_SELECT3(func1, func2, a, b, c) \ - _Generic((b), char* : func2, const char* : func2, FuriString* : func1, const FuriString* : func1)(a, b, c) +#define FURI_STRING_SELECT3(func1, func2, a, b, c) \ + _Generic((b), char*: func2, const char*: func2, FuriString*: func1, const FuriString*: func1)( \ + a, b, c) /** * @brief Select for 4 arguments */ -#define FURI_STRING_SELECT4(func1, func2, a, b, c, d) \ - _Generic((b), char* : func2, const char* : func2, FuriString* : func1, const FuriString* : func1)(a, b, c, d) +#define FURI_STRING_SELECT4(func1, func2, a, b, c, d) \ + _Generic((b), char*: func2, const char*: func2, FuriString*: func1, const FuriString*: func1)( \ + a, b, c, d) /** * @brief Allocate new FuriString and set it content to string (or C string). diff --git a/lib/digital_signal/digital_signal.h b/lib/digital_signal/digital_signal.h index f29facfd8..1ab637009 100644 --- a/lib/digital_signal/digital_signal.h +++ b/lib/digital_signal/digital_signal.h @@ -26,9 +26,9 @@ extern "C" { // DigitalSignal uses 10 picosecond time units (1 tick = 10 ps). // Use the macros below to convert the time from other units. -#define DIGITAL_SIGNAL_MS(x) ((x)*100000000UL) -#define DIGITAL_SIGNAL_US(x) ((x)*100000UL) -#define DIGITAL_SIGNAL_NS(x) ((x)*100UL) +#define DIGITAL_SIGNAL_MS(x) ((x) * 100000000UL) +#define DIGITAL_SIGNAL_US(x) ((x) * 100000UL) +#define DIGITAL_SIGNAL_NS(x) ((x) * 100UL) #define DIGITAL_SIGNAL_PS(x) ((x) / 10UL) typedef struct DigitalSignal DigitalSignal; diff --git a/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.h b/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.h index 764f1a6b5..664d54598 100644 --- a/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.h +++ b/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.h @@ -11,7 +11,7 @@ extern "C" { #define ISO14443_3A_POLLER_MAX_BUFFER_SIZE (512U) #define ISO14443_3A_POLLER_SEL_CMD(cascade_lvl) (0x93 + 2 * (cascade_lvl)) -#define ISO14443_3A_POLLER_SEL_PAR(bytes, bits) (((bytes) << 4 & 0xf0U) | ((bits)&0x0fU)) +#define ISO14443_3A_POLLER_SEL_PAR(bytes, bits) (((bytes) << 4 & 0xf0U) | ((bits) & 0x0fU)) #define ISO14443_3A_POLLER_SDD_CL (0x88U) typedef enum { diff --git a/lib/nfc/protocols/mf_classic/crypto1.c b/lib/nfc/protocols/mf_classic/crypto1.c index 02bc677ba..0758b05fb 100644 --- a/lib/nfc/protocols/mf_classic/crypto1.c +++ b/lib/nfc/protocols/mf_classic/crypto1.c @@ -6,7 +6,7 @@ // Algorithm from https://github.com/RfidResearchGroup/proxmark3.git #define SWAPENDIAN(x) \ - ((x) = ((x) >> 8 & 0xff00ff) | ((x)&0xff00ff) << 8, (x) = (x) >> 16 | (x) << 16) + ((x) = ((x) >> 8 & 0xff00ff) | ((x) & 0xff00ff) << 8, (x) = (x) >> 16 | (x) << 16) #define LF_POLY_ODD (0x29CE5C) #define LF_POLY_EVEN (0x870804) diff --git a/lib/pulse_reader/pulse_reader.c b/lib/pulse_reader/pulse_reader.c index 1c3cb4a58..0fcafe67c 100644 --- a/lib/pulse_reader/pulse_reader.c +++ b/lib/pulse_reader/pulse_reader.c @@ -212,8 +212,8 @@ uint32_t pulse_reader_receive(PulseReader* signal, int timeout_us) { /* probably larger values, so choose a wider data type */ if(signal->unit_divider > 1) { - delta_unit = - (uint32_t)((uint64_t)delta * (uint64_t)signal->unit_multiplier / signal->unit_divider); + delta_unit = (uint32_t)((uint64_t)delta * (uint64_t)signal->unit_multiplier / + signal->unit_divider); } else { delta_unit = delta * signal->unit_multiplier; } diff --git a/lib/u8g2/u8x8.h b/lib/u8g2/u8x8.h index 389fdfa9b..834284f5d 100644 --- a/lib/u8g2/u8x8.h +++ b/lib/u8g2/u8x8.h @@ -688,8 +688,8 @@ uint8_t u8x8_byte_sed1520(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ #define U8X8_MSG_GPIO(x) (64 + (x)) #ifdef U8X8_USE_PINS -#define u8x8_GetPinIndex(u8x8, msg) ((msg)&0x3f) -#define u8x8_GetPinValue(u8x8, msg) ((u8x8)->pins[(msg)&0x3f]) +#define u8x8_GetPinIndex(u8x8, msg) ((msg) & 0x3f) +#define u8x8_GetPinValue(u8x8, msg) ((u8x8)->pins[(msg) & 0x3f]) #endif #define U8X8_MSG_GPIO_D0 U8X8_MSG_GPIO(U8X8_PIN_D0) diff --git a/scripts/debug/41-udev.rules b/scripts/debug/41-udev.rules new file mode 100644 index 000000000..6b4b37b92 --- /dev/null +++ b/scripts/debug/41-udev.rules @@ -0,0 +1,10 @@ +#Flipper Zero serial port +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", ATTRS{manufacturer}=="Flipper Devices Inc.", TAG+="uaccess", GROUP="dialout" +#Flipper Zero DFU +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", ATTRS{manufacturer}=="STMicroelectronics", TAG+="uaccess", GROUP="dialout" +#Flipper ESP32s2 BlackMagic +SUBSYSTEMS=="usb", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="40??", ATTRS{manufacturer}=="Flipper Devices Inc.", TAG+="uaccess", GROUP="dialout" +#Flipper U2F +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5741", ATTRS{manufacturer}=="Flipper Devices Inc.", ENV{ID_SECURITY_TOKEN}="1" +#ST-Link-V3 +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="37??", ATTRS{manufacturer}=="STMicroelectronics", TAG+="uaccess", GROUP="dialout" diff --git a/scripts/fbt_tools/gdb.py b/scripts/fbt_tools/gdb.py index ea29e9c92..f1c90040d 100644 --- a/scripts/fbt_tools/gdb.py +++ b/scripts/fbt_tools/gdb.py @@ -1,7 +1,7 @@ def generate(env): env.SetDefault( GDB="gdb", - GDBPY="gdb-py", + GDBPY="gdb-py3", GDBCOM="$GDB $GDBOPTS $SOURCES", # no $TARGET GDBPYCOM="$GDBPY $GDBOPTS $GDBPYOPTS $SOURCES", # no $TARGET ) diff --git a/scripts/toolchain/fbtenv.cmd b/scripts/toolchain/fbtenv.cmd index 51708b8c4..186cbf28a 100644 --- a/scripts/toolchain/fbtenv.cmd +++ b/scripts/toolchain/fbtenv.cmd @@ -13,7 +13,7 @@ if not ["%FBT_NOENV%"] == [""] ( exit /b 0 ) -set "FLIPPER_TOOLCHAIN_VERSION=23" +set "FLIPPER_TOOLCHAIN_VERSION=28" if ["%FBT_TOOLCHAIN_PATH%"] == [""] ( set "FBT_TOOLCHAIN_PATH=%FBT_ROOT%" @@ -46,7 +46,7 @@ set "HOME=%USERPROFILE%" set "PYTHONHOME=%FBT_TOOLCHAIN_ROOT%\python" set "PYTHONPATH=" set "PYTHONNOUSERSITE=1" -set "PATH=%FBT_TOOLCHAIN_ROOT%\python;%FBT_TOOLCHAIN_ROOT%\bin;%FBT_TOOLCHAIN_ROOT%\protoc\bin;%FBT_TOOLCHAIN_ROOT%\openocd\bin;%PATH%" +set "PATH=%FBT_TOOLCHAIN_ROOT%\bin;%FBT_TOOLCHAIN_ROOT%\python;%PATH%" set "PROMPT=(fbt) %PROMPT%" :already_set diff --git a/scripts/toolchain/fbtenv.sh b/scripts/toolchain/fbtenv.sh index 990776b27..ea7c9019b 100755 --- a/scripts/toolchain/fbtenv.sh +++ b/scripts/toolchain/fbtenv.sh @@ -4,7 +4,7 @@ # public variables DEFAULT_SCRIPT_PATH="$(pwd -P)"; -FBT_TOOLCHAIN_VERSION="${FBT_TOOLCHAIN_VERSION:-"23"}"; +FBT_TOOLCHAIN_VERSION="${FBT_TOOLCHAIN_VERSION:-"28"}"; if [ -z ${FBT_TOOLCHAIN_PATH+x} ] ; then FBT_TOOLCHAIN_PATH_WAS_SET=0; @@ -27,7 +27,7 @@ fbtenv_show_usage() fbtenv_curl() { - curl --progress-bar -SLo "$1" "$2"; + curl --progress-bar -SLo "$1" "$2" -w "%{http_code}" | grep -q 200; } fbtenv_wget() @@ -38,11 +38,7 @@ fbtenv_wget() fbtenv_restore_env() { TOOLCHAIN_ARCH_DIR_SED="$(echo "$TOOLCHAIN_ARCH_DIR" | sed 's/\//\\\//g')" - PATH="$(echo "$PATH" | sed "s/$TOOLCHAIN_ARCH_DIR_SED\/python\/bin://g")"; PATH="$(echo "$PATH" | sed "s/$TOOLCHAIN_ARCH_DIR_SED\/bin://g")"; - PATH="$(echo "$PATH" | sed "s/$TOOLCHAIN_ARCH_DIR_SED\/protobuf\/bin://g")"; - PATH="$(echo "$PATH" | sed "s/$TOOLCHAIN_ARCH_DIR_SED\/openocd\/bin://g")"; - PATH="$(echo "$PATH" | sed "s/$TOOLCHAIN_ARCH_DIR_SED\/openssl\/bin://g")"; if [ -n "${PS1:-""}" ]; then PS1="$(echo "$PS1" | sed 's/\[fbt\]//g')"; elif [ -n "${PROMPT:-""}" ]; then @@ -57,7 +53,7 @@ fbtenv_restore_env() unset REQUESTS_CA_BUNDLE; fi - if [ "$SYS_TYPE" = "Linux" ]; then + if [ "$SYS_TYPE" = "linux" ]; then if [ -n "$SAVED_TERMINFO_DIRS" ]; then export TERMINFO_DIRS="$SAVED_TERMINFO_DIRS"; else @@ -135,38 +131,17 @@ fbtenv_check_env_vars() fbtenv_get_kernel_type() { - SYS_TYPE="$(uname -s)"; + SYS_TYPE="$(uname -s | tr '[:upper:]' '[:lower:]')"; ARCH_TYPE="$(uname -m)"; - if [ "$ARCH_TYPE" != "x86_64" ] && [ "$SYS_TYPE" != "Darwin" ]; then - echo "We only provide toolchain for x86_64 CPUs, sorry.."; - return 1; - fi - if [ "$SYS_TYPE" = "Darwin" ]; then - fbtenv_check_rosetta || return 1; - TOOLCHAIN_ARCH_DIR="$FBT_TOOLCHAIN_PATH/toolchain/x86_64-darwin"; - TOOLCHAIN_URL="https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-10.3-x86_64-darwin-flipper-$FBT_TOOLCHAIN_VERSION.tar.gz"; - elif [ "$SYS_TYPE" = "Linux" ]; then - TOOLCHAIN_ARCH_DIR="$FBT_TOOLCHAIN_PATH/toolchain/x86_64-linux"; - TOOLCHAIN_URL="https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-10.3-x86_64-linux-flipper-$FBT_TOOLCHAIN_VERSION.tar.gz"; - elif echo "$SYS_TYPE" | grep -q "MINGW"; then + if echo "$SYS_TYPE" | grep -q "MINGW"; then echo "In MinGW shell, use \"[u]fbt.cmd\" instead of \"[u]fbt\""; return 1; - else + elif [ $SYS_TYPE != "linux" ] && [ $SYS_TYPE != "darwin" ]; then echo "Your system configuration is not supported. Sorry.. Please report us your configuration."; return 1; fi - return 0; -} - -fbtenv_check_rosetta() -{ - if [ "$ARCH_TYPE" = "arm64" ]; then - if ! pgrep -q oahd; then - echo "Flipper Zero Toolchain needs Rosetta2 to run under Apple Silicon"; - echo "Please install it by typing 'softwareupdate --install-rosetta --agree-to-license'"; - return 1; - fi - fi + TOOLCHAIN_ARCH_DIR="$FBT_TOOLCHAIN_PATH/toolchain/$ARCH_TYPE-$SYS_TYPE"; + TOOLCHAIN_URL="https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-12.3-$ARCH_TYPE-$SYS_TYPE-flipper-$FBT_TOOLCHAIN_VERSION.tar.gz"; return 0; } @@ -196,7 +171,10 @@ fbtenv_download_toolchain_tar() { echo "Downloading toolchain:"; mkdir -p "$FBT_TOOLCHAIN_PATH/toolchain" || return 1; - "$FBT_DOWNLOADER" "$FBT_TOOLCHAIN_PATH/toolchain/$TOOLCHAIN_TAR.part" "$TOOLCHAIN_URL" || return 1; + "$FBT_DOWNLOADER" "$FBT_TOOLCHAIN_PATH/toolchain/$TOOLCHAIN_TAR.part" "$TOOLCHAIN_URL" || { + echo "Failed to download $TOOLCHAIN_URL"; + return 1; + }; # restoring oroginal filename if file downloaded successfully mv "$FBT_TOOLCHAIN_PATH/toolchain/$TOOLCHAIN_TAR.part" "$FBT_TOOLCHAIN_PATH/toolchain/$TOOLCHAIN_TAR" echo "done"; @@ -328,11 +306,7 @@ fbtenv_main() fbtenv_check_download_toolchain || return 1; fbtenv_set_shell_prompt; fbtenv_print_config; - PATH="$TOOLCHAIN_ARCH_DIR/python/bin:$PATH"; PATH="$TOOLCHAIN_ARCH_DIR/bin:$PATH"; - PATH="$TOOLCHAIN_ARCH_DIR/protobuf/bin:$PATH"; - PATH="$TOOLCHAIN_ARCH_DIR/openocd/bin:$PATH"; - PATH="$TOOLCHAIN_ARCH_DIR/openssl/bin:$PATH"; export PATH; export SAVED_SSL_CERT_FILE="${SSL_CERT_FILE:-""}"; @@ -341,15 +315,15 @@ fbtenv_main() export SAVED_PYTHONPATH="${PYTHONPATH:-""}"; export SAVED_PYTHONHOME="${PYTHONHOME:-""}"; - export SSL_CERT_FILE="$TOOLCHAIN_ARCH_DIR/python/lib/python3.11/site-packages/certifi/cacert.pem"; + export SSL_CERT_FILE="$TOOLCHAIN_ARCH_DIR/lib/python3.11/site-packages/certifi/cacert.pem"; export REQUESTS_CA_BUNDLE="$SSL_CERT_FILE"; export PYTHONNOUSERSITE=1; export PYTHONPATH=; export PYTHONHOME=; - if [ "$SYS_TYPE" = "Linux" ]; then + if [ "$SYS_TYPE" = "linux" ]; then export SAVED_TERMINFO_DIRS="${TERMINFO_DIRS:-""}"; - export TERMINFO_DIRS="$TOOLCHAIN_ARCH_DIR/ncurses/share/terminfo"; + export TERMINFO_DIRS="$TOOLCHAIN_ARCH_DIR/share/terminfo"; fi } diff --git a/scripts/toolchain/windows-toolchain-download.ps1 b/scripts/toolchain/windows-toolchain-download.ps1 index f30b157da..9a4d2e18f 100644 --- a/scripts/toolchain/windows-toolchain-download.ps1 +++ b/scripts/toolchain/windows-toolchain-download.ps1 @@ -6,8 +6,8 @@ $download_dir = (Get-Item "$PSScriptRoot\..\..").FullName $toolchain_version = $args[0] $toolchain_target_path = $args[1] -$toolchain_url = "https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-10.3-x86_64-windows-flipper-$toolchain_version.zip" -$toolchain_dist_folder = "gcc-arm-none-eabi-10.3-x86_64-windows-flipper" +$toolchain_url = "https://update.flipperzero.one/builds/toolchain/gcc-arm-none-eabi-12.3-x86_64-windows-flipper-$toolchain_version.zip" +$toolchain_dist_folder = "gcc-arm-none-eabi-12.3-x86_64-windows-flipper" $toolchain_zip = "$toolchain_dist_folder-$toolchain_version.zip" $toolchain_zip_temp_path = "$download_dir\$toolchain_zip" @@ -29,6 +29,11 @@ if (!(Test-Path -LiteralPath "$toolchain_target_path\..")) { New-Item "$toolchain_target_path\.." -ItemType Directory -Force } +if (Test-Path -LiteralPath "$toolchain_dist_temp_path") { + Write-Host "Cleaning up temp toolchain path.." + Remove-Item -LiteralPath "$toolchain_dist_temp_path" -Force -Recurse +} + Write-Host -NoNewline "Extracting Windows toolchain.." # This is faster than Expand-Archive Add-Type -Assembly "System.IO.Compression.Filesystem" diff --git a/scripts/ufbt/SConstruct b/scripts/ufbt/SConstruct index 8df1ae110..a26c2e404 100644 --- a/scripts/ufbt/SConstruct +++ b/scripts/ufbt/SConstruct @@ -74,7 +74,7 @@ env = core_env.Clone( "crosscc", { "toolchain_prefix": "arm-none-eabi-", - "versions": (" 10.3",), + "versions": (" 12.3.", " 13.2."), }, ), "fwbin", @@ -361,7 +361,7 @@ for template_file in project_template_dir.Dir(".vscode").glob("*"): dist_env.WhereIs("arm-none-eabi-gcc") ), "@UFBT_TOOLCHAIN_GDB_PY@": _path_as_posix( - dist_env.WhereIs("arm-none-eabi-gdb-py") + dist_env.WhereIs("arm-none-eabi-gdb-py3") ), "@UFBT_TOOLCHAIN_OPENOCD@": _path_as_posix(dist_env.WhereIs("openocd")), "@UFBT_APP_DIR@": _path_as_posix(original_app_dir.abspath), diff --git a/site_scons/cc.scons b/site_scons/cc.scons index 55ab72ba6..029f9d415 100644 --- a/site_scons/cc.scons +++ b/site_scons/cc.scons @@ -23,6 +23,7 @@ ENV.AppendUnique( "-Wall", "-Wextra", "-Werror", + "-Wno-error=deprecated-declarations", "-Wno-address-of-packed-member", "-Wredundant-decls", "-Wdouble-promotion", @@ -44,5 +45,6 @@ ENV.AppendUnique( "-mfpu=fpv4-sp-d16", "-mlittle-endian", "-mthumb", + "-Wl,--no-warn-rwx-segment", ], ) diff --git a/site_scons/extapps.scons b/site_scons/extapps.scons index 769b3eb15..22d0be867 100644 --- a/site_scons/extapps.scons +++ b/site_scons/extapps.scons @@ -41,7 +41,6 @@ appenv.AppendUnique( "-Xlinker", "-Map=${TARGET}.map", "-specs=nano.specs", - "-specs=nosys.specs", ], LIBS=[ "m", diff --git a/site_scons/firmwareopts.scons b/site_scons/firmwareopts.scons index e4cc8db58..6af861324 100644 --- a/site_scons/firmwareopts.scons +++ b/site_scons/firmwareopts.scons @@ -35,7 +35,6 @@ else: ENV.AppendUnique( LINKFLAGS=[ "-specs=nano.specs", - "-specs=nosys.specs", "-Wl,--gc-sections", "-Wl,--undefined=uxTopUsedPriority", "-Wl,--wrap,_malloc_r", diff --git a/targets/f18/api_symbols.csv b/targets/f18/api_symbols.csv index ffb664a3e..4d6f9e32b 100644 --- a/targets/f18/api_symbols.csv +++ b/targets/f18/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,54.0,, +Version,+,55.0,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, Header,+,applications/services/cli/cli_vcp.h,, @@ -176,6 +176,7 @@ Header,+,targets/f7/furi_hal/furi_hal_serial_control.h,, Header,+,targets/f7/furi_hal/furi_hal_serial_types.h,, Header,+,targets/f7/furi_hal/furi_hal_spi_types.h,, Header,+,targets/f7/furi_hal/furi_hal_usb_cdc.h,, +Header,+,targets/f7/platform_specific/cxx_virtual_stub.h,, Header,+,targets/f7/platform_specific/intrinsic_export.h,, Header,+,targets/f7/platform_specific/math_wrapper.h,, Header,+,targets/furi_hal_include/furi_hal.h,, @@ -306,6 +307,7 @@ Function,+,__aeabi_uldivmod,void*,"uint64_t, uint64_t" Function,-,__assert,void,"const char*, int, const char*" Function,+,__assert_func,void,"const char*, int, const char*, const char*" Function,+,__clear_cache,void,"void*, void*" +Function,+,__cxa_pure_virtual,void, Function,-,__eprintf,void,"const char*, const char*, unsigned int, const char*" Function,+,__errno,int*, Function,-,__fpclassifyd,int,double @@ -393,6 +395,7 @@ Function,-,_fsetpos_r,int,"_reent*, FILE*, const fpos_t*" Function,-,_ftell_r,long,"_reent*, FILE*" Function,-,_ftello_r,_off_t,"_reent*, FILE*" Function,-,_funopen_r,FILE*,"_reent*, const void*, int (*)(void*, char*, int), int (*)(void*, const char*, int), fpos_t (*)(void*, fpos_t, int), int (*)(void*)" +Function,-,_fwalk_sglue,int,"_reent*, int (*)(_reent*, __FILE*), _glue*" Function,-,_fwrite_r,size_t,"_reent*, const void*, size_t, size_t, FILE*" Function,-,_fwrite_unlocked_r,size_t,"_reent*, const void*, size_t, size_t, FILE*" Function,-,_getc_r,int,"_reent*, FILE*" @@ -2062,7 +2065,6 @@ Function,+,protocol_dict_get_write_data,_Bool,"ProtocolDict*, size_t, void*" Function,+,protocol_dict_render_brief_data,void,"ProtocolDict*, FuriString*, size_t" Function,+,protocol_dict_render_data,void,"ProtocolDict*, FuriString*, size_t" Function,+,protocol_dict_set_data,void,"ProtocolDict*, size_t, const uint8_t*, size_t" -Function,-,pselect,int,"int, fd_set*, fd_set*, fd_set*, const timespec*, const sigset_t*" Function,-,pulse_reader_alloc,PulseReader*,"const GpioPin*, uint32_t" Function,-,pulse_reader_free,void,PulseReader* Function,-,pulse_reader_receive,uint32_t,"PulseReader*, int" @@ -2153,7 +2155,6 @@ Function,+,scene_manager_stop,void,SceneManager* Function,+,sd_api_get_fs_type_text,const char*,SDFsType Function,-,secure_getenv,char*,const char* Function,-,seed48,unsigned short*,unsigned short[3] -Function,-,select,int,"int, fd_set*, fd_set*, fd_set*, timeval*" Function,-,serial_svc_is_started,_Bool, Function,-,serial_svc_notify_buffer_is_empty,void, Function,-,serial_svc_set_callbacks,void,"uint16_t, SerialServiceEventCallback, void*" @@ -2563,8 +2564,13 @@ Variable,-,ITM_RxBuffer,volatile int32_t, Variable,-,MSIRangeTable,const uint32_t[16], Variable,-,SmpsPrescalerTable,const uint32_t[4][6], Variable,+,SystemCoreClock,uint32_t, +Variable,-,__atexit,_atexit*, +Variable,-,__atexit0,_atexit, +Variable,-,__sf,__FILE[3], +Variable,-,__sglue,_glue, +Variable,-,__stdio_exit_handler,void (*)(), Variable,+,_ctype_,const char[], -Variable,+,_global_impure_ptr,_reent*, +Variable,+,_impure_data,_reent, Variable,+,_impure_ptr,_reent*, Variable,-,_sys_errlist,const char*[], Variable,-,_sys_nerr,int, diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index f852a69be..837ad9ffc 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,54.0,, +Version,+,55.0,, Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, @@ -243,6 +243,7 @@ Header,+,targets/f7/furi_hal/furi_hal_spi_types.h,, Header,+,targets/f7/furi_hal/furi_hal_subghz.h,, Header,+,targets/f7/furi_hal/furi_hal_target_hw.h,, Header,+,targets/f7/furi_hal/furi_hal_usb_cdc.h,, +Header,+,targets/f7/platform_specific/cxx_virtual_stub.h,, Header,+,targets/f7/platform_specific/intrinsic_export.h,, Header,+,targets/f7/platform_specific/math_wrapper.h,, Header,+,targets/furi_hal_include/furi_hal.h,, @@ -375,6 +376,7 @@ Function,+,__aeabi_uldivmod,void*,"uint64_t, uint64_t" Function,-,__assert,void,"const char*, int, const char*" Function,+,__assert_func,void,"const char*, int, const char*, const char*" Function,+,__clear_cache,void,"void*, void*" +Function,+,__cxa_pure_virtual,void, Function,-,__eprintf,void,"const char*, const char*, unsigned int, const char*" Function,+,__errno,int*, Function,-,__fpclassifyd,int,double @@ -462,6 +464,7 @@ Function,-,_fsetpos_r,int,"_reent*, FILE*, const fpos_t*" Function,-,_ftell_r,long,"_reent*, FILE*" Function,-,_ftello_r,_off_t,"_reent*, FILE*" Function,-,_funopen_r,FILE*,"_reent*, const void*, int (*)(void*, char*, int), int (*)(void*, const char*, int), fpos_t (*)(void*, fpos_t, int), int (*)(void*)" +Function,-,_fwalk_sglue,int,"_reent*, int (*)(_reent*, __FILE*), _glue*" Function,-,_fwrite_r,size_t,"_reent*, const void*, size_t, size_t, FILE*" Function,-,_fwrite_unlocked_r,size_t,"_reent*, const void*, size_t, size_t, FILE*" Function,-,_getc_r,int,"_reent*, FILE*" @@ -2646,7 +2649,6 @@ Function,+,protocol_dict_get_write_data,_Bool,"ProtocolDict*, size_t, void*" Function,+,protocol_dict_render_brief_data,void,"ProtocolDict*, FuriString*, size_t" Function,+,protocol_dict_render_data,void,"ProtocolDict*, FuriString*, size_t" Function,+,protocol_dict_set_data,void,"ProtocolDict*, size_t, const uint8_t*, size_t" -Function,-,pselect,int,"int, fd_set*, fd_set*, fd_set*, const timespec*, const sigset_t*" Function,-,pulse_reader_alloc,PulseReader*,"const GpioPin*, uint32_t" Function,-,pulse_reader_free,void,PulseReader* Function,-,pulse_reader_receive,uint32_t,"PulseReader*, int" @@ -2737,7 +2739,6 @@ Function,+,scene_manager_stop,void,SceneManager* Function,+,sd_api_get_fs_type_text,const char*,SDFsType Function,-,secure_getenv,char*,const char* Function,-,seed48,unsigned short*,unsigned short[3] -Function,-,select,int,"int, fd_set*, fd_set*, fd_set*, timeval*" Function,-,serial_svc_is_started,_Bool, Function,-,serial_svc_notify_buffer_is_empty,void, Function,-,serial_svc_set_callbacks,void,"uint16_t, SerialServiceEventCallback, void*" @@ -3347,8 +3348,13 @@ Variable,-,ITM_RxBuffer,volatile int32_t, Variable,-,MSIRangeTable,const uint32_t[16], Variable,-,SmpsPrescalerTable,const uint32_t[4][6], Variable,+,SystemCoreClock,uint32_t, +Variable,-,__atexit,_atexit*, +Variable,-,__atexit0,_atexit, +Variable,-,__sf,__FILE[3], +Variable,-,__sglue,_glue, +Variable,-,__stdio_exit_handler,void (*)(), Variable,+,_ctype_,const char[], -Variable,+,_global_impure_ptr,_reent*, +Variable,+,_impure_data,_reent, Variable,+,_impure_ptr,_reent*, Variable,-,_sys_errlist,const char*[], Variable,-,_sys_nerr,int, diff --git a/targets/f7/ble_glue/gap.c b/targets/f7/ble_glue/gap.c index f0533567e..8e3ec58b7 100644 --- a/targets/f7/ble_glue/gap.c +++ b/targets/f7/ble_glue/gap.c @@ -11,7 +11,7 @@ #define FAST_ADV_TIMEOUT 30000 #define INITIAL_ADV_TIMEOUT 60000 -#define GAP_INTERVAL_TO_MS(x) (uint16_t)((x)*1.25) +#define GAP_INTERVAL_TO_MS(x) (uint16_t)((x) * 1.25) typedef struct { uint16_t gap_svc_handle; diff --git a/targets/f7/furi_hal/furi_hal_flash.c b/targets/f7/furi_hal/furi_hal_flash.c index 7ac7a8bd1..37eec744c 100644 --- a/targets/f7/furi_hal/furi_hal_flash.c +++ b/targets/f7/furi_hal/furi_hal_flash.c @@ -43,7 +43,7 @@ */ #define FURI_HAL_FLASH_C2_LOCK_TIMEOUT_MS (3000U) /* 3 seconds */ -#define IS_ADDR_ALIGNED_64BITS(__VALUE__) (((__VALUE__)&0x7U) == (0x00UL)) +#define IS_ADDR_ALIGNED_64BITS(__VALUE__) (((__VALUE__) & 0x7U) == (0x00UL)) #define IS_FLASH_PROGRAM_ADDRESS(__VALUE__) \ (((__VALUE__) >= FLASH_BASE) && ((__VALUE__) <= (FLASH_BASE + FLASH_SIZE - 8UL)) && \ (((__VALUE__) % 8UL) == 0UL)) diff --git a/targets/f7/furi_hal/furi_hal_memory.c b/targets/f7/furi_hal/furi_hal_memory.c index 3f8df1f44..0d60a3af5 100644 --- a/targets/f7/furi_hal/furi_hal_memory.c +++ b/targets/f7/furi_hal/furi_hal_memory.c @@ -46,8 +46,8 @@ void furi_hal_memory_init() { } uint32_t sram2a_busy_size = (uint32_t)&__sram2a_free__ - (uint32_t)&__sram2a_start__; - uint32_t sram2a_unprotected_size = (sbrsa)*1024; - uint32_t sram2b_unprotected_size = (snbrsa)*1024; + uint32_t sram2a_unprotected_size = (sbrsa) * 1024; + uint32_t sram2b_unprotected_size = (snbrsa) * 1024; memory->region[SRAM_A].start = (uint8_t*)&__sram2a_free__; memory->region[SRAM_B].start = (uint8_t*)&__sram2b_start__; diff --git a/targets/f7/furi_hal/furi_hal_os.c b/targets/f7/furi_hal/furi_hal_os.c index 85f2d2e45..efa760b47 100644 --- a/targets/f7/furi_hal/furi_hal_os.c +++ b/targets/f7/furi_hal/furi_hal_os.c @@ -17,8 +17,8 @@ #define FURI_HAL_IDLE_TIMER_CLK_HZ 32768 #define FURI_HAL_OS_TICK_HZ configTICK_RATE_HZ -#define FURI_HAL_OS_IDLE_CNT_TO_TICKS(x) (((x)*FURI_HAL_OS_TICK_HZ) / FURI_HAL_IDLE_TIMER_CLK_HZ) -#define FURI_HAL_OS_TICKS_TO_IDLE_CNT(x) (((x)*FURI_HAL_IDLE_TIMER_CLK_HZ) / FURI_HAL_OS_TICK_HZ) +#define FURI_HAL_OS_IDLE_CNT_TO_TICKS(x) (((x) * FURI_HAL_OS_TICK_HZ) / FURI_HAL_IDLE_TIMER_CLK_HZ) +#define FURI_HAL_OS_TICKS_TO_IDLE_CNT(x) (((x) * FURI_HAL_IDLE_TIMER_CLK_HZ) / FURI_HAL_OS_TICK_HZ) #define FURI_HAL_IDLE_TIMER_TICK_PER_EPOCH (FURI_HAL_OS_IDLE_CNT_TO_TICKS(FURI_HAL_IDLE_TIMER_MAX)) #define FURI_HAL_OS_MAX_SLEEP (FURI_HAL_IDLE_TIMER_TICK_PER_EPOCH - 1) diff --git a/targets/f7/platform_specific/cxx_virtual_stub.c b/targets/f7/platform_specific/cxx_virtual_stub.c new file mode 100644 index 000000000..a81e5a5e0 --- /dev/null +++ b/targets/f7/platform_specific/cxx_virtual_stub.c @@ -0,0 +1,6 @@ +#include "cxx_virtual_stub.h" +#include + +void __cxa_pure_virtual() { + furi_crash("C++ pure virtual call"); +} diff --git a/targets/f7/platform_specific/cxx_virtual_stub.h b/targets/f7/platform_specific/cxx_virtual_stub.h new file mode 100644 index 000000000..46211030e --- /dev/null +++ b/targets/f7/platform_specific/cxx_virtual_stub.h @@ -0,0 +1,13 @@ +#pragma once +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void __cxa_pure_virtual(); + +#ifdef __cplusplus +} +#endif