This tutorial shows how to use VisualGDB to create, build and debug a basic WiFi-enabled application for the CC3220S chip. We will start with creating a simple “Blinking LED” application, show how to verify the debug settings and then proceed to making and exploring a simple WiFi application.
Before you begin, install VisualGDB.
- Start Visual Studio and select File->New Project->VisualGDB->Embedded Project Wizard:
- Proceed with the “Create a new project -> Embedded Binary” choice:
- On the next page select the ARM toolchain and choose the CC3200S device. In this tutorial we will be using the CC3220SF-Launchpad board with the CC3220SF device featuring 1MB of FLASH memory, however as of August 2017 no debugging tools support CC3220 FLASH programming, so we will limit our project to only use the RAM by selecting the CC3220S chip instead:
- Select PWMLED on the next page:
- Go to the Debug Method page and connect the board to your computer via USB. VisualGDB should recognize it as a CMSIS-DAP debug probe and show it, although OpenOCD won’t automatically recognize the device type. Enable the “show raw OpenOCD scripts” setting and choose the “cc32xx.cfg” script:
- Select JTAG as the debug protocol and press “Test”:
- VisualGDB will launch OpenOCD and ensure that the chip can be debugged:
- Press “Finish” to create the project and start debugging it by hitting F5. See how the two LEDs on the board begin to gradually turn on and off:
- Note that the debugging with OpenOCD will be extremely slow:This happens because the on-board XDS110 debug probe is running in the compatibility mode with CMSIS-DAP and is using the slow USB HID mechanism to exchange data. To speed up debugging, we will now switch from OpenOCD to the proprietary TI XDS GDB stub. The TI GDB stub is less reliable, however it utilizes the proprietary TI commands to interface with the XDS110 debug probe, resulting in much higher performance.
- Download and install the TI XDS Emulation Software Package. Then locate the gdb_agent_console.exe file inside its installation folder and create another file called cc3220s.dat in the same folder with the following contents:
12345678910111213141516171819202122232425262728293031323334# config version=3.5$ sepkpod_drvr=jioxds110.dllpod_port=0pod_supply=0pod_voltage_selection=0pod_voltage=0$ /$ producttitle="Texas Instruments XDS110 USB"alias=TI_XDS110_USBname=XDS110$ /$ usciftdoedge=FALLtclk_program=DEFAULTtclk_frequency=2.5MHzjtag_isolate=enable$ /$ dot7dts_usage=nothing$ /$ swdswd_debug=disabledswo_data=aux_uart$ /@ icepick_c family=icepick_c irbits=6 drbits=1 subpaths=1& subpath_0 address=16 default=no custom=no force=yes pseudo=no@ cs_dap family=cs_dap irbits=4 drbits=1 subpaths=1 identify=0 revision=Legacy& subpath_1 type=legacy address=0 default=no custom=no force=yes pseudo=yes@ cortex_m4_0 family=cortex_mxx irbits=0 drbits=0 identify=0x02000000 traceid=0x0& /& /# /
- You can configure VisualGDB to run the TI gdb server by selecting the “Custom GDB Stub” in the VisualGDB Debug Settings, however an easier way would be to register it with VisualGDB as another debug method. Create the following folder: %LOCALAPPDATA%\VisualGDB\EmbeddedDebugPackages\com.sysprogs.arm.ti.xds-gdbstub; then create a file called edp.xml inside it with the following contents:
123456789101112131415161718192021222324252627<?xml version="1.0"?><EmbeddedDebugPackage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><PackageID>com.sysprogs.arm.ti.xds-gdbstub</PackageID><PackageVersion>1.0</PackageVersion><GNUTargetFilter>^arm-.*</GNUTargetFilter><UserFriendlyName>TI XDS GDB Stub</UserFriendlyName><SupportedDebugMethods><DebugMethod><UserFriendlyName>TI XDS GDB Stub</UserFriendlyName><ID>ti.xds</ID><GDBServerApplication>c:\ti\ccs_base\common\uscif\gdb_agent_console.exe</GDBServerApplication><GDBServerWorkingDir>c:\ti\ccs_base\common\uscif</GDBServerWorkingDir><GDBServerArguments><Template>cc3220s.dat</Template></GDBServerArguments><GDBServerDelay>500</GDBServerDelay><GDBStartupCommands><string>target remote :55000</string><string>mon reset</string><string>load</string></GDBStartupCommands><UseContinueToStart>true</UseContinueToStart><SendCtrlCToGDBServer>false</SendCtrlCToGDBServer><RequireExplicitDisconnect>true</RequireExplicitDisconnect></DebugMethod></SupportedDebugMethods></EmbeddedDebugPackage>
Do not forget to adjust the path to gdb_agent_console.exe in GDBServerApplication and GDBServerWorkingDir if you installed the TI debug tools in a different folder.
- Restart Visual Studio (or open and close the Tools->VisualGDB->VisualGDB Package Manager window). VisualGDB should now show the TI XDS GDB Stub in the debug method list under VisualGDB Project Properties -> Debug Settings:Change the debug method to TI XDS GDB Stub and press OK to save it.
- Start debugging again. Notice how the debugging experience is now much faster:
- Now we will create a Wi-Fi-based project. Open the VisualGDB Embedded Project Wizard and select the “Network Terminal” sample:
- Ensure you select the TI XDS GDB Stub from the very beginning:
- The network terminal sample will accept user commands over the on-board COM port, so find out its number via Device Manager:
- Then enable VisualGDB Raw Terminal for that port (requires Custom edition) or use any other terminal program that is capable of connecting to COM ports:
- Start debugging your project and note how the program shows the help screen via the COM port:
- Run the following command to create a new Wi-Fi network:
1wlan_ap_start -s CC3220
- Note the IP address reported by the demo program. Then connect to the CC3220 Wi-Fi network from your computer and open that address in a browser:
- Now we will show how to run a basic TCP/IP test. Open the socket_cmd.c file and locate the TCPServer() function:
- Use the “find all references” command to find that TCPServer() is called by the cmdSendCallback() function that is in turn registered as a callback for the “send” command. Set a breakpoint in the beginning of the TCPServer() function and type “send -p 1234″ in the network terminal console:
- Run “telnet <IP address of the board> 1234″ to connect to the board. Note how the sl_Send() function will get called to send test data via the connection:
- You can use the Code Map provided by the VisualGDB Clang IntelliSense engine to quickly find out the functions called by TCPServer() to get a quick overview of the TCP-related CC3220 API: