Skip to content

Flashing EN

Alex Egony edited this page May 6, 2021 · 4 revisions

Flashing sticks/shields v4 (cc2652/cc1352) using a python flasher.

Tested on Windows 7 x64 + python 3.8.6.

Everything is the same on Linux.


Attention!

This method works only if the chip has BSL-enabled firmware!

Attention!

Flashing firmware from the wrong device, or firmware without BSL, or firmware in which BSL it is activated via NOT the DIO_15 pin - there is a chance to get a brick, which can only be reflashed by the programmer!

Attention!

If you want to flash Koenkk's firmware, check the type of your board in this table.


Preparation

Option 1

Download and install python 3.8.6.

Install necessary add-ons:

pip3 install pyserial
pip3 install intelhex

Unpack the flasher (file cc2538-bsl.py). This is a double-modified flasher from JelmerT (modified by jethome and mine). Original flasher does not flash all revisions of my boards, so it should not be used.

Option 2

Use the precompiled exe file cc2538-bsl_x64.exe. You do not need to install python and its modules.


Flashing process

The process of flashing for sticks of different revisions looks different due to different methods of activating the bootloader - by buttons or automatically (Auto BSL).

Attention!!! All of the following is true ONLY for the sticks that I personally built.

Attention!!! On sticks with the ability to flash without using buttons (Auto BSL) - the functionality of the buttons is not guaranteed.

The stick revision can be viewed on the board.

Flashing sticks with Auto BSL

No buttons are required.

rev. 2.0E and rev. 1.0R

python.exe cc2538-bsl.py -p COM3 --invoke-bootloader 3 -ewv znp_CC2652P.hex

rev. 2.1E and rev. 2.3E

python.exe cc2538-bsl.py -p COM3 --bootloader-invert-lines -ewv znp_CC2652P.hex

rev. 2.5E and rev. 3.xX

python.exe cc2538-bsl.py -p COM3 -ewv znp_CC2652P.hex

Flashing the rest of the sticks and pi shields/hat (activating the bootloader with buttons)

Hold down the RESET (RST) and FLASH (BSL) buttons, release RESET, then release FLASH.

or

Hold down the FLASH (BSL) button, insert the stick into USB, release FLASH (BSL) button.

python.exe cc2538-bsl.py -p COM3 -ewv znp_CC2652P.hex

The process looks something like this:

Opening port COM3, baud 500000
Reading data from CC1352P2_CC2652P_other_20201113.hex
Your firmware looks like an Intel Hex file
Connecting to target ...
CC1350 PG2.0 (7x7mm): 352KB Flash, 20KB SRAM, CCFG.BL_CONFIG at 0x00057FD8
Primary IEEE Address: 00: 12: 4B: 00: 21: B4: 94: C2
    Performing mass erase
Erasing all main bank flash sectors
    Erase done
Writing 360 448 bytes starting at address 0x00000000
Write 104 bytes at 0x00057F980
    Write done
Verifying by comparing CRC32 calculations.
    Verified (match: 0x55e2e461)

At the end of the flashing, you may need to unplug-plug the stick into USB or press RESET.

After flashing, it is strongly recommended to clear the stick memory (only for coordinator firmware, routers do not need to be cleaned).


Clearing the coordinator memory

During the flashing process, the coordinator's memory (NVMEM) may contain arbitrary data, which may in some cases prevent NVMEM recovery from the zigbee2mqtt backup.

The coordinator's memory is cleared by the zStackEraseAllNvMem.js script, which is usually located in this directory:

/opt/zigbee2mqtt/scripts 

The command line will look something like this:

node zStackEraseAllNvMem.js /dev/ttyUSB0

At the end of the flashing, you may need to unplug-plug the stick into USB or press RESET.