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

    Cześć. Mam parę sztuk Ebyte CC2531 i chciałbym tam zmienić oprogramowanie na Zigbee2MQTT. Niestety nie dysponuję RaspberryPi czy programatorem. Czy jesteś w stanie mi taką usługę odpłatnie wykonać ? Proszę policzyć koszt i przekazać mi informację bo nie znam nikogo kto by to robił a znalazłem Twoją stronę. Pozdrawiam, Jacek

    1. pablo
      Reply to: Programowanie Zigbee2MQTT CC2531

      Powiem szczerze, że nie chce mi się :D Ale polecam napisać post na grupkach na FB, tam jest sporo pasjonatów z wolnym czasem. A jak coś, to możesz też spróbować zapolować na bramki zigbee tuya, które idzie tanio wyrwać w Aliexpress Choice. Ostatnio sam tam sporo sprzętu kupiłem.

  2. Terminator007

    Witam. Czy ktoś mógłby mi pomóc ( odpłatnie ) w zaprogramowaniu 8szt takich dongle ? Nie mam odpowiedniego sprzętu ( RPi4B ) więc może ktoś się nade mną zlituje. Bardzo proszę. Pozdrawiam. Jacek

Add a comment

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