I started getting involved with a new project that involves working with embedded systems for the first time. I started working with TI's CC3200 chip on their Launchpad development board. Unfortunately, their SDK and documentation strictly targets for Windows OS, and even their installer is a Windows executable.
Fortunaltely, I found a few articles that describe how to work with their SDK on a Linux machine. This post will be mainly a summary of this great document along with a couple of other references (see here and here) to be up and running with the SDK on GNU/Linux.
Following versions were used for writing this page- Fedora 24 (4.11.12-100.fc24.x86_64) | OpenSUSE Tumbleweed (4.12.8-1-default (4d7933a) x86_64)
- CC3200SDK 1.3.0
- OpenOCD 0.10.0
- gcc-arm-none-eabi 5.4 2016 q3
Download CC3200 SDK
- Fetch the SDK from
TI's website
I had issues actually creating an account, so instead I used a BugMeNot account.
- Extract the content
- Copy the installed directory
to
/path/to/cc3200sdkon your Linux systemFor convenience, assign a variable to this path:> echo "export CC3200SDK=/path/to/cc3200sdk" >> ~/.bashrc
.exe
installer. This document
says that they had success using wine. Instead, I got a hold
of a Windows machine and extracted it directly there. All the
required files are bundled in the installed directory.
Configure LaunchXL JTAG debug interface
With the development board plugged in, if you runlsusb you should see something like this:
> lsusb
...
Bus 003 Device 007: ID 0451:c32a Texas Instruments, Inc.
...
Load the ftdi-sio kernel module
su -c "modprobe ftdi-sio"
su -c "echo 0451 c32a > /sys/bus/usb-serial/drivers/ftdi_sio/new_id"
The first four hexadecimal digits 0451 is the Vendor
ID and the second c32a is the Device ID. If you are
running an old kernel, syntax will be slightly different. See
references above.
Make sure a device path exists under /dev/:
> ls /dev/ttyUSB*
# example output: /dev/ttyUSB0
I have only /dev/ttyUSB0 so from this point on, I
will refer treat it as the only device path.
If you have multiple ones, you can run dmesg --follow and
see which which tty it gets assigned to, or you can match tty to the usb device.
Build and Install OpenOCD
OpenOCD is the On-Chip Debugger. Very cool.- Install libusb development libraries
On Fedora
yum install libusb-develor on openSUSE
zypper in libusb-1_0-devel - Download and build OpenOCD. On OpenSUSE, they're in the
default repositories
But on Fedora you might have to build them yourself. Download OpenOCD. and build them. Run thezypper in openocdconfigureexecutable and make sure that at the end it reports
Configure, build, and install:MPSSE mode of FTDI based devices yes (auto)
Update the group name in> ./configure > make -j 4 > su -c "make install"contrib/60-openocd.rules, replacingYOUR_GROUP_NAME_GOES_HEREwith the group your username actually belongs to:
The rules do not affect devices that are already plugged in. If your board was plugged in, unplug and replug it for the new rules to take effect.> sed -i s/plugdev/YOUR_GROUP_NAME_GOES_HERE/g contrib/60-openocd.rules > su -c "cp openocd/contrib/60-openocd.rules /etc/udev/rules.d/" - Plug in the CC3200 board and make sure
openocdruns> openocd -f $CC3200SDK/tools/gcc_scripts/cc3200.cfgand you should output similar to this:
Open On-Chip Debugger 0.10.0 Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html adapter speed: 1000 kHz Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'. cc3200_dbginit Info : clock speed 1000 kHz Info : JTAG tap: cc3200.jrc tap/device found: 0x0b97c02f (mfg: 0x017 (Texas Instruments), part: 0xb97c, ver: 0x0) Info : JTAG tap: cc3200.dap enabled Info : cc3200.cpu: hardware has 6 breakpoints, 4 watchpointsPress
Ctrl-cto quit. Also, make sure you can access/dev/ttyUSB0> cat /dev/ttyUSB0which should display nothing and just wait. Press
Ctrl-cto quit.
Install cross toolchain
- Install toolchain
- Edit
$CC3200SDK/tools/gcc_scripts/gdbinitto make sure OpenOCD finds its configuration files. Modified line:target remote | openocd -c "gdb_port pipe; log_output openocd.log" -f $CC3200SDK/tools/gcc_scripts/cc3200.cfg
In Fedora, toolchain is available in fedora repos:
su -c "yum install arm-none-eabi arm-none-eabi-newlib arm-none-eabi-gdb"
For OpenSUSE, build or download prebuild toolchain binaries. Put the binaries in path, e.g.
> echo "export PATH=$PATH:/opt/gcc-arm-none-eabi-5_4-2016q3/bin/" >> ~.bashrc
and reload your .bashrc
> . ~/.bashrc
Flashing
I've used cc3200tool for flashing (and downloading) files to the board. The README file that comes with it is self-explanatory.Compile and Run Examples
For all examples, make sure the jumpers on the board are set correctly. See reference above, the$CC3200SDK/docs/Getting_Started_Guide.pdf,
and $CC3200SDK/docs/example/ documents.
Example 1: Blinky
- Build
> cd $CC3200SDK/example/blinky/gcc > make - Run a GDB session with the built file
Press
You should see a GDB session launch with a breakpoint at beginning of> arm-none-eabi-gdb -x $CC3200SDK/tools/gcc_scripts/gdbinit exe/blinky.axfmainfunctionType "apropos word" to search for commands related to "word"... Reading symbols from exe/blinky.axf...done. Open On-Chip Debugger 0.10.0 Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html 0x20005e74 in pui32Stack () Loading section .text, size 0xf78 lma 0x20004000 Loading section .data, size 0x18 lma 0x20004f78 Start address 0x20004778, load size 3984 Transfer rate: 61 KB/sec, 1992 bytes/write. Breakpoint 1 at 0x20004474: file ../main.c, line 199. Breakpoint 1, main () at ../main.c:199 199 BoardInit(); (gdb)cto continue execution of the code
You should see the LED lights on the board periodically
flashing. Press
Ctrl-c followed by q to quit
Example 2: AP
The$CC3200SDK/example/getting_started_with_wlan_ap
example sets the WiFi chip to AP mode and waits for a device to
connect to it. But the code prompts you to enter the SSID of the
wifi board, which is hard to do if you never actually see the
prompt.
- Set the jumpers on the board in the right configuration (see previous note)
- Build the application
> cd $CC3200SDK/example/blinky/gcc > make - Read the contents of the serial port of the board
Leave this running. Alternatively, you can use> cat /dev/ttyUSB0screenfor this. More on this later. - Run a GDB session in a separate terminal
and press> arm-none-eabi-gdb -x ~/cc3200-sdk/tools/gcc_scripts/gdbinit exe/wlan_ap.axfcto continue code execution You should see the terminal runningcatbeing filled with program output and asking for an SSID input:************************************************* CC3200 WLAN AP Application ************************************************* Host Driver Version: 1.0.1.11 Build Version 2.2.0.1.31.1.2.0.2.1.0.3.23 Device is configured in default state Device started as STATION Enter the AP SSID name: - Of course,
catdoesn't accept inputs. Open another terminal and send the SSID by directly writing to the tty
and it should start up in AP mode.> echo "this is my ssid" > /dev/ttyUSB0
cating and echoing to the
buffer, you can use screen:
- Get the terminal's baudrate
> stty < /dev/ttyUSB0 - Open a screen
and replace> screen /dev/ttyUSB0 insert_baudrate_hereinsert_baudrate_herewith the actual baudrate
Example 3: TCP socket
The $CC3200SDK/example/tcp_socket lets you open
TCP sockets and both receive or send packets. We can
use nc and telnet that comes shipped
with your distro for testing both.
First, for sending packets to CC3200
-
Overwrite
SSID_NAME,SECURITY_TYPE, andSECURITY_KEYThese macros that are defined in$CC3200SDK/example/common/common.hfile. Sincecommon.his shared with other examples, you may want to consider doing it in themain.cfile instead: I'll have it connect to my router with SSID "FreeWifi" that uses WPA2 protocols.// $CC3200SDK/example/tcp_socket #undef SSID_NAME #define SSID_NAME "FreeWifi" #undef SECURITY_TYPE #define SECURITY_TYPE SL_SEC_TYPE_WPA #undef SECURITY_KEY #define SECURITY_KEY "YgfHhueTKg+ZRG1AS8BImFG3" - Build the example as before
-
catthe/dev/ttyUSB0tty (or usescreen) - Run a GDB session with the built file
- Make selections in prompted options
Make the "Packet size" to be 10 so we fill it quickly by hand.
- Navigate the menus and make CC3200 listen for packets
- Start a telnet connection to the CC3200
> telnet <LOCAL_IP_ADDRESS_OF_CC3200> 5001Obviously, your computer has to be on the same network as the CC3200. Start typing random strings followed by enter. Repeat a total of 10 times.
Receiving packets on CC3200
- Change settings
Follow the prompt and make following selections:
- Packet size: 10
- Destination IP: Local IP of your computer
- Port: 5001
- Configure your local firewall
Your OS may by default be blocking incoming traffics. Make sure that incoming connections from CC3200's IP to port 5001 are allowed. You can use other ports if you prefer, and you generally need root access for binding to ports below 1024.
- Start a server on local machine
> nc -vl <LOCAL_COMPUTER_IP_ADDRESS> 5001 - Nagivate the menus on CC3200 and set it to send packets to server (your computer)