• Home Automation, Raspberry Pi
    3 min | 31389

    #Zigbee: Flashing a CC2531 dongle using a Raspberry Pi

    Home Automation, Raspberry Pi | 3 min | 31389

    Last April, I published a tutorial about connecting the Aqara sensors to a Raspberry Pi without using the Xiaomi Gateway. To make that possible, I needed a CC Debugger to flash the TI CC2531 Zigbee Dongle. This debugger was used only one time, and then the Zigbee-USB dongle worked without any problem.

    In this article, I will cover a way to flash the CC2531 without the CC Debugger. This reduces project costs (about $10 for debugger + cable adapters) and waiting time. Usually, you wait 30 days to get a low cost version of the debugger (using the cheapest shipping option). Let's start!


    You need the following hardware for this project:

    DIY: Hardware Connection

    You need a soldering iron and 4 jumper cables. Then, solder 4 wires to the pins: GND, DC, DD and RST of the CC2531 header (see CC2531 Pin Header in Fig. 1a). The header is very small and you can bend the pins a little, if you cannot solder them directly.

    However, if you are not good at soldering, or if you don't have any soldering iron, you can buy the following adapter:

    Raspberry Pi
    • CC2531 Sniffer Adapter

    The adapter connects using a flat cable to the CC2531 and it has a bigger pin header on board side. Thus, you can connect the female jumper connectors directly to that header (see CC Debugger Pin Header in Fig. 1a). It doesn't matter which option you have chosen (solder or adapter), but then, connect the other end of the wires to the Raspberry Pi header (see Fig. 1b) as described in the following table:

    Raspberry PiCC2531
    Pin 38DD
    Pin 36DC
    Pin 35RST

    After connecting the CC2531 header to the Raspberry Pi headers, plug the USB dongle to a USB port of the Raspberry Pi and then, power up the Raspberry Pi.

    If you use the flexible flat cable (FFC) provided with the adapter and you want to connect male jumper connectors from there to the Raspberry Pi, please be aware that connection is not described in Fig. 1a (CC Debugger Pin Header). You need to mirror it.
    CC2531 PINsRaspberry Pi
    Fig. 1a: PIN description CC2531Fig. 1b: PIN description Raspberry Pi

    DIY: Flashing the CC2531

    1. On the Raspberry Pi, check if you have already installed Wiring Pi typing: gpio -v in the terminal. If not, install it following these instructions.
    2. Clone the jmichault/flash_cc2531 repository typing the following:
      git clone https://github.com/jmichault/flash_cc2531.git
    3. Go inside the flash_cc2531 folder and check if the Zigbee-USB dongle is wired correctly and if it's identified:
      cd flash_cc2531
    4. You should see ID=b524. If you get any other text (e.g. 0000 or ffff), re-check your wiring.
    5. Download the latest firmware from Koenkk/Z-Stack-firmware.
      wget https://github.com/Koenkk/Z-Stack-firmware/archive/master.zip
      unzip master.zip
      # (**)
      cd Z-Stack-firmware-master/coordinator/Z-Stack_Home_1.2/bin/default/
      # (*)
      unzip CC2531_DEFAULT_<<yyyymmdd>>.zip   
    6. Erase the CC2531 flash with ./cc_erase
    7. Flash the firmware using ./cc_write /path/to/CC2531ZNP-Prod.hex. This will take about 3 min.
    8. Disconnect the wires/adapter and reboot the Raspberry Pi
    (*) Note 1: change yyyymmdd with the actual date of the file (check it here: /bin/default, /bin/source_routing).

    (**) Note 2: I used the default version of the Z-Stack coordinator. But:
    • a. If you have a network of 1 - 30 devices, the Z-Stack_Home_1.2 /bin/default firmware is recommended.
    • b. If you have a network of 30+ devices, the Z-Stack_Home_1.2 /bin/source_routing firmware is recommended.
    This changes the folder and file in step 5. More info available here.
    Raspberry Pi 1 users
    I copy here a comment written by whooty on 01.26.2020 (THANKS!):

    Just did it with a pi 1. all you have to do is use different pins. Check the documentation for flash_cc2531, there is a section which tells you how to change the pins you use. Use 'gpio readall' to figure out which pins you have connected to what, and use the wPi number off that for the command flags in flash_cc2531.


    This tutorial covers an alternative way to flash the CC2531 without using the official TI CC Debugger or the low cost SmartRF04EB. If you followed the steps as described, you should have your CC2531 dongle flashed with the firmware. Then, you can follow this article to integrate the Aqara sensors to Hass.io: #Raspberry Pi: Xiaomi Sensors & Home Assistant (Hass.io) or use a broker explained here: #Zigbee: Xiaomi Sensors using Raspberry Pi (without Gateway!).


    Many thanks to the developers of the following software: