Commit Graph

11237 Commits

Author SHA1 Message Date
Damien George c47a3ddf4a py/pairheap: Properly unlink node on pop and delete.
This fixes a bug in the pairing-heap implementation when nodes are deleted
with mp_pairheap_delete and then reinserted later on.
2020-03-26 01:21:04 +11:00
Damien George 98ab7643a7 travis: Print errors out for OSX job. 2020-03-26 01:21:04 +11:00
Damien George ab00f4c44e qemu-arm: Set default board as mps2-an385 to get more flash for tests.
And use Ubuntu bionic for qemu-arm Travic CI job.
2020-03-26 01:21:04 +11:00
Damien George f8fc78691d py/mpconfig.h: Enable MICROPY_MODULE_GETATTR by default.
To enable lazy loading of submodules (among other things), which is very
useful for MicroPython libraries that want to have optional subcomponents.

Disabled explicitly on minimal ports.
2020-03-26 01:21:04 +11:00
Zoltán Vörös c5cc64175b ports: Add lib/libm/roundf.c to bare-metal Makefile's.
This function is not used by the core but having it as part of the build
allows it to be used by user C modules, or board extensions.  The linker
won't include it in the final firmware if it remains unused.
2020-03-25 01:22:00 +11:00
Damien George bf4fb16250 esp32/modsocket: Handle poll of a closed socket.
This gets tests/extmod/uselect_poll_basic.py working on the esp32.
2020-03-25 01:17:12 +11:00
Andreas Motl fbfea3b440 drivers/onewire: Fix undefined variable errors.
On CPython, and with pylint, the variables MATCH_ROM and SEARCH_ROM are
undefined.  This code works in MicroPython because these variables are
constants and the MicroPython parser/compiler optimises them out.  But it
is not valid Python because they are technically undefined within the scope
they are used.

This commit makes the code valid Python code.  The const part is removed
completely because these constants are part of the public API and so cannot
be moved to the global scope (where they could still use the MicroPython
const optimisation).
2020-03-25 01:09:14 +11:00
David Lechner 2f7d2bb3e2 py/stream.h: Include sys/types.h to get size_t and off_t for POSIX API. 2020-03-25 01:00:52 +11:00
David Lechner 58d9a4815d extmod/vfs_posix_file: Include unistd.h to get STD{IN,OUT,ERR}_FILENO. 2020-03-25 00:59:39 +11:00
David Lechner d0edaf88a3 windows/windows_mphal: Fix missing semicolon. 2020-03-25 00:59:34 +11:00
David Lechner 3b07736b6d unix,windows: Use STDIN_FILENO, STDOUT_FILENO macros where appropriate.
This replaces 0 and 1 with STDIN_FILENO and STDOUT_FILENO to make the
intention of the code clearer.
2020-03-25 00:59:05 +11:00
David Lechner 100012bec6 windows: Remove custom definition of MP_PLAT_PRINT_STRN.
This removes the port-specific definition of MP_PLAT_PRINT_STRN on the
windows port, so that the default mp_hal_stdout_tx_strn_cooked() is always
used.  This fixes releasing the GIL during the call to write() (this was
missed in bc3499f010).

Also, mp_hal_dupterm_tx_strn() was defined but never used anywhere so it is
safe to delete it.
2020-03-25 00:56:38 +11:00
David Lechner b1066a9f96 unix: Remove custom definition of MP_PLAT_PRINT_STRN.
This removes the port-specific definition of MP_PLAT_PRINT_STRN on the unix
port.  Since fee7e5617f this is no longer a
single function call so we are not really optimising anything over using
the default definition of MP_PLAT_PRINT_STRN which calls
mp_hal_stdout_tx_strn_cooked().
2020-03-25 00:54:18 +11:00
Damien George 9fa32169e9 esp8266/modnetwork: Add support for wlan.ifconfig('dhcp').
Fixes issue #5780.
2020-03-25 00:43:04 +11:00
Damien George feb2577585 all: Remove spaces between nested paren and inside function arg paren.
Using new options enabled in the uncrustify configuration.
2020-03-25 00:39:46 +11:00
stijn f62cc41fac windows/msvc: Fix warnings regarding function declarations.
Fix missing mkdir and gettimeofday declarations, then silence msvc-specific
compiler warning C4996: 'The POSIX name for this item is deprecated'.
2020-03-25 00:38:11 +11:00
stijn 1b3e0e10b9 tools/codeformat.py: Include all msvc C code in auto-format. 2020-03-25 00:36:42 +11:00
Maureen Helm 76a5b3a97a zephyr: Update machine.Pin class to use new zephyr gpio api.
Zephyr v2.2 reworked its gpio api to support linux device tree bindings and
pin logical levels.  This commit updates the zephyr port's machine.Pin
class to replace the deprecated gpio api calls with the new supported gpio
api.  This resolves several build warnings.

