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
Zastanawiam się, jak to jest możliwe, by dokonać fleshowania dongla plikiem hex o rozmiarze 508 kB, podczas gdy pamięć flash w donglu to zaledwie 352 kB. Próbowałem to wykonać na koordynatorze z układem cc2652 z modułem USB-Serial CH9102X i nie udało się. Użyłem dokładnie takiego samego firmware CC1352P2_CC2652P_launchpad_coordinator_20230507.zip pod Windowsem 11 przy pomocy SmartRF Flash Programmer 2 w wersji 1.8.2. Nie udało się. Zrezygnowalem, gdy zorientowałem się że ten wsad jest za duży na pojemność pamięci flash dongla, akupionego na Aliexpress. Oczywiście mogłem zapisywać wsadami do około 380 kB, nie więcej.
- PabloReply to: Jlynx54
Dzięki za tak szczegółowy opis — na początek dobra wiadomość: rozmiar pliku .hex to nie rozmiar wsadu. Intel HEX to format tekstowy (każdy bajt zapisany jako dwa znaki plus narzut linii), więc 508 kB pliku to realnie ok. 190 kB obrazu — mieści się w 352 kB bez problemu. A 352 kB to zresztą normalna pojemność dla CC2652P (większy flash ma dopiero wariant P7), więc sam rozmiar nie powinien blokować flashowania. Skoro inne wsady przechodziły, a ten nie, podejrzewam jedną z trzech rzeczy: (1) SFFP2 wyrzuca konkretny błąd — jaki dokładnie komunikat? To od razu zawęzi diagnozę; (2) build launchpad bywa kapryśny na klonach — różnice w CCFG i mapowaniu pinów między płytkami robią swoje; (3) samo wejście w tryb bootloadera przy tej próbie. Najprościej wrócić do metody z artykułu: python3 cc2538-bsl.py -e -v -w -p COMx CC1352P2_CC2652P_launchpad_coordinator_20230507.hex (zamiast SmartRF). cc2538-bsl wypisze w logu, jaki układ faktycznie widzi i czy przyjął cały obraz — drobna ciekawostka: potrafi zgłosić CC2652P jako CC1352P, to normalne. Jeśli i to rzuci błąd, wklej tutaj dokładny komunikat — łatwiej będzie trafić w przyczynę.
Add a comment
Comments are published after moderation. Your e-mail address stays private.