Commit Graph

1150 Commits

Author SHA1 Message Date
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
Damien George 22cedef95f stmhal/usbdev: For MSC implement SCSI SYNCHRONIZE_CACHE command.
Currently just a dummy command that returns "success", but it's needed for
some O/S's to correctly talk with the SCSI layer.
2017-06-08 12:29:10 +10:00
Damien George f86c57fedf stmhal/usb: Make state for USB device private to top-level USB driver. 2017-06-07 16:03:45 +10:00
Sylvain Pelissier 3bb69f645a stmhal/usb: Use local USB handler variable in Start-of-Frame handler. 2017-06-07 16:03:19 +10:00
Sylvain Pelissier 6adcf7bb82 stmhal: Pass USB handler as parameter to allow more than one USB handler 2017-06-07 15:50:26 +10:00
Dave Hylands 551a731755 stmhal: Add support for NUCLEO_F446RE board. 2017-06-07 13:14:40 +10:00
Damien George 6ff0ecfffc ports: Convert from using stmhal's input() to core provided version. 2017-06-01 16:02:49 +10:00
Damien George 821dc27eec stmhal/boards: Enable DAC for NUCLEO_F767ZI board. 2017-05-30 18:31:55 +10:00
Scott Shawcroft aaf01481aa Change the approach for input so that its not included in every single build. Put it next to readline instead. 2017-05-25 12:14:42 -07:00
Scott Shawcroft 32a4eb2c53 atmel-samd: Add input support. Fixes #143 2017-05-25 11:55:38 -07:00
Paul Sokolovsky bcf31a3908 esp8266, stmhal, zephyr: Rename machine.Pin high/low methods to on/off.
For consistent Pin/Signal class hierarchy. With it, Signal is a proper
(while still ducktyped) subclass of a Pin, and any (direct) usage of Pin
can be replace with Signal.

As stmhal's class is reused both as machine.Pin and legacy pyb.Pin,
high/low methods actually retained there.
2017-05-21 17:44:58 +03:00
Damien George a004554dc1 stmhal/modmachine: Remove TODO comment that is now implemented. 2017-05-16 17:44:14 +10:00
Damien George 37bd3b4f4c stmhal/modmachine: Add machine.UART class, linking to pyb.UART.
pyb.UART has a superset of machine.UART functionality so can be used to
provide compatibility with other ports that also implement machine.UART.
2017-05-16 17:40:22 +10:00
Damien George f1609bc843 ports: Add ilistdir in uos module. 2017-05-10 12:13:53 +10:00
Damien George 0986675451 stmhal: Convert all module and method tables to use MP_ROM macros. 2017-05-06 17:03:40 +10:00
Damien George 49de9b68d2 qemu-arm, stmhal: Remove dummy memory.h since it's no longer needed.
extmod/crypto-algorithms/sha256.c was recently fixed so that it didn't
include this header.
2017-04-28 22:07:14 +10:00
Damien George 03053f82db mpy-cross, unix, windows, stmhal: Enable return-if-else optimisation.
Prior to making this a config option it was previously available on these
(and all other) ports, and it makes sense to keep it enabled for mpy-cross
as well as ports that have a decent amount of space for the code.
2017-04-22 15:12:48 +10:00
Henrik Sölver 1f3887dc28 stmhal/timer: Clear interrupt flag before setting callback.
Sometimes when setting a channel callback the callback fires immediately,
even if the compare register is set to a value far into the future. This
happens when the free running counter has previously been equal to what
happens to be in the compare register.

This patch make sure that there is no pending interrupt when setting a
callback.
2017-04-18 18:09:59 +10:00
Damien George 9156c8b460 stmhal: Enable parsing of all Pin constructor args by machine.Signal. 2017-04-11 13:12:54 +10:00
Damien George 3b447ede78 stmhal/usbd_cdc_interface: Change CDC RX to use a circular buffer.
This should be a little more efficient (since we anyway scan the input
packet for the interrupt char), and it should also fix any non-atomic read
issues with the buffer state being changed during an interrupt.

Throughput tests show that RX rate is unchanged by this patch.
2017-04-04 16:23:25 +10:00
Damien George 9a8e7f7a8e stmhal/usbd_cdc_interface: Increase in-endpoint timeout to 500ms.
The previous timeout value of 150ms could lead to data being lost (ie never
received by the host) in some rare cases, eg when the host is under load.
A value of 500ms is quite conservative and allows the host plenty of time
to read our data.
2017-04-04 15:18:58 +10:00
Damien George 4c307bfba1 all: Move BYTES_PER_WORD definition from ports to py/mpconfig.h
It can still be overwritten by a port in mpconfigport.h but for almost
all cases one can use the provided default.
2017-04-01 11:39:38 +11:00
Damien George b6c7e4b143 all: Use full path name when including mp-readline/timeutils/netutils.
This follows the pattern of how all other headers are now included, and
makes it explicit where the header file comes from.  This patch also
removes -I options from Makefile's that specify the mp-readline/timeutils/
netutils directories, which are no longer needed.
2017-03-31 22:29:39 +11:00
Damien George 2460888c74 stmhal/i2c: Clean the cache so that I2C DMA works on F7 MCUs. 2017-03-31 12:56:18 +11:00
Damien George aa7de3ff67 stmhal: Move L4/F7 I2C timing constants from mpconfigboard.h to i2c.c.
Such constants are MCU specific so shouldn't be specified in the board
config file (else it leads to too much duplication of code).

