circuitpython/stmhal
Scott Shawcroft dfb61f01db Merge tag 'v1.8.7'
Support for Xtensa emitter and assembler, and upgraded F4 and F7 STM HAL

This release adds support for the Xtensa architecture as a target for the
native emitter, as well as Xtensa inline assembler.  The int.from_bytes
and int.to_bytes methods now require a second argument (the byte order)
per CPython (only "little" is supported at this time).  The "readall"
method has been removed from all stream classes that used it; "read" with
no arguments should be used instead.  There is now support for importing
packages from compiled .mpy files.  Test coverage is increased to 96%.

The generic I2C driver has improvements: configurable clock stretching
timeout, "stop" argument added to readfrom/writeto methods, "nack"
argument added to readinto, and write[to] now returns num of ACKs
received.  The framebuf module now handles 16-bit depth (generic colour
format) and has hline, vline, rect, line methods.  A new utimeq module is
added for efficient queue ordering defined by modulo time (to be
compatible with time.ticks_xxx functions).  The pyboard.py script has been
modified so that the target board is not reset between scripts or commands
that are given on a single command line.

For the stmhal port the STM Cube HAL has been upgraded: Cube F4 HAL to
v1.13.1 (CMSIS 2.5.1, HAL v1.5.2) and Cube F7 HAL to v1.1.2.  There is a
more robust pyb.I2C implementation (DMA is now disabled by default, can be
enabled via an option), and there is an implementation of machine.I2C with
robust error handling and hardware acceleration on F4 MCUs.  It is now
recommended to use machine.I2C instead of pyb.I2C.  The UART class is now
more robust with better handling of errors/timeouts.  There is also more
accurate VBAT and VREFINT measurements for the ADC.  New boards that are
supported include: NUCLEO_F767ZI, STM32F769DISC and NUCLEO_L476RG.

For the esp8266 port select/poll is now supported for sockets using the
uselect module.  There is support for native and viper emitters, as well
as an inline assembler (with limited iRAM for storage of native functions,
or the option to store code to flash).  There is improved software I2C
with a slight API change: scl/sda pins can be specified as positional only
when "-1" is passed as the first argument to indicate the use of software
I2C.  It is recommended to use keyword arguments for scl/sda.  There is
very early support for over-the-air (OTA) updates using the yaota8266
project.

A detailed list of changes follows.

py core:
- emitnative: fix native import emitter when in viper mode
- remove readall() method, which is equivalent to read() w/o args
- objexcept: allow clearing traceback with 'exc.__traceback__ = None'
- runtime: mp_resume: handle exceptions in Python __next__()
- mkrules.mk: rework find command so it works on OSX
- *.mk: replace uses of 'sed' with $(SED)
- parse: move function to check for const parse node to parse.[ch]
- parse: make mp_parse_node_new_leaf an inline function
- parse: add code to fold logical constants in or/and/not operations
- factor persistent code load/save funcs into persistentcode.[ch]
- factor out persistent-code reader into separate files
- lexer: rewrite mp_lexer_new_from_str_len in terms of mp_reader_mem
- lexer: provide generic mp_lexer_new_from_file based on mp_reader
- lexer: rewrite mp_lexer_new_from_fd in terms of mp_reader
- lexer: make lexer use an mp_reader as its source
- objtype: implement __call__ handling for an instance w/o heap alloc
- factor out common code from assemblers into asmbase.[ch]
- stream: move ad-hoc ioctl constants to stream.h and rename them
- compile: simplify configuration of native emitter
- emit.h: remove long-obsolete declarations for cpython emitter
- move arch-specific assembler macros from emitnative to asmXXX.h
- asmbase: add MP_PLAT_COMMIT_EXEC option for handling exec code
- asmxtensa: add low-level Xtensa assembler
- integrate Xtensa assembler into native emitter
- allow inline-assembler emitter to be generic
- add inline Xtensa assembler
- emitinline: embed entire asm struct instead of a pointer to it
- emitinline: move inline-asm align and data methods to compiler
- emitinline: move common code for end of final pass to compiler
- asm: remove need for dummy_data when doing initial assembler passes
- objint: from_bytes, to_bytes: require byteorder arg, require "little"
- binary: do zero extension when storing a value larger than word size
- builtinimport: support importing packages from compiled .mpy files
- mpz: remove unreachable code in mpn_or_neg functions
- runtime: zero out fs_user_mount array in mp_init
- mpconfig.h: enable MICROPY_PY_SYS_EXIT by default
- add MICROPY_KBD_EXCEPTION config option to provide mp_kbd_exception
- compile: add an extra pass for Xtensa inline assembler
- modbuiltins: remove unreachable code
- objint: rename mp_obj_int_as_float to mp_obj_int_as_float_impl
- emitglue: refactor to remove assert(0), to improve coverage
- lexer: remove unreachable code in string tokeniser
- lexer: remove unnecessary check for EOF in lexer's next_char func
- lexer: permanently disable the mp_lexer_show_token function
- parsenum: simplify and generalise decoding of digit values
- mpz: fix assertion in mpz_set_from_str which checks value of base
- mpprint: add assertion for, and comment about, valid base values
- objint: simplify mp_int_format_size and remove unreachable code
- unicode: comment-out unused function unichar_isprint
- consistently update signatures of .make_new and .call methods
- mkrules.mk: add MPY_CROSS_FLAGS option to pass flags to mpy-cross
- builtinimport: fix bug when importing names from frozen packages

