aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-07-01stm32/mboot: Remove the use of timeout in DFU_GETSTATUS.Andrew Leech
This is treated more like a "delay before continuing" in the spec and official tools and does not appear to be really needed. In particular, downloading firmware is much slower with non-zero timeouts because the host must pause by the timeout between sending each DFU_GETSTATUS to poll for download/erase complete.
2020-06-30py: Rework mp_convert_member_lookup to properly handle built-ins.Damien George
This commit fixes lookups of class members to make it so that built-in functions that are used as methods/functions of a class work correctly. The mp_convert_member_lookup() function is pretty much completely changed by this commit, but for the most part it's just reorganised and the indenting changed. The functional changes are: - staticmethod and classmethod checks moved to later in the if-logic, because they are less common and so should be checked after the more common cases. - The explicit mp_obj_is_type(member, &mp_type_type) check is removed because it's now subsumed by other, more general tests in this function. - MP_TYPE_FLAG_BINDS_SELF and MP_TYPE_FLAG_BUILTIN_FUN type flags added to make the checks in this function much simpler (now they just test this bit in type->flags). - An extra check is made for mp_obj_is_instance_type(type) to fix lookup of built-in functions. Fixes #1326 and #6198. Signed-off-by: Damien George <damien@micropython.org>
2020-06-30py/obj.h: Make existing MP_TYPE_FLAG_xxx macros sequential.Damien George
There's no reason to have them non-sequential, this was likely a typo from commit 9ec1caf42e7733b5141b7aecf1b6e58834a94bf7. Signed-off-by: Damien George <damien@micropython.org>
2020-06-30zephyr/make-minimal: Disable FAT and LFS2 options to make it build.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-30zephyr: Implement machine.Pin.irq() for setting callbacks on pin change.Damien George
Supports hard and soft interrupts. In the current implementation, soft interrupt callbacks will only be called when the VM is executing, ie they will not be called during a blocking kernel call like k_msleep. And the behaviour of hard interrupt callbacks will depend on the underlying device, as well as the amount of ISR stack space. Soft and hard interrupts tested on frdm_k64f and nucleo_f767zi boards. Signed-off-by: Damien George <damien@micropython.org>
2020-06-30lib/utils: Protect all of mpirq.c with MICROPY_ENABLE_SCHEDULER.Damien George
So it can be unconditionally included in a port's build even if certain configurations in that port do not use its features, to simplify the Makefile. Signed-off-by: Damien George <damien@micropython.org>
2020-06-30docs/esp32: Add info about PWM duty cycle range to esp32 quickref.spacemanspiff2007
See related #4581.
2020-06-30docs/library: Clarify that the arg to esp.deepsleep is in microseconds.victor
2020-06-30stm32/mboot: Add DFU logic to respond to DFU_GETSTATE request.Damien George
This is required for some DFU programmers, eg ST's DfuSe demo PC app. Signed-off-by: Damien George <damien@micropython.org>
2020-06-30stm32/flash: Update flash_get_sector_info to return -1 on invalid addr.Andrew Leech
So the caller can tell when an invalid address is used and can take appropriate action.
2020-06-30stm32/mboot: Implement DFU mass erase.Andrew Leech
The implementation internally uses sector erase to wipe everything except the sector(s) that mboot lives in (by erasing starting from APPLICATION_ADDR). The erase command can take some time (eg an STM32F765 with 2MB of flash takes 8 to 10 seconds). This time is normally enough to make pydfu.py fail with a timeout. The DFU standard includes a mechanism for the DFU device to request a longer timeout as part of the get-status response just before starting an operation. This timeout functionality has been implemented here.
2020-06-30tools/pydfu.py: Respect longer timeouts requested by DFU device/mboot.Andrew Leech
2020-06-29stm32/timer: Properly initialise timer deadtime/brk on WB MCUs.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-29stm32/usbd_cdc_interface: Remove full==size-1 limitation on tx ringbuf.Andrew Leech
Before this commit the USB VCP TX ring-buffer used the basic implementation where it can only be filled to a maximum of buffer size-1. For a 1024 size buffer this means the largest packet that can be sent is 1023. Once a packet of this size is sent the next byte copied in goes to the final byte in the buffer, so must be sent as a 1 byte packet before the read pointer can be wrapped around to the beginning. So in large streaming transfers, watching the USB sniffer you basically get alternating 1023 byte packets then 1 byte packets. This commit changes the ring-buffer implementation to a scheme that doesn't have the full-size limitation, and the USB VCP driver can now achieve a constant stream of full-sized packets. This scheme introduces a restriction on the size of the buffer: it must be a power of 2, and the maximum size is half of the size of the index (in this case the index is 16-bit, so the maximum size would be 32767 bytes rounded to 16384 for a power-of-2). But this is not a big limitation because the size of the ring-buffer prior to this commit was restricted to powers of 2 because it was using a mask-based method to wrap the indices. For an explanation of the new scheme see https://www.snellman.net/blog/archive/2016-12-13-ring-buffers/ The RX buffer could likely do with a similar change, though as it's not read from in chunks like the TX buffer it doesn't present the same issue, all that's lost is one byte capacity of the buffer. USB VCP TX throughput is improved by this change, potentially doubling the speed in certain cases.
2020-06-27py/objcomplex: Add mp_obj_get_complex_maybe for use in complex bin-op.Damien George
This allows complex binary operations to fail gracefully with unsupported operation rather than raising an exception, so that special methods work correctly. Signed-off-by: Damien George <damien@micropython.org>
2020-06-27py/emitnative: Implement binary operations for viper uint operands.Damien George
uint types in viper mode can now be used for all binary operators except floor-divide and modulo. Fixes issue #1847 and issue #6177. Signed-off-by: Damien George <damien@micropython.org>
2020-06-27py/asm: Add condition codes for signed comparisons.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-27py/asm: Add funcs/macros to emit machine code for logical-shift-right.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-26stm32/i2cslave: Pass I2C instance to callbacks to support multi I2Cs.Damien George
By passing through the I2C instance to the application callbacks, the application can implement multiple I2C slave devices on different peripherals (eg I2C1 and I2C2). This commit also adds a proper rw argument to i2c_slave_process_addr_match for F7/H7/WB MCUs, and enables the i2c_slave_process_tx_end callback. Mboot is also updated for these changes. Signed-off-by: Damien George <damien@micropython.org>
2020-06-26travis: Build mboot for PYBV10 with LFS2 enabled in stm32 job.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-26stm32/mboot: Update README to describe WB and littlefs support.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-26stm32/mboot: Add support for littlefs.Damien George
Mboot now supports FAT, LFS1 and LFS2 filesystems, to load firmware from. The filesystem needed by the board must be explicitly enabled by the configuration variables MBOOT_VFS_FAT, MBOOT_VFS_LFS1 and MBOOT_VFS_LFS2. Boards that previously used FAT implicitly (with MBOOT_FSLOAD enabled) must now add the following config to mpconfigboard.h: #define MBOOT_VFS_FAT (1) Signed-off-by: Damien George <damien@micropython.org>
2020-06-26stm32/mboot: Decouple stream, filesystem and top-level loading code.Damien George
This commit factors the code for files and streaming to separate source files (vfs_fat.c and gzstream.c respectively) and introduces an abstract gzstream interface to make it easier to plug in different filesystems. Signed-off-by: Damien George <damien@micropython.org>
2020-06-26stm32/mboot: Don't search for firmware on FS, just attempt to open it.Damien George
There's no need to do a directory listing to search for the given firmware filename, it just takes extra time and code size. Instead this commit changes it so that the requested firmware file is opened immediately and will abort if the file couldn't be opened. This also allows to specify files in a directory. Signed-off-by: Damien George <damien@micropython.org>
2020-06-25stm32/boards: Enable LFS2 on PYBD_SF3 and PYBD_SF6.Damien George
This was missed in commit 120368ba1ab444b2f1c17d1eb69bc6f09072ec5d Signed-off-by: Damien George <damien@micropython.org>
2020-06-25stm32/timer: Support TIM1 on WB MCUs.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-25stm32/mpconfigport.h: Enable PY_IO_FILEIO when any VFS is enabled.Damien George
Previously, if FAT was not enabled but LFS1/2 was then MICROPY_PY_IO_FILEIO would be disabled and file binary-mode was not supported. Signed-off-by: Damien George <damien@micropython.org>
2020-06-25extmod/vfs_lfs: Fix littlefs bindings to build in nan-box mode.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-24tools/makemanifest.py: Support freezing a subdirectory recursively.Damien George
This adds support for freezing an entire directory while keeping the directory as part of the import path. For example freeze("path/to/library", "module") will recursively freeze all scripts in "path/to/library/module" and have them importable as "from module import ...". Signed-off-by: Damien George <damien@micropython.org>
2020-06-24py/objtype: Support passing in an OrderedDict to type() as the locals.Damien George
An OrderedDict can now be used for the locals when creating a type explicitly via type(name, bases, locals). Signed-off-by: Damien George <damien@micropython.org>
2020-06-24extmod/moductypes: Use mp_obj_is_dict_or_ordereddict to simplify code.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-24py/obj.h: Add public mp_obj_is_dict_or_ordereddict() helper macro.Damien George
And use it in py/objdict.c instead of mp_obj_is_dict_type. Signed-off-by: Damien George <damien@micropython.org>
2020-06-23stm32/mboot: Use additional CFLAGS to compile string0.c.Damien George
This is the same as a902b69dd51de0e3fe3bb6955296591d6a93abab but applied to mboot's Makefile. Signed-off-by: Damien George <damien@micropython.org>
2020-06-23stm32/mboot: Set VTOR on start up to ensure it has the correct value.Damien George
Commit 8675858465f3d83aab709170eab6dc141570acf4 switched to using the CMSIS provided SystemInit function which sets VTOR to 0x00000000 (previously it was 0x08000000). A VTOR of 0x00000000 will be correct on some MCUs but not on others where the built-in bootloader is remapped to this address, via __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH(). To make sure mboot has the correct vector table, this commit explicitly sets VTOR to the correct value of 0x08000000. Signed-off-by: Damien George <damien@micropython.org>
2020-06-22travis: In stm32 job, build mboot for NUCLEO_WB55.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-22stm32/boards: Add build-time option for NUCLEO_WB55 to use mboot.Damien George
As an example of how to use mboot on a WB series MCU. Signed-off-by: Damien George <damien@micropython.org>
2020-06-22stm32/mboot: Add support for using mboot with WB MCUs.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-22stm32/mboot: Use CMSIS system source code for SystemInit function.Damien George
There's no need to duplicate this functionality in mboot, the code provided in stm32lib/CMSIS does the same thing and makes it easier to support other MCU series. Signed-off-by: Damien George <damien@micropython.org>
2020-06-22stm32/mboot: Use flash routines from main stm32 code rather than custom.Damien George
The flash functions in ports/stm32/flash.c are almost identical to those in ports/stm32/mboot/main.c, so remove the duplicated code in mboot and use instead the main stm32 code. This also allows supporting other MCU series. Signed-off-by: Damien George <damien@micropython.org>
2020-06-22stm32/flash: Add flash_is_valid_addr, and extend sectors for 2MB F7.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-22stm32/i2cslave: Add support for WB MCUs.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-22stm32/flash: Make flash C-API reusable, and funcs return an error code.Damien George
This commit makes the low-level flash C functions usable by code other than flashbdev.c (eg by mboot). Changes in this commit are: - flash_erase() and flash_write() now return an errno error code, a negative value on error. - flash_erase() now automatically locks the flash, as well as unlocking it. - flash_write() now automatically unlocks the flash, as well as locking it. - flashbdev.c is modified for the above changes. Signed-off-by: Damien George <damien@micropython.org>
2020-06-22stm32/powerctrlboot: Include irq.h to get definitions of IRQ priorities.Damien George
irq.h is included by py/mphal.h but it's better to be explicit, eg if mboot uses powerctrlboot.c. Signed-off-by: Damien George <damien@micropython.org>
2020-06-22stm32/irq: Clean up irq.h so it does not depend on core uPy defines.Damien George
The irq.h file now just provides low-level IRQ definitions and priorities. All Python binding definitions are moved to modmachine.h, with some renaming of pyb -> machine, and also the machine_idle definition (was pyb_wfi) is moved to modmachine.c. The cc3200 and teensy ports are updated to build with these changes. Signed-off-by: Damien George <damien@micropython.org>
2020-06-22travis: Build qemu-arm with MP_ENDIANNESS_BIG=1 to test bigendian build.Damien George
Eventually it would be good to run the full test suite on a big-endian system, but for now this will help to catch build errors with the big-endian configuration. Signed-off-by: Damien George <damien@micropython.org>
2020-06-22qemu-arm/Makefile: Add CFLAGS_EXTRA to CFLAGS.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-22py/misc.h: Add missing semi-colon in mp_float_union_t for big-endian.Damien George
Fixes issue #6161. Signed-off-by: Damien George <damien@micropython.org>
2020-06-19esp32/esp32_rmt: Call rmt_driver_install before rmt_config.Jonathan Hogg
Otherwise the RMT will repeat pulses when using loop(True). This repeating is due to a bug in the IDF which will be fixed in an upcoming release, but for now the accepted workaround is to swap these calls, which should still work in the fixed version of the IDF. Fixes issue #6167.
2020-06-19tools/uncrustify: Enable more opts to remove space between func and '('.David Lechner
With only `sp_func_proto_paren = remove` set there are some cases where uncrustify misses removing a space between the function name and the opening '('. This sets all of the related options to `force` as well.
2020-06-18tools/codeformat.py: Include extmod/{btstack,nimble} in code formatting.Damien George
Signed-off-by: Damien George <damien@micropython.org>