This patch also adds I2C timing values for the F767/F769 for 100k, 400k
and 1MHz I2C bus frequencies.
2017-03-31 12:53:56 +11:00
Damien George 00b1a3e4d2 stmhal/dma: Don't include SDMMC2 struct if SDMMC2 is not available.
Not all F7 MCUs have SDMMC2.
2017-03-30 18:24:31 +11:00
Damien George 81e19eaf05 stmhal/boards: Remove F769 alt function table, it's same as for F767. 2017-03-30 18:00:31 +11:00
Damien George 41cbe8045e stmhal/boards/STM32F769DISC: Fix user switch pin, and document stlink. 2017-03-30 17:59:36 +11:00
Damien George c74fa7f58e stmhal/boards/STM32F769DISC: Get SD card working by using SDMMC2. 2017-03-30 17:58:45 +11:00
Damien George 9818c0db43 stmhal/boards: Update F76x alternate function table to add SDMMC2. 2017-03-30 17:57:18 +11:00
Damien George 7876e54aa5 stmhal/sdcard: Add support for SDMMC2 on F7 MCUs.
By default the SDIO (F4) or SDMMC1 (L4, F7) is used as the SD card
peripheral, but if a board config defines MICROPY_HW_SDMMC2_CK and other
pins then the SD card driver will use SDMMC2.
2017-03-30 17:55:21 +11:00
Damien George 43defc9e98 stmhal: Support SDMMC alternate functions in pin generation. 2017-03-30 17:52:20 +11:00
Damien George 22e2f4a0e8 stmhal/spi: Increase SPI transfer timeout, proportional to num bytes.
With the existing timeout of 100ms the transfer would end prematurely if
the baudrate was low and the number of bytes to send was high.  This patch
fixes the problem by making the timeout proportional to the number of bytes
that are being transferred.
2017-03-29 16:02:43 +11:00
Damien George a9c8db07bd stmhal: Update for changes to mp_obj_str_get_data. 2017-03-29 12:56:45 +11:00
Damien George ca06fac4a1 stmhal: Update to use size_t for tuple/list accessors. 2017-03-29 12:56:45 +11:00
Damien George 7b1804c582 stmhal/dma: Fix reinitialisation of DMA on F7 MCUs, following F4. 2017-03-28 12:59:02 +11:00
Damien George e997bb6328 stmhal/hal: For F7 MCUs, expose DMA_CalcBaseAndBitshift function.
It's needed by the DMA driver to do an efficient reinitialisation.  This
patch follows what is done in the F4 HAL.
2017-03-28 12:56:18 +11:00
Damien George ff927cb106 stmhal/spi: Clean and/or invalidate D-cache before SPI DMA transfers.
On MCUs with a cache (eg F7) this must be done or else the SPI data that is
transferred is incorrect.
2017-03-28 12:54:01 +11:00
Damien George 9a1b3da158 stmhal/board: Fix existing and add more pin defs for NUCLEO_F767ZI. 2017-03-28 12:42:23 +11:00
Damien George 8b36664e17 stmhal/boards: Fix alt-func config for PA5 of STM32F767. 2017-03-28 12:41:55 +11:00
Damien George 125eae1ba3 py/modbuiltins: For round() builtin use nearbyint instead of round.
The C nearbyint function has exactly the semantics that Python's round()
requires, whereas C's round() requires extra steps to handle rounding of
numbers half way between integers.  So using nearbyint reduces code size
and potentially eliminates any source of errors in the handling of half-way
numbers.

Also, bare-metal implementations of nearbyint can be more efficient than
round, so further code size is saved (and efficiency improved).

nearbyint is provided in the C99 standard so it should be available on all
supported platforms.
2017-03-24 11:00:45 +11:00
Krzysztof Blazewicz 75589272ef all/Makefile: Remove -ansi from GCC flags, its ignored anyway.
The -ansi flag is used for C dialect selection and it is equivalent to -std=c90.
Because it goes right before -std=gnu99 it is ignored as for conflicting flags
GCC always uses the last one.
2017-03-23 15:32:12 +11:00
Damien George 3509e2d307 stmhal/systick: Make mp_hal_delay_ms release the GIL when sleeping. 2017-03-22 12:54:43 +11:00
Damien George 96c35d0ac4 stmhal/pybthread: Allow interrupts to work during lock/unlock of mutex.
When locking/unlocking a mutex we only need to protect against a thread
switch, not general interrupts.
2017-03-22 12:44:04 +11:00
Damien George 080210ddc6 stmhal/irq: Shift IRQ priorities of TIM and EXTINT to be above PENDSV.
This way, Timer and ExtInt callbacks can interrupt the low-priority
pendsv handler (for example thread switching).
2017-03-22 12:39:32 +11:00
Damien George ebbaf7ee57 stmhal/pendsv: Disable interrupts during a thread switch.
We can actually handle interrupts during a thread switch (because we always
have a valid stack), but only if those interrupts don't access any of the
thread state (because the state may not correspond to the stack pointer).
So to be on the safe side we disable interrupts during the very short
period of the thread state+stack switch.
2017-03-20 18:56:46 +11:00
Damien George a5159edc20 stmhal: Enable micropython.schedule().
ExtInt, Timer and CAN IRQ callbacks are made to work with the scheduler.
They are still hard IRQs by default, but one can now call
micropython.schedule within the hard IRQ to schedule a soft callback.
2017-03-20 15:20:26 +11:00
Damien George 12d0731b91 extmod/vfs_fat: Remove obsolete and unused str/len members. 2017-03-10 19:09:42 +11:00
Damien George 8236d18338 stmhal/main: Allocate flash's VFS struct on the heap to trace root ptrs. 2017-03-10 19:02:20 +11:00
Damien George 4351d16e62 stmhal/mphalport: Get ticks_cpu() working on F7 MCUs. 2017-03-10 14:58:26 +11:00