Chocolate Plus Firmware analysis

Home Custom Firmware Build from source
What we found out about the firmware of the M-VAVE Chocolate Plus (FootCtrlPlus).

These notes come from analysing the original firmware 012 so that the custom firmware could be built and the pedal configured with our own tools. The page describes formats, algorithms and addresses. It contains no M-VAVE or JieLi code (see what is not published). All numbers refer to the original firmware 012 unless noted.

  1. Device and chip
  2. .fwsc file (Sinco wrapper)
  3. .ufw container (JieLi)
  4. Members of firmware 012
  5. flash.bin and the app area
  6. Scrambling, encryption and key
  7. Checksums
  8. Memory map and functions
  9. Footswitch handling
  10. Display, battery, status LED
  11. Bluetooth services
  12. Control protocol and settings
  13. Firmware update (OTA)
  14. USB download and recovery
  15. Pitfalls we hit
  16. What is not published

Device and chip

ProductM-VAVE Chocolate Plus, Bluetooth name and firmware name FootCtrlPlus, board marking PD41 V04
ChipJieLi AC636N (BR25 family), CPU core pi32v2, internal flash, Bluetooth LE + Classic
Original firmwareFootCtrlPlus_012 (version 012). Distributed as FootCtrlPlus_012.fwsc (583476 bytes)
Update toolsSincoOTA (Android) and the CubeSuite app, both over Bluetooth LE
Development toolsJieLi toolchain 2.5.3 (clang for pi32v2) and the public JieLi AC63 SDK (github.com/Jieli-Tech/fw-AC63_BT_SDK), which matches the firmware's structure
Display3-digit 7-segment display, driven through a 74HC164 shift register
Mode switchU / O / H: U = USB, O = off, H = host (USB and Bluetooth). U is also used to force USB download mode.

.fwsc file (Sinco wrapper)

A .fwsc file is a JieLi .ufw file with 20 extra bytes woven in: after every 47 bytes of the .ufw, one metadata byte is inserted, 20 times. The rest of the file follows unchanged. Removing bytes 47, 95, 143, … (every 48th byte, 20 times) gives the original .ufw.

.ufw container (JieLi)

All numbers little-endian. The 64-byte header and every table entry are scrambled (see scrambling); the members themselves are stored at their offsets.

Header (0x40 bytes, scrambled)

OffsetTypeMeaning012
0x00u16header CRC over header bytes 0x02..0x3f (descrambled)0x0002
0x02u16table CRC over the table as stored (scrambled)0x9ac1
0x04u32total file size583456
0x08u16number of members8
0x10char[]chip nameAC636N

Member table (count × 0x50 bytes from offset 0x40, each entry scrambled on its own)

OffsetTypeMeaning
0x00u8flag/type byte (differs per member, meaning not needed)
0x02u16member index
0x04u16member CRC (CRC-16 over the stored member bytes; verified for the code members)
0x08u32offset in the file
0x0cu32size
0x10u32size rounded up (alignment)
0x40char[16]member name

Members of firmware 012

#NameOffsetSizeContent
0flash.bin0x00400161280the application (boot header + encrypted app area)
1info.log0x27a000empty
2isd_config.ini0x27a004390download/flash configuration (encrypted text, contents)
3ota.bin0x28b40252636update loader that the pedal runs during an update
4script.ver0x6662027version script
5flash2.bin0x66640163840second copy of the application for the update bank (same code as flash.bin)
6blimit.bin0x8e640144small binary block (purpose not analysed)
7tail.bin0x8e6e064trailer

A patch has to change flash.bin and flash2.bin identically; the other members stay untouched.

flash.bin and the app area

App area layout (decrypted)

OffsetContent
0x00area header: u16 header CRC over 0x02..0x1f, u16 data CRC over 0x20..area_len, u32 area length at 0x08 (012: 0x26410), name app_area_head
0x20entry for app.bin: u16 header CRC over 0x22..0x3f, u16 code CRC, u32 code address 0x24 (012: 0x120), u32 code length 0x28 (012: 0x25f90), name app.bin
0x120application code; entry point 0x01e00120

