b326edf68c
This commit removes all parts of code associated with the existing MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE optimisation option, including the -mcache-lookup-bc option to mpy-cross. This feature originally provided a significant performance boost for Unix, but wasn't able to be enabled for MCU targets (due to frozen bytecode), and added significant extra complexity to generating and distributing .mpy files. The equivalent performance gain is now provided by the combination of MICROPY_OPT_LOAD_ATTR_FAST_PATH and MICROPY_OPT_MAP_LOOKUP_CACHE (which has been enabled on the unix port in the previous commit). It's hard to provide precise performance numbers, but tests have been run on a wide variety of architectures (x86-64, ARM Cortex, Aarch64, RISC-V, xtensa) and they all generally agree on the qualitative improvements seen by the combination of MICROPY_OPT_LOAD_ATTR_FAST_PATH and MICROPY_OPT_MAP_LOOKUP_CACHE. For example, on a "quiet" Linux x64 environment (i3-5010U @ 2.10GHz) the change from CACHE_MAP_LOOKUP_IN_BYTECODE, to LOAD_ATTR_FAST_PATH combined with MAP_LOOKUP_CACHE is: diff of scores (higher is better) N=2000 M=2000 bccache -> attrmapcache diff diff% (error%) bm_chaos.py 13742.56 -> 13905.67 : +163.11 = +1.187% (+/-3.75%) bm_fannkuch.py 60.13 -> 61.34 : +1.21 = +2.012% (+/-2.11%) bm_fft.py 113083.20 -> 114793.68 : +1710.48 = +1.513% (+/-1.57%) bm_float.py 256552.80 -> 243908.29 : -12644.51 = -4.929% (+/-1.90%) bm_hexiom.py 521.93 -> 625.41 : +103.48 = +19.826% (+/-0.40%) bm_nqueens.py 197544.25 -> 217713.12 : +20168.87 = +10.210% (+/-3.01%) bm_pidigits.py 8072.98 -> 8198.75 : +125.77 = +1.558% (+/-3.22%) misc_aes.py 17283.45 -> 16480.52 : -802.93 = -4.646% (+/-0.82%) misc_mandel.py 99083.99 -> 128939.84 : +29855.85 = +30.132% (+/-5.88%) misc_pystone.py 83860.10 -> 82592.56 : -1267.54 = -1.511% (+/-2.27%) misc_raytrace.py 21490.40 -> 22227.23 : +736.83 = +3.429% (+/-1.88%) This shows that the new optimisations are at least as good as the existing inline-bytecode-caching, and are sometimes much better (because the new ones apply caching to a wider variety of map lookups). The new optimisations can also benefit code generated by the native emitter, because they apply to the runtime rather than the generated code. The improvement for the native emitter when LOAD_ATTR_FAST_PATH and MAP_LOOKUP_CACHE are enabled is (same Linux environment as above): diff of scores (higher is better) N=2000 M=2000 native -> nat-attrmapcache diff diff% (error%) bm_chaos.py 14130.62 -> 15464.68 : +1334.06 = +9.441% (+/-7.11%) bm_fannkuch.py 74.96 -> 76.16 : +1.20 = +1.601% (+/-1.80%) bm_fft.py 166682.99 -> 168221.86 : +1538.87 = +0.923% (+/-4.20%) bm_float.py 233415.23 -> 265524.90 : +32109.67 = +13.756% (+/-2.57%) bm_hexiom.py 628.59 -> 734.17 : +105.58 = +16.796% (+/-1.39%) bm_nqueens.py 225418.44 -> 232926.45 : +7508.01 = +3.331% (+/-3.10%) bm_pidigits.py 6322.00 -> 6379.52 : +57.52 = +0.910% (+/-5.62%) misc_aes.py 20670.10 -> 27223.18 : +6553.08 = +31.703% (+/-1.56%) misc_mandel.py 138221.11 -> 152014.01 : +13792.90 = +9.979% (+/-2.46%) misc_pystone.py 85032.14 -> 105681.44 : +20649.30 = +24.284% (+/-2.25%) misc_raytrace.py 19800.01 -> 23350.73 : +3550.72 = +17.933% (+/-2.79%) In summary, compared to MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE, the new MICROPY_OPT_LOAD_ATTR_FAST_PATH and MICROPY_OPT_MAP_LOOKUP_CACHE options: - are simpler; - take less code size; - are faster (generally); - work with code generated by the native emitter; - can be used on embedded targets with a small and constant RAM overhead; - allow the same .mpy bytecode to run on all targets. See #7680 for further discussion. And see also #7653 for a discussion about simplifying mpy-cross options. Signed-off-by: Jim Mussared <jim.mussared@gmail.com> |
||
---|---|---|
.. | ||
FreeRTOS | ||
boards | ||
bootmgr | ||
fatfs/src/drivers | ||
ftp | ||
hal | ||
misc | ||
mods | ||
simplelink | ||
telnet | ||
tools | ||
util | ||
Makefile | ||
README.md | ||
application.lds | ||
application.mk | ||
appsign.sh | ||
fatfs_port.c | ||
main.c | ||
mpconfigport.h | ||
mptask.c | ||
mptask.h | ||
mpthreadport.c | ||
mpthreadport.h | ||
qstrdefsport.h | ||
serverstask.c | ||
serverstask.h | ||
version.h |
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 offtdi_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
andota_*.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"
- Connect to the network created by the board (as boots up in AP mode), ssid = "wipy-wlan", key = "www.wipy.io".
-
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.