extmod:
- machine_i2c: make the clock stretching timeout configurable
- machine_i2c: raise an error when clock stretching times out
- machine_i2c: release SDA on bus error
- machine_i2c: add a C-level I2C-protocol, refactoring soft I2C
- machine_i2c: add argument to C funcs to control stop generation
- machine_i2c: rewrite i2c.scan in terms of C-level protocol
- machine_i2c: rewrite mem xfer funcs in terms of C-level protocol
- machine_i2c: remove unneeded i2c_write_mem/i2c_read_mem funcs
- machine_i2c: make C-level functions return -errno on I2C error
- machine_i2c: add 'nack' argument to i2c.readinto
- machine_i2c: make i2c.write[to] methods return num of ACKs recvd
- machine_i2c: add 'stop' argument to i2c readfrom/writeto meths
- machine_i2c: remove trivial function wrappers
- machine_i2c: expose soft I2C obj and readfrom/writeto funcs
- machine_i2c: add hook to constructor to call port-specific code
- modurandom: allow to build with float disabled
- modframebuf: make FrameBuffer handle 16bit depth
- modframebuf: add back legacy FrameBuffer1 "class"
- modframebuf: optimise fill and fill_rect methods
- vfs_fat: implement POSIX behaviour of rename, allow to overwrite
- moduselect: use stream helper function instead of ad-hoc code
- moduselect: use configurable EVENT_POLL_HOOK instead of WFI
- modlwip: add ioctl method to socket, with poll implementation
- vfs_fat_file: allow file obj to respond to ioctl flush request
- modbtree: add method to sync the database
- modbtree: rename "sync" method to "flush" for consistency
- modframebuf: add hline, vline, rect and line methods
- machine_spi: provide reusable software SPI class
- modframebuf: make framebuf implement the buffer protocol
- modframebuf: store underlying buffer object to prevent GC free
- modutimeq: copy of current moduheapq with timeq support for refactoring
- modutimeq: refactor into optimized class
- modutimeq: make time_less_than be actually "less than", not less/eq

lib:
- utils/interrupt_char: use core-provided mp_kbd_exception if enabled

drivers:
- display/ssd1306.py: update to use FrameBuffer not FrameBuffer1
- onewire: enable pull up on data pin
- onewire/ds18x20: fix negative temperature calc for DS18B20

tools:
- tinytest-codegen: blacklist recently added uheapq_timeq test (qemu-arm)
- pyboard.py: refactor so target is not reset between scripts/cmd
- mpy-tool.py: add support for OPT_CACHE_MAP_LOOKUP_IN_BYTECODE

