LED 标牌开放固件构建的硬件详细信息和相关信息
Hardware details and information to build an open firmware for Bluetooth LED badges, compatible with Badge Magic app
Warning: Flashing this firmware on an unsupported badge can brick it permanently. The OEM firmware is read-protected and cannot be dumped, so there is no recovery path once overwritten. See #59 for a real example of this happening.
This firmware targets one specific badge variant:
LSLEDAfter flashing this firmware, the default BLE device name is LED Badge Magic.
Many LED badges look identical on the outside and often ship with OEM firmware advertising the same BLE name (LSLED), but differ internally in chipset or LED grid size (e.g. 11×44 vs 11×55). Identical appearance and OEM BLE name do not guarantee compatibility.
To verify your badge before flashing:
For hardware photos and further identification help, see CH582.md.
Note: Compatibility with other badge variants (e.g. LeSun B1144 or other Alibaba sourced clones) is not established. Pinout reverse engineering for those boards is still in progress.
Install wchisp.
Download prebuilt binaries from release or the latest development builds.
Make the chip enter bootloader mode (ISP mode) by power cycling the chip while the boot pin is pulled down in one of two ways:
See CH582.md for a technical explanation on why both the above methods work.
If the badge has successfully entered ISP mode, a single pixel roughly in the middle of the display will be lit. The badge will stay in ISP mode for approximately ten seconds before rebooting into normal mode.
On Linux, you can also check dmesg if the chip has entered the ISP mode with idVendor=4348 and idProduct=55e0.
Note: The photos shown below for option 2 show two different hardware revisions (Micro-USB and USB-C). C3 is in a different position on each board - Identify your revision before proceeding.
With the badge in ISP mode, run:
wchisp config reset
wchisp flash badgemagic-ch582.bin
On Windows, you have the option to install and run wchisp studio instead of the wchisp CLI tool. Connect the badge via USB and enter bootloader mode, per the instructions above.
The device will automatically appear in the UI.
Select the badgemagic-ch582.bin file and click 'Download'.
Where badgemagic-ch582.bin is the binary downloaded above, the .elf file also works.
Once the open source firmware is installed, there is no further need to remove the battery or short-circuit C3 to enter ISP mode. Simply long-press KEY2 to enter ISP mode. Then, flash updated firmware with
wchisp config reset
wchisp flash badgemagic-ch582.bin
For usual usages, please refer to badgemagic-app and led-name-badge-ls32.
See BadgeBLE.md.
From the device perspective, the data format is just the same as the BLE Data Format. The only difference is the data width. It's 64 bytes, while BLE, is only 16.
Located at Interface 0x00 and Endpoint 0x01. Interface Number and Enpoint Address might not be always fixed, any app using this should check them before using.
For more detail about USB HID, please refer to USB HID Device Class Definition.
Similar to USB HID, but more convenient. From the host's perspective, it appears as a serial device, which can be interacted directly without the additional library. e.g. A bitmap.bin file with a format just like the BLE Data Format can be transferred to the badge by:
stty -F /dev/ttyACM0 raw && cat bitmap.bin > /dev/ttyACM0
For more detail about USB CDC ACM, see Class definitions for Communication Devices 1.2.
This firmware was implemented following the BLE Device Information standard. Any device with BLE-capable can easily get the version by reading the value of the Firmware Revision String Characteristic (0x2A26) in the Device Information Profile (0x18A).
The version can be read from USB by reading the USB Serial Number String.
While the badge is in charging state, it display a animation followed by a version repeatedly.
Set the toolchain location, e.g.:
export PREFIX=../MRS_Toolchain_Linux_x64_V1.92/RISC-V_Embedded_GCC/bin/riscv-none-embed-
Simply run make to build the firmware for the second generation version (previously known as the USB-C version), with the output directed to the build/ directory. To build for the Micro USB version of the badge and specify a custom output directory:
BUILD_DIR=custom-dir HARDWARE_REV1=1 make
To build for the third generation hardware, simply replace HARDWARE_REV1=1 with HARDWARE_REV3=1.
[!NOTE]
Switching
HARDWARE_REV*will require a clean build to make sure the new build does not contain the previous build blob. To rebuild:make clean all
To flash the firmware, enter the bootloader, then run:
BUILD_DIR=custom-dir-if-needed make isp
This firmware supports two independent build choices — you need to know both before building or downloading:
HARDWARE_REV1 / HARDWARE_REV3
(see the Build section above for what each targets).KEY_COUNT flag: KEY_COUNT=4
(default) or KEY_COUNT=2.If you're not sure which board revision or button count your badge has, see CH582.md for identification help before flashing.
Set the toolchain location first, as described in Build:
export PREFIX=../MRS_Toolchain_Linux_x64_V1.92/RISC-V_Embedded_GCC/bin/riscv-none-embed-
4-key badge, second-gen hardware (default):
make
4-key badge, Micro USB (first-gen) hardware:
BUILD_DIR=custom-dir HARDWARE_REV1=1 make
2-key badge, second-gen hardware:
BUILD_DIR=custom-dir KEY_COUNT=2 make
2-key badge, Micro USB (first-gen) hardware:
BUILD_DIR=custom-dir HARDWARE_REV1=1 KEY_COUNT=2 make
[!NOTE] Switching
KEY_COUNT, like switchingHARDWARE_REV*, requires a clean build so the new build doesn't contain the previous build's blob:make clean allThis only matters if you're reusing the same
BUILD_DIRfor different variants. Building each variant into its ownBUILD_DIRavoids the need formake cleanbetween builds.
To flash directly after building, enter the bootloader (see Installation above), then:
BUILD_DIR=custom-dir-if-needed make isp
Download the binary matching your hardware from releases:
badgemagic-4key-<rev>.bin — 4-key badgesbadgemagic-2key-<rev>.bin — 2-key badgesWhere <rev> matches your board revision, per CH582.md.
Then, same as any firmware update:
wchisp config reset
wchisp flash badgemagic-<variant>.bin
Long-press KEY2 to enter ISP mode first if the badge isn't already there.
Flashing the wrong KEY_COUNT variant won't damage the badge, but menu
navigation will be incomplete or stuck, since some button handlers expect
hardware that isn't present — reflash the correct variant to fix it.
Currently, only the UART1 with baudrate=921600 is used for debugging. To enable the log from UART, set the DEBUG=1 when building the project.
Any USB to UART dongle will work. Use your favorite terminal emulator to see the log, e.g.:
picocom -b921600 /dev/ttyUSB0 --imap lfcrlf
The badgemagic-hardware have this UART wired over USB-C. So it can be used without opening the case, but required an aditional hardware to split the serial lines from USB-C.
This is convenient as it doesn't require additional hardware, but it may not be useful for early logging when the USB is not yet initialized, and the user cannot open the serial port quickly enough.
Use cdc_tx_poll() to log to this serial channel.
This is a mystery.
To create a new custom data exchange channel, add a new BLE profile to the firmware
by duplicating /src/ble/profile/legacy.c and reconfig it. Rename
xxx_registerService() function. Call this function after peripheral_init() to
register your new profile.
For more detail of how to config a gatt service, see BLE GATT.
To add a new custom USB Composite Device (e.g., keyboard, mouse, speaker, etc.), duplicate src/usb/composite/hiddev.c. Rename and configure the file according to the Device Class you intend to implement, then call your device's xxx_init() function in usb_start() to initialize it. Each device class has specific specifications, so be sure to refer to them when implementing your new device.
BadgeMagic target hardware features a custom 11x44 LED matrix display, Bluetooth LE and low power consumption.
The design relies on a single MCU. MCU type has changed depending on manufacturer batches.
See specific pages regarding each version of the hardware below
The custom 11x44 LED dot matrix displays using persistence of vision.
Bitmaps are drawn using 24 pins in [charlieplexing](https://en.wikipedia.org/wiki/Cha
暂无开放 Issues,或尚未同步最近议题。