Просмотр исходного кода

[FL-3302] ble: attempt to handle hardfaulted c2 (#2653)

* ble: attempt to handle hardfaulted c2
* MfKey32: nicer macros
* FuriHal: slightly different core2 hardfault message
* Update ReadMe

Co-authored-by: あく <alleteam@gmail.com>
hedger 2 лет назад
Родитель
Сommit
eebc6241b7
5 измененных файлов с 56 добавлено и 25 удалено
  1. 0 1
      ReadMe.md
  2. 1 1
      applications/external/mfkey32/mfkey32.c
  3. 20 0
      firmware/targets/f7/ble_glue/ble_glue.c
  4. 34 23
      lib/ReadMe.md
  5. 1 0
      lib/stm32wb.scons

+ 0 - 1
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
 - `applications`    - applications and services used in firmware
 - `assets`          - assets used by applications and services
 - `assets`          - assets used by applications and services
 - `furi`            - Furi Core: OS-level primitives and helpers
 - `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
 - `documentation`   - documentation generation system configs and input files
 - `firmware`        - firmware source code
 - `firmware`        - firmware source code
 - `lib`             - our and 3rd party libraries, drivers, etc.
 - `lib`             - our and 3rd party libraries, drivers, etc.

+ 1 - 1
applications/external/mfkey32/mfkey32.c

@@ -41,7 +41,7 @@
 #define BIT(x, n) ((x) >> (n)&1)
 #define BIT(x, n) ((x) >> (n)&1)
 #define BEBIT(x, n) BIT(x, (n) ^ 24)
 #define BEBIT(x, n) BIT(x, (n) ^ 24)
 #define SWAPENDIAN(x) \
 #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)
 //#define SIZEOF(arr) sizeof(arr) / sizeof(*arr)
 
 
 static int eta_round_time = 56;
 static int eta_round_time = 56;

+ 20 - 0
firmware/targets/f7/ble_glue/ble_glue.c

@@ -54,6 +54,26 @@ void ble_glue_set_key_storage_changed_callback(
     ble_glue->context = context;
     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() {
 void ble_glue_init() {
     ble_glue = malloc(sizeof(BleGlue));
     ble_glue = malloc(sizeof(BleGlue));
     ble_glue->status = BleGlueStatusStartup;
     ble_glue->status = BleGlueStatusStartup;

+ 34 - 23
lib/ReadMe.md

@@ -1,27 +1,38 @@
 # Structure
 # 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
 - `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
 - `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

+ 1 - 0
lib/stm32wb.scons

@@ -48,6 +48,7 @@ sources += Glob(
 )
 )
 sources += Glob(
 sources += Glob(
     "stm32wb_copro/wpan/interface/patterns/ble_thread/tl/*_tl*.c",
     "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,
     source=True,
 )
 )
 sources += [
 sources += [