Tested on frdm_k64f and mimxrt1050_evk boards.
2020-03-25 00:29:42 +11:00
Damien George 40255aff23 stm32/mboot: Remove unnecessary test for led being 1 in led_state.
The "led" argument is always a pointer to the GPIO port, or'd with the pin
that the LED is on, so testing that it is "1" is unnecessary.  The type of
"led" is also changed to uint32_t so it can properly hold a 32-bit pointer.
2020-03-25 00:10:32 +11:00
Andrew Leech 9dd470b768 stm32/mboot: Update LED0 state from systick handler.
Updating the LED0 state from systick handler ensures LED0 is always
consistent with its flash rate regardless of other processing going on in
either interrupts or main.  This improves the visible stability of the
bootloader, rather than LED0 flashing somewhat randomly at times.

This commit also changes the LED0 flash rate depending on the current state
of DFU, giving slightly more visual feedback on what the device is doing.
2020-03-25 00:08:32 +11:00
Andrew Leech 38ccb4c643 tools/pydfu.py: Display any error strings from device/mboot. 2020-03-22 15:24:57 +11:00
Andrew Leech f7130a99b6 stm32/mboot: Protect against invalid address flash writes.
And provide a DFU error message for invalid erases and writes.
2020-03-22 15:23:49 +11:00
Andrew Leech b41d08cf15 stm32/mboot: Update dfu state/status flags to better match standard. 2020-03-22 14:11:16 +11:00
Andrew Leech 03b1ed80e7 stm32/mboot: Allow overriding led_init and led_state in board folder.
Allows for custom functions/logic to display mboot state.
2020-03-22 13:48:45 +11:00
Andrew Leech 2966d83a65 tools/pydfu.py: Add args for VID/PID & exit with cleaner error handling. 2020-03-22 13:33:04 +11:00
Jim Mussared 9715905b18 esp32/README.md: Update build instructions for newer toolchain.
Also fix Espressif links to the specific version they apply to.
2020-03-22 13:26:03 +11:00
Jim Mussared 0cd13081df esp8266/README.md: Add docker build instructions. 2020-03-22 13:26:03 +11:00
Damien George 8d34344dce esp8266/modmachine: Implement machine.soft_reset().
Fixes issue #5764.
2020-03-20 13:40:01 +11:00
Damien George 19ea30bdd5 tests/run-multitests.py: Print test summary and do exit(1) on failure. 2020-03-18 21:33:40 +11:00
Damien George 2cdf1d25f5 unix: Remove custom file implementation to use extmod's VFS POSIX one.
The implementation in extmod/vfs_posix_file.c is now equivalent to that in
ports/unix/file.c, so remove the latter and use the former instead.
2020-03-18 21:01:07 +11:00
Damien George 68b1bc2042 extmod/vfs_posix_file: Lock GIL when writing and allow stdio flush.
Also support MP_STREAM_GET_FILENO ioctl.  The stdio flush change was done
previously for the unix port in 3e0b46b9af.
These changes make this POSIX file implementation equivalent to the unix
file implementation.
2020-03-18 21:01:07 +11:00
Damien George ad9a0ec8ab all: Convert exceptions to use mp_raise_XXX helpers in remaining places. 2020-03-18 17:26:19 +11:00
Damien George 8f0778b209 extmod/modlwip: Properly handle non-blocking and timeout on UDP recv.
Fixes UDP non-blocking recv so it returns EAGAIN instead of ETIMEDOUT.
Timeout waiting for incoming data is also improved by replacing 100ms delay
with poll_sockets(), as is done in other parts of this module.

Fixes issue #5759.
2020-03-18 10:51:32 +11:00
Damien George 00267aae0b extmod/modlwip: Fix polling of UDP socket so it doesn't return HUP.
STATE_NEW will return HUP when polled so put active UDP sockets into a new
state which is different to STATE_NEW.

