34 Commits

Author SHA1 Message Date
evan.liu
57762e50be tools: self-contained portable production package
- tools/python-embed/: embedded Python 3.12.10 runtime with bleak/pyserial
  preinstalled (git-ignored, fetched from the huaweicloud mirror); bats
  resolve Python in order: python-embed -> .venv-ble -> system
- NSpyocd.exe + DFP pack copied into tools/ (git-ignored);
  flash_package.py prefers the in-tools copies
- make_release.bat/ps1: one-click zip to out/mothercup_tools_<ts>.zip
  (staged in TEMP to avoid self-inclusion; zip excluded from git)
- all bats converted to CRLF (LF-only breaks cmd block parsing and %~dp0)
- verified: zip extracted outside the repo runs ble_ota --uart end-to-end
  (PASS, 27 kB/s) and flash_package via the bundled NSpyocd
- docs: dev log section 49, AGENTS.md tools section + heap 18KB fix
2026-09-05 10:34:59 +08:00
evan.liu
dd218addce tools: add requirements-ble.txt for the (git-ignored) .venv-ble
The venv is a per-machine artifact and stays out of git; the bats
auto-create it on first run but only installed bleak - pyserial
(required by UART OTA) was missing on a fresh machine. Both bats now
install from requirements-ble.txt (bleak==3.0.2, pyserial==3.5).
2026-09-05 10:07:14 +08:00
evan.liu
8a7cebcf77 V1.00.26: UART baud 115200 -> 460800
- firmware BSP_USART_BAUDRATE 460800 (divider error +0.03%); uartrst/
  uartinfo follow the macro
- RX DMA ring 2KB -> 3KB: at 460800 2KB only covers 44ms, less than the
  ~45ms flash-erase interrupt-off window; stack top now 0x2000BDE8
  (guard warns <1KB from the 0x2000C000 cliff, by design)
- tools: ble_ota_update.py UartTransport and uart_cap.py default baud
- Verified: stream OTA 55832B in 2.6s @23kB/s (one lost frame recovered
  by go-back-N), PASS after reboot; text CLI fine at 460800
- docs: ble_protocol.md, design spec, AGENTS.md, dev log section 48
2026-09-05 10:01:23 +08:00
evan.liu
f729d16ff2 V1.00.25: UART OTA stream mode + RX DMA ring + SRAM cliff fix
Firmware:
- bsp_usart: RX moved from RXDNE byte-queue IRQ to DMA CH2 circular ring
  (2KB) + IDLE-irq wakeup; bytes keep landing during flash-erase
  interrupt-off windows (the reason lockstep was needed before)
- app_ota: stream mode (ble_protocol.md section 6.7) - 16B BEGIN with
  flags bit0=STREAM (UART channel only), DATA acked on 4KB sector
  crossings (original chunk length; two ack-gating bugs fixed during
  field test), throttled BAD_STATE for go-back-N
- FreeRTOS heap 20KB->18KB: the 2KB ring pushed the stack top past the
  0x2000C000 SRAM cliff (probed via SWD: accesses above fault on this
  silicon, usable app SRAM is 32KB) which locked the board at boot;
  merge_image.py now hard-fails the package when the image initial SP
  leaves (0x20004000, 0x2000C000]

Tools:
- ble_ota_update.py: UART stream sender (8KB window, stall watchdog
  rewind, auto-fallback to lockstep on pre-V1.00.24 firmware,
  --lockstep to force); case-insensitive option parsing
- flash_package.py/bat: stream NSpyocd output live (chunked reads keep
  the \r progress bar), vendor banner rebranded to CAIIC NSLINK UMP
- merge_image.py: initial-SP cliff guard

Verified: UART stream OTA both directions, 55.8KB in ~5.9s @9.5kB/s
0 rewinds (lockstep was 39s), PASS after reboot; board boot fixed and
verified via SWD.

Docs: ble_protocol.md section 6.7, dev log section 47 (+ SRAM cliff
post-mortem), AGENTS.md RAM rule rewritten (both cliffs) + V1.00.25
2026-09-05 09:48:28 +08:00
evan.liu
30b5dd908b docs: add design specification (architecture/protocol/conventions/extension guide) 2026-09-05 08:16:50 +08:00
evan.liu
3e87d333cb App: adapt to firmware V1.00.23 BLE protocol + field debugging fixes
- BluetoothManager: per-characteristic isolated channels (per-UUID read
  queue/timeout/dispatch, no cross-char write blocking), 10007 delayed
  retry for read/write, 300ms link settle after discovery, full tx/rx
  hex logging
- McmCli/McmInfo/McmOta: command/response, TLV parse and OTA frame logs
- home.vue: Auto refresh switch (polling off by default, no GATT
  interference with OTA), MTU-then-load sequencing
- ota.vue: SAF file picker via plus.android (ACTION_GET_CONTENT) with
  Scanner whole-stream read + magic self-check + per-byte fallback;
  default path moved to _doc (Android 10+ scoped storage)
- docs: change logs for 2026-09-04 protocol adaptation and 2026-09-05
  field debugging; AGENTS.md updated
2026-09-05 06:45:04 +08:00
evan.liu
ead16ef671 V1.00.23 + OTA tool fine-grained progress display
- firmware version bump V1.00.22 -> V1.00.23 (0x00010017), no code change;
  user-verified BLE OTA (APP1->APP2) and UART OTA both PASS
- ble_ota_update.py: frame-level live progress bar on tty (bar/pct/bytes/
  rate/per-frame ack RTT, ~10fps throttled), 5%-step lines when redirected;
  resend/resync notices no longer mix into the bar line; END summary now
  reports resent/resynced counters; BEGIN/END stage banners
- docs: dev log 46, AGENTS.md sync
2026-09-04 21:33:25 +08:00
evan.liu
5dcbdbad65 V1.00.22 + OTA tool bank-misselection fix (triple protection)
- firmware: version bump to V1.00.22 (0x00010016), no code change
- ble_ota_update.py: cur-bank detection now reads the full devinfo output
  and parses strictly (early break at the 'cur bank:' prefix could miss
  'APP2' and silently default to APP1 -> wrong payload selection, caught
  by the device bank_mismatch guard on hardware)
- new pre-flight check_blob_bank(): payload vector reset PC must land in
  the target bank before transferring (BLE and UART paths)
- UART path: post-reboot verification over the text CLI (bank+version),
  deterministic PASS/FAIL like the BLE path
- verified: UART OTA APP2->APP1 V1.00.22 full pass with auto-verify
- docs: dev log 45, AGENTS.md sync
2026-09-04 20:49:15 +08:00
evan.liu
efc7bd129f V1.00.21: UART OTA channel verified + mode-switch handshake + loss-tolerant lockstep
- UART binary mode switch mechanism: enter handshake marker '[ota] binary
  mode ON', explicit exit via OTA_ABORT (immediate), 10s idle fallback
  (was 3s, must exceed the host retry window); host resync by CR probe
- fix: otaIdleMs not re-armed on mode entry - every second 'ota' entry was
  kicked out by an instant idle timeout (leftover count from prior session)
- lossy-link tolerance: device drops partial frames after a 100ms byte gap
  so host resends re-align; OTA session is now single-owner (second BEGIN
  on another channel gets BAD_STATE)
- ble_ota_update.py: wait for the enter marker instead of blind sleeps,
  per-frame resend (2s x3), BAD_STATE+expected-offset treated as implicit
  ack for duplicate DATA/BEGIN (resync after ack loss), stage-labeled
  timeouts with raw-rx dump
- verified on hardware: UART OTA full pass (55.7KB/41s, 4-5 lost frames
  auto-recovered) + BLE OTA regression pass; docs: dev log 44,
  ble_protocol.md 6.6 rework, AGENTS.md sync
2026-09-04 20:19:00 +08:00
evan.liu
520838ce65 V1.00.20: OTA_END ack guaranteed delivery via deferred reset
- app_ota.c: after END ok, wait until the RSP is consumed by the host
  (BLE e0005 read-out / UART TX done) plus 300ms grace before resetting,
  2s timeout fallback; polled from the BLE schedule task (rwip_schedule
  must keep running for the ATT read to be processed)
