Files
JIANT/firmware/bt/ble/ble_stack.c
T
Claude 9f0a4d81c9 V10.12: MENU > SYSTEM > BLUETOOTH (BLE-MIDI peripheral in a segment at 0xEA000)
docs/BLE_FEASIBILITY.md route C2, stage 2 step 3 (section 7 added: as built).

- firmware/bt/: Optimist's BLE stack (Henri David; the hardware-tested copy in
  charlesvestal/fm1-base bt/ble 4039a8b, GPL-3.0-only OR MPL-2.0, unchanged,
  headers kept) and bt_seg.c, its glue, built as a unit of its own. Peripheral
  only: advertises "JIANT FM-1" with the BLE-MIDI service UUID, connectable; no
  scanner, no central, no SMP pairing, no LL encryption, BLE_DIAG 0, 27-octet
  PDUs (as Melodee). MIDI is not routed yet (dropped / nothing sent).
- hal/fm1_ble.h, fm1_ble_rf.h: Melodee's (Kerem Kilic, GPL-3.0-only: the
  iterative start-up replay, the crystal ramp's burst in .ram_text);
  hal/fm1_rf_cal.h and ble_rf_tables_v15.h: felucca-bsp's (Apache-2.0).
  hal/fm1_irq.h: FM1_IRQ_EXTERN for the second unit (the crash record and the
  fault entry stay the app's).
- app.ld: BTSEG at XIP 0x020E6000 = flash 0xEA000 (72 KiB) for the segment's
  header + code + constants (27,344 B, 7 sectors); its RAM in the pool (3,336 B)
  but the 1,508 B baseband block (the radio's DMA) in .bss; .noinit.* after
  .noinit (no record moves). The PC guard's window reaches _bt_end.
- tools/build.py: compiles bt_seg.c, writes build/bt.bin (header: magic, length,
  CRC-32) and the same length / CRC-32 into the app's bt_want; refuses
  initialised data in the segment and a ramp burst outside .ram_text; the
  package carries bt.bin; the layout recorder ignores the segment.
- src/bt.c: MENU > SYSTEM > BLUETOOTH OFF (default) / ON, saved in TRIO's
  retired favourites row ([6][24..31]: a mark, ON, the static random address
  made once at the first start). ON only while stopped ("STOP FIRST"), at once
  or at power-on when saved; the value reads ADV / CONN and the connections since
  power-on, NO SEG (segment missing or of another build), FAILED. OFF stops
  advertising and closes a link. Boot guard: bt_crumb (.noinit) set across the
  start; a reset in it, or a crash / watchdog reset while it ran, turns it OFF
  at the next power-on with a message.
- src/bt_hw.c: the plain XIP window set (fl_plain_window_init, JIANT never set
  it), the segment's header and CRC-32 checked, then the start with the
  interrupts off, the second core parked and the audio buffer silent: the
  vectors (IRQ 45 / 29 at priority 2, below ALNK0 3 and TIMER5 4), the live
  calibration (records 106-108 the SDK board's constants, 187 measured), the
  stack, advertising.
- MENU > ABOUT's credits, LICENSING.md, LICENSES/MPL-2.0.txt: Optimist, Melodee,
  felucca-bsp, JieLi.
- tests/ui_test.c: SYSTEM has 8 rows (31 in all); the BLUETOOTH row, STOP
  FIRST, the saved bytes, NO SEG on the host, the boot guard.
- tools/audio_layout.txt: repinned (the UI code before the sound grew).

App 584,208 B of 584,336 (+1,096 B, 128 B free); RAM .data+.bss 95,280 B
(+1,524); pool spare 9,568 B (-3,360).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
2026-10-31 19:33:17 +00:00

30 lines
1.3 KiB
C

/* SPDX-License-Identifier: GPL-3.0-only OR MPL-2.0 */
/* The BLE stack as part of the firmware's unity build (felucca.c, FELUCCA_BLE=1): every stack function is static
* here (BLE_API), so what this build never calls is left out (the app is linked without --gc-sections).
* A baseband driver built as a unit of its own would need BLE_API empty instead. */
#define BLE_API static
#include "ble_prim.c"
#if BLE_LL_ENC
#include "ble_aes.c"
#endif
#include "ble_midi.c"
#include "ble_ll.c"
#include "ble_smp.c"
#include "ble_host.c"
#include "ble_att.c"
#include "ble_store.c" /* the one remembered device (the DEVICES list's LAST) */
#if BLE_CENTRAL
#include "ble_scan.c" /* the AD parser and the nearby devices' table */
#include "ble_gattc.c" /* the ATT client: the peripheral's BLE-MIDI characteristic */
#include "ble_central.c" /* connecting out: security, the client, the end of it */
#endif
#if defined(FELUCCA_BLE_HW)
#define BLE_HW_WL82 0 /* the build brings its own driver */
#elif defined(FELUCCA_BLE_STUB) && FELUCCA_BLE_STUB
#define BLE_HW_WL82 0
#include "ble_hw_stub.c" /* a stand-in that never advertises (the stack alone) */
#else
#define BLE_HW_WL82 1
#include "ble_hw_wl82.c" /* the AC791N / WL82 baseband engine (hal/fm1_ble.h, docs/BLE-STACK.md §7) */
#endif