aboutsummaryrefslogtreecommitdiff
path: root/ports/unix
AgeCommit message (Collapse)Author
2021-04-14unix/main: Make static variable that's potentially clobbered by longjmp.Marian Buschsieweke
This fixes `error: variable 'subpkg_tried' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]` when compiling on ppc64le and aarch64 (and possibly other architectures/toolchains).
2021-04-07unix: Improve command line argument processing.stijn
Per CPython everything which comes after the command, module or file argument is not an option for the interpreter itself. Hence the processing of options should stop when encountering those, and the remainder be passed as sys.argv. Note the latter was already the case for a module or file but not for a command. This fixes issues like 'micropython myfile.py -h' showing the help and exiting instead of passing '-h' as sys.argv[1], likewise for '-X <something>' being treated as a special option no matter where it occurs on the command line.
2021-04-01examples/usercmodules: Simplify user C module enabling.Damien George
It's a bit of a pitfall with user C modules that including them in the build does not automatically enable them. This commit changes the docs and examples for user C modules to encourage writers of user C modules to enable them unconditionally. This makes things simpler and covers most use cases. See discussion in issue #6960, and also #7086. Signed-off-by: Damien George <damien@micropython.org>
2021-03-12tests: Rename run-tests to run-tests.py for consistency.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2021-02-16unix/moduselect: Don't allow both posix and non-posix configurations.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-02-12unix/mpbtstackport_common: Implement mp_bluetooth_hci_active.Damien George
So that BTSTACK can be enabled with SYNC_EVENTS. Signed-off-by: Damien George <damien@micropython.org>
2021-02-04all: Rename BYTES_PER_WORD to MP_BYTES_PER_OBJ_WORD.Damien George
The "word" referred to by BYTES_PER_WORD is actually the size of mp_obj_t which is not always the same as the size of a pointer on the target architecture. So rename this config value to better reflect what it measures, and also prefix it with MP_. For uses of BYTES_PER_WORD in setting the stack limit this has been changed to sizeof(void *), because the stack usually grows with machine-word sized values (eg an nlr_buf_t has many machine words in it). Signed-off-by: Damien George <damien@micropython.org>
2021-01-30py/qstr.h: Remove QSTR_FROM_STR_STATIC macro.stijn
It practically does the same as qstr_from_str and was only used in one place, which should actually use the compile-time MP_QSTR_XXX form for consistency; qstr_from_str is for runtime strings only.
2021-01-23unix/modtime: Fix time() precision on unix ports with non-double floats.Oliver Joos
With MICROPY_FLOAT_IMPL_FLOAT the results of utime.time(), gmtime() and localtime() change only every 129 seconds. As one consequence tests/extmod/vfs_lfs_mtime.py will fail on a unix port with LFS support. With this patch these functions only return floats if MICROPY_FLOAT_IMPL_DOUBLE is used. Otherwise they return integers.
2020-12-07py/mpprint: Fix length calculation for strings with precision-modifier.Joris Peeraer
Two issues are tackled: 1. The calculation of the correct length to print is fixed to treat the precision as a maximum length instead as the exact length. This is done for both qstr (%q) and for regular str (%s). 2. Fix the incorrect use of mp_printf("%.*s") to mp_print_strn(). Because of the fix of above issue, some testcases that would print an embedded null-byte (^@ in test-output) would now fail. The bug here is that "%s" was used to print null-bytes. Instead, mp_print_strn is used to make sure all bytes are outputted and the exact length is respected. Test-cases are added for both %s and %q with a combination of precision and padding specifiers.
2020-11-24extmod/modbluetooth: Add API for L2CAP channels.Jim Mussared
Also known as L2CAP "connection oriented channels". This provides a socket-like data transfer mechanism for BLE. Currently only implemented for NimBLE on STM32 / Unix. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-13extmod/nimble: Make stm32 and unix NimBLE ports use synchronous events.Jim Mussared
This changes stm32 from using PENDSV to run NimBLE to use the MicroPython scheduler instead. This allows Python BLE callbacks to be invoked directly (and therefore synchronously) rather than via the ringbuffer. The NimBLE UART HCI and event processing now happens in a scheduled task every 128ms. When RX IRQ idle events arrive, it will also schedule this task to improve latency. There is a similar change for the unix port where the background thread now queues the scheduled task. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-13extmod/modbluetooth: Re-instate optional no-ringbuf modbluetooth.Jim Mussared
This requires that the event handlers are called from non-interrupt context (i.e. the MicroPython scheduler). This will allow the BLE stack (e.g. NimBLE) to run from the scheduler rather than an IRQ like PENDSV, and therefore be able to invoke Python callbacks directly/synchronously. This allows writing Python BLE handlers for events that require immediate response such as _IRQ_READ_REQUEST (which was previous a hard IRQ) and future events relating to pairing/bonding. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-13unix: Make mp_hal_delay_ms run MICROPY_EVENT_POLL_HOOK.Jim Mussared
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-13unix: Handle pending events/scheduler in MICROPY_EVENT_POLL_HOOK.Andrew Leech
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
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-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-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-22unix: Enable more warnings.Emil Renner Berthing
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-01unix/variants: Enable MICROPY_DEBUG_PARSE_RULE_NAME on coverage build.Damien George
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-09-18tests/basics: Add test for MICROPY_PY_ALL_INPLACE_SPECIAL_METHODS ops.Damien George
And enable this feature on unix, the coverage variant. The .exp test file is needed so the test can run on CPython versions prior to "@=" operator support. Signed-off-by: Damien George <damien@micropython.org>
2020-09-18ports: Add utime.gmtime() function.Damien George
To portably get the Epoch. This is simply aliased to localtime() on ports that are not timezone aware. Signed-off-by: Damien George <damien@micropython.org>
2020-09-11py/parse: Pass in an mp_print_t to mp_parse_node_print.Damien George
So the output can be redirected if needed. Signed-off-by: Damien George <damien@micropython.org>
2020-09-08extmod/nimble: Add timeout for HCI sync on startup.Jim Mussared
This allows `ble.active(1)` to fail correctly if the HCI controller is unavailable. It also avoids an infine loop in the NimBLE event handler where NimBLE doesn't correctly detect that the HCI controller is unavailable and keeps trying to reset. Furthermore, it fixes an issue where GATT service registrations were left allocated, which led to a bad realloc if the stack was activated multiple times.
2020-09-08extmod/btstack: Detect HCI UART init failure.Jim Mussared
2020-09-08extmod/modbluetooth: Implement configuration of address modes.Jim Mussared
Changes `BLE.config('mac')` to return a tuple (addr_mode, addr). Adds `BLE.config(addr_mode=...)` to set the addressing mode.
2020-09-08unix: Implement BLE H4 HCI UART for btstack/nimble.Jim Mussared
This commit adds support for using Bluetooth on the unix port via a H4 serial interface (distinct from a USB dongle), with both BTstack and NimBLE Bluetooth stacks. Note that MICROPY_PY_BLUETOOTH is now disabled for the coverage variant. Prior to this commit Bluetooth was anyway not being built on Travis because libusb was not detected. But now that bluetooth works in H4 mode it will be built, and will lead to a large decrease in coverage because Bluetooth tests cannot be run on Travis.
2020-09-08unix/Makefile: Always enable -f*-sections regardless of DEBUG setting.Jim Mussared
2020-09-08extmod/modbluetooth: Refactor stack/hci/driver/port bindings.Jim Mussared
Previously the interaction between the different layers of the Bluetooth stack was different on each port and each stack. This commit defines common interfaces between them and implements them for cyw43, btstack, nimble, stm32, unix.
2020-09-02unix/fatfs_port: Fix month offset in timestamp calculation.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-09-01extmod/vfs: Add option to use 1970 as Epoch.Damien George
By setting MICROPY_EPOCH_IS_1970 a port can opt to use 1970/1/1 as the Epoch for timestamps returned by stat(). And this setting is enabled on the unix and windows ports because that's what they use. Signed-off-by: Damien George <damien@micropython.org>
2020-09-01unix/modos: Support larger integer range in uos.stat fields.Damien George
On 32-bit builds these stat fields will overflow a small-int, so use mp_obj_new_int_from_uint to construct the int object. Signed-off-by: Damien George <damien@micropython.org>
2020-08-30unix/variants: Fix fast and freedos variants so they build again.Damien George
This regressed in bd2fff66875ed5adab8ce163a7f2bdafbd0332f9 Signed-off-by: Damien George <damien@micropython.org>
2020-08-22py/mphal.h: Introduce mp_hal_time_ns and implement on various ports.Damien George
This should return a 64-bit value being the number of nanoseconds since 1970/1/1. Signed-off-by: Damien George <damien@micropython.org>
2020-08-22unix/fatfs_port: Implement get_fattime.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-07-18unix: Make the MICROPY_xxx_ATOMIC_SECTION mutex recursive.Jim Mussared
This mutex is used to make the unix port behave more like bare metal, i.e. it allows "IRQ handlers" to run exclusively by making the mutex recursive.
2020-07-08unix/variants: Enable VFS and all supported filesystems on dev variant.Damien George
So that micropython-dev can be used to test VFS code, and inspect and build filesystem images that are compatible with bare-metal systems. Signed-off-by: Damien George <damien@micropython.org>
2020-07-01unix: Enable uasyncio on dev variant.Jim Mussared
2020-07-01unix: Make manifest selection match other ports.Jim Mussared
Changes are: - The default manifest.py is moved to the variants directory (it's in "boards" in other ports). - The coverage variant now uses a custom manifest in its variant directory to add frzmpy/frzstr. - The frzmpy/frzstr tests are moved to variants/coverage/.
2020-06-10unix/btstack_usb: Allow choosing adaptor via environment variable.Jim Mussared
This allows running (for example): env MICROPYBTUSB=2-2 ./micropython-dev ../../examples/bluetooth/ble_temperature_central.py
2020-05-16unix/main: Enter REPL when inspect active, even with stdin redirected.Yu-Ming Chang
This is how CPython behaves.
2020-04-30all: Fix auto-enable of MICROPY_GCREGS_SETJMP to select GC behaviour.Damien George
Only enable it if MICROPY_GCREGS_SETJMP is not already defined, and no supported architecture is defined.
2020-04-29all: Factor gchelper code to one place and use it for unix & ARM ports.Jim Mussared
No functionality change is intended with this commit, it just consolidates the separate implementations of GC helper code to the lib/utils/ directory as a general set of helper functions useful for any port. This reduces duplication of code, and makes it easier for future ports or embedders to get the GC implementation correct. Ports should now link against gchelper_native.c and either gchelper_m0.s or gchelper_m3.s (currently only Cortex-M is supported but other architectures can follow), or use the fallback gchelper_generic.c which will work on x86/x64/ARM. The gc_helper_get_sp function from gchelper_m3.s is not really GC related and was only used by cc3200, so it has been moved to that port and renamed to cortex_m3_get_sp.
2020-04-29unix: Add btstack to the unix submodules list.Jim Mussared
But only when bluetooth is enabled, i.e. if building the dev or coverage variants, and we have libusb available. Update travis to match, i.e. specify the variant when doing `make submodules`.
2020-04-29extmod/modbluetooth: Fix sign compare and unused variable warnings.Jim Mussared
2020-04-29unix: Enable modbluetooth on the "dev" and "coverage" variants.Jim Mussared
And MICROPY_PY_URANDOM_EXTRA_FUNCS is enabled on "dev" so tha the Bluetooth examples all run.