Programming and Flashing CC2531 Without a Cable Using Raspberry Pi

Published: May 11, 2021

How to flash a CC2531 without a CC Debugger (downloader cable), without a UART cable and without an ESP, using only Raspberry Pi. To program the module, you will need a few jumper wires with pins and a soldering iron (although you may even manage without one). This guide works with any CC2531 device; I used the EBYTE E18-2G4U04B PA model.

Connection

Take another look at the pinout of a typical CC2531 and the pinout of my EBYTE module.

My connection looked like this. Keep in mind that I used a somewhat unusual module.

Now connect the module to the Raspberry Pi USB port. If its LED lights up, everything looks OK so far.

WiringPi

WiringPi is a library written in C that provides access to the ports of the BCM2835, BCM2836 and BCM2837 SoCs used in older Raspberry Pi models. Installation involves cloning the repository, which unfortunately is no longer available from the author's original hosting service. Fortunately, a mirror exists.

Open the console on your Raspberry Pi, clone the repository, enter its directory and build the code.

git clone https://github.com/WiringPi/WiringPi
cd WiringPi
./build

Download the firmware

The firmware is called Z-Stack Home and is available in the author's official repository - https://github.com/Koenkk/Z-Stack-firmware/. The author updates the firmware from time to time, so there is a chance that a direct link may stop working. The author provides two types of firmware - coordinator and router. We need the first one, so open the coordinator folder. It contains two versions - 3.0 and 1.2. The author does not recommend using version 3.0 because it is still under development, so select the Z-Stack_Home_1.2 folder. If anything changes, read the description on the project's Github page, where you will find the latest information. Then open the bin folder and select the default version. Now you need to download the zip file matching the name of your chip, so its name must contain CC2531. Download the zip file and extract it somewhere. At the time of writing this guide, the correct archive is available here: CC2531_DEFAULT_20201127.zip.

Flashing

Flashing means removing the existing firmware from the chip and then installing the new one. First, download the required script and check whether the connection to the module works.

cd
git clone https://github.com/jmichault/flash_cc2531
cd flash_cc2531

You should see ID = b524.. If you see ID = 0000 or ID = ffff, something is connected incorrectly.

Then enter ./cc_erase to remove the current firmware.

Copy the firmware you extracted earlier into the script directory, i.e. flash_cc2531. Then write it using the ./cc_write command with the hex file as its argument. In my case, this was ./cc_write CC2531ZNP-Prod.hex. Keep in mind that the author may change the name of this file in the future, so pay attention during this step. Writing the firmware took about 3 minutes in my case. During that time, try not to touch the device so that you do not accidentally disconnect anything.

That's it. Disconnect the hardware, remove the jumper wires and put the module back into its case (if it had one). You can now connect it to the device where you plan to use it.

Comments (3)

  1. Programowanie Zigbee2MQTT CC2531

    Hello. I have a few Ebyte CC2531 units and would like to change their firmware to Zigbee2MQTT. Unfortunately, I don’t have a Raspberry Pi or a programmer. Would you be able to provide this service for a fee? Please calculate the cost and let me know, as I don’t know anyone who does this and I found your website. Best regards, Jacek

    1. pablo
      Reply to: Programowanie Zigbee2MQTT CC2531

      To be honest, I don’t feel like it :D But I recommend writing a post in some Facebook groups—there are plenty of enthusiasts with free time there. You can also try hunting for Tuya Zigbee gateways, which can be picked up cheaply through AliExpress Choice. I’ve bought quite a lot of equipment there myself recently.

  2. Terminator007

    Hello. Could someone help me (for a fee) program 8 of these dongles? I don’t have the appropriate equipment (RPi4B), so perhaps someone would take pity on me. Please. Best regards, Jacek

Add a comment

Comments are published after moderation. Your e-mail address stays private.