circuitpython/cc3200
Paul Sokolovsky 0748143a4c cc3200: Add targets to erase flash, deploy firmware using cc3200tool.
cc3200tool, https://github.com/ALLTERCO/cc3200tool is a (mostly, some
binary blobs present) open-source, Linux-friendly tool to flash a cc3200
devices. It's an alternative to fully proprietary, Windows-only Uniflash
from TI.

The provided make targets are for erasing flash, flashing the uPy
bootloader and firmware, and flashing vendor's WiFi firmware "servicepacks"
(the latter needs to be downloaded from vendor side, a link is present
inside Makefile).
2016-12-29 17:12:47 +03:00
..
boards cc3200: Enable UART REPL by default. 2016-12-28 14:57:36 +03:00
bootmgr py: Change qstr_* functions to use size_t as the type for str len arg. 2015-11-29 14:25:04 +00:00
fatfs/src cc3200: Correct buffer offset in serial flash diskio module. 2015-11-29 18:34:51 +01:00
FreeRTOS cc3200: Shrink the FreeRTOS heap and place TCB+stack in freed location. 2016-06-28 11:28:53 +01:00
ftp all: Add py/mphal.h and use it in all ports. 2015-10-31 19:14:30 +03:00
hal cc3200: Use mp_raise_XXX helper functions to reduce code size. 2016-10-18 09:53:43 +11:00
misc cc3200: Use mp_raise_XXX helper functions to reduce code size. 2016-10-18 09:53:43 +11:00
mods py/stream: Move ad-hoc ioctl constants to stream.h and rename them. 2016-12-02 16:37:29 +11:00
simplelink cc3200: Shrink the FreeRTOS heap and place TCB+stack in freed location. 2016-06-28 11:28:53 +01:00
telnet cc3200: Make telnet server ignore NULL characters. 2015-11-05 21:42:58 +01:00
tools cc3200/tools/smoke.py: Change readall() to read(). 2016-11-14 23:31:08 +11:00
util py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros. 2016-10-21 16:26:01 +11:00
application.lds cc3200: Fix "debug" build. 2016-02-21 21:53:21 +01:00
application.mk cc3200: make: Rename "deploy" target to "deploy-ota". 2016-12-29 01:27:50 +03:00
appsign.sh cc3200/appsign.sh: Use md5 if running under Darwin. 2015-11-18 19:50:28 +01:00
main.c cc3200: Shrink the FreeRTOS heap and place TCB+stack in freed location. 2016-06-28 11:28:53 +01:00
Makefile cc3200: Add targets to erase flash, deploy firmware using cc3200tool. 2016-12-29 17:12:47 +03:00
mpconfigport.h extmod/moduselect: Use configurable EVENT_POLL_HOOK instead of WFI. 2016-12-02 16:40:39 +11:00
mptask.c cc3200: Re-add support for UART REPL (MICROPY_STDIO_UART setting). 2016-12-27 01:05:37 +03:00
mptask.h cc3200: Use xTaskCreateStatic instead of osi_TaskCreate. 2016-06-28 11:28:52 +01:00
mpthreadport.c cc3200: Fix thread mutex's so threading works with interrupts. 2016-10-19 14:24:56 +11:00
mpthreadport.h cc3200: Allow to compile bootloader with threading enabled. 2016-06-28 11:28:53 +01:00
qstrdefsport.h py: Add rules for automated extraction of qstrs from sources. 2016-04-16 13:18:09 +01:00
README.md cc3200: make: Rename "deploy" target to "deploy-ota". 2016-12-29 01:27:50 +03:00
serverstask.c cc3200: Use mp_raise_XXX helper functions to reduce code size. 2016-10-18 09:53:43 +11:00
serverstask.h cc3200: Use xTaskCreateStatic instead of osi_TaskCreate. 2016-06-28 11:28:52 +01:00
version.h cc3200: Update WiPy software version to 1.2.0 2016-02-27 00:19:53 +01:00

Build Instructions for the CC3200

Currently the CC3200 port of MicroPython builds under Linux and OSX but not under Windows.

The tool chain required for the build can be found at https://launchpad.net/gcc-arm-embedded.

In order to download the image to the CC3200 you will need the CCS_Uniflash tool from TI, which at this moment is only available for Windows, so, you need Linux/OSX to build and Windows to flash the image.

To build an image suitable for debugging:

In order to debug the port specific code, optimizations need to be disabled on the port file (check the Makefile for specific details). You can use CCS from TI. Use the CC3200.ccxml file supplied with this distribution for the debuuger configuration.

