circuitpython/cc3200
Scott Shawcroft 30ee7019ca Merge tag 'v1.9.1'
Fixes for stmhal USB mass storage, lwIP bindings and VFS regressions

This release provides an important fix for the USB mass storage device in
the stmhal port by implementing the SCSI SYNCHRONIZE_CACHE command, which
is now require by some Operating Systems.  There are also fixes for the
lwIP bindings to improve non-blocking sockets and error codes.  The VFS has
some regressions fixed including the ability to statvfs the root.

All changes are listed below.

py core:
- modbuiltins: add core-provided version of input() function
- objstr: catch case of negative "maxsplit" arg to str.rsplit()
- persistentcode: allow to compile with complex numbers disabled
- objstr: allow to compile with obj-repr D, and unicode disabled
- modsys: allow to compile with obj-repr D and PY_ATTRTUPLE disabled
- provide mp_decode_uint_skip() to help reduce stack usage
- makeqstrdefs.py: make script run correctly with Python 2.6
- objstringio: if created from immutable object, follow copy on write policy

extmod:
- modlwip: connect: for non-blocking mode, return EINPROGRESS
- modlwip: fix error codes for duplicate calls to connect()
- modlwip: accept: fix error code for non-blocking mode
- vfs: allow to statvfs the root directory
- vfs: allow "buffering" and "encoding" args to VFS's open()
- modframebuf: fix signed/unsigned comparison pendantic warning

lib:
- libm: use isfinite instead of finitef, for C99 compatibility
- utils/interrupt_char: remove support for KBD_EXCEPTION disabled

tests:
- basics/string_rsplit: add tests for negative "maxsplit" argument
- float: convert "sys.exit()" to "raise SystemExit"
- float/builtin_float_minmax: PEP8 fixes
- basics: convert "sys.exit()" to "raise SystemExit"
- convert remaining "sys.exit()" to "raise SystemExit"

unix port:
- convert to use core-provided version of built-in import()
- Makefile: replace references to make with $(MAKE)

windows port:
- convert to use core-provided version of built-in import()

qemu-arm port:
- Makefile: adjust object-file lists to get correct dependencies
- enable micropython.mem_*() functions to allow more tests

stmhal port:
- boards: enable DAC for NUCLEO_F767ZI board
- add support for NUCLEO_F446RE board
- pass USB handler as parameter to allow more than one USB handler
- usb: use local USB handler variable in Start-of-Frame handler
- usb: make state for USB device private to top-level USB driver
- usbdev: for MSC implement SCSI SYNCHRONIZE_CACHE command
- convert from using stmhal's input() to core provided version

cc3200 port:
- convert from using stmhal's input() to core provided version

teensy port:
- convert from using stmhal's input() to core provided version

esp8266 port:
- Makefile: replace references to make with $(MAKE)
- Makefile: add clean-modules target
- convert from using stmhal's input() to core provided version

zephyr port:
- modusocket: getaddrinfo: Fix mp_obj_len() usage
- define MICROPY_PY_SYS_PLATFORM (to "zephyr")
- machine_pin: use native Zephyr types for Zephyr API calls

docs:
- machine.Pin: remove out_value() method
- machine.Pin: add on() and off() methods
- esp8266: consistently replace Pin.high/low methods with .on/off
- esp8266/quickref: polish Pin.on()/off() examples
- network: move confusingly-named cc3200 Server class to its reference
- uos: deconditionalize, remove minor port-specific details
- uos: move cc3200 port legacy VFS mounting functions to its ref doc
- machine: sort machine classes in logical order, not alphabetically
- network: first step to describe standard network class interface