tests:
- micropython: add test for import from within viper function
- use read() instead of readall()
- basics: add test for logical constant folding
- micropython: add test for creating traceback without allocation
- micropython: move alloc-less traceback test to separate test file
- extmod: improve ujson coverage
- basics: improve user class coverage
- basics: add test for dict.fromkeys where arg is a generator
- basics: add tests for if-expressions
- basics: change dict_fromkeys test so it doesn't use generators
- basics: enable tests for list slice getting with 3rd arg
- extmod/vfs_fat_fileio: add test for constructor of FileIO type
- extmod/btree1: exercise btree.flush()
- extmod/framebuf1: add basics tests for hline, vline, rect, line
- update for required byteorder arg for int.from_bytes()/to_bytes()
- extmod: improve moductypes test coverage
- extmod: improve modframebuf test coverage
- micropython: get heapalloc_traceback test running on baremetal
- struct*: make skippable
- basics: improve mpz test coverage
- float/builtin_float_round: test round() with second arg
- basics/builtin_dir: add test for dir() of a type
- basics: add test for builtin locals()
- basics/set_pop: improve coverage of set functions
- run-tests: for REPL tests make sure the REPL is exited at the end
- basics: improve test coverage for generators
- import: add a test which uses ... in from-import statement
- add tests to improve coverage of runtime.c
- add tests to improve coverage of objarray.c
- extmod: add test for utimeq module
- basics/lexer: add a test for newline-escaping within a string
- add a coverage test for printing the parse-tree
- utimeq_stable: test for partial stability of utimeq queuing
- heapalloc_inst_call: test for no alloc for simple object calls
- basics: add tests for parsing of ints with base 36
- basics: add tests to improve coverage of binary.c
- micropython: add test for micropython.stack_use() function
- extmod: improve ubinascii.c test coverage
- thread: improve modthread.c test coverage
- cmdline: improve repl.c autocomplete test coverage
- unix: improve runtime_utils.c test coverage
- pyb/uart: update test to match recent change to UART timeout_char
- run-tests: allow to skip set tests
- improve warning.c test coverage
- float: improve formatfloat.c test coverage using Python
- unix: improve formatfloat.c test coverage using C
- unix/extra_coverage: add basic tests to import frozen str and mpy
- types1: split out set type test to set_types
- array: allow to skip test if "array" is unavailable
- unix/extra_coverage: add tests for importing frozen packages

unix port:
- rename define for unix moduselect to MICROPY_PY_USELECT_POSIX
- Makefile: update freedos target for change of USELECT config name
- enable utimeq module
- main: allow to print the parse tree in coverage build
- Makefile: make "coverage_test" target mirror Travis test actions
- moduselect: if file object passed to .register(), return it in .poll()
- Makefile: split long line for coverage target, easier to modify
- enable and add basic frozen str and frozen mpy in coverage build
- Makefile: allow cache-map-lookup optimisation with frozen bytecode

windows port:
- enable READER_POSIX to get access to lexer_new_from_file

