Flashing the CC2652P Chip Using CH9102X

Published: March 21, 2024

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:

  1. Remove the dongle case.

  2. Connect it to a USB port

  3. Hold down the K1 button (the middle one).

  4. Press and release the RST button (located near the antenna).

  5. 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

  1. Clone the repository containing the flashing tool:

git clone https://github.com/JelmerT/cc2538-bsl.git

Go to the cloned directory:

cd cc2538-bsl

Download 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.zip

Extract the downloaded archive:

unzip CC1352P2_CC2652P_launchpad_coordinator_20230507.zip

Install the required Python packages:

pip3 install wheel pyserial intelhex python-magic

Install the zigpy-znp library:

pip3 install zigpy-znp

Back 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.json

Flash the new firmware

python3 cc2538-bsl.py -e -v -w CC1352P2_CC2652P_launchpad_coordinator_20230507.hex

Once 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)

  1. 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.

    1. Pablo
      Reply 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.