Fixes issue #5758.
2020-03-18 10:49:27 +11:00
Damien George eae495a714 stm32/main: Fix bug mounting 3rd SD partition.
Fixes issue #5753.
2020-03-12 12:34:31 +11:00
Thomas Friebel baf8aa286a examples/bluetooth: Replace "connectable" parameter with "adv_type".
Follow up to dd0bc26e65 which changed the
parameter list of the IRQ_SCAN_RESULT event.  Adapt
ble_temperature_central.py accordingly.
2020-03-12 10:58:08 +11:00
Maureen Helm 110a610f70 zephyr: Execute main.py file if it exists.
Adds support in the zephyr port to execute main.py if the file system is
enabled and the file exists. Existing support for executing a main.py
frozen module is preserved, since pyexec_file_if_exists() works just
like pyexec_frozen_module() if there's no vfs.
2020-03-11 08:30:42 -05:00
Maureen Helm 78c7e4a859 zephyr: Enable usb mass storage class on mimxrt1050_evk.
Enables the zephyr usb device stack and mass storage class on the
mimxrt1050_evk board. The mass storage class is backed by the sdhc disk
access driver, so it's now possible to browse and modify the contents of
the SD card from a USB host (your PC). This is in preparation to support
writing a main.py script to the SD card, and then executing it after the
next reset.
2020-03-11 07:46:41 -05:00
Maureen Helm 5feb54afbb zephyr: Mount a file system during init.
Adds support in the zephyr port to mount a file system if a block device
(sdhc disk access or flash area) is available. The mount point is either
"/sd" or "/flash" depending on the type of block device.

Tested with an sdhc disk access block device and fatfs on the
mimxrt1050_evk board.

Tested with a flash area block device and littlefs on the reel_board.
2020-03-11 07:46:41 -05:00
Damien George f552451cba travis: For unix tests use Makefile target instead of explicit commands. 2020-03-11 20:20:18 +11:00
Damien George ea1ea909d7 tests/run-tests: Consider all tests as native when emit=native is used.
So that they are skipped when running on a target that doesn't support the
native emitter, eg a nanbox build.
2020-03-11 20:20:18 +11:00
Damien George 359213fbe1 unix/Makefile: Detect and pass thru mpy-cross flags when running tests. 2020-03-11 20:20:18 +11:00
Andrew Leech 86bfabec11 py/modmicropython: Add heap_locked function to test state of heap.
This commit adds micropython.heap_locked() which returns the current
lock-depth of the heap, and can be used by Python code to check if the heap
is locked or not.  This new function is configured via
MICROPY_PY_MICROPYTHON_HEAP_LOCKED and is disabled by default.

This commit also changes the return value of micropython.heap_unlock() so
it returns the current lock-depth as well.
2020-03-11 16:54:16 +11:00
Jim Mussared 7eea0d8b6c mimxrt: Add MIMXRT1010 board. 2020-03-11 15:36:27 +11:00
Jim Mussared f46782dde9 mimxrt: Add new, minimal port to NXP i.MX RT series CPUs.
This is an extremely minimal port to the NXP i.MX RT, in the style of the
SAMD port  It's largely based on the TinyUSB mimxrt implementation, using
the NXP SDK.  It currently supports the Teensy 4.0 board with a REPL over
the USB-VCP interface.

This commit also adds the NXP SDK submodule (also from TinyUSB) to
lib/nxp_driver.

Note: if you already have the tinyusb submodule initialized recursively you
will need to run the following as the tinyusb sub-submodules have been
rearranged (upstream):

    git submodule deinit lib/tinyusb
    rm -rf .git/modules/lib/tinyusb
    git submodule update --init lib/tinyusb
2020-03-11 15:34:13 +11:00
Jim Mussared 211032a5c9 samd: Fix to build with latest tinyusb. 2020-03-11 15:34:10 +11:00
Jim Mussared 6cea369b89 lib/tinyusb: Update to a6b916ba for i.MX support. 2020-03-11 15:32:55 +11:00
Andrew Leech ed93778e00 py/objstringio: Expose tell() on StringIO and BytesIO objects.
To match file objects.

Fixes issue #5581.
2020-03-11 14:43:03 +11:00
David Lechner 8a4ce6b79a tools/codeformat.py: Eliminate need for sizeof fixup.
This eliminates the need for the sizeof regex fixup by rearranging things a
bit.  All other bitfields already use the parentheses around expressions
with sizeof, so one case is fixed by following this convention.

VM_MAX_STATE_ON_STACK is the only remaining problem and it can be worked
around by changing the order of the operands.
2020-03-11 14:34:40 +11:00
Tom Collins fccf17521a py/objstr: Remove duplicate % in error string.
The double-% was added in 11de8399fe (Jun
2014) when such errors were formatted with printf.  But then
55830dd9bf (Dec 2018) changed
mp_obj_new_exception_msg() to not format the message, as discussed
in #3004.  So such error strings are no longer formatted and a % is just
that.
2020-03-11 14:31:29 +11:00