This quick post explains how to compile the OpenMote firmware, available in our GitHub repository, and also how to flash it to an OpenMote-CC2538 board through an UART port using the bootloader backdoor mechanism present in the Texas Instruments CC2538 SoC. In this post we assume that you have an OpenMote-CC2538 board and an OpenBase board connected to a computer through the emulated USB port (using an FTDI chip), as depicted in the next image. By the way, you only need the cable between the ON/SLEEP and GND pins in the OpenBase if the OpenMote-CC2538 board does not enter the bootloader backdoor automatically (if it does not work either, try to short RTS/AD6/DIO6 to GND). We also assume that you are using the Ubuntu 14.04 LTS operating system on your compter, either natively or in a virtual machine. We know the process can be also run under Windows with a little bit of patience, but we have not tried it so far. If you do it, please let us know! :-)
To start with, you will need to install the toolchain to compile C/C++ code for the ARM Cortex platform and also the Python environment that is used to upload code through the serial port with the cc2538-bsl script. To do it, open a terminal and issue the following commands one after the other:
sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded sudo apt-get update sudo apt-get dist-upgrade sudo apt-get install build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi python python-serial
You will also need the C/C++ standard library for the ARM Cortex platform. Unfortunately, the package is not currently available in the standard Ubuntu repositories and, thus, you will need to install it manually. To install it manually, issue the following commands in the same terminal:
wget http://mirrors.kernel.org/ubuntu/pool/universe/libs/libstdc++-arm-none-eabi/libstdc++-arm-none-eabi-newlib_4.8.3-11ubuntu1+4_all.deb sudo dpkg -i libstdc++-arm-none-eabi-newlib_4.8.3-11ubuntu1+4_all.deb
Once you have installed the required tools, you will need to obtain the OpenMote formware by cloning our GitHub repository. Use the following command to ensure that the cc2538-bsl script under the tools directory is also cloned in the process.
git clone --recursive https://github.com/OpenMote/firmware.git OpenMote/firmware
If you already have the OpenMote firmware repository in your computer then you need to execute the following command to check out the cc2538-bsl script explicitely.
git submodule update --init --recursive
Once you have installed the toolchain and cloned the OpenMote firmware repository in your computer, you are good to go. The next step is compiling and uploading an example project into the target OpenMote-CC2538 board. For that, go to the OpenMote/firmware/projects directory.
There you will see that there are many example projects, e.g., how to use the LEDs, buttons, etc. We will start with the test-leds project, which demonstrates how to blink the LEDs on the OpenMote-CC2538 platform. To compile the project go inside the test-leds/src subdirectory and issue the following command:
cd test-leds/src make TARGET=cc2538 all
Right after executing this last command you should see the ouput of the Makefile system compiling the different files of the test-leds project. The process is pretty fast but you may notice some warnings caused by the Texas Instruments CC2538 Foundation Firmware
. Once completed, you should see a message stating that the building of the test-leds has completed. Once finished, it is time to upload the binary (test-leds.hex) to the OpenMote-CC2538 board. To do it, issue the following command:
make TARGET=cc2538 bsl
This command invokes the cc2538-bsl script, which uploads the firmware to the OpenMote-CC2538 via the UART port. Once the script completes erasing and flashing the board you should see the LEDs of the OpenMote-CC2538 blinking periodically. You are done! Now that you know how to program the OpenMote-CC2538 feel free to explore the other test projects that we have build so far.