From eebc6241b7aae4ca55aa76c1b37c1f924e72a58f Mon Sep 17 00:00:00 2001 From: hedger Date: Tue, 9 May 2023 07:06:44 +0300 Subject: [PATCH] [FL-3302] ble: attempt to handle hardfaulted c2 (#2653) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ble: attempt to handle hardfaulted c2 * MfKey32: nicer macros * FuriHal: slightly different core2 hardfault message * Update ReadMe Co-authored-by: あく --- ReadMe.md | 1 - applications/external/mfkey32/mfkey32.c | 2 +- firmware/targets/f7/ble_glue/ble_glue.c | 20 +++++++++ lib/ReadMe.md | 57 +++++++++++++++---------- lib/stm32wb.scons | 1 + 5 files changed, 56 insertions(+), 25 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index 411f5b41d..b60d66fbd 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -99,7 +99,6 @@ Make sure your Flipper is on, and your firmware is functioning. Connect your Fli - `applications` - applications and services used in firmware - `assets` - assets used by applications and services - `furi` - Furi Core: OS-level primitives and helpers -- `debug` - debug tool: GDB plugins, an SVD file, etc. - `documentation` - documentation generation system configs and input files - `firmware` - firmware source code - `lib` - our and 3rd party libraries, drivers, etc. diff --git a/applications/external/mfkey32/mfkey32.c b/applications/external/mfkey32/mfkey32.c index 2934d837a..d4b2d3e4a 100644 --- a/applications/external/mfkey32/mfkey32.c +++ b/applications/external/mfkey32/mfkey32.c @@ -41,7 +41,7 @@ #define BIT(x, n) ((x) >> (n)&1) #define BEBIT(x, n) BIT(x, (n) ^ 24) #define SWAPENDIAN(x) \ - (x = (x >> 8 & 0xff00ff) | (x & 0xff00ff) << 8, x = x >> 16 | x << 16) //-V1003 + ((x) = ((x) >> 8 & 0xff00ff) | ((x)&0xff00ff) << 8, (x) = (x) >> 16 | (x) << 16) //#define SIZEOF(arr) sizeof(arr) / sizeof(*arr) static int eta_round_time = 56; diff --git a/firmware/targets/f7/ble_glue/ble_glue.c b/firmware/targets/f7/ble_glue/ble_glue.c index c73bbd866..6b527cfca 100644 --- a/firmware/targets/f7/ble_glue/ble_glue.c +++ b/firmware/targets/f7/ble_glue/ble_glue.c @@ -54,6 +54,26 @@ void ble_glue_set_key_storage_changed_callback( ble_glue->context = context; } +/////////////////////////////////////////////////////////////////////////////// + +/* TL hook to catch hardfaults */ + +int32_t ble_glue_TL_SYS_SendCmd(uint8_t* buffer, uint16_t size) { + if(furi_hal_bt_get_hardfault_info()) { + furi_crash("ST(R) Copro(R) HardFault"); + } + + return TL_SYS_SendCmd(buffer, size); +} + +void shci_register_io_bus(tSHciIO* fops) { + /* Register IO bus services */ + fops->Init = TL_SYS_Init; + fops->Send = ble_glue_TL_SYS_SendCmd; +} + +/////////////////////////////////////////////////////////////////////////////// + void ble_glue_init() { ble_glue = malloc(sizeof(BleGlue)); ble_glue->status = BleGlueStatusStartup; diff --git a/lib/ReadMe.md b/lib/ReadMe.md index 884a0b8c0..93236b267 100644 --- a/lib/ReadMe.md +++ b/lib/ReadMe.md @@ -1,27 +1,38 @@ # Structure -- `app-scened-template` - Scened template app library -- `app-template` - Template app library +- `FreeRTOS-Kernel` - FreeRTOS kernel source code +- `FreeRTOS-glue` - Extra glue to hold together FreeRTOS kernel and flipper firmware +- `ST25RFAL002` - ST25R3916 Driver and protocol stack +- `app-scened-template` - C++ app library - `callback-connector` - Callback connector library -- `drivers` - Drivers that we wrote -- `fatfs` - External storage file system +- `cmsis_core` - CMSIS Core package, contain cortex-m core headers +- `cxxheaderparser` - C++ headers parser, used by SDK bundler +- `digital_signal` - Digital signal library: used by NFC for software implemented protocols +- `drivers` - Various flipper drivers +- `fatfs` - FatFS file system driver +- `flipper_application` - Flipper application library, used for FAPs - `flipper_format` - Flipper File Format library -- `fnv1a-hash` - Fnv1a hash library -- `heatshrink` - Image compression library -- `infrared` - Infrared library -- `libusb_stm32` - STM32 USB library -- `littlefs` - Internal storage file system -- `micro-ecc` - Elliptic Curve Crytography library -- `microtar` - TAR archive support library -- `mlib` - Algorithms and containers -- `nanopb` - Nano Protobuf library -- `nfc` - Nfc library -- `one_wire` - One wire library -- `qrcode` - Qr code generator library -- `ST25RFAL002` - ST253916 driver and NFC hal -- `stm32wb_cmsis` - STM32WB series CMSIS component -- `stm32wb_copro` - STM32WB Coprocessor fimrware + WPAN library -- `stm32wb_hal_driver` - STM32WB series HAL -- `subghz` - SubGhz library -- `toolbox` - Toolbox of things that we are using but don't place in core -- `u8g2` - Graphics library that we use to draw GUI +- `fnv1a-hash` - FNV-1a hash library +- `heatshrink` - Heatshrink compression library +- `ibutton` - ibutton library, used by iButton application +- `infrared` - Infrared library, used by Infrared application +- `lfrfid` - LF-RFID library, used by LF RFID application +- `libusb_stm32` - LibUSB for STM32 series MCU +- `littlefs` - LittleFS file system driver, used by internal storage +- `mbedtls` - MbedTLS cryptography library +- `micro-ecc` - MicroECC cryptography library +- `microtar` - MicroTAR library +- `mlib` - M-Lib C containers library +- `nanopb` - NanoPB library, protobuf implementation for MCU +- `nfc` - NFC library, used by NFC application +- `one_wire` - OneWire library, used by iButton application +- `print` - Tiny printf implementation +- `pulse_reader` - Pulse Reader library used by NFC for software implemented protocols +- `qrcode` - QR-Code library +- `stm32wb_cmsis` - STM32WB series CMSIS headers, extends CMSIS Core +- `stm32wb_copro` - STM32WB Copro library: contains WPAN and radio co-processor firmware +- `stm32wb_hal` - STM32WB HAL library, extends STM32WB CMSIS and provides HAL +- `subghz` - Subghz library, used by SubGhz application +- `toolbox` - Toolbox library, contains various things that is used by flipper firmware +- `u8g2` - u8g2 graphics library, used by GUI subsystem +- `update_util` - update utilities library, used by updater \ No newline at end of file diff --git a/lib/stm32wb.scons b/lib/stm32wb.scons index 9c184872b..7cb2fa8bd 100644 --- a/lib/stm32wb.scons +++ b/lib/stm32wb.scons @@ -48,6 +48,7 @@ sources += Glob( ) sources += Glob( "stm32wb_copro/wpan/interface/patterns/ble_thread/tl/*_tl*.c", + exclude="stm32wb_copro/wpan/interface/patterns/ble_thread/tl/shci_tl_if.c", source=True, ) sources += [