aboutsummaryrefslogtreecommitdiff
path: root/extmod
AgeCommit message (Collapse)Author
2018-06-06extmod/vfs: Use u_rom_obj properly in argument structures.Damien George
2018-05-31extmod/modussl_mbedtls: Use mbedtls_entropy_func for CTR-DRBG entropy.Damien George
If mbedtls_ctr_drbg_seed() is available in the mbedtls bulid then so should be mbedtls_entropy_func(). Then it's up to the port to configure a valid entropy source, eg via MBEDTLS_ENTROPY_HARDWARE_ALT.
2018-05-31extmod/modussl_mbedtls: Populate sock member right away in wrap_socket.Damien George
Otherwise the "sock" member may have an undefined value if wrap_socket fails with an exception and exits early, and then if the finaliser runs it will try to close an invalid stream object. Fixes issue #3828.
2018-05-21extmod/modlwip: Allow to compile with MICROPY_PY_LWIP disabled.Damien George
2018-05-17extmod/modlwip: Set POLLHUP flag for sockets that are new.Damien George
This matches CPython behaviour on Linux: a socket that is new and not listening or connected is considered "hung up". Thanks to @rkojedzinszky for the initial patch, PR #3457.
2018-05-17extmod/modlwip: Update to work with lwIP v2.0.Damien George
lwIP v2.0.3 has been tested with this lwip module and it works very well.
2018-05-04extmod/modlwip: In ioctl handle case when socket is in an error state.Damien George
Using MP_STREAM_POLL_HUP for ERR_RST state follows how *nix handles this case.
2018-05-02extmod/uzlib: Fix C-language sequencing error with uzlib_get_byte calls.Damien George
The order of function calls in an arithmetic expression is undefined and so they must be written out as sequential statements. Thanks to @dv-extrarius for reporting this issue, see issue #3690.
2018-05-02extmod/vfs: Delegate import_stat to vfs.stat to allow generic FS import.Damien George
2018-04-23extmod/modlwip: Check if getaddrinfo() constraints are supported or not.Damien George
In particular don't issue a warning if the passed-in constraints are actually supported because they are the default values.
2018-04-10extmod/re1.5: Fix compilecode.c compile problem on IAR tool chain.armink
The 2nd and 3rd args of the ternary operator are treated like they are in the same expression and must have similar types. void is not compatible with int so that's why the compiler is complaining.
2018-04-10py/stream: Switch stream close operation from method to ioctl.Damien George
This patch moves the implementation of stream closure from a dedicated method to the ioctl of the stream protocol, for each type that implements closing. The benefits of this are: 1. Rounds out the stream ioctl function, which already includes flush, seek and poll (among other things). 2. Makes calling mp_stream_close() on an object slightly more efficient because it now no longer needs to lookup the close method and call it, rather it just delegates straight to the ioctl function (if it exists). 3. Reduces code size and allows future types that implement the stream protocol to be smaller because they don't need a dedicated close method. Code size reduction is around 200 bytes smaller for x86 archs and around 30 bytes smaller for the bare-metal archs.
2018-03-12extmod/vfs_fat: Add file size as 4th element of uos.ilistdir tuple.Tom Collins
2018-03-10drivers/bus: Pull out software SPI implementation to dedicated driver.Damien George
This patch takes the software SPI implementation from extmod/machine_spi.c and moves it to a dedicated file in drivers/bus/softspi.c. This allows the SPI driver to be used independently of the uPy runtime, making it a more general component.
2018-03-02extmod/machine_spi: Make SPI protocol structure public.Damien George
So it can be referenced directly without the need for the uPy object.
2018-02-28extmod/vfs_fat_diskio: Use a C-stack-allocated bytearray for block buf.Damien George
This patch eliminates heap allocation in the VFS FAT disk IO layer, when calling the underlying readblocks/writeblocks methods. The bytearray object that is passed to these methods is now allocated on the C stack rather than the heap (it's only 4 words big). This means that these methods should not retain a pointer to the buffer object that is passed in, but this was already a restriction because the original heap-allocated bytearray had its buffer passed by reference.
2018-02-23extmod/vfs_fat: Remove declaration of mp_builtin_open_obj.Damien George
It's declared already in py/builtin.h.
2018-02-23extmod/vfs_fat: Make fat_vfs_open_obj wrapper public, not its function.Damien George
This patch just moves the definition of the wrapper object fat_vfs_open_obj to the location of the definition of its function, which matches how it's done in most other places in the code base.
2018-02-23extmod/vfs_fat: Merge remaining vfs_fat_misc.c code into vfs_fat.c.Damien George
The only function left in vfs_fat_misc.c is fat_vfs_import_stat() which can logically go into vfs_fat.c, allowing to remove vfs_fat_misc.c.
2018-02-23extmod/vfs_fat: Move ilistdir implementation from misc to main file.Damien George
The fat_vfs_ilistdir2() function was only used by fat_vfs_ilistdir_func() so moving the former into the same file as the latter allows it to be placed directly into the latter function, thus saving code size.
2018-02-15extmod/modujson: Implement ujson.dump() function.Damien George
2018-01-31extmod/vfs_fat_file: Implement SEEK_CUR for non-zero offset.Ayke van Laethem
CPython doesn't allow SEEK_CUR with non-zero offset for files in text mode, and uPy inherited this behaviour for both text and binary files. It makes sense to provide full support for SEEK_CUR of binary-mode files in uPy, and to do this in a minimal way means also allowing to use SEEK_CUR with non-zero offsets on text-mode files. That seems to be a fair compromise.
2017-12-14extmod/modframebuf: Add 8-bit greyscale format (GS8).Damien George
2017-12-14extmod/modframebuf: Add 2-bit color format (GS2_HMSB).Petr Viktorin
This format is used in 2-color LED matrices and in e-ink displays like SSD1606.
2017-12-13extmod/modure: Add cast to workaround bug in MSVC.Damien George
2017-12-13extmod/modussl_mbedtls: Clean up mbedtls state when error during setup.Damien George
Without this patch, if the SSL handshake fails (eg the connection was lost) then the mbedtls state (memory) will never be freed.
2017-12-11extmod/modure: Convert alloca() to use new scoped allocation API.Damien George
2017-12-11extmod/machine_signal: Change VLA to use new scoped allocation API.Damien George
2017-11-24extmod/modlwip: Commit TCP out data to lower layers if buffer gets full.Damien George
Dramatically improves TCP sending throughput because without an explicit call to tcp_output() the data is only sent to the lower layers via the lwIP slow timer which (by default) ticks every 500ms.
2017-11-24extmod/modussl_axtls: Implement key and cert kw args to wrap_socket.Damien George
The key and cert must both be a str/bytes object in DER format.
2017-11-24py/runtime: Add MP_BINARY_OP_CONTAINS as reverse of MP_BINARY_OP_IN.Damien George
Before this patch MP_BINARY_OP_IN had two meanings: coming from bytecode it meant that the args needed to be swapped, but coming from within the runtime meant that the args were already in the correct order. This lead to some confusion in the code and comments stating how args were reversed. It also lead to 2 bugs: 1) containment for a subclass of a native type didn't work; 2) the expression "{True} in True" would illegally succeed and return True. In both of these cases it was because the args to MP_BINARY_OP_IN ended up being reversed twice. To fix these things this patch introduces MP_BINARY_OP_CONTAINS which corresponds exactly to the __contains__ special method, and this is the operator that built-in types should implement. MP_BINARY_OP_IN is now only emitted by the compiler and is converted to MP_BINARY_OP_CONTAINS by swapping the arguments.
2017-11-20extmod/vfs_fat: Mount FatFS on creation so VFS methods can be used.Damien George
It's possible to use the methods (eg ilistdir) of a VFS FatFS object without it being mounted in the VFS itself. This previously worked but only because FatFS was "mounting" the filesystem automatically when any function (eg f_opendir) was called. But it didn't work for ports that used synchronisation objects (_FS_REENTRANT) because they are only initialised via a call to f_mount. So, call f_mount explicitly when creating a new FatFS object so that everything is set up correctly. Then also provide a finaliser to do the f_umount call, but only if synchronisation objects are enabled (since otherwise the f_umount call does nothing).
2017-11-16py/objstr: Remove "make_qstr_if_not_already" arg from mp_obj_new_str.Damien George
This patch simplifies the str creation API to favour the common case of creating a str object that is not forced to be interned. To force interning of a new str the new mp_obj_new_str_via_qstr function is added, and should only be used if warranted. Apart from simplifying the mp_obj_new_str function (and making it have the same signature as mp_obj_new_bytes), this patch also reduces code size by a bit (-16 bytes for bare-arm and roughly -40 bytes on the bare-metal archs).
2017-11-16extmod/vfs: Use existing qstr for forward-slash string object.Damien George
2017-11-12extmod/moduhashlib: Enable SHA1 hashing when using "mbedtls" library.Christopher Cooper
The SHA1 hashing functionality is provided via the "axtls" library's implementation, and hence is unavailable when the "axtls" library is not being used. This change provides the same SHA1 hashing functionality when using the "mbedtls" library by using its implementation instead.
2017-11-02extmod/modussl_axtls: Typo fix in comment.Paul Sokolovsky
2017-11-02extmod/modussl_axtls: socket_read: Handle EAGAIN.Paul Sokolovsky
If SSL_EAGAIN is returned (which is a feature of MicroPython's axTLS fork), return EAGAIN. Original axTLS returns SSL_OK both when there's no data to return to user yet and when the underlying stream returns EAGAIN. That's not distinctive enough, for example, original module code works well for blocking stream, but will infinite-loop for non-blocking socket with EAGAIN. But if we fix non-blocking case, blocking calls to .read() will return few None's initially (while axTLS progresses thru handshake). Using SSL_EAGAIN allows to fix non-blocking case without regressing the blocking one. Note that this only handles case of non-blocking reads of application data. Initial handshake and writes still don't support non-blocking mode and must be done in the blocking way.
2017-10-30extmod/modussl_mbedtls: Allow to compile with unix coverage build.Damien George
Fixes a few C warnings. No functional changes.
2017-10-30extmod/modussl: Add finaliser support for ussl objects.Eric Poulsen
Per the comment found here https://github.com/micropython/micropython-esp32/issues/209#issuecomment-339855157, this patch adds finaliser code to prevent memory leaks from ussl objects, which is especially useful when memory for a ussl context is allocated outside the uPy heap. This patch is in-line with the finaliser code found in many modsocket implementations for various ports. This feature is configured via MICROPY_PY_USSL_FINALISER and is disabled by default because there may be issues using it when the ussl state *is* allocated on the uPy heap, rather than externally.
2017-10-27extmod/vfs: Replace VLA in proxy func with small, static sized array.Damien George
VLAs can be expensive on stack usage due to stack alignment requirements, and also the fact that extra local variables are needed to track the dynamic size of the stack. So using fixed-size arrays when possible can help to reduce code size and stack usage. In this particular case, the maximum value of n_args in the VLA is 2 and so it's more efficient to just allocate this array with a fixed size. This reduces code size by around 30 bytes on Thumb2 and Xtensa archs. It also reduces total stack usage of the function: on Thumb2 the usage with VLA is between 40 and 48 bytes, which is reduced to 32; on Xtensa, VLA usage is between 64 and 80 bytes, reduced to 32; on x86-64 it's at least 88 bytes reduced to 80.
2017-10-24all: Use NULL instead of "" when calling mp_raise exception helpers.Damien George
This is the established way of doing it and reduces code size by a little bit.
2017-10-19extmod/uos_dupterm: Swallow any errors from dupterm closing the stream.Damien George
Without this the board will crash when deactivating a stream that doesn't have a close() method (eg UART) or that raises an exception within the method (eg user-defined function).
2017-10-13extmod/uos_dupterm: Update uos.dupterm() and helper funcs to have index.Damien George
The uos.dupterm() signature and behaviour is updated to reflect the latest enhancements in the docs. It has minor backwards incompatibility in that it no longer accepts zero arguments. The dupterm_rx helper function is moved from esp8266 to extmod and generalised to support multiple dupterm slots. A port can specify multiple slots by defining the MICROPY_PY_OS_DUPTERM config macro to an integer, being the number of slots it wants to have; 0 means to disable the dupterm feature altogether. The unix and esp8266 ports are updated to work with the new interface and are otherwise unchanged with respect to functionality.
2017-10-04all: Remove inclusion of internal py header files.Damien George
Header files that are considered internal to the py core and should not normally be included directly are: py/nlr.h - internal nlr configuration and declarations py/bc0.h - contains bytecode macro definitions py/runtime0.h - contains basic runtime enums Instead, the top-level header files to include are one of: py/obj.h - includes runtime0.h and defines everything to use the mp_obj_t type py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h, and defines everything to use the general runtime support functions Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-10-03extmod/modure: Add stack overflow checking when executing a regex.Paul Sokolovsky
2017-10-02extmod/re1.5: Upgrade to v0.8.2, adds hook for stack overflow checking.Paul Sokolovsky
2017-09-24extmod/re1.5: Update to 0.8.1.Paul Sokolovsky
Allow literal minus in char classes to be in trailing position, e.g. [a-c-]. (Previously, minus was allowed only at the start.) This increases ARM Thumb2 code size by 8 bytes.
2017-09-12extmod/machine_pinbase: Put PinBase singleton in ROM.Damien George
This patch also removes the empty type "pinbase_type" (which crashes if accessed) and uses "machine_pinbase_type" instead as the type of the PinBase singleton.
2017-09-06extmod/modussl_mbedtls: Allow to compile with MBEDTLS_DEBUG_C disabled.Damien George
With MBEDTLS_DEBUG_C disabled the function mbedtls_debug_set_threshold() doesn't exist. There's also no need to call mbedtls_ssl_conf_dbg() so a few bytes can be saved on disabling that and not needing the mbedtls_debug callback.
2017-09-06all: Update Makefiles and others to build with new ports/ dir layout.Damien George
Also renames "stmhal" to "stm32" in documentation and everywhere else.