Flashing the CC2652P Chip Using CH9102X
Flashing the CC2652P Chip Using CH9102X
Flashing the CC2652P chip lets you install coordinator firmware on the chip, which is essential for using it with Zigbee2Mqtt. In this post, we will go through the process of flashing the CC2652P chip with a CH9102X USB-Serial module step by step.
Preparing for Flashing
Before starting the flashing process, make sure you have all the required tools and files. You will need:
Zigbee2mqtt dongle with a CH9102X chip
Linux or MacOs system
Python 3 version 3.7 or newer
Entering Bootloader Mode
To start flashing, you need to put the dongle into bootloader mode. Here is how:
Remove the dongle case.
Connect it to a USB port
Hold down the K1 button (the middle one).
Press and release the RST button (located near the antenna).
Release the K1 button.
The dongle should now be in bootloader mode and ready for flashing. If it does not work, check the connection. In my case, I had to place the module on a small support.
Flashing Process on Linux/macOS
Below are step-by-step instructions for flashing the device
Clone the repository containing the flashing tool:
git clone https://github.com/JelmerT/cc2538-bsl.gitGo to the cloned directory:
cd cc2538-bslDownload the latest firmware. At the time of writing, this link is current. If it changes, check the repository for the name of the latest file.
wget https://github.com/Koenkk/Z-Stack-firmware/raw/master/coordinator/Z-Stack_3.x.0/bin/CC1352P2_CC2652P_launchpad_coordinator_20230507.zipExtract the downloaded archive:
unzip CC1352P2_CC2652P_launchpad_coordinator_20230507.zipInstall the required Python packages:
pip3 install wheel pyserial intelhex python-magicInstall the zigpy-znp library:
pip3 install zigpy-znpBack up the current NVRAM data. Make sure the dongle is detected as /dev/ttyACM0; on your system it may have a different name. You can find the correct name by checking what appears after running ls /dev/tty* when you connect the module.
python3 -m zigpy_znp.tools.nvram_read /dev/ttyACM0 -o nvram_backup.jsonFlash the new firmware
python3 cc2538-bsl.py -e -v -w CC1352P2_CC2652P_launchpad_coordinator_20230507.hexOnce the flashing process is complete, the dongle should be ready to use with the new firmware.
Summary
Done! Now you only need to configure zigbee2mqtt correctly so it works with the chip. If you previously used a cc2531, you will probably only need to disconnect the old module and connect the new one.
Comments (2)
- Jlynx54
I’m wondering how it’s possible to flash the dongle with a 508 kB hex file when the dongle’s flash memory is only 352 kB. I tried doing this on a coordinator with a CC2652 chip and a CH9102X USB-to-Serial module, but it didn’t work. I used exactly the same firmware, CC1352P2_CC2652P_launchpad_coordinator_20230507.zip, on Windows 11 with SmartRF Flash Programmer 2 version 1.8.2. It didn’t work. I gave up when I realized that this firmware was too large for the flash memory capacity of the dongle purchased on AliExpress. Of course, I was able to write firmware files of up to around 380 kB, but no more.
- PabloReply to: Jlynx54
Thanks for such a detailed description — first, the good news: the size of the .hex file is not the size of the firmware image. Intel HEX is a text format (each byte is stored as two characters plus line overhead), so a 508 kB file is actually about a 190 kB image — it fits into 352 kB without any problem. And 352 kB is, incidentally, the normal capacity for the CC2652P (only the P7 variant has larger flash), so the size itself should not prevent flashing. Since other images worked and this one does not, I suspect one of three things: (1) SFFP2 is reporting a specific error — what exactly is the message? That would immediately narrow down the diagnosis; (2) the LaunchPad build can be finicky on clones — differences in CCFG and pin mapping between boards can make a difference; (3) the bootloader mode itself when making this attempt. The simplest approach is to go back to the method from the article: python3 cc2538-bsl.py -e -v -w -p COMx CC1352P2_CC2652P_launchpad_coordinator_20230507.hex (instead of SmartRF). cc2538-bsl will show in the log which chip it actually detects and whether it accepted the entire image — a small curiosity: it may report the CC2652P as CC1352P, which is normal. If that also produces an error, paste the exact message here — it will be easier to identify the cause.
Add a comment
Comments are published after moderation. Your e-mail address stays private.