Flashing TI CC2538/CC2652 modules and sticks using the cc2538-bsl utility

You can update the firmware of a module or stick via a serial port through the built-in serial bootloader in the CC2538 and CC2652 microcontrollers using the cc2538-bsl.

Important: To flash a device via serial, the device must be in bootloader mode. The procedure for entering bootloader mode depends on the software installed on the device and may not be compatible or supported by JetHome devices. Therefore, the operation of the mechanism for switching to bootloader mode for third-party firmware is not guaranteed. Use only recommended firmware. See TI CC2538 based module software and Firmware for sticks and modules based on the TI CC2652P1 chip

Installing the utility

For the utility to work, you need to install additional packages:

pip3 install pyserial intelhex python-magic

You can download the utility with the command:

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

Switch device to bootloader mode

For flashing, the microcontroller must be switched to bootloader mode (serial bootloader).

To switch stick to bootloader mode, you must:

< ul>
  • Disconnect the stick from the USB port;
  • Press the “FLASH” button on the stick board;
  • Hold the “FLASH” button and insert the stick into the USB port of the computer;
  • Then you can release the FLASH button.
  • To switch the module to bootloader mode, see the documentation for the module.

    Firmware

    An example command for flashing a device (from the directory where the flashing utility was installed):

    python3 cc2538-bsl.py -p /dev/ttyUSB0 -e -v -w 

    where:

    /dev/ttyUSB0  is the serial port device file corresponding to the connected one. May differ from the example shown depending on the operating system and the number of devices connected to the computer. For sticks connected to a Linux computer, this is /dev/ttyUSB*. For modules, see the documentation for the device in which the module is installed;

     - file name with firmware in bin or hex format (you must specify the full path to file with the firmware).

    Specifying the  -e option completely erases the entire internal flash memory of the microcontroller before flashing it.

    Auto switch to loader mode for sticks

    JetHome sticks have the ability to automatically reset the stick and switch it to bootloader mode for flashing without having to disconnect the stick from the USB port and press a button on it. To use this feature, you need a modified version of the cc2538-bsl utility.

    This version of the utility has a command line option –invoke-bootloader=METHOD that sets the algorithm used to switch to bootloader mode. Available values of the METHOD parameter:

    • 0 - disables the bootloader activation procedure. At the moment, the original cc2538-bsl utility always starts the bootloader activation procedure using the DTR and RTS lines;
    • 1 - the bootloader activation procedure is used in case of independent connection of the DTR and RTS control lines to the microcontroller. This procedure is used by default and is similar to the procedure used by the original utility;
    • 2 - the bootloader activation procedure is used if the DTR and RTS control lines are connected according to the scheme with protection against unintentional reset of the microcontroller, similar to that used in NodeMCU modules.< /li>

    For the utility to work, you must also install additional packages:

    pip3 install pyserial intelhex python-magic

    To enter bootloader mode uses method "2". An example command for flashing a JetHome USB stick in this case would be:

    python3 cc2538-bsl --invoke-bootloader=2 -p /dev/ttyUSB0 -e -w CC1352P2_CC2652P_launchpad_coordinator_20210120 .hex