stmhal port:
- dma: de-init the DMA peripheral properly before initialising
- i2c: add option to I2C to enable/disable use of DMA transfers
- i2c: reset the I2C peripheral if there was an error on the bus
- rename mp_hal_pin_set_af to _config_alt, to simplify alt config
- upgrade to STM32CubeF4 v1.13.0 - CMSIS/Device 2.5.1
- upgrade to STM32CubeF4 v1.13.0 - HAL v1.5.1
- apply STM32CubeF4 v1.13.1 patch - upgrade HAL driver to v1.5.2
- hal/i2c: reapply HAL commit ea040a4 for f4
- hal/sd: reapply HAL commit 1d7fb82 for f4
- hal: reapply HAL commit 9db719b for f4
- hal/rcc: reapply HAL commit c568a2b for f4
- hal/sd: reapply HAL commit 09de030 for f4
- boards: configure all F4 boards to work with new HAL
- make-stmconst.py: fix regex's to work with current CMSIS
- i2c: handle I2C IRQs
- dma: precalculate register base and bitshift on handle init
- dma: mark DMA sate as READY even if HAL_DMA_Init is skipped
- can: clear FIFO flags in IRQ handler
- i2c: provide custom IRQ handlers
- hal: do not include <stdio.h> in HAL headers
- mphalport.h: use single GPIOx->BSRR register
- make-stmconst.py: add support for files with invalid utf8 bytes
- update HALCOMMITS due to change to hal
- make-stmconst.py: restore Python 2 compatibility
- update HALCOMMITS due to change to hal
- moduselect: move to extmod/ for reuse by other ports
- i2c: use the HAL's I2C IRQ handler for F7 and L4 MCUs
- updates to get F411 MCUs compiling with latest ST HAL
- i2c: remove use of legacy I2C_NOSTRETCH_DISABLED option
- add beginnings of port-specific machine.I2C implementation
- i2c: add support for I2C4 hardware block on F7 MCUs
- i2c: expose the pyb_i2c_obj_t struct and some relevant functions
- machine_i2c: provide HW implementation of I2C peripherals for F4
- add support for flash storage on STM32F415
- add back GPIO_BSRRL and GPIO_BSRRH constants to stm module
- add OpenOCD configuration for STM32L4
- add address parameters to openocd config files
- adc: add "mask" selection parameter to pyb.ADCAll constructor
- adc: provide more accurate measure of VBAT and VREFINT
- adc: make ADCAll.read_core_temp return accurate float value
- adc: add ADCAll.read_vref method, returning "3.3v" value
- adc: add support for F767 MCU
- adc: make channel "16" always map to the temperature sensor
- sdcard: clean/invalidate cache before DMA transfers with SD card
- moduos: implement POSIX behaviour of rename, allow to overwrite
- adc: use constants from new HAL version
- refactor UART configuration to use pin objects
- uart: add support for UART7 and UART8 on F7 MCUs
- uart: add check that UART id is valid for the given board
- cmsis: update STM32F7 CMSIS device include files to V1.1.2
- hal: update ST32CubeF7 HAL files to V1.1.2
- port of f4 hal commit c568a2b to updated f7 hal
- port of f4 hal commit 09de030 to updated f7 hal
- port of f4 hal commit 1d7fb82 to updated f7 hal
- declare and initialise PrescTables for F7 MCUs
- boards/STM32F7DISC: define LSE_STARTUP_TIMEOUT
- hal: update HALCOMMITS due to change in f7 hal files
- refactor to use extmod implementation of software SPI class
- cmsis: add CMSIS file stm32f767xx.h, V1.1.2
- add NUCLEO_F767ZI board, with openocd config for stm32f7
- cmsis: add CMSIS file stm32f769xx.h, V1.1.2
- add STM32F769DISC board files
- move PY_SYS_PLATFORM config from board to general config file
- mpconfigport: add weak-module links for io, collections, random
- rename mp_const_vcp_interrupt to mp_kbd_exception
- usb: always use the mp_kbd_exception object for VCP interrupt
- use core-provided keyboard exception object
- led: properly initialise timer handle to zero before using it
- mphalport.h: explicitly use HAL's GPIO constants for pull modes
- usrsw: use mp_hal_pin_config function instead of HAL_GPIO_Init
- led: use mp_hal_pin_config function instead of HAL_GPIO_Init
- sdcard: use mp_hal_pin_config function instead of HAL_GPIO_Init
- add support for STM32 Nucleo64 L476RG
- uart: provide a custom function to transmit over UART
- uart: increase inter-character timeout by 1ms
- enable utimeq module

cc3200 port:
- tools/smoke.py: change readall() to read()
- pybspi: remove static mode=SPI.MASTER parameter for latest HW API
- mods/pybspi: remove SPI.MASTER constant, it's no longer needed
- update for moduselect moved to extmod/
- re-add support for UART REPL (MICROPY_STDIO_UART setting)
- enable UART REPL by default
- README: (re)add information about accessing REPL on serial
- make: rename "deploy" target to "deploy-ota"
- add targets to erase flash, deploy firmware using cc3200tool
- README: reorganize and update to the current state of affairs
- modwlan: add network.WLAN.print_ver() diagnostic function

esp8266 port:
- enable uselect module
- move websocket_helper.py from scripts to modules for frozen BC
- refactor to use extmod implementation of software SPI class
- mpconfigport_512k: disable framebuf module for 512k build
- enable native emitter for Xtensa arch
- enable inline Xtensa assembler
- add "ota" target to produce firmware binary for use with yaota8266
- use core-provided keyboard exception object
- add "erase" target to Makefile, to erase entire flash
- when doing GC be sure to trace the memory holding native code
- modesp: flash_user_start(): support configuration with yaota8266
- force relinking OTA firmware image if built after normal one
- scripts/inisetup: dump FS starting sector/size on error
- Makefile: produce OTA firmware as firmware-ota.bin
- modesp: make check_fw() work with OTA firmware
- enable utimeq module
- Makefile: put firmware-ota.bin in build/, for consistency
- modules/flashbdev: add RESERVED_SECS before the filesystem
- modules/flashbdev: remove code to patch bootloader flash size
- modules/flashbdev: remove now-unused function set_bl_flash_size
- modules/flashbdev: change RESERVED_SECS to 0