make BTARGET=application BTYPE=debug BOARD=LAUNCHXL

To build an image suitable to be flashed to the device:

make BTARGET=application BTYPE=release BOARD=LAUNCHXL

Building the bootloader

make BTARGET=bootloader BTYPE=release BOARD=LAUNCHXL

Regarding old revisions of the CC3200-LAUNCHXL

First silicon (pre-release) revisions of the CC3200 had issues with the ram blocks, and MicroPython cannot run there. Make sure to use a v4.1 (or higer) LAUNCHXL board when trying this port, otherwise it won't work.

Flashing the CC3200

  • Make sure that you have built both the bootloader and the application in release mode.
  • Make sure the SOP2 jumper is in position.
  • Open CCS_Uniflash and connect to the board (by default on port 22).
  • Format the serial flash (select 1MB size in case of the CC3200-LAUNCHXL, 2MB in case of the WiPy, leave the rest unchecked).
  • Mark the following files for erasing: /cert/ca.pem, /cert/client.pem, /cert/private.key and /tmp/pac.bin.
  • Add a new file with the name of /sys/mcuimg.bin, and select the URL to point to cc3200\bootmgr\build<BOARD_NAME>\bootloader.bin.
  • Add another file with the name of /sys/factimg.bin, and select the URL to point to cc3200\build<BOARD_NAME>\mcuimg.bin.
  • Click "Program" to apply all changes.
  • Flash the latest service pack (servicepack_1.0.0.10.0.bin) using the "Service Pack Update" button.
  • Close CCS_Uniflash, remove the SOP2 jumper and reset the board.

Playing with MicroPython and the CC3200:

Once the software is running, you have two options to access the MicroPython REPL:

  • Through telnet.

    • Connect to the network created by the board (as boots up in AP mode), ssid = "wipy-wlan", key = "www.wipy.io".
      • You can also reinitialize the WLAN in station mode and connect to another AP, or in AP mode but with a different ssid and/or key.
    • Use your favourite telnet client with the following settings: host = 192.168.1.1, port = 23.
    • Log in with user = "micro" and password = "python"
  • Thru UART (serial).

    • This is enabled by default in the standard configuration, for UART0 (speed 115200).
    • For CC3200-LAUNCHXL, you will need to configure Linux ftdi_sio driver as described in the blog post. After that, connecting a board will create two /dev/ttyUSB* devices, a serial console is available on the 2nd one (usually /dev/ttyUSB1).
    • WiPy doesn't have onboard USB-UART converter, so you will need an external one, connected to GPIO01 (Tx) and GPIO02 (Rx).
    • Usage of UART port for REPL is controlled by MICROPY_STDIO_UART setting (and is done at the high level, using a suitable call to os.dupterm() function in boot.py, so you can override it at runtime regardless of MICROPY_STDIO_UART setting).

The board has a small file system of 192K (WiPy) or 64K (Launchpad) located in the serial flash connected to the CC3200. SD cards are also supported, you can connect any SD card and configure the pinout using the SD class API.

Uploading scripts:

To upload your MicroPython scripts to the FTP server, open your FTP client of choice and connect to: ftp://192.168.1.1, user = "micro", password = "python"

I have tested the FTP server with FileZilla, FireFTP, FireFox, IE and Chrome, other clients should work as well, but I am not 100% sure of it.

Upgrading the firmware Over The Air:

OTA software updates can be performed through the FTP server. After building a new mcuimg.bin in release mode, upload it to: /flash/sys/mcuimg.bin it will take around 6s (The TI simplelink file system is quite slow because every file is mirrored for safety). You won't see the file being stored inside /flash/sys/ because it's actually saved bypassing FatFS, but rest assured that the file was successfully transferred, and it has been signed with a MD5 checksum to verify its integrity. Now, reset the MCU by pressing the switch on the board, or by typing:

import machine
machine.reset()

There's a script which automates this process from the host side:

  • Make sure the board is running and connected to the same network as the computer.
make BTARGET=application BTYPE=release BOARD=LAUNCHXL WIPY_IP=192.168.1.1 WIPY_USER=micro WIPY_PWD=python deploy-ota

If WIPY_IP, WIPY_USER or WIPY_PWD are omitted the default values (the ones shown above) will be used.

Note regarding FileZilla:

Do not use the quick connect button, instead, open the site manager and create a new configuration. In the "General" tab make sure that encryption is set to: "Only use plain FTP (insecure)". In the Transfer Settings tab limit the max number of connections to one, otherwise FileZilla will try to open a second command connection when retrieving and saving files, and for simplicity and to reduce code size, only one command and one data connections are possible.