- main.c: app_ota_reset_poll() in the BLE schedule task loop
- docs: ble_protocol.md 6.6 note, dev log section 43, AGENTS.md sync
2026-09-04 17:35:01 +08:00
evan.liu
266fcec731 mcm-ddc-ble V1.00.18:发布命名整理(生产整包mothercup_ble_prod,OTA单文件发布件mothercup_ble_ota);合并OTA包头扩为52B(新增hdr_len/total_size/payload_crc,原json清单信息全部收进头部,单文件发布);merge_image.py新增--combo-name;ble_ota_update.py/ble_ota.bat PC端BLE OTA升级器(实验性:CUR_BANK选包/扇区擦除避让节流/复位检测,实机调通中);SWD单bank升级流程实测通过(bin\@基址部分烧录+bsset修记录+appsw切入);格式与升级流程写入ble_protocol.md §7供App/UART升级开发;开发日志40~41 2026-09-04 16:01:41 +08:00
evan.liu
a546dc5f46 mcm-ddc-ble V1.00.16~17:实测板载硅片为256KB(0x01040000起CPU读回绕/SWD fault),Flash布局回退256KB(Boot16K/bs8K/APP_DATA8K不变,APP1 0x01008000/112K,APP2 0x01024000/112K);新增appsw命令切换运行bank(记录校验+目标镜像CRC32复算防呆);uvprojx新增APP2 target(链接0x01024000,VTOR基址宏化,版本号可被target覆盖);新增make_dual_package.bat双APP整包脚本(merge_image.py支持--app2/--with-appdata);新增信息项0x07 CUR_BANK识别当前运行bank;OTA双bank配套:出包同时产bank1/bank2两份载荷(清单带target_bank),OTA_END校验镜像向量表Reset地址落在目标bank(新状态6 bank_mismatch);flash_package.bat改用DFP pack的n32wb031keq6_2 target+smart_flash=false;appsw双bank切换与CUR_BANK已实测通过;文档同步(开发日志37~39/ble_protocol.md/AGENTS.md) 2026-09-04 15:22:53 +08:00
evan.liu
4b4f20774d mcm-ddc-ble V1.00.14:引入cJSON v1.7.18到src/infra(分配经cJSON_InitHooks挂FreeRTOS pvPortMalloc,惰性初始化);参数接口层JSON化(appget json输出JSON对象,appset json {"led":500}入参,未知键忽略前向兼容,越界整体不生效,成功回显JSON);Flash存储层保持caiic_params_t二进制记录不动;uvprojx三target加infra组;文档同步(开发日志§34/ble_protocol.md §6.5/AGENTS.md);整包+OTA包已出到tools/out 2026-09-04 13:35:26 +08:00
evan.liu
d82b6217a4 mcm-ddc-ble V1.00.11~13:CLI新增reset/factory/uartrst/uartinfo四条维护命令(复位单板/恢复出厂设置/复位串口/查询串口参数);CLI读写特征应答改分包上报(缓冲512B->1024B+读游标,片长att_mtu-2恒短读避开Read Blob偏移不下发的栈限制,0长度包=应答结束);help恢复完整帮助表+help <cmd>单条查询;ble_cli_test.py与App McmCli.ts同步改循环读;文档同步(开发日志31~33/ble_protocol.md/AGENTS.md/App修改记录);整包+OTA包已出到tools/out 2026-09-04 11:29:28 +08:00
evan.liu
9c84bdb6cb mcm-ddc-ble V1.00.09:新增bootsetting与APP_DATA参数区结构化读写(仅命令访问,无裸读写防变砖);param命令管理caiic_params_t参数记录(led1_blink_ms即时生效于LED1闪烁/pwm_duty_pct仅存储),bsdump/bsset结构化读写bootsetting(自动重算CRC+擦除编程+读回校验);UART与BLE CLI读写特征双通道可用;AGENTS.md恢复为/init新版并同步;整包+OTA包已出到tools/out 2026-09-04 10:20:54 +08:00
evan.liu
1bc2ca6ec5 将编译的中间文件删除 2026-09-04 10:06:41 +08:00
evan.liu
c65809a6f1 SmartAssiter去notify重设计:BLE通信切换到固件读写特征接口(CLI特征...c72e0003写命令读应答,只读参数特征...c72e0004 TLV);删除帧协议/notify代码(FrameCodec/McmChannel/OtaManager/Crc);BluetoothManager重写(通用readChar读队列+writeCliChar,scanServices校验特征);连接就绪信号改为bleState 0;OTA页暂停用(notify上行不通待固件修复) 2026-09-04 09:21:08 +08:00
evan.liu
9366d116c4 将APP迁移到一起,方便开发管理 2026-09-04 08:56:15 +08:00
evan.liu
2117c140fc mcm-ddc-ble V1.00.02~08:新增CLI读写特征(...c72e0003,写命令读应答)与只读参数特征(...c72e0004,全项TLV);修复温度开机首读垃圾值(ADC初始化预热+丢弃首转);blelog补写回调/CCCD订阅可见日志并修正CCCD值解析;tools新增bleak测试客户端(ble_cli_test.py/ble_cli.bat/ble_temp_watch.py);make_package.bat改指mcm-ddc-ble;merge_image.py自动取APP_FW_VERSION_NUM写入OTA清单;AGENTS.md记录固件版本递增约定;开发日志第28节 2026-09-04 08:52:44 +08:00
evan.liu
77ec340db2 ble_protocol.md新增手机端开发指南(连接初始化/CRC与组帧解帧参考实现/字节级示例表/时序与异常处理);merge_image.py出整包时同步产出OTA镜像(_ota.bin+_ota.json清单);文档目录移至仓库根docs/ 2026-09-03 06:31:48 +08:00
evan.liu
8ee0a7cce2 mcm-ddc-ble补齐BLE三业务:OTA(直写flash,惰性擦扇区,仅4B对齐暂存)+设备信息查询(INFO_QUERY/INFO_RSP TLV,ADC芯片温度/VDD,风扇转速weak数据源)+CLI透传;连接后主动MTU=247交换;CLI新增devinfo命令;ble_protocol.md升级V1.1;修复出包流程(必须UV4 -r全量重建,校验向量表SP与map一致);整包上板验证通过 2026-09-03 06:26:17 +08:00
evan.liu
31357227d0 实现ble_protocol.md帧协议(CLI-over-BLE,rdtss承载);协议文档补rdtss服务UUID表与线上字节示例;开发日志第22节(mcm-ddc-ble工程全程:创建/FreeRTOS/CLI搬迁/帧协议) 2026-09-02 22:00:48 +08:00
evan.liu
62d8f20c6e 重新生成caiic_full整包(上一轮误删) 2026-09-02 21:33:38 +08:00
evan.liu
789ebca725 mcm-ddc-ble并入mcm-ddc-04的CLI框架+UART驱动:bsp_usart/cli_core/app_cli移植,新增ble_up(BLE notify上行,ke_msg上下文约束);拆除app_usart透传与ns_log_lpuart(fputc冲突);rdtss下行接CLI输入;Keil跨target同名组合并坑,三个target同步清理;出caiic_ble_full整包 2026-09-02 21:33:09 +08:00
evan.liu
b5186aa30f 修复Boot跳转后BLE失败:Boot跳转前__enable_irq( PRIMASK继承问题),APP/Boot的IRAM改从0x20004000起(低16KB为ROM/BLE保留区,踩了必HardFault);bootsetting增加start_address,Boot按地址跳转;merge_image.py生成缺省bootsetting并支持参数化;make_package改-r全量重建;mcm-ddc-ble重链接到0x01008000并出caiic_ble_full整包;HardFault加栈帧打印 2026-09-02 21:04:08 +08:00
evan.liu
7aa2834828 USART1波特率115200->1000000(APB2=64MHz分频4.0零误差);RX维持RXDNE中断不切DMA(评估记录见开发日志第20节) 2026-09-02 08:54:47 +08:00
evan.liu
5d5c1d827c Boot改为跳转时不校验镜像CRC(校验移到OTA升级过程),修复Keil下载后无法调试;新增debug_app.ini调试旁路;补充开发日志(第19节)与mcm-ddc-ble工程日志 2026-09-02 08:22:53 +08:00
evan.liu
5e9de32eee 推送相关文件到服务器 2026-09-02 07:53:48 +08:00
evan.liu
bcd307db92 接入BLE:自定义GATT服务(CAIIC-MCM)+CLI-over-BLE帧协议+双bank直写OTA;新增自写bootloader(Boot工程,512KB布局);器件改N32WB031KEQ6-2 2026-09-01 23:00:00 +08:00
evan.liu
135a42452b 增加固件版本号V1.00.01(app_version.h);新增sysinfo命令查询FreeRTOS运行信息(任务表/heap/uptime) 2026-09-01 21:01:32 +08:00
evan.liu
e17648f7fe 任务栈统一1024字(heap调至20KB);CLI增加Ctrl+Z关日志/Tab补全/命令历史;提示符改为caiic-> 2026-09-01 20:52:44 +08:00
evan.liu
41ff7fb52a 串口增加DMA发送与RX中断,主动打印开关(默认关),新增CLI命令框架(独立任务,支持\r\n/\n\r/\r/\n结束符) 2026-09-01 20:28:03 +08:00
evan.liu
f4c87f538d 初步框架已经搭建好 2026-09-01 20:06:25 +08:00
evan.liu
204f5964bc 第一次提交 2026-09-01 06:22:11 +08:00