zephyr port:
- add .gitignore to ignore Zephyr's "outdir" directory
- zephyr_getchar: update to Zephyr 1.6 unified kernel API
- switch to Zephyr 1.6 unified kernel API
- support raw REPL
- implement soft reset feature
- main: initialize sys.path and sys.argv
- use core-provided keyboard exception object
- uart_core: access console UART directly instead of printk() hack
- enable slice subscription

docs:
- remove references to readall() and update stream read() docs
- library/index: elaborate on u-modules
- library/machine.I2C: refine definitions of I2C methods
- library/pyb.Accel: add hardware note about pins used by accel
- library/pyb.UART: added clarification about timeouts
- library/pyb.UART: moved writechar doc to sit with other writes
- esp8266/tutorial: update intro to add Getting the firmware section
- library/machine.I2C: fix I2C constructor docs to match impl
- esp8266/tutorial: close socket after reading page content
- esp8266/general: add "Scarcity of runtime resources" section
- library/esp: document esp.set_native_code_location() function
- library/esp: remove para and add further warning about flash
- usocket: clarify that socket timeout raises OSError exception

travis:
- build STM32 F7 and L4 boards under Travis CI
- include persistent bytecode with floats in coverage tests

examples:
- hwapi: button_led: Add GPIO pin read example
- hwapi: add soft_pwm example converted to uasyncio
- http_client: use read() instead of readall()
- hwapi: add uasyncio example of fading 2 LEDs in parallel
- hwapi: add example for machine.time_pulse_us()
- hwapi: add hwconfig for console tracing of LED operations
- accellog.py: change 1: to /sd/, and update comment about FS
- hwapi/hwconfig_console: don't alloc memory in value()
2017-01-10 09:56:09 -08:00
..
boards stmhal: Add support for STM32 Nucleo64 L476RG. 2016-12-22 17:45:50 +11:00
cmsis stmhal/cmsis: Add CMSIS file stm32f769xx.h, V1.1.2. 2016-12-13 16:25:56 +11:00
hal stmhal/hal: Update HALCOMMITS due to change in f7 hal files. 2016-12-07 17:36:42 +11:00
usbdev stmhal/usb: Use real packet size (not maximum) in HID receive. 2016-10-04 15:39:31 +11:00
usbhost Initial checkin with STM HAL 2014-03-11 23:55:41 -07:00
.gitignore stmhal: Add support for Espruino Pico board. 2015-04-18 21:40:59 +01:00
Makefile stmhal: Add address parameters to openocd config files. 2016-11-28 15:27:36 +11:00
README.md stmhal: Add makefile target and configuration to deploy via OpenOCD. 2016-03-09 23:00:17 +00:00
accel.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
accel.h Add license header to (almost) all files. 2014-05-03 23:27:38 +01:00
adc.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
adc.h Add license header to (almost) all files. 2014-05-03 23:27:38 +01:00
autoflash Add device ID to autoflash script. 2014-05-02 23:03:23 +01:00
bufhelper.c py: Remove mp_obj_str_builder and use vstr instead. 2015-01-21 23:18:02 +00:00
bufhelper.h py: Remove mp_obj_str_builder and use vstr instead. 2015-01-21 23:18:02 +00:00
builtin_open.c extmod/vfs_fat_file: Reusable FatFs module, move from stmhal/file. 2016-02-15 00:16:46 +02:00
can.c Merge tag 'v1.8.7' 2017-01-10 09:56:09 -08:00
can.h stmhal: Remove PYBVxx defines and use config vars for UART/CAN names. 2015-05-27 16:51:04 +01:00
dac.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
dac.h Add license header to (almost) all files. 2014-05-03 23:27:38 +01:00
dma.c stmhal/i2c: Add support for I2C4 hardware block on F7 MCUs. 2016-11-25 11:21:18 +11:00
dma.h stmhal/i2c: Add support for I2C4 hardware block on F7 MCUs. 2016-11-25 11:21:18 +11:00
extint.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
extint.h stamhal: Add definitions for MCU_SERIES_F4 and MCU_SERIES_F7 2015-08-07 08:52:42 +01:00
fatfs_port.c extmod/fsusermount: Support mounting of multiple block devices. 2016-02-10 23:40:10 +00:00
flash.c stmhal: L4: Modify flash.c and storage.c to support L4 MCU. 2016-04-21 13:03:38 +01:00
flash.h Add license header to (almost) all files. 2014-05-03 23:27:38 +01:00
font_petme128_8x8.h extmod: Add initial framebuf module. 2016-04-12 14:06:53 +01:00
gccollect.c stmhal: Collect all root pointers together in 1 place. 2015-01-07 23:38:50 +00:00
gccollect.h stmhal: Remove some unnecessary declarations, purely for cleanup. 2015-03-20 22:27:34 +00:00
gchelper.s REPl working on UART6 with STMHAL 2014-03-12 18:15:55 -07:00
help.c cc3200, stmhal, teensy: Use pyhelp_print_obj function. 2016-04-25 18:54:59 +03:00
i2c.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
i2c.h stmhal/i2c: Expose the pyb_i2c_obj_t struct and some relevant functions. 2016-11-25 16:30:51 +11:00
import.c extmod/vfs_fat: Add fat_vfs_import_stat(), reusable import stat routine. 2016-02-29 00:44:32 +02:00
input.c stmhal: Make pybstdio usable by other ports, and use it. 2015-02-13 15:04:53 +00:00
irq.c stmhal: Add pyb.irq_stats() to get statistics about IRQ calls. 2015-12-22 21:00:20 +00:00
irq.h py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros. 2016-10-21 16:26:01 +11:00
lcd.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
lcd.h stmhal: Update and improve LCD driver. 2014-06-15 00:41:47 +01:00
led.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
led.h Add license header to (almost) all files. 2014-05-03 23:27:38 +01:00
machine_i2c.c stmhal/machine_i2c: Provide HW implementation of I2C peripherals for F4. 2016-11-25 16:31:43 +11:00
main.c Merge tag 'v1.8.7' 2017-01-10 09:56:09 -08:00
make-stmconst.py stmhal: Add back GPIO_BSRRL and GPIO_BSRRH constants to stm module. 2016-11-28 15:02:42 +11:00
memory.h stmhal: Enable uhashlib module; add heapq, hashlib weak links. 2014-11-27 17:54:37 +00:00
modmachine.c stmhal: Implement machine.soft_reset(). 2016-10-17 13:16:47 +11:00
modmachine.h py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros. 2016-10-21 16:26:01 +11:00
modnetwork.c stmhal: Disable network and usocket for ESPRUINO_PICO 2016-10-06 11:47:45 +11:00
modnetwork.h lib: Move some common mod_network_* functions to lib/netutils. 2015-05-04 11:48:40 +01:00
modnwcc3k.c Merge tag 'v1.8.7' 2017-01-10 09:56:09 -08:00
modnwwiznet5k.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
modpyb.c py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros. 2016-10-21 16:26:01 +11:00
modstm.c all: Remove 'name' member from mp_obj_module_t struct. 2016-09-22 00:23:16 +10:00
moduos.c stmhal/moduos: Implement POSIX behaviour of rename, allow to overwrite. 2016-12-02 15:13:29 +11:00
modusocket.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
modutime.c stmhal/modutime: Consistently convert to MP_ROM_QSTR/MP_ROM_PTR. 2016-10-29 17:46:47 +03:00
mpconfigport.h stmhal, esp8266: Enable utimeq module. 2016-12-23 14:49:13 +03:00
mpconfigport.mk stmhal: Initial implementation of cc3k module and driver. 2014-09-26 00:57:26 +01:00
mphalport.c stmhal: Updates to get F411 MCUs compiling with latest ST HAL. 2016-11-21 23:24:24 +11:00
mphalport.h stmhal/mphalport.h: Explicitly use HAL's GPIO constants for pull modes. 2016-12-22 14:55:26 +11:00
pendsv.c stmhal: Rename mp_const_vcp_interrupt to mp_kbd_exception. 2016-12-15 12:32:00 +11:00
pendsv.h stmhal: Remove some unnecessary declarations, purely for cleanup. 2015-03-20 22:27:34 +00:00
pin.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
pin.h py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros. 2016-10-21 16:26:01 +11:00
pin_defs_stmhal.c all: Add py/mphal.h and use it in all ports. 2015-10-31 19:14:30 +03:00
pin_defs_stmhal.h stmhal: Add STM32F7DISC and associated changes. 2015-07-30 00:38:32 +01:00
pin_named_pins.c all: Add py/mphal.h and use it in all ports. 2015-10-31 19:14:30 +03:00
portmodules.h stmhal/moduselect: Move to extmod/ for reuse by other ports. 2016-11-21 00:05:56 +03:00
pybcdc.inf_template Rename "Micro Python" to "MicroPython" in REPL, help, readme's and misc. 2015-10-12 00:06:25 +01:00
pybstdio.c all: Remove readall() method, which is equivalent to read() w/o args. 2016-11-14 00:24:22 +03:00
qstrdefsport.h py: Add rules for automated extraction of qstrs from sources. 2016-04-16 13:18:09 +01:00
rng.c stmhal: Replace #include "stm32f4xx_hal.h" with #include STM32_HAL_H. 2015-07-30 00:38:25 +01:00
rng.h py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros. 2016-10-21 16:26:01 +11:00
rtc.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
rtc.h stmhal: Add rtc.init() method to force RTC to re-initialise. 2015-12-04 12:05:05 +00:00
sdcard.c stmhal/sdcard: Use mp_hal_pin_config function instead of HAL_GPIO_Init. 2016-12-22 14:55:26 +11:00
sdcard.h extmod/fsusermount: Support mounting of multiple block devices. 2016-02-10 23:40:10 +00:00
servo.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
servo.h py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros. 2016-10-21 16:26:01 +11:00
spi.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
spi.h stmhal/spi: Make machine.SPI class conform to correct API. 2016-10-03 17:12:43 +11:00
startup_stm32.S stmhal: L4: Adapt startup code, clock configuration and interrupts. 2016-05-05 15:14:42 +01:00
stm32_it.c stmhal/uart: Add support for UART7 and UART8 on F7 MCUs. 2016-12-05 15:14:22 +11:00
stm32_it.h stmhal: Enable two USB phys to be supported together. 2015-12-09 09:56:36 +00:00
storage.c stmhal: Add STM32F769DISC board files. 2016-12-13 16:26:13 +11:00
storage.h extmod/fsusermount: Support mounting of multiple block devices. 2016-02-10 23:40:10 +00:00
system_stm32.c stmhal: Declare and initialise PrescTables for F7 MCUs. 2016-12-07 17:31:09 +11:00
systick.c stmhal: Replace #include "stm32f4xx_hal.h" with #include STM32_HAL_H. 2015-07-30 00:38:25 +01:00
systick.h stmhal: Make pyb.[u]delay use systick with IRQs, busy loop otherwise. 2014-11-30 21:23:25 +00:00
timer.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
timer.h stmhal: Add PWM capability for LED(3) and LED(4) on pyboards. 2016-01-29 22:44:43 +00:00
uart.c Merge tag 'v1.8.7' 2017-01-10 09:56:09 -08:00
uart.h stmhal/uart: Add support for UART7 and UART8 on F7 MCUs. 2016-12-05 15:14:22 +11:00
usb.c Merge tag 'v1.8.7' 2017-01-10 09:56:09 -08:00
usb.h py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros. 2016-10-21 16:26:01 +11:00
usbd_cdc_interface.c stmhal: Use core-provided keyboard exception object. 2016-12-15 15:51:34 +11:00
usbd_cdc_interface.h stmhal/usb: Always use the mp_kbd_exception object for VCP interrupt. 2016-12-15 12:45:56 +11:00
usbd_conf.c stmhal: L4: Modify usbd_conf.c to support L4 MCU. 2016-04-17 12:02:26 +01:00
usbd_conf.h stmhal: Replace #include "stm32f4xx_hal.h" with #include STM32_HAL_H. 2015-07-30 00:38:25 +01:00
usbd_desc.c all: Add py/mphal.h and use it in all ports. 2015-10-31 19:14:30 +03:00
usbd_desc.h stmhal: Fix USB CDC-only mode under Windows. 2015-10-09 00:18:01 +01:00
usbd_hid_interface.c stmhal/usb: Use correct ClassData structure for HID receive. 2016-10-04 15:38:32 +11:00
usbd_hid_interface.h stmhal/usb: Add support to receive USB HID messages from host. 2016-10-04 15:38:01 +11:00
usbd_msc_storage.c stmhal: Include fatfs headers using lib/fatfs prefix. 2015-03-04 20:35:41 +00:00
usbd_msc_storage.h Add license header to (almost) all files. 2014-05-03 23:27:38 +01:00
usrsw.c all: Consistently update signatures of .make_new and .call methods. 2017-01-04 16:10:42 +03:00
usrsw.h Add license header to (almost) all files. 2014-05-03 23:27:38 +01:00
wdt.c stmhal/wdt: Implement keyword args to WDT constructor. 2016-09-06 14:19:40 +10:00
wdt.h stmhal: Add machine.WDT class. 2016-09-04 00:12:48 +10:00

README.md

MicroPython port to STM32 MCUs

This directory contains the port of MicroPython to ST's line of STM32Fxxx microcontrollers. It is based on the STM32Cube HAL library and currently supports: STM32F401, STM32F405, STM32F411, STM32F429, STM32F746.

The officially supported boards are the line of pyboards: PYBv1.0 and PYBv1.1 (both with STM32F405), and PYBLITEv1.0 (with STM32F411). See micropython.org/pyboard for further details.

Other boards that are supported include ST Discovery and Nucleo boards. See the boards/ subdirectory, which contains the configuration files used to build each individual board.

Build instructions

An ARM compiler is required for the build, along with the associated binary utilities. The default compiler is arm-none-eabi-gcc, which is available for Arch Linux via the package arm-none-eabi-gcc, for Ubuntu via instructions here, or see here for the main GCC ARM Embedded page. The compiler can be changed using the CROSS_COMPILE variable when invoking make.

To build for a given board, run:

$ make BOARD=PYBV11

The default board is PYBV10 but any of the names of the subdirectories in the boards/ directory can be passed as the argument to BOARD=. The above command should produce binary images in the build-PYBV11/ subdirectory (or the equivalent directory for the board specified).

You must then get your board/microcontroller into DFU mode. On the pyboard connect the 3V3 pin to the P1/DFU pin with a wire (they are next to each other on the bottom left of the board, second row from the bottom) and then reset (by pressing the RST button) or power on the board. Then flash the firmware using the command:

$ make BOARD=PYBV11 deploy

This will use the included tools/pydfu.py script. You can use instead the dfu-util program (available here) by passing USE_PYDFU=0:

$ make BOARD=PYBV11 USE_PYDFU=0 deploy

If flashing the firmware does not work it may be because you don't have the correct permissions. Try then:

$ sudo make BOARD=PYBV11 deploy

Or using dfu-util directly:

$ sudo dfu-util -a 0 -d 0483:df11 -D build-PYBV11/firmware.dfu

ST Discovery or Nucleo boards have a builtin programmer called ST-LINK. With these boards and using Linux or OS X, you have the option to upload the stmhal firmware using the st-flash utility from the stlink project. To do so, connect the board with a mini USB cable to its ST-LINK USB port and then use the make target deploy-stlink. For example, if you have the STM32F4DISCOVERY board, you can run:

$ make BOARD=STM32F4DISC deploy-stlink

The st-flash program should detect the USB connection to the board automatically. If not, run lsusb to determine its USB bus and device number and set the STLINK_DEVICE environment variable accordingly, using the format <USB_BUS>:<USB_ADDR>. Example:

$ lsusb
[...]
Bus 002 Device 035: ID 0483:3748 STMicroelectronics ST-LINK/V2
$ export STLINK_DEVICE="002:0035"
$ make BOARD=STM32F4DISC deploy-stlink

Flashing the Firmware with OpenOCD

Another option to deploy the firmware on ST Discovery or Nucleo boards with a ST-LINK interface uses OpenOCD. Connect the board with a mini USB cable to its ST-LINK USB port and then use the make target deploy-openocd. For example, if you have the STM32F4DISCOVERY board:

$ make BOARD=STM32F4DISC deploy-openocd

The openocd program, which writes the firmware to the target board's flash, is configured via the file stmhal/boards/openocd_stm32f4.cfg. This configuration should work for all boards based on a STM32F4xx MCU with a ST-LINKv2 interface. You can override the path to this configuration by setting OPENOCD_CONFIG in your Makefile or on the command line.

Accessing the board

Once built and deployed, access the MicroPython REPL (the Python prompt) via USB serial or UART, depending on the board. For the pyboard you can try:

$ picocom /dev/ttyACM0