aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-06-15esp32: Update to latest ESP IDF.Damien George
2018-06-15stm32/i2cslave: Fix ordering of event callbacks in slave IRQ handler.Damien George
It's possible (at least on F4 MCU's) to have RXNE and STOPF set at the same time during a call to the slave IRQ handler. In such cases RXNE should be handled before STOPF so that all bytes are processed before i2c_slave_process_rx_end() is called.
2018-06-15stm32/i2c: Fix num_acks calculation in i2c_write for F0 and F7 MCU's.Damien George
Due to buffering of outgoing bytes on the I2C bus, detection of a NACK using the ISR_NACKF flag needs to account for the case where ISR_NACKF corresponds to the previous-to-previous byte.
2018-06-15stm32/timer: Support TIM1 on F0 MCUs.Damien George
2018-06-14drivers/memory/spiflash: Add functions for direct erase/read/write.Damien George
These new API functions do not use the cache.
2018-06-14drivers/memory/spiflash: Rename functions to indicate they use cache.Damien George
This patch renames the existing SPI flash API functions to reflect the fact that the go through the cache: mp_spiflash_flush -> mp_spiflash_cache_flush mp_spiflash_read -> mp_spiflash_cached_read mp_spiflash_write -> mp_spiflash_cached_write
2018-06-14stm32/boards/STM32L476DISC: Update SPI flash config for cache change.Damien George
2018-06-14drivers/memory/spiflash: Move cache buffer to user-provided config.Damien George
This patch removes the global cache variables from the SPI flash driver and now requires the user to provide the cache memory themselves, via the SPI flash configuration struct. This allows to either have a shared cache for multiple SPI flash devices (by sharing a mp_spiflash_cache_t struct), or have a single cache per device (or a mix of these options). To configure the cache use: mp_spiflash_cache_t spi_bdev_cache; const mp_spiflash_config_t spiflash_config = // any bus options .cache = &spi_bdev_cache, };
2018-06-13esp32/fatfs_port: Implement get_fattime so FAT files have a timestamp.Damien George
Fixes issue #3859.
2018-06-13extmod/modussl_axtls: Fix __del__ to point to mp_stream_close_obj.Damien George
2018-06-12extmod/uos_dupterm: Use native C stream methods on dupterm object.Damien George
This patch changes dupterm to call the native C stream methods on the connected stream objects, instead of calling the Python readinto/write methods. This is much more efficient for native stream objects like UART and webrepl and doesn't require allocating a special dupterm array. This change is a minor breaking change from the user's perspective because dupterm no longer accepts pure user stream objects to duplicate on. But with the recent addition of uio.IOBase it is possible to still create such classes just by inheriting from uio.IOBase, for example: import uio, uos class MyStream(uio.IOBase): def write(self, buf): # existing write implementation def readinto(self, buf): # existing readinto implementation uos.dupterm(MyStream())
2018-06-12stm32/Makefile: Rebuild all qstrs when any board configuration changes.Damien George
2018-06-12py/mkrules.mk: Regenerate all qstrs when config files change.Damien George
A port can define QSTR_GLOBAL_DEPENDENCIES to add extra files.
2018-06-12esp32: Remove port-specific uhashlib implementation and use common one.Damien George
Now that the common module has mbedtls support for both SHA1 and SHA256 it can now be used on this port.
2018-06-12extmod/moduhashlib: Make function objects STATIC.Yonatan Goldschmidt
These are not exported to anyone anyway.
2018-06-12extmod/moduhashlib: Allow using the sha256 implementation of mbedTLS.Yonatan Goldschmidt
2018-06-12extmod/moduhashlib: Allow to disable the sha256 class.Yonatan Goldschmidt
Via the config value MICROPY_PY_UHASHLIB_SHA256. Default to enabled to keep backwards compatibility. Also add default value for the sha1 class, to at least document its existence.
2018-06-12extmod/moduhashlib: Reorder funcs so that they are grouped by hash type.Yonatan Goldschmidt
Makes the code much more readable by reducing the number of #ifdefs and keeping related functions close.
2018-06-12extmod/moduhashlib: Prefix all Python methods and objects with uhashlib.Yonatan Goldschmidt
For consistency with other modules, and to help avoid clashes with the actual underlying functions that do the hashing (eg crypto-algorithms/sha256.c:sha256_update).
2018-06-12tests/extmod: Add test for VFS and user-defined filesystem and files.Damien George
2018-06-12tests/io: Add simple IOBase test.Damien George
2018-06-12ports: Enable IOBase on unix, stm32, esp8266 and esp32.Damien George
It's a core feature, in particular required for user-streams with uasyncio.
2018-06-12py/modio: Add uio.IOBase class to allow to define user streams.Damien George
A user class derived from IOBase and implementing readinto/write/ioctl can now be used anywhere a native stream object is accepted. The mapping from C to Python is: stream_p->read --> readinto(buf) stream_p->write --> write(buf) stream_p->ioctl --> ioctl(request, arg) Among other things it allows the user to: - create an object which can be passed as the file argument to print: print(..., file=myobj), and then print will pass all the data to the object via the objects write method (same as CPython) - pass a user object to uio.BufferedWriter to buffer the writes (same as CPython) - use select.select on a user object - register user objects with select.poll, in particular so user objects can be used with uasyncio - create user files that can be returned from user filesystems, and import can import scripts from these user files For example: class MyOut(io.IOBase): def write(self, buf): print('write', repr(buf)) return len(buf) print('hello', file=MyOut()) The feature is enabled via MICROPY_PY_IO_IOBASE which is disabled by default.
2018-06-12py/lexer: Add support for underscores in numeric literals.Damien George
This is a very convenient feature introduced in Python 3.6 by PEP 515.
2018-06-12ports: Call gc_sweep_all() when doing a soft reset.Damien George
This calls finalisers of things like files and sockets to cleanly close them.
2018-06-12py/gc: Add gc_sweep_all() function to run all remaining finalisers.Damien George
This patch adds the gc_sweep_all() function which does a garbage collection without tracing any root pointers, so frees all the memory, and most importantly runs any remaining finalisers. This helps primarily for soft reset: it will close any open files, any open sockets, and help to get the system back to a clean state upon soft reset.
2018-06-08tools/pydfu.py: Increase download packet size to full 2048 bytes.Damien George
The ST DFU bootloader supports a transfer size up to 2048 bytes, so send that much data on each download (to device) packet. This almost halves total download time.
2018-06-08stm32/mboot: Increase USB rx_buf and DFU buf sizes to full 2048 bytes.Damien George
The DFU USB config descriptor returns 0x0800=2048 for the supported transfer size, and this applies to both TX (IN) and RX (OUT). So increase the rx_buf to support this size without having a buffer overflow on received data. With this patch mboot in USB DFU mode now works with dfu-util.
2018-06-08esp32/modnetwork: Fix isconnected() when using static IP config.Glenn Moloney
Currently <WLAN>.isconnected() always returns True if a static IP is set, regardless of the state of the connection. This patch introduces a new flag 'wifi_sta_connected' which is set in event_handler() when GOT_IP event is received and reset when DISCONNECTED event is received (unless re-connect is successful). isconnected() now simply returns the status of this flag (for STA_IF). The pre-existing flag misleadingly named 'wifi_sta_connected" is also renamed to 'wifi_sta_connect_requested'. Fixes issue #3837
2018-06-08tests/pyb: Make i2c and pyb1 pyboard tests run again.Damien George
For i2c.py: the accelerometer now uses the new I2C driver so need to explicitly init the legacy i2c object to get the test working. For pyb1.py: the legacy pyb.hid() call will crash if the USB_HID object is not initialised.
2018-06-08stm32/mpconfigport.h: Enable DELATTR_SETATTR and BUILTINS_NOTIMPLEMENTEDDamien George
MICROPY_PY_DELATTR_SETATTR can now be enabled without a performance hit for classes that don't use this feature. MICROPY_PY_BUILTINS_NOTIMPLEMENTED is a minor addition that improves compatibility with CPython.
2018-06-08ports: Enable descriptors on stm32, esp8266, esp32 ports.Damien George
They are now efficient (in runtime performance) and provide a useful feature that's hard to obtain without them enabled. See issue #3644 and PR #3826 for background.
2018-06-08py/objtype: Optimise instance get/set/del by skipping special accessors.Damien George
This patch is a code optimisation, trading text bytes for speed. On pyboard it's an increase of 0.06% in code size for a gain (in pystone performance) of roughly 6.5%. The patch optimises load/store/delete of attributes in user defined classes by not looking up special accessors (@property, __get__, __delete__, __set__, __setattr__ and __getattr_) if they are guaranteed not to exist in the class. Currently, if you do my_obj.foo() then the runtime has to do a few checks to see if foo is a property or has __get__, and if so delegate the call. And for stores things like my_obj.foo = 1 has to first check if foo is a property or has __set__ defined on it. Doing all those checks each and every time the attribute is accessed has a performance penalty. This patch eliminates all those checks for cases when it's guaranteed that the checks will always fail, ie no attributes are properties nor have any special accessor methods defined on them. To make this guarantee it checks all attributes of a user-defined class when it is first created. If any of the attributes of the user class are properties or have special accessors, or any of the base classes of the user class have them, then it sets a flag in the class to indicate that special accessors must be checked for. Then in the load/store/delete code it checks this flag to see if it can take the shortcut and optimise the lookup. It's an optimisation that's pretty widely applicable because it improves lookup performance for all methods of user defined classes, and stores of attributes, at least for those that don't have special accessors. And, it allows to enable descriptors with minimal additional runtime overhead if they are not used for a particular user class. There is one restriction on dynamic class creation that has been introduced by this patch: a user-defined class cannot go from zero special accessors to one special accessor (or more) after that class has been subclassed. If the script attempts this an AttributeError is raised (see addition to tests/misc/non_compliant.py for an example of this case). The cost in code space bytes for the optimisation in this patch is: unix x64: +528 unix nanbox: +508 stm32: +192 cc3200: +200 esp8266: +332 esp32: +244 Performance tests that were done: - on unix x86-64, pystone improved by about 5% - on pyboard, pystone improved by about 6.5%, from 1683 up to 1794 - on pyboard, bm_chaos (from CPython benchmark suite) improved by about 5% - on esp32, pystone improved by about 30% (but there are caching effects) - on esp32, bm_chaos improved by about 11%
2018-06-08py/objtype: Don't expose mp_obj_instance_attr().Damien George
mp_obj_is_instance_type() can be used instead to check for instance types.
2018-06-08py/obj.h: Introduce a "flags" entry in mp_obj_type_t.Damien George
2018-06-06travis: Install explicit version of urllib3 for coveralls.Damien George
Coveralls requires a "recent" version of urllib3, whereas requests requires a "not so recent" version, less than 1.23. So force urllib3 v1.22 to get it all working.
2018-06-06py/mpconfig.h: Add default MICROPY_VFS_FAT config value.Damien George
At least to document it's existence.
2018-06-06extmod/vfs: Introduce a C-level VFS protocol, with fast import_stat.Damien George
Following other C-level protocols, this VFS protocol is added to help abstract away implementation details of the underlying VFS in an efficient way. As a starting point, the import_stat function is put into this protocol so that the VFS sub-system does not need to know about every VFS implementation in order to do an efficient stat for importing files. In the future it might be worth adding other functions to this protocol.
2018-06-06unix/moduos_vfs: Add missing uos functions from traditional uos module.Damien George
Now that the coverage build has fully switched to the VFS sub-system these functions were no longer available, so add them to the uos_vfs module. Also, vfs_open is no longer needed, it's available as the built-in open.
2018-06-06tests/extmod: Remove conditional import of uos_vfs, it no longer exists.Damien George
This conditional import was only used to get the tests working on the unix coverage build, which has now switched to use VFS by default so the uos module alone has the required functionality.
2018-06-06tests/extmod: Add test for importing a script from a user VFS.Damien George
2018-06-06unix: Support MICROPY_VFS_POSIX and enable it in coverage build.Damien George
The unix coverage build is now switched fully to the VFS implementation, ie the uos module is the uos_vfs module. For example, one can now sandbox uPy to their home directory via: $ ./micropython_coverage >>> import uos >>> uos.umount('/') # unmount existing root VFS >>> vfs = uos.VfsPosix('/home/user') # create new POSIX VFS >>> uos.mount(vfs, '/') # mount new POSIX VFS at root Some filesystem/OS features may no longer work with the coverage build due to this change, and these need to be gradually fixed. The standard unix port remains unchanged, it still uses the traditional uos module which directly accesses the underlying host filesystem.
2018-06-06extmod/vfs: Add fast path for stating VfsPosix filesystem.Damien George
2018-06-06py/reader: Allow MICROPY_VFS_POSIX to work with MICROPY_READER_POSIX.Damien George
2018-06-06extmod: Add VfsPosix filesystem component.Damien George
This VFS component allows to mount a host POSIX filesystem within the uPy VFS sub-system. All traditional POSIX file access then goes through the VFS, allowing to sandbox a uPy process to a certain sub-dir of the host system, as well as mount other filesystem types alongside the host filesystem.
2018-06-06extmod/vfs_fat: Rename FileIO/TextIO types to mp_type_vfs_fat_XXX.Damien George
So they don't clash with other VFS implementations.
2018-06-06extmod/vfs: Use u_rom_obj properly in argument structures.Damien George
2018-06-05esp8266/modules/ntptime.py: Remove print of newly-set time.Damien George
It should be up to the user if they want to print the new time out or not. Fixes issue #3766.
2018-06-05esp32: Add support for building with external SPI RAM.Damien George
This patch adds support for building the firmware with external SPI RAM enabled. It is disabled by default because it adds overhead (due to silicon workarounds) and reduces performance (because it's slower to have bytecode and objects stored in external RAM). To enable it, either use "make CONFIG_SPIRAM_SUPPORT=1", or add this line to you custom makefile/GNUmakefile (before "include Makefile"): CONFIG_SPIRAM_SUPPORT = 1 When this option is enabled the MicroPython heap is automatically allocated in external SPI RAM. Thanks to Angus Gratton for help with the compiler and linker settings.
2018-06-05esp32/Makefile: Extract common C & C++ flags for consistent compilation.Angus Gratton