examples:
- embedding: use core-provided KeyboardInterrupt object
2017-06-20 10:56:05 -07:00
..
FreeRTOS cc3200: Shrink the FreeRTOS heap and place TCB+stack in freed location. 2016-06-28 11:28:53 +01:00
boards cc3200: Enable UART REPL by default. 2016-12-28 14:57:36 +03:00
bootmgr cc3200: Remove remaining references to std.h. 2017-02-21 18:01:43 +11:00
fatfs/src/drivers cc3200: Remove util/std.h, can just use stdio.h instead. 2017-02-21 17:26:21 +11:00
ftp all: Use full path name when including mp-readline/timeutils/netutils. 2017-03-31 22:29:39 +11:00
hal cc3200: Refactor "ticks" functions to use common extmod implementation. 2017-02-06 11:14:16 +11:00
misc cc3200: When raising OSError's use MP_Exxx as arg instead of a string. 2017-02-22 12:58:11 +11:00
mods Merge tag 'v1.9.1' 2017-06-20 10:56:05 -07:00
simplelink cc3200: Use simplelink API instead of emulated BSD API. 2017-02-21 17:24:12 +11:00
telnet cc3200: Use simplelink API instead of emulated BSD API. 2017-02-21 17:24:12 +11:00
tools cc3200/tools/smoke.py: Change readall() to read(). 2016-11-14 23:31:08 +11:00
util cc3200: Remove util/std.h, can just use stdio.h instead. 2017-02-21 17:26:21 +11:00
Makefile all/Makefile: Remove -ansi from GCC flags, its ignored anyway. 2017-03-23 15:32:12 +11:00
README.md various: Spelling fixes 2017-05-29 11:36:05 +03:00
application.lds cc3200: Fix "debug" build. 2016-02-21 21:53:21 +01:00
application.mk ports: Convert from using stmhal's input() to core provided version. 2017-06-01 16:02:49 +10:00
appsign.sh cc3200/appsign.sh: Use md5 if running under Darwin. 2015-11-18 19:50:28 +01:00
fatfs_port.c cc3200: Convert to use new VFS sub-system and new ooFatFs library. 2017-01-30 12:26:07 +11:00
main.c cc3200: Move stoupper to ftp.c and define in terms of unichar_toupper. 2017-02-21 17:20:58 +11:00
mpconfigport.h ports: Convert from using stmhal's input() to core provided version. 2017-06-01 16:02:49 +10:00
mptask.c Merge tag 'v1.9.1' 2017-06-20 10:56:05 -07: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
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

README.md

MicroPython port to CC3200 WiFi SoC

This is a MicroPython port to Texas Instruments CC3200 WiFi SoC (ARM Cortex-M4 architecture). This port supports 2 boards: WiPy and TI CC3200-LAUNCHXL.

Build Instructions for the CC3200

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

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

In order to flash the image to the CC3200 you will need the cc3200tool. An alternative is to use CCS_Uniflash tool from TI, which works only under Windows, and all support is provided by TI itself.

Building the bootloader:

make BTARGET=bootloader BTYPE=release BOARD=LAUNCHXL

Building the "release" image:

make BTARGET=application BTYPE=release BOARD=LAUNCHXL

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

Flashing the CC3200-LAUNCHXL

Note that WiPy comes factory programmed with a default version of MicroPython, it cannot be programmed via serial, and can be upgraded only with OTA (see below).

  • Make sure that you have built both the bootloader and the application in release mode.
  • Make sure the SOP2 jumper is in position.
  • Make sure you Linux system recognized the board and created ttyUSB* devices (see below for configuration of ftdi_sio driver).
  • Run "make erase" and immediately press Reset button on the device.
  • Wait few seconds.
  • Run "make deploy" and immediately press Reset button on the device.
  • You are recommended to install the latest vendor WiFi firmware servicepack from http://www.ti.com/tool/cc3200sdk. Download CC3200SDK-SERVICEPACK package, install it, and locate ota_*.ucf and ota_*.ucf.signed.bin files. Copy them to the port's directory and run "make servicepack", with immediate press of Reset button.
  • Remove the SOP2 jumper and reset the board.

Flashing process using TI Uniflash:

  • 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"
  • Through 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"

Tested FTP clients are: FileZilla, FireFTP, FireFox, IE and Chrome. Other clients should work as well, but you may need to configure them to use a single connection (this should be the default for any compliant FTP client).

Upgrading the firmware Over The Air (OTA)

OTA software updates can be performed through the builtin 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.

Notes and known issues

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 higher) LAUNCHXL board when trying this port, otherwise it won't work.

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.