aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-02-24py/compile: Adjust c_assign_atom_expr() to use return instead of goto.Damien George
Makes the flow of the function a little more obvious, and allows to reach 100% coverage of compile.c when using gcov.
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-23stm32: Move MCU-specific cfg from mphalport.h to mpconfigboard_common.h.Damien George
It's cleaner to have all the MCU-specific configuration in one location, not least to help with adding support for a new MCU series.
2018-02-23stm32/flash: Use FLASH_TYPEPROGRAM_WORD to support newer HALs.Damien George
2018-02-23stm32: Use "GEN" for describing files generated in the build.Damien George
Instead of "Create", to match the build output from the py/ core.
2018-02-23examples/embedding: Don't prefix $(MPTOP) to ports/unix source files.Damien George
Otherwise the build process puts the corresponding output object files in two directories lower, not in build/ports/unix.
2018-02-22examples/embedding: Update broken paths to use correct $(MPTOP).talljosh
Some ".." need to be changed to $(MPTOP), and in some places "ports/" needs to be inserted to get to the "ports/unix/" subdir.
2018-02-22stm32: Add board config option to enable/disable the ADC.Damien George
The new option is MICROPY_HW_ENABLE_ADC and is enabled by default.
2018-02-22minimal/Makefile: Explicitly include lib/utils/printf.c in build.Damien George
The bare-metal port needs it and it's no longer included by default since the Makefile now uses $(PY_CORE_O).
2018-02-22py: Use "GEN" consistently for describing files generated in the build.Damien George
2018-02-22py/py.mk: Remove .. path component from list of extmod files.Damien George
This just makes it a bit cleaner in the output of the build process: instead of "CC ../../py/../extmod/" there is now "CC ../../extmod/".
2018-02-22ports/{bare-arm,minimal}/Makefile: Only build with core source files.Damien George
These ports don't need anything from extmod so don't include those files at all in the build. This speeds up the build by about 10% when building with a single core.
2018-02-22py/py.mk: Split list of uPy sources into core and extmod files.Damien George
If a port only needs the core files then it can now use the $(PY_CORE_O) variable instead of $(PY_O). $(PY_EXTMOD_O) contains the list of extmod files (including some files from lib/). $(PY_O) retains its original definition as the list of all object file (including those for frozen code) and is a convenience variable for ports that want everything.
2018-02-21py/objdeque: Use m_new0 when allocating items to avoid need to clear.Damien George
Saves a few bytes of code space, and is more efficient because with MICROPY_GC_CONSERVATIVE_CLEAR enabled by default all memory is already cleared when allocated.
2018-02-21py/objdeque: Protect against negative maxlen in deque constructor.Damien George
Otherwise passing -1 as maxlen will lead to a zero allocation and subsequent unbound buffer overflow in deque.append() because i_put is allowed to grow without bound.
2018-02-21tests/basics: Add tests to improve coverage of py/objdeque.c.Damien George
2018-02-21tests/basics/deque*: Tests for ucollections.deque.Paul Sokolovsky
2018-02-21ports: Enable ucollections.deque on relevant ports.Damien George
These ports are all capable of running uasyncio.
2018-02-21py/objdeque: Allow to compile without warnings by disabling deque_clear.Damien George
2018-02-21py/objdeque: Implement ucollections.deque type with fixed size.Paul Sokolovsky
So far, implements just append() and popleft() methods, required for a normal queue. Constructor doesn't accept an arbitarry sequence to initialize from (am empty deque is always created), so an empty tuple must be passed as such. Only fixed-size deques are supported, so 2nd argument (size) is required. There's also an extension to CPython - if True is passed as 3rd argument, append(), instead of silently overwriting the oldest item on queue overflow, will throw IndexError. This behavior is desired in many cases, where queues should store information reliably, instead of silently losing some items.
2018-02-21esp32/modsocket: Allow getaddrinfo() to take up to 6 args.Damien George
Currently only the first 2 args are used, but this patch should at least make getaddrinfo() signature-compatible with CPython and other bare-metal ports that use the lwip bindings.
2018-02-21esp32/main: Allocate the uPy heap via malloc instead of on the bss.Damien George
This allows to get slightly more memory for the heap (currently around 110k vs previous 92k) because the ESP IDF frees up some RAM after booting up.
2018-02-21esp32: Update to the latest ESP IDF.Damien George
This update requires a new ESP32 toolchain: 1.22.0-80-g6c4433a-5.2.0.
2018-02-21py/objint: Use MP_OBJ_IS_STR_OR_BYTES macro instead of 2 separate ones.Damien George
2018-02-20py/objstr: Remove unnecessary check for positive splits variable.Damien George
At this point in the code the variable "splits" is guaranteed to be positive due to the check for "splits == 0" above it.
2018-02-20py/modmicropython: Allow to have stack_use() func without mem_info().Damien George
The micropython.stack_use() function is useful to query the current C stack usage, and it's inclusion in the micropython module doesn't need to be tied to the inclusion of mem_info()/qstr_info() because it doesn't rely on any of the code from these functions. So this patch introduces the config option MICROPY_PY_MICROPYTHON_STACK_USE which can be used to independently control the inclusion of stack_use(). By default it is enabled if MICROPY_PY_MICROPYTHON_MEM_INFO is enabled (thus not changing any of the existing ports).
2018-02-20py/builtinimport: Add compile-time option to disable external imports.Damien George
The new option is MICROPY_ENABLE_EXTERNAL_IMPORT and is enabled by default so that the default behaviour is the same as before. With it disabled import is only supported for built-in modules, not for external files nor frozen modules. This allows to support targets that have no filesystem of any kind and that only have access to pre-supplied built-in modules implemented natively.
2018-02-20py/objmodule: Factor common code for calling __init__ on builtin module.Damien George
2018-02-19esp32/modnetwork: Implement dhcp_hostname for WLAN.config().Damien George
2018-02-19py/objstr: Protect against creating bytes(n) with n negative.Damien George
Prior to this patch uPy (on a 32-bit arch) would have severe issues when calling bytes(-1): such a call would call vstr_init_len(vstr, -1) which would then +1 on the len and call vstr_init(vstr, 0), which would then round this up and allocate a small amount of memory for the vstr. The bytes constructor would then attempt to zero out all this memory, thinking it had allocated 2^32-1 bytes.
2018-02-19py/repl: Generalise REPL autocomplete to use qstr probing.Damien George
This patch changes the way REPL autocomplete finds matches. It now probes the target object for all qstrs via mp_load_method_maybe to look for a match with the given input string. Similar to how the builtin dir() function works, this new algorithm now find all methods and instances of user-defined classes including attributes of their parent classes. This helps a lot at the REPL prompt for user-discovery and to autocomplete names even for classes that are derived. The downside is that this new algorithm is slower than the previous one, and in particular will be slower the more qstrs there are in the system. But because REPL autocomplete is primarily used in an interactive way it is not that important to make it fast, as long as it is "fast enough" compared to human reaction. On a slow microcontroller (CPU running at 16MHz) the autocomplete time for a list of 35 names in the outer namespace (pressing tab at a bare prompt) takes about 160ms with this algorithm, compared to about 40ms for the previous implementation (this time includes the actual printing of the names as well). This time of 160ms is very reasonable especially given the new functionality of listing all the names. This patch also decreases code size by: bare-arm: +0 minimal x86: -128 unix x64: -128 unix nanbox: -224 stm32: -88 cc3200: -80 esp8266: -92 esp32: -84
2018-02-19py/modbuiltins: Simplify and generalise dir() by probing qstrs.Damien George
This patch improves the builtin dir() function by probing the target object with all possible qstrs via mp_load_method_maybe. This is very simple (in terms of implementation), doesn't require recursion, and allows to list all methods of user-defined classes (without duplicates) even if they have multiple inheritance with a common parent. The downside is that it can be slow because it has to iterate through all the qstrs in the system, but the "dir()" function is anyway mostly used for testing frameworks and user introspection of types, so speed is not considered a priority. In addition to providing a more complete implementation of dir(), this patch is simpler than the previous implementation and saves some code space: bare-arm: -80 minimal x86: -80 unix x64: -56 unix nanbox: -48 stm32: -80 cc3200: -80 esp8266: -104 esp32: -64
2018-02-19py/qstr: Add QSTR_TOTAL() macro to get number of qstrs.Damien George
2018-02-19py/gc: Update comment now that gc_drain_stack is called gc_mark_subtree.Damien George
2018-02-19py/gc: Make GC stack pointer a local variable.Ayke van Laethem
This saves a bit in code size, and saves some precious .bss RAM: .text .bss minimal CROSS=1: -28 -4 unix (64-bit): -64 -8
2018-02-19py/gc: Rename gc_drain_stack to gc_mark_subtree and pass it first block.Ayke van Laethem
This saves a bit in code size: minimal CROSS=1: -44 unix: -96
2018-02-19py/gc: Reduce code size by specialising VERIFY_MARK_AND_PUSH macro.Ayke van Laethem
This macro is written out explicitly in the two locations that it is used and then the code is optimised, opening possibilities for further optimisations and reducing code size: unix: -48 minimal CROSS=1: -32 stm32: -32
2018-02-18py/objdict: Disallow possible modifications to fixed dicts.Mike Wadsten
2018-02-19esp32/machine_touchpad: Swap pins 32 and 33.Damien George
Based on testing, this is how the mapping should be.
2018-02-19py/pystack: Use "pystack exhausted" as error msg for out of pystack mem.Damien George
Using the message "maximum recursion depth exceeded" for when the pystack runs out of memory can be misleading because the pystack can run out for reasons other than deep recursion (although in most cases pystack exhaustion is probably indirectly related to deep recursion). And it's important to give the user more precise feedback as to the reason for the error: if they know precisely that the pystack was exhausted then they have a chance to increase the amount of memory available to the pystack (as opposed to not knowing if it was the C stack or pystack that ran out). Also, C stack exhaustion is more serious than pystack exhaustion because it could have been that the C stack overflowed and overwrote/corrupted some data and so the system must be restarted. The pystack can never corrupt data in this way so pystack exhaustion does not require a system restart. Knowing the difference between these two cases is therefore important. The actual exception type for pystack exhaustion remains as RuntimeError so that programatically it behaves the same as a C stack exhaustion.
2018-02-18drivers/sdcard: Update SD mounting example code for ESP8266.Damien George
2018-02-18py/nlrthumb: Do not mark nlr_push as not returning anything.Ayke van Laethem
By adding __builtin_unreachable() at the end of nlr_push, we're essentially telling the compiler that this function will never return. When GCC LTO is in use, this means that any time nlr_push() is called (which is often), the compiler thinks this function will never return and thus eliminates all code following the call. Note: I've added a 'return 0' for older GCC versions like 4.6 which complain about not returning anything (which doesn't make sense in a naked function). Newer GCC versions (tested 4.8, 5.4 and some others) don't complain about this.
2018-02-17esp32/machine_rtc: Move export declaration from .c to common .h file.Damien George
2018-02-17esp32/modesp32: Add new module "esp32" to support extra wake features.Eric Poulsen
The machine.Pin class is also updated to support these wake-on-pin features.
2018-02-17esp32/machine_rtc: Add RTC class to machine module with sleep impl.Eric Poulsen
The machine.RTC class is added and the machine module is updated with the implementation of sleep, deepsleep, reset_cause and wake_reason.
2018-02-15py/objexcept: Remove long-obsolete mp_const_MemoryError_obj.Damien George
This constant exception instance was once used by m_malloc_fail() to raise a MemoryError without allocating memory, but it was made obsolete long ago by 3556e45711c3b7ec712748d013e678d035185bdd. The functionality is now replaced by the use of mp_emergency_exception_obj which lives in the global uPy state, and which can handle any exception type, not just MemoryError.
2018-02-15stm32: Change header include guards from STMHAL to STM32 to match dir.Damien George