Scrambling, encryption and key

Both layers use the same JieLi LFSR (linear feedback shift register, 32-bit state); the keystream byte is the low byte of the state after each step. Both are plain XOR, so the same function encrypts and decrypts. A reference implementation is lfsr_next() in firmware/fwsctool.py of the repository; the browser patcher contains the same in JavaScript.

Header and table scrambling

Member encryption (the key)

DataKeyStart pos
App area = flash.bin from 0x1000 (same for flash2.bin)0x180f0x20000
isd_config.ini0x180f0x7a00

Check: with the right parameters the app-area CRC chain verifies and the text app.bin appears at 0x30. Our first attempt with other parameters (0x9d0f / 0x1400) decrypted only about 40 % of the blocks correctly.

Checksums

All checksums are CRC-16/XMODEM (polynomial 0x1021, start value 0, no final XOR). After changing code, they must be rebuilt in this order:

  1. app.bin code CRC (entry 0x22), then the entry's header CRC (0x20)
  2. app area data CRC (0x02), then the area header CRC (0x00)
  3. re-encrypt the app area, member CRC in the .ufw table entry (re-scramble the entry)
  4. table CRC and header CRC in the .ufw header (re-scramble the header)
  5. wrap as .fwsc with the name of the new file

Self-test used by build.py: rebuilding the chain on the unchanged original must reproduce it byte for byte.

Memory map and functions

CPU addresses in firmware 012. Names are our own.

AddressWhat
0x01e00000start of the app area in the CPU address space
0x01e00120application entry point
0x1e11cf25 ms poll: footswitches and display refresh (registered with a 5 ms timer)
0x1e122f6disp3(c0, c1, c2): show 3 ASCII characters
0x1e189df / 0x1e18c747-segment font: digits / letters (upper and lower case share one table)
0x1e0e4a0vbat_percent(): battery 0…100 %, linear up to 4.20 V
0x1e1297020 ms status-LED timer (blink 400 ms / steady)
0x1e1271e / 0x1e12706Bluetooth off / on (stock B+C hold ~2 s)
0x1e18c8e27-byte slot with the name/version reply FootCtrlPlus_012
0x1e144cacall that draws the first screen after start (hook for the boot greeting)
0x1e04a84Bluetooth pairing-record function: looks unused but is reached indirectly. Never overwrite.
0x1e11b06USB EP0 send function (descriptors during USB detection): looks unused but is reached through a pointer. Overwritten up to 141, so USB-MIDI was not detected. Never overwrite.
0x1e00406timer period change (1 s), called by the LRC clock calibration timer 0x1e15a40
0x1e1930832 bytes 0xff: start values of the Bluetooth link scheduler 0x1e1cc1c
0x1e13a7e / 0x1e13a9astart screen of modes 2 / 3 (000), drawn ~5 ms after power-on
0x193a0 + 0xf4RAM: u32 display content (left digit in bits 16-23)
0x13490 + 0x5c63RAM: Bluetooth-off flag (LED stays dark while set)

Free space for patches

The flash is almost full. Used for the patches: the timer function at 0x1e00406 (104 bytes; its only caller is removed), the 0xff block at 0x1e19308 (32 bytes; its only reader is pointed to another 0xff block) and the 0xff padding at 0x1e26088 (40 bytes).

"No reference found" does not mean free. Code reached through function pointers has no visible caller: 0x1e04a84 (Bluetooth pairing) and 0x1e11b06 (USB, see above) both looked unused.

Footswitch handling

Each switch has a small state machine in the 5 ms poll:

  1. idle → pressed for D consecutive ticks → pending (counter = 0)
  2. pending → still pressed when the counter reaches F → pressed, press event sent
  3. pending → released before F → back to idle, no event

The pending window exists to detect two switches pressed together (A+B, C+D combos). Original values: D = 4, F = 15 ticks.

