summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-11-13extmod/machine_mem: Only allow integers in machine.memX subscript.Arrowana
Prior to this change machine.mem32['foo'] (or using any other non-integer subscript) could result in a fault due to 'foo' being interpreted as an integer. And when writing code it's hard to tell if the fault is due to a bad subscript type, or an integer subscript that specifies an invalid memory address. The type of the object used in the subscript is now tested to be an integer by using mp_obj_get_int_truncated instead of mp_obj_int_get_truncated. The performance hit of this change is minimal, and machine.memX objects are more for convenience than performance (there are many other ways to read/write memory in a faster way), Fixes issue #6588.
2020-11-12esp32/machine_pin: Reset pin if init sets mode.Jonathan Hogg
This will forcibly grab the pin back from the ADC if it has previously been associated with it. Fixes #5771.
2020-11-12stm32/Makefile: Make the generation of `firmware.bin` explicit.Sébastien NEDJAR
The file `$(BUILD)/firmware.bin` was used by the target `deploy-stlink` and `deploy-openocd` but it was generated indirectly by the target `firmware.dfu`. As this file could be used to program boards directly by a Mass Storage copy, it's better to make it explicitly generated. Additionally, some target are refactored to remove redundancy and be more explicit on dependencies.
2020-11-12tools/makeqstrdefs.py: Run qstr preprocessing in parallel.Jim Mussared
This gives a substantial speedup of the preprocessing step, i.e. the generation of qstr.i.last. For example on a clean build, making qstr.i.last: 21s -> 4s on STM32 (WB55) 8.9 -> 1.8s on Unix (dev). Done in collaboration with @stinos. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-11py/binary: Fix sign extension setting wide integer on 32-bit archs.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-11-11extmod/moductypes: Fix storing to (U)INT64 arrays on 32-bit archs.Damien George
Fixes issue #6583. Signed-off-by: Damien George <damien@micropython.org>
2020-11-11py/mpz: Do sign extension in mpz_as_bytes for negative values.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-11-11lib/utils/pyexec: Add MICROPY_BOARD hooks before/after executing code.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-11-11stm32/boardctrl: Define MICROPY_BOARD_EARLY_INIT alongside others.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-11-11stm32: Add MICROPY_BOARD calls in various places in stm32_main.Damien George
For a board to have full configurability of the soft reset loop. Signed-off-by: Damien George <damien@micropython.org>
2020-11-11stm32/main: Move update_reset_mode to outside the soft-reset loop.Damien George
Running the update inside the soft-reset loop will mean that (on boards like PYBD that use a bootloader) the same reset mode is used each reset loop, eg factory reset occurs each time. Signed-off-by: Damien George <damien@micropython.org>
2020-11-05extmod/nimble/nimble.mk: Add -Wno-old-style-declaration.Jim Mussared
This is needed since -Wextra was added to the build in bef412789ea93c521bd9c2dddc22b9b3484da574 Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-05extmod/btstack/btstack.mk: Add -Wimplicit-fallthrough=0.Jim Mussared
This is needed since -Wextra was added to the build in bef412789ea93c521bd9c2dddc22b9b3484da574 Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-10-29tests/micropython/extreme_exc.py: Unlink alloc'd lists earlier in chain.Damien George
To help the GC collect this memory that's no longer needed after the test. Signed-off-by: Damien George <damien@micropython.org>
2020-10-29stm32: Support C++ code and user C modules written in C++.Damien George
Also build user C modules as part of the stm32 CI. Signed-off-by: Damien George <damien@micropython.org>
2020-10-29stm32/boards: Factor out common data/bss/heap/stack linker sections.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-10-29unix/Makefile: Move coverage.c and coveragecpp.cpp to coverage variant.Damien George
So that g++ is not needed to build a non-coverage unix variant. Signed-off-by: Damien George <damien@micropython.org>
2020-10-29docs/develop/cmodules.rst: Add link to source code for user C example.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-10-29examples: Add example code for user C modules, both C and C++.stijn
Add working example code to provide a starting point for users with files that they can just copy, and include the modules in the coverage test to verify the complete user C module build functionality. The cexample module uses the code originally found in cmodules.rst, which has been updated to reflect this and partially rewritten with more complete information.
2020-10-29esp32,unix: Support building C++ code.stijn
Support building .cpp files and linking them into the micropython executable in a way similar to how it is done for .c files. The main incentive here is to enable user C modules to use C++ files (which are put in SRC_MOD_CXX by py.mk) since the core itself does not utilize C++. However, to verify build functionality a unix overage test is added. The esp32 port already has CXXFLAGS so just add the user modules' flags to it. For the unix port use a copy of the CFLAGS but strip the ones which are not usable for C++.
2020-10-29py/py.mk: Support C++ code for user C modules.stijn
Support C++ code in .cpp files by providing CXX counterparts of the _USERMOD_ flags we have for C already. This merely enables the Makefile of user C modules to use variables specific to C++ compilation, it is still up to each port's main Makefile to also include these in the build.
2020-10-29docs: Fix reference to QSTR_GEN_CFLAGS Makefile flag.stijn
2020-10-29py: Workaround clang error when building misc.h with C++ compiler.stijn
2020-10-29py/makeqstrdefs.py: Support preprocessing C++ files for QSTR generation.stijn
When SCR_QSTR contains C++ files they should be preprocessed with the same compiler flags (CXXFLAGS) as they will be compiled with, to make sure code scanned for QSTR occurrences is effectively the code used in the rest of the build. The 'split SCR_QSTR in .c and .cpp files and process each with different flags' logic isn't trivial to express in a Makefile and the existing principle for deciding which files to preprocess was already rather complicated, so the actual preprocessing is moved into makeqstrdefs.py completely.
2020-10-29py/mkrules.mk: Add target for compiling C++ files.stijn
Move the target from the ESP32 Makefile since that does what is needed already, but also include files from user C modules as is done for the C files.
2020-10-29py/makeqstrdefs.py: Process C++ files as well.stijn
Preprocessed C++ code isn't different from C code when it comes to QSTR instances so process it as well.
2020-10-29py/makeqstrdefs.py: Fix beaviour when scanning non-C preprocessed files.stijn
When process_file() is passed a preprocessed C++ file for instance it won't find any lines containing .c files and the last_fname variable remains None, so handle that gracefully.
2020-10-29extmod/modurandom: Support urandom.seed() without an argument.Damien George
If a port provides MICROPY_PY_URANDOM_SEED_INIT_FUNC as a source of randomness then this will be used when urandom.seed() is called without an argument (or with None as the argument) to seed the pRNG. Other related changes in this commit: - mod_urandom___init__ is changed to call seed() without arguments, instead of explicitly passing in the result of MICROPY_PY_URANDOM_SEED_INIT_FUNC. - mod_urandom___init__ will only ever seed the pRNG once (before it could seed it again if imported by, eg, random and then urandom). - The Yasmarang state is moved to the BSS for builds where the state is guaranteed to be initialised on import of the (u)random module. Signed-off-by: Damien George <damien@micropython.org>
2020-10-29stm32/rng: Use SysTick+RTC+unique-id to seed pRNG for MCUs without RNG.Damien George
The same seed will only occur if the board is the same, the RTC has the same time (eg freshly powered up) and the first call to this function (eg via an "import random") is done at exactly the same time since reset. Signed-off-by: Damien George <damien@micropython.org>
2020-10-29stm32/mpconfigport.h: Seed the urandom module on import.robert
For seeding the rng_get function is used, which is also the heart of uos.urandom and pyb.rng, and is a hardware RNG where available.
2020-10-29esp8266/mpconfigport.h: Seed the urandom module on import.robert
For seeding, the hardware RNG of the esp8266 is used.
2020-10-29esp32/mpconfigport.h: Seed the urandom module on import.robert
For seeding, the RNG function of the ESP-IDF is used, which is told to be a true RNG, at least when WiFi or Bluetooth is enabled. Seeding on import is as per CPython. To obtain a reproducible sequence of pseudo-random numbers one must explicitly seed with a known value.
2020-10-29extmod/vfs_lfs: Support mounting LFS filesystems in read-only mode.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-10-29stm32/machine_adc: Fix ADC auto-calibration to run when ADC not enabled.Damien George
Prior to this commit, the ADC calibration code was never executing because ADVREGEN bit was set making the CR register always non-zero. This commit changes the logic so that ADC calibration is always run when the ADC is disabled and an ADC channel is initialised. It also uses the LL API functions to do the calibration, to make sure it is done correctly on each MCU variant. Signed-off-by: Damien George <damien@micropython.org>
2020-10-28tests/thread/stress_schedule.py: Assign globals before running test.Damien George
When threading is enabled without the GIL then there can be races between the threads accessing the globals dict. Avoid this issue by making sure all globals variables are allocated before starting the threads. Signed-off-by: Damien George <damien@micropython.org>
2020-10-22unix: Enable more warnings.Emil Renner Berthing
2020-10-22mpy-cross: Enable more warnings.Emil Renner Berthing
2020-10-22py, extmod: Introduce and use MP_FALLTHROUGH macro.Emil Renner Berthing
Newer GCC versions are able to warn about switch cases that fall through. This is usually a sign of a forgotten break statement, but in the few cases where a fall through is intended we annotate it with this macro to avoid the warning.
2020-10-22extmod: Disable -Wmissing-field-initializers for lfs2.Emil Renner Berthing
2020-10-22py/vmentrytable: Ignore GCC -Woverride-init.Emil Renner Berthing
Like Clang, GCC warns about this file, but only with -Woverride-init which is enabled by -Wextra. Disable the warnings for this file just like we do for Clang to make -Wextra happy.
2020-10-22py, extmod: Add explicit initializers for default values.Emil Renner Berthing
When compiling with -Wextra which includes -Wmissing-field-initializers GCC will warn that the defval field of mp_arg_val_t is not initialized. This is just a warning as it is defined to be zero initialized, but since it is a union it makes sense to be explicit about which member we're going to use, so add the explicit initializers and get rid of the warning.
2020-10-22py: Use unsigned comparison of chars.Emil Renner Berthing
On x86 chars are signed, but we're comparing a char to '0' + unsigned int, which is promoted to an unsigned int. Let's promote the char to unsigned before doing the comparison to avoid weird corner cases.
2020-10-22py/objexcept: Compare mp_emergency_exception_buf_size signed.Emil Renner Berthing
mp_emergency_exception_buf_size is signed, so let's make sure we compare it as such.
2020-10-22py/scope: Name and use id_kind_type_t.Emil Renner Berthing
The function scope_find_or_add_id used to take a scope_kind_t enum and save it in an uint8_t. Saving an enum in a uint8_t is fine, but everywhere this function is called it is not actually given a scope_kind_t but an anonymous enum instead. Let's give this enum a name and use that as the argument type. This doesn't change the generated code, but is a C type mismatch that unfortunately doesn't show up unless you enable -Wenum-conversion.
2020-10-22docs/reference/glossary.rst: Fix minor grammar error, An -> A.Kevin Thomas
2020-10-22stm32/usbd_cdc_interface: Check and handle CDC TX wrap-overflow.Damien George
If the device is not connected over USB CDC to a host then all output to the CDC (eg initial boot messages) is written to the CDC TX buffer with wrapping, so that the most recent data is retained when the USB CDC is eventually connected (eg so the REPL banner is displayed upon connection). This commit fixes a bug in this behaviour, which was likely introduced in e4fcd216e02eef0b389c84ecd67be3114aac0a5d, where the initial data in the CDC TX buffer is repeated multiple times on first connection of the device to the host. Signed-off-by: Damien George <damien@micropython.org>
2020-10-22stm32: Fix broken build when FAT FS multi-partition is disabled.iabdalkader
2020-10-21esp32/mpconfigport.h: Enable MICROPY_PY_DELATTR_SETATTR.Andrew Leech
To align with unix and stm32 ports.
2020-10-20unix/mpconfigport.h: Enable MICROPY_PY_DELATTR_SETATTR.Andrew Leech
This is a generally useful feature and because it's part of the object model it cannot be added at runtime by some loadable Python code, so enable it on the standard unix build.
2020-10-20docs/library/machine.Timer.rst: Add mention of constructor arguments.Howard Lovatt