aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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
2020-10-20docs/library/machine.Signal.rst: Correct typo: usecases to use cases.Howard Lovatt
2020-10-20docs/library/machine.rst: Correct minor typo: timout to timeout.Howard Lovatt
2020-10-20docs/library/btree.rst: Correct method typo: __detitem__ to __delitem__.Howard Lovatt
2020-10-20tools/upip.py: Support explicit port number in host.awachtler
Adding a port number other then 443 to a PyPI URL may be needed if a local server like devpi is used.
2020-10-17ports: Use correct in/out endpoint size in TUD_CDC_DESCRIPTOR.Damien George
The last argument of TUD_CDC_DESCRIPTOR() is the endpoint size (or wMaxPacketSize), not the CDC RX buffer size (which can be larger than the endpoint size). Signed-off-by: Damien George <damien@micropython.org>
2020-10-16stm32/boards/NUCLEO_WB55/rfcore_firmware.py: Increase GET_STATE timeout.Jim Mussared
When installing WS firmware, the very first GET_STATE can take several seconds to respond (especially with the larger binaries like BLE_stack_full). Allows stm.rfcore_sys_hci to take an optional timeout, defaulting to SYS_ACK_TIMEOUT_MS (which is 250ms). Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-10-16stm32/boards/NUCLEO_WB55/rfcore_firmware.py: Fix bad variable name.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-10-16stm32/boards/NUCLEO_WB55/rfcore_firmware.py: Fix flash unlock.Jim Mussared
The flash can sometimes be in an already-unlocked state, and attempting to unlock it again will cause an immediate reset. So make _Flash.unlock() check FLASH_CR_LOCK to get the current state. Also fix some magic numbers for FLASH_CR_LOCK AND FLASH_CR_STRT. The machine.reset() could be removed because it no longer crashes now that the flash unlock is fixed. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-10-10py/objtype: Handle __dict__ attribute when type has no locals.Jim Mussared
2020-10-10py/objdict: Add mp_const_empty_dict_obj, use it for mp_const_empty_map.Jim Mussared
2020-10-09stm32/rfcore: Update to support WS=1.9.0.0.4.Jim Mussared
This WS update to 1.9.0.0.4 broke the workaround used in rfcore for OCF_CB_SET_EVENT_MASK2, so fix it to support WS 1.8 and 1.9.
2020-10-08stm32/boards/NUCLEO_WB55: Add standalone WB55 FUS/WS firmware updater.Jim Mussared
This commit adds a script that can be run on-device to install FUS and WS binaries from the filesystem. Instructions for use are provided in the rfcore_firmware.py file. The commit also removes unneeded functionality from the existing rfcore.py debug script (and renames it rfcore_debug.py).
2020-10-08stm32/rfcore: Add Python API for basic rfcore operations.Jim Mussared
The new functions provide FUS/WS status, version and SYS HCI commands: - stm.rfcore_status() - stm.rfcore_fw_version(fw_id) - stm.rfcore_sys_hci(ogf, ocf, cmd)
2020-10-06stm32/sdcard: Fix H7 build when using SDMMC2.iabdalkader
Changes are: - Fix missing IRQ handler when SDMMC2 is used instead of SDMMC1 with H7 MCUs. - Removed outdated H7 series compatibility macros. - Defined common IRQ handler macro for F4 series.
2020-10-06stm32/sdio: Don't change any DMA2 settings on H7 MCUs.iabdalkader
DMA2 clock and registers should be left in their current state in the H7 build.
2020-10-06esp32: Use path relative to root for netutils/timeutils headers.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-10-02stm32/Makefile: Allow boards to extend SRC_C, SRC_O and OBJ variables.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-10-01unix/variants: Enable MICROPY_DEBUG_PARSE_RULE_NAME on coverage build.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-10-01py/parse: Expose rule-name printing as MICROPY_DEBUG_PARSE_RULE_NAME.Damien George
So it can be enabled without modifying the source. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01extmod/utime_mphal: Add generic utime.time_ns() function.Damien George
It requires mp_hal_time_ns() to be provided by a port. This function allows very accurate absolute timestamps. Enabled on unix, windows, stm32, esp8266 and esp32. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01unix,windows: Implement mp_hal_time_ns using gettimeofday.Damien George
This provides microsecond accuracy. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01docs: Update I2C and SPI docs to add reference to SoftI2C and SoftSPI.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-10-01ports: Support legacy soft I2C/SPI construction via id=-1 arg.Damien George
With a warning that this way of constructing software I2C/SPI is deprecated. The check and warning will be removed in a future release. This should help existing code to migrate to the new SoftI2C/SoftSPI types. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01ports: Add SoftI2C and SoftSPI to machine module where appropriate.Damien George
Previous commits removed the ability for one I2C/SPI constructor to construct both software- or hardware-based peripheral instances. Such construction is now split to explicit soft and non-soft types. This commit makes both types available in all ports that previously could create both software and hardware peripherals: machine.I2C and machine.SPI construct hardware instances, while machine.SoftI2C and machine.SoftSPI create software instances. This is a breaking change for use of software-based I2C and SPI. Code that constructed I2C/SPI peripherals in the following way will need to be changed: machine.I2C(-1, ...) -> machine.SoftI2C(...) machine.I2C(scl=scl, sda=sda) -> machine.SoftI2C(scl=scl, sda=sda) machine.SPI(-1, ...) -> machine.SoftSPI(...) machine.SPI(sck=sck, mosi=mosi, miso=miso) -> machine.SoftSPI(sck=sck, mosi=mosi, miso=miso) Code which uses machine.I2C and machine.SPI classes to access hardware peripherals does not need to change. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01extmod/machine_spi: Remove "id" arg in SoftSPI constructor.Damien George
The SoftSPI constructor is now used soley to create SoftSPI instances, it can no longer delegate to create a hardware-based SPI instance. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01extmod/machine_i2c: Remove "id" arg in SoftI2C constructor.Damien George
The SoftI2C constructor is now used soley to create SoftI2C instances, it can no longer delegate to create a hardware-based I2C instance. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01extmod/machine_i2c: Rename type to SoftI2C and add custom print method.Damien George
Also rename machine_i2c_type to mp_machine_soft_i2c_type. These changes make it clear that it's a soft-I2C implementation, and match SoftSPI. Signed-off-by: Damien George <damien@micropython.org>