Custom firmware: D = 3, F = 6 (≈ 45 ms, combo window 30 ms), and a released switch in the pending state goes to the press path, so short taps send press + release.

Bank number bug (advanced custom mode)

The displayed bank was counted up/down from its own value instead of the saved bank index. After power-on it started at 0, and bank-down showed an invalid bank (255). The selected presets were always correct, only the number was wrong.

Display, battery, status LED

Bluetooth services

PurposeServiceWriteNotify
Sinco control protocol (settings, identity)ae40ae41ae42
JieLi update protocol (OTA)ae00ae01ae02
Firmware version180a Device Information-2a26 (read)

16-bit UUIDs in the Bluetooth base UUID (0000xxxx-0000-1000-8000-00805f9b34fb). The apps find the pedal by its exact name FootCtrlPlus, so the name must not be changed.

Control protocol and settings

Frame (all numbers little-endian):

00 59 | cmd | length (u24) | payload | checksum      checksum = ~(sum of payload bytes) & 0xff
cmdMeaningPayload
0x11name + version- (reply NAME_VVV…, e.g. FootCtrlPlus_012)
0x13firmware version-
0x15send MIDIraw MIDI bytes
0x17device type-
0x21erasetype (u8), address (u32)
0x22writetype (u8), address (u32), n (u24), data[n]
0x23readtype (u8), address (u32), n (u24)

Memory types: NOR = 0, NAND = 1, SD = 2, EFF = 3, DEV = 4 (settings), USR = 5, RAM = 6.

Settings block (DEV, address 0, 23646 bytes)

OffsetSizeField
01mode (0…12)
11TRS MIDI on/off
21MIDI channel (0…16)
310user values [5][2]
1380tap MIDI codes [16]
9313344advanced custom: 8 banks × 4 switches, 417 bytes each
1343772custom keys [6][4][3]
1350910128mixed keys [6][4], 422 bytes each
236373bank maximum [3]
23640…236456user page, HID page, polarity, bank MIDI, PC display, mix page

MIDI code = 5 bytes: enabled, channel, type, data1, data2. Advanced-custom entry (417 bytes) = mode + 16 MIDI codes (A) + 16 MIDI codes (B) + SysEx A (128) + SysEx B (128). The Web Config uses exactly this protocol.

Firmware update (OTA)

The update uses JieLi's RCSP protocol on service ae00, as documented in the public JieLi SDK.

FE DC BA | flags | opcode | length (u16, big-endian) | [status] | sequence | parameters | EF
flags: bit 7 = command, bit 6 = reply wanted
OpcodeMeaning
03target info (capabilities, single/dual bank, MTU)
E1where the firmware info is in the file (offset, length)
E2can the device update with this file? (0 = yes)
E3enter update mode
E5device requests a block (offset u32, length u16); the host answers with those file bytes
E6update result
E7reboot
E8total size
0Bchange communication way (reconnect)

Two phases (the pedal is single-bank with an update loader)

  1. E1 → E2 → the device pulls the loader (ota.bin) with E8/E5 → E6 → 0B: the pedal restarts into its update loader.
  2. Reconnect, the device now reports "mandatory upgrade" → E1 → E2 → E3 → E8/E5 for the whole file → E6 = 0 → E7 reboot.

If phase 2 is interrupted, the pedal stays in its loader and can be flashed again (SincoOTA → Mandatory upgrade). The loader itself is never overwritten, so the original firmware can always be restored this way.

Connection authentication

Before any command, app and pedal authenticate each other: each side sends a 16-byte random challenge, the other answers with the Bluetooth legacy E1 function (SAFER+) computed with a fixed key from JieLi's library, then both confirm with pass. The key is not published here (see below).

USB download and recovery

Pitfalls we hit

What is not published

This page only contains facts about formats, interfaces and addresses, found while making the pedal work with our own software. On purpose it does not contain:

The original firmware is available from M-VAVE: Chocolate Plus product page. Not affiliated with M-VAVE, Sinco or JieLi. All product names belong to their owners.