Wykres commitów

349 Commity (master)

Autor SHA1 Wiadomość Data
David Lechner 0eead94181 lib/libm: Use __asm__ instead of asm.
`asm` is not part of the C standard and causes a complier error when
`-std=c99` is used. `__asm__` is the recommended alternative.

https://gcc.gnu.org/onlinedocs/gcc/extensions-to-the-c-language-family/alternate-keywords.html

Signed-off-by: David Lechner <david@pybricks.com>
2022-11-10 11:36:41 +11:00
Damien George 1531a7c8ca lib/micropython-lib: Update submodule to latest.
This brings in mip-cmdline, espflash, use of machine.dht_readinto, and
other improvements to existing libraries.

Signed-off-by: Damien George <damien@micropython.org>
2022-11-09 14:58:49 +11:00
Damien George 4f946ba963 lib/btstack: Update to v1.5.3.
Signed-off-by: Damien George <damien@micropython.org>
2022-10-22 13:21:28 +11:00
Jim Mussared ba3652f15d lib/micropython-lib: Update submodule to latest.
This brings in the `mip` tool for installing packages.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-30 00:46:26 +10:00
yn386 ae0b0e7018 lib/stm32lib: Update library to get L1 v1.10.3, and some other fixes.
Changes in this new library version are:
- Add L1 HAL at v1.10.3.
- H7_HAL/rcc_ex: Add SPI45 to HAL_RCCEx_GetPeriphCLKFreq.
- L4_HAL/gpio_ex: Add #define for GPIO_AF14_TIM2 on L4P5/L4Q5.
- F4_HAL/i2c: Fix I2C frequency calculation macros.
- L1_HAL/utils: Fix compile error when USE_HAL_DRIVER is defined.
2022-09-25 23:56:20 +10:00
Jim Mussared aeff6911d7 lib/micropython-lib: Update submodule to latest.
This brings in the drivers and libraries that were previously in this
repo.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-08 11:27:00 +10:00
Damien George ccd210984e lib/micropython-lib: Update to latest version with manifest changes.
Signed-off-by: Damien George <damien@micropython.org>
2022-09-05 18:24:27 +10:00
Damien George 9a826e0f24 lib/lwip: Update lwIP to v2.1.3, tag STABLE-2_1_3_RELEASE.
There don't seem to be many changes going from v2.1.2 to v2.1.3 of lwIP.
Mostly they are:
- IPv6 fixes and improvements
- changes to apps and other code that MicroPython doesn't use
- comments and tests
- minor bug fixes

In particular there doesn't look to be any change to the API of any
function used by MicroPython.

Network multi tests pass on PYBD_SF2 and PYBD_SF6.  PYBD_SF2, PYBD_SF6 and
PICO_W have unchanged iperf3 performance.  Similar results for networking
on the mimxrt port.

Signed-off-by: Damien George <damien@micropython.org>
2022-08-29 14:41:21 +10:00
Jim Mussared 9a1b7d8448 lib/micropython-lib: Add micropython-lib as a submodule.
Several boards now depend on libraries from micropython-lib.  Rather than
expecting micropython-lib to be available as a sibling of the micropython
repo, instead make it a submodule.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-03 00:04:06 +10:00
Peter Harper 9fd8250d69 lib/cyw43-driver: Update driver to latest version.
This version of the driver adds an event hook to call during firmware
download, and the ability to query the current power mode.
2022-07-26 01:37:47 +10:00
robert-hh d1ef3815e6 lib/tinyusb: Update to the most recent master. 2022-07-19 11:26:54 +10:00
Damien George f4e69ab103 lib/cyw43-driver: Update cyw43-driver to fix ap_auth mode setting.
Signed-off-by: Damien George <damien@micropython.org>
2022-07-05 11:04:20 +10:00
Damien George f525e17793 lib/pico-sdk: Update to version 1.4.0.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-30 16:03:21 +10:00
Damien George 18a010b5b1 lib/cyw43-driver: Add new submodule for CYW43xx WiFi driver.
Signed-off-by: Damien George <damien@micropython.org>
2022-06-30 16:03:21 +10:00
Andrew Leech cb436e357f lib/wiznet5k: Add submodule for Wiznet Ethernet drivers.
Signed-off-by: Andrew Leech <andrew@alelec.net>
2022-06-03 14:29:11 +10:00
robert-hh dbe8b0c0ca lib/nxp_driver: Update nxp_driver to v2.10. 2022-06-03 10:48:04 +10:00
Damien George 9269835226 lib/littlefs: Remove assignment of variables to themselves.
To prevent compiler warnings (eg on clang).

Signed-off-by: Damien George <damien@micropython.org>
2022-05-24 12:51:49 +10:00
Damien George 3a544b832b lib/littlefs: Guard lfs2_file_rawopen with LFS2_NO_MALLOC.
To prevent warnings about this function being unused when malloc is
disabled.

Signed-off-by: Damien George <damien@micropython.org>
2022-05-24 12:51:17 +10:00
Damien George 115a23da24 lib/littlefs: Update littlefs2 to v2.5.0.
At commit 40dba4a556e0d81dfbe64301a6aa4e18ceca896c

Signed-off-by: Damien George <damien@micropython.org>
2022-05-24 12:51:17 +10:00
TakeoTakahashi2020 4c9b00b425 lib/fsp: Add renesas fsp git repository as submodule.
Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
2022-04-29 10:55:58 +09:00
Damien George 7f445e3d39 lib/stm32lib: Update library for G0 v1.5.1.
Changes in this new library version are:
- Add G0 HAL at v1.5.1.

Signed-off-by: Damien George <damien@micropython.org>
2022-04-28 11:56:15 +10:00
Damien George adfd57c5fe lib/re1.5: Distinguish between subject start-of-line and start-of-srch.
Otherwise a repeated sub/split will continue to match ^ to the start of
that search.

Signed-off-by: Damien George <damien@micropython.org>
2022-03-16 12:21:00 +11:00
Damien George d4997c7b60 lib/stm32lib: Update library for fix to F7 USB HS.
Fixes build on MCUs with built-in USB HS PHY.

Signed-off-by: Damien George <damien@micropython.org>
2022-01-06 16:43:22 +11:00
Damien George a0f5b3148a lib/stm32lib: Update library for L4 v1.17.0, new G4, WL, and MMC fixes.
Changes in this new library version are:
- Update L4 HAL to v1.17.0.
- Add G4 HAL at v1.3.0.
- Add WL HAL at v1.1.0.
- Fix F4 UART and DMA data loss with RX hardware flow control.
- Optimise USB to pass config struct by reference.
- Fix bug in F4 MMC HAL_MMC_Erase function.
- Fix bug setting MMC relative address in F4 and F7 HAL.

Signed-off-by: Damien George <damien@micropython.org>
2021-12-14 10:48:01 +11:00
iabdalkader 97a7cc243b lib: Update pico-sdk to 1.3.0 and tinyusb to 0.12.0.
Fixes #8025
2021-11-26 12:05:38 +11:00
Damien George f27be2d78a lib/asf4: Point submodule to latest commit on circuitpython branch. 2021-11-18 12:44:30 +11:00
Jim Mussared 948e3289bf extmod/nimble: Update to NimBLE v1.4.
We're using the MicroPython fork of NimBLE, which on the
`micropython_1_4_0` branch re-adds support for 64-bit targets and fixes
initialisation of g_msys_pool_list.

Also updates modbluetooth_nimble.c to suit v1.4.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-10-26 16:43:18 +11:00
Damien George e3291e1801 lib,shared: Update README's based on contents of these dirs.
Signed-off-by: Damien George <damien@micropython.org>
2021-07-13 00:17:02 +10:00
Damien George 4d546713ec shared: Introduce new top-level dir and move 1st party lib code there.
This commit moves all first-party code developed for this project from lib/
to shared/, so that lib/ now only contains third-party code.

The following directories are moved as-is from lib to shared:

    lib/libc            -> shared/libc
    lib/memzip          -> shared/memzip
    lib/netutils        -> shared/netutils
    lib/timeutils       -> shared/timeutils
    lib/upytesthelper   -> shared/upytesthelper

All files in lib/embed/ have been moved to shared/libc/.

lib/mp-readline has been moved to shared/readline.

lib/utils has been moved to shared/runtime, with the exception of
lib/utils/printf.c which has been moved to shared/libc/printf.c.

Signed-off-by: Damien George <damien@micropython.org>
2021-07-12 17:07:36 +10:00
Damien George 6dd92d7742 lib/crypto-algorithms: Move crypto-algorithms code from extmod to lib.
It's third-party code, and not necessarily tied to extmod.

Signed-off-by: Damien George <damien@micropython.org>
2021-07-12 16:36:37 +10:00
Damien George d1bfb271d7 lib/uzlib: Move uzlib code from extmod to lib.
It's third-party code, and not necessarily tied to extmod.

Signed-off-by: Damien George <damien@micropython.org>
2021-07-12 16:36:34 +10:00
Damien George d1d172f536 lib/re1.5: Move re1.5 code from extmod to lib.
It's third-party code, and not necessarily tied to extmod.

Signed-off-by: Damien George <damien@micropython.org>
2021-07-12 16:36:26 +10:00
Damien George 75c1609c3a lib/axtls: Update to latest axtls 2.1.5 wih additional commits.
Changes are:
- update axTLS from 2.1.3 to 2.1.5
- os_port.h is now provided by the user of the library
- PLATFORM_RNG_U8 can be defined for get_random
- fix -fsanitize=undefined diagnostics

Signed-off-by: Damien George <damien@micropython.org>
2021-07-08 23:51:39 +10:00
Damien George 20a6044952 lib/utils/stdout_helpers: Make mp_hal_stdout_tx_strn_cooked efficient.
To reduce the number of calls to mp_hal_stdout_tx_strn and improve the
overall throughput of printing data.  This implementation is taken from
ports/stm32/mphalport.c.

Signed-off-by: Damien George <damien@micropython.org>
2021-07-08 12:59:31 +10:00
Damien George d67bd494b5 lib/pico-sdk: Update to version 1.2.0.
Signed-off-by: Damien George <damien@micropython.org>
2021-07-05 16:18:28 +10:00
Damien George c8e9e04541 lib/tinyusb: Update to version 0.10.1.
Signed-off-by: Damien George <damien@micropython.org>
2021-07-05 16:18:28 +10:00
Krzysztof Adamski 6409bbcb72 mimxrt: Move calc_weekday helper function to timeutils.
This function may be useful for other ports as well so lets move it to
timeutils so it can be reused.

Signed-off-by: Krzysztof Adamski <k@japko.eu>
2021-06-25 10:28:32 +10:00
Damien George 0aa01b0205 lib/mbedtls: Switch to currently latest commit of LTS branch v2.16.
Signed-off-by: Damien George <damien@micropython.org>
2021-05-25 00:04:01 +10:00
Ayke van Laethem 70f50c46cc lib/utils: Add ARM semihosting utility functions.
This can be a replacement for a UART in custom ports.
2021-05-11 23:33:12 +10:00
Damien George b6b39bff47 py/gc: Make gc_lock_depth have a count per thread.
This commit makes gc_lock_depth have one counter per thread, instead of one
global counter.  This makes threads properly independent with respect to
the GC, in particular threads can now independently lock the GC for
themselves without locking it for other threads.  It also means a given
thread can run a hard IRQ without temporarily locking the GC for all other
threads and potentially making them have MemoryError exceptions at random
locations (this really only occurs on MCUs with multiple cores and no GIL,
eg on the rp2 port).

The commit also removes protection of the GC lock/unlock functions, which
is no longer needed when the counter is per thread (and this also fixes the
cas where a hard IRQ calling gc_lock() may stall waiting for the mutex).

It also puts the check for `gc_lock_depth > 0` outside the GC mutex in
gc_alloc, gc_realloc and gc_free, to potentially prevent a hard IRQ from
waiting on a mutex if it does attempt to allocate heap memory (and putting
the check outside the GC mutex is now safe now that there is a
gc_lock_depth per thread).

Signed-off-by: Damien George <damien@micropython.org>
2021-05-10 13:07:16 +10:00
Damien George 530c76f6ca lib/utils: Remove unused PYEXEC_SWITCH_MODE from pyexec.h.
It was made obsolete by commit c98c128fe8.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-24 00:10:59 +10:00
Damien George a62e791978 lib/pico-sdk: Update to latest version 1.1.0.
Signed-off-by: Damien George <damien@micropython.org>
2021-03-12 01:00:00 +11:00
Yonatan Goldschmidt 098ac11bb0 lib/utils/gchelper_generic: Implement AArch64 support. 2021-03-11 12:54:05 +11:00
Mirko Vogt 7d73b9ff99 lib/mbedtls: Switch to currently latest commit of LTS branch v2.16.
From a version numbering point of view this is a downgrade (2.17.0 ->
2.16.x).  However the latest commit for version 2.17.0 is from March 2019
and no further minor release happened after 2.17.0.  This version is EOL.
2.16.x though is still actively maintained as a long term release, hence
security and stability fixes are still being backported, including
compatibility with upcoming compiler releases.
2021-03-11 11:49:18 +11:00
Damien George 9b7d8b87ee lib/tinyusb: Update to version 0.8.0.
Includes support for RP2040.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-12 12:50:22 +11:00
Damien George 9b277d9815 lib/pico-sdk: Update to latest version v1.0.1.
In particular it fixes GPIO19 so that it can be used as an output.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-02 10:59:27 +11:00
stijn fca2730ea0 lib/utils/pyexec: Remove obsolete LCD initialization.
This was added a long time ago in 75abee206d
when USB host support was added to the stm (now stm32) port, and when this
pyexec code was actually part of the stm port.  It's unlikely to work as
intended anymore.  If it is needed in the future then generic hook macros
can be added in pyexec.
2021-01-30 13:41:36 +11:00
Damien George ef3ee7aa10 lib/pico-sdk: Add new pico-sdk submodule, for the rp2 port.
Signed-off-by: Damien George <damien@micropython.org>
2021-01-29 23:57:10 +11:00
Damien George 33f10381d6 lib/timeutils: Provide simple impl of extra funcs when Epoch is 1970.
Dates/times must be post 2000/1/1 to work correctly with these simple
implementations.

Signed-off-by: Damien George <damien@micropython.org>
2021-01-29 23:57:10 +11:00
Damien George 0ce6948653 lib/libhydrogen: Add new libhydrogen submodule.
This library is a small and easy-to-use cryptographic library which is well
suited to embedded systems.

Signed-off-by: Damien George <damien@micropython.org>
2021-01-18 12:43:01 +11:00
Damien George f694a6fa20 lib/stm32lib: Update library for WB v1.10.0.
Changes in this new library version are:
- Update WB HAL to v1.10.0.

Signed-off-by: Damien George <damien@micropython.org>
2020-12-10 12:26:24 +11:00
Damien George 8a29319a15 lib/littlefs: Guard lfs2_mlist_isopen with LFS2_NO_ASSERT.
To prevent warnings about this function being unused when assertions are
disabled.

Signed-off-by: Damien George <damien@micropython.org>
2020-12-09 13:19:31 +11:00
Damien George d9d761b057 lib/littlefs: Update littlefs2 to v2.3.0.
At commit 1a59954ec64ca168828a15242cc6de94ac75f9d1

Signed-off-by: Damien George <damien@micropython.org>
2020-12-09 11:01:24 +11:00
Damien George bb24c69b90 lib/utils/pyexec: Add stdin-reader on raw REPL with flow control.
Background: the friendly/normal REPL is intended for human use whereas the
raw REPL is for computer use/automation.  Raw REPL is used for things like
pyboard.py script_to_run.py.  The normal REPL has built-in flow control
because it echos back the characters.  That's not so with raw REPL and flow
control is just implemented by rate limiting the amount of data that goes
in.  Currently it's fixed at 256 byte chunks every 10ms.  This is sometimes
too fast for slow MCUs or systems with small stdin buffers.  It's also too
slow for a lot of higher-end MCUs, ie it could be a lot faster.

This commit adds a new raw REPL mode which includes flow control: the
device will echo back a character after a certain number of bytes are sent
to the host, and the host can use this to regulate the data going out to
the device.  The amount of characters is controlled by the device and sent
to the host before communication starts.  This flow control allows getting
the maximum speed out of a serial link, regardless of the link or the
device at the other end.

Also, this new raw REPL mode parses and compiles the incoming data as it
comes in.  It does this by creating a "stdin reader" object which is then
passed to the lexer.  The lexer requests bytes from this "stdin reader"
which retrieves bytes from the host, and does flow control.  What this
means is that no memory is used to store the script (in the existing raw
REPL mode the device needs a big buffer to read in the script before it can
pass it on to the lexer/parser/compiler).  The only memory needed on the
device is enough to parse and compile.

Finally, it would be possible to extend this new raw REPL to allow bytecode
(.mpy files) to be sent as well as text mode scripts (but that's not done
in this commit).

Some results follow. The test was to send a large 33k script that contains
mostly comments and then prints out the heap, run via pyboard.py large.py.

On PYBD-SF6, prior to this PR:

$ ./pyboard.py large.py
stack: 524 out of 23552
GC: total: 392192, used: 34464, free: 357728
 No. of 1-blocks: 12, 2-blocks: 2, max blk sz: 2075, max free sz: 22345
GC memory layout; from 2001a3f0:
00000: h=hhhh=======================================hhBShShh==h=======h
00400: =====hh=B........h==h===========================================
00800: ================================================================
00c00: ================================================================
01000: ================================================================
01400: ================================================================
01800: ================================================================
01c00: ================================================================
02000: ================================================================
02400: ================================================================
02800: ================================================================
02c00: ================================================================
03000: ================================================================
03400: ================================================================
03800: ================================================================
03c00: ================================================================
04000: ================================================================
04400: ================================================================
04800: ================================================================
04c00: ================================================================
05000: ================================================================
05400: ================================================================
05800: ================================================================
05c00: ================================================================
06000: ================================================================
06400: ================================================================
06800: ================================================================
06c00: ================================================================
07000: ================================================================
07400: ================================================================
07800: ================================================================
07c00: ================================================================
08000: ================================================================
08400: ===============================================.....h==.........
       (349 lines all free)

(the big blob of used memory is the large script).

Same but with this PR:

$ ./pyboard.py large.py
stack: 524 out of 23552
GC: total: 392192, used: 1296, free: 390896
 No. of 1-blocks: 12, 2-blocks: 3, max blk sz: 40, max free sz: 24420
GC memory layout; from 2001a3f0:
00000: h=hhhh=======================================hhBShShh==h=======h
00400: =====hh=h=B......h==.....h==....................................
       (381 lines all free)

The only thing in RAM is the compiled script (and some other unrelated
items).

Time to download before this PR: 1438ms, data rate: 230,799 bits/sec.

Time to download with this PR: 119ms, data rate: 2,788,991 bits/sec.

So it's more than 10 times faster, and uses significantly less RAM.

Results are similar on other boards. On an stm32 board that connects via
UART only at 115200 baud, the data rate goes from 80kbit/sec to
113kbit/sec, so gets close to saturating the UART link without loss of
data.

The new raw REPL mode also supports a single ctrl-C to break out of this
flow-control mode, so that a ctrl-C can always get back to a known state.
It's also backwards compatible with the original raw REPL mode, which is
still supported with the same sequence of commands.  The new raw REPL
mode is activated by ctrl-E, which gives an error on devices that do not
support the new mode.

Signed-off-by: Damien George <damien@micropython.org>
2020-11-30 11:37:44 +11:00
Damien George 7789cd5f16 lib/utils/pyexec: Add MICROPY_BOARD hooks before/after executing code.
Signed-off-by: Damien George <damien@micropython.org>
2020-11-11 21:47:13 +11:00
Damien George 8f20cdc353 all: Rename absolute time-based functions to include "epoch".
For time-based functions that work with absolute time there is the need for
an Epoch, to set the zero-point at which the absolute time starts counting.
Such functions include time.time() and filesystem stat return values.  And
different ports may use a different Epoch.

To make it clearer what functions use the Epoch (whatever it may be), and
make the ports more consistent with their use of the Epoch, this commit
renames all Epoch related functions to include the word "epoch" in their
name (and remove references to "2000").

Along with this rename, the following things have changed:

- mp_hal_time_ns() is now specified to return the number of nanoseconds
  since the Epoch, rather than since 1970 (but since this is an internal
  function it doesn't change anything for the user).

- littlefs timestamps on the esp8266 have been fixed (they were previously
  off by 30 years in nanoseconds).

Otherwise, there is no functional change made by this commit.

Signed-off-by: Damien George <damien@micropython.org>
2020-09-18 17:20:34 +10:00
Jim Mussared 23109988c2 stm32/uart: Allow static IRQ handler registration.
This will allow the HCI UART to use a non-heap mp_irq_obj_t, which avoids
needing to make a root pointer for it.
2020-09-08 10:46:30 +10:00
Damien George 3ff7079277 lib/utils/mpirq: Add mp_irq_init func, and clean up unused init method.
mp_irq_init() is useful when the IRQ object is allocated by the caller.

The mp_irq_methods_t.init method is not used anywhere so has been removed.

Signed-off-by: Damien George <damien@micropython.org>
2020-09-04 12:40:38 +10:00
Damien George 38959ed8f1 lib/libm: Reduce size of static two_over_pi array.
Thanks to Jeff Epler for the idea.

Signed-off-by: Damien George <damien@micropython.org>
2020-09-04 00:45:56 +10:00
Damien George badd351150 lib/timeutils: Add helper functions to deal with nanosecs since 1970.
Signed-off-by: Damien George <damien@micropython.org>
2020-08-22 15:41:10 +10:00
Damien George d9b7261024 lib/libc: Fix string0's implementation of strncpy.
Fixing 98e583430f, the semantics of strncpy
require that the remainder of dst be filled with null bytes.

Signed-off-by: Damien George <damien@micropython.org>
2020-07-22 16:29:54 +10:00
Zoltán Vörös 27767aafa2 lib/libm_dbl: Add round.c source code.
This code is imported from musl, to match existing code in libm_dbl.

The file is also added to the build in stm32/Makefile.  It's not needed by
the core code but, similar to c5cc64175b,
allows round() to be used by user C modules or board extensions.
2020-07-21 11:07:19 +10:00
Damien George f80b1d8535 lib/stm32lib: Update library for H7 v1.6.0 and WB v1.6.0.
Changes in this new library version are:
- Update H7 HAL to v1.6.0.
- Update WB HAL to v1.6.0.
- Add patches to fix F4 ll_uart clock selection for UART9/UART10.

Signed-off-by: Damien George <damien@micropython.org>
2020-07-21 01:02:58 +10:00
Thorsten von Eicken 3e758ef235 lib/mbedtls_errors: Add code to patch mbedtls for shortened error strs.
The file `mbedtls_errors/mp_mbedtls_errors.c` can be used instead of
`mbedtls/library/error.c` to give shorter error strings, reducing the build
size of the error strings from about 12-16kB down to about 2-5kB.
2020-07-20 23:53:27 +10:00
Thorsten von Eicken 98e583430f lib/libc: Add implementation of strncpy. 2020-07-20 23:42:04 +10:00
Damien George 9d5edb3559 lib/utils: Protect all of mpirq.c with MICROPY_ENABLE_SCHEDULER.
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-30 22:31:41 +10:00
David Lechner 77ed6f69ac tools/uncrustify: Enable more opts to remove space between func and '('.
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-19 22:07:32 +10:00
Damien George b2030e1661 lib/utils/pyexec: Add missing MP_ERROR_TEXT when compiler disabled. 2020-06-02 15:43:44 +10:00
Damien George 4bbba3060d lib/utils: Lock the scheduler when executing hard callback functions.
Otherwise scheduled functions may execute during the hard callback and then
fail if they try to allocate heap memory.
2020-05-27 17:53:31 +10:00
Damien George 9ee5aff334 lib/nrfx: Upgrade to nrfx v2.0.0. 2020-05-15 15:06:02 +10:00
Jim Mussared 710426024a all: Factor gchelper code to one place and use it for unix & ARM ports.
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-29 23:45:19 +10:00
Jim Mussared c37fd78071 lib/btstack: Update to c8b9823 for USB HCI reset timeout fix. 2020-04-29 16:54:12 +10:00
Damien George e08ca78f40 py/stream: Remove mp_stream_errno and use system errno instead.
This change is made for two reasons:

1. A 3rd-party library (eg berkeley-db-1.xx, axtls) may use the system
   provided errno for certain errors, and yet MicroPython stream objects
   that it calls will be using the internal mp_stream_errno.  So if the
   library returns an error it is not known whether the corresponding errno
   code is stored in the system errno or mp_stream_errno.  Using the system
   errno in all cases (eg in the mp_stream_posix_XXX wrappers) fixes this
   ambiguity.

2. For systems that have threading the system-provided errno should always
   be used because the errno value is thread-local.

For systems that do not have an errno, the new lib/embed/__errno.c file is
provided.
2020-04-27 23:58:46 +10:00
Jim Mussared 0dceab0ddf lib/mynewt-nimble: Update submodule to NimBLE release 1.3.0. 2020-04-27 22:50:42 +10:00
stijn 84fa3312cf all: Format code to add space after C++-style comment start.
Note: the uncrustify configuration is explicitly set to 'add' instead of
'force' in order not to alter the comments which use extra spaces after //
as a means of indenting text for clarity.
2020-04-23 11:24:25 +10:00
stijn d6243568a0 all: Remove commented-out include statements. 2020-04-23 11:24:15 +10:00
stijn 70affd9ba2 all: Fix implicit floating point to integer conversions.
These are found when building with -Wfloat-conversion.
2020-04-18 22:42:24 +10:00
stijn bcf01d1686 all: Fix implicit conversion from double to float.
These are found when building with -Wfloat-conversion.
2020-04-18 22:42:24 +10:00
Damien George 7a07e71915 lib/littlefs: Update littlefs2 to v2.2.0.
At commit a049f1318eecbe502549f9d74a41951985fb956f
2020-04-09 15:59:28 +10:00
Damien George fa285be9d7 lib/btstack: Update to latest master btstack commit. 2020-04-07 13:46:56 +10:00
Jim Mussared def76fe4d9 all: Use MP_ERROR_TEXT for all error messages. 2020-04-05 15:02:06 +10: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 6cea369b89 lib/tinyusb: Update to a6b916ba for i.MX support. 2020-03-11 15:32:55 +11:00
Damien George d35fefe30a lib: Add BlueKitchen BTstack submodule. 2020-03-10 01:53:42 +11:00
Damien George 69661f3343 all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28 10:33:03 +11:00
Damien George abe2caf6df py/scheduler: Move clearing of kbd traceback to mp_keyboard_interrupt.
This is a more logical place to clear the KeyboardInterrupt traceback,
right before it is set as a pending exception.  The clearing is also
optimised from a function call to a simple store of NULL.
2020-02-07 16:08:31 +11:00
Damien George 9efb36bfa6 py/scheduler: Move mp_keyboard_interrupt from lib/utils to py core.
This function is tightly coupled to the state and behaviour of the
scheduler, and is a core part of the runtime: to schedule a pending
exception.  So move it there.
2020-02-07 16:08:26 +11:00
Damien George 5a91cd9ff3 lib/utils/pyexec: Handle pending exceptions after disabling kbd intrs.
Pending exceptions would otherwise be handled later on where there may not
be an NLR handler in place.

A similar fix is also made to the unix port's REPL handler.

Fixes issues #4921 and #5488.
2020-02-07 16:08:26 +11:00
odewdney b51a2c266a lib/utils: Change default value of pyexec_mode_kind to 0 to put in bss.
By simply reordering the enums for pyexec_mode_kind_t it eliminates a data
variable which costs ROM to initialise it.  And the minimal build now has
nothing in the data section.

It seems the compiler is smart enough so that the generated code for
if-logic which tests these enum values is unchanged.
2020-02-04 18:10:26 +11:00
Yonatan Goldschmidt 853aaa06f2 lib/mp-readline: Add word-based move/delete EMACS key sequences.
This commit adds backward-word, backward-kill-word, forward-word,
forward-kill-word sequences for the REPL, with bindings to Alt+F, Alt+B,
Alt+D and Alt+Backspace respectively.  It is disabled by default and can be
enabled via MICROPY_REPL_EMACS_WORDS_MOVE.

Further enabling MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE adds extra bindings
for these new sequences: Ctrl+Right, Ctrl+Left and Ctrl+W.

The features are enabled on unix micropython-coverage and micropython-dev.
2020-01-12 13:09:27 +11:00
Yonatan Goldschmidt dce590c29d lib/mp-readline: Add an assert() to catch buffer overflows.
During readline development, this function may receive bad `pos` values.
It's easier to understand the assert() failing error than to have a "stack
smashing detected" message.
2020-01-12 13:09:23 +11:00
Yonatan Goldschmidt 61d2b40ad5 lib/utils/pyexec: Introduce MICROPY_REPL_INFO, wrap debug prints in it.
For the 3 ports that already make use of this feature (stm32, nrf and
teensy) this doesn't make any difference, it just allows to disable it from
now on.

For other ports that use pyexec, this decreases code size because the debug
printing code is dead (it can't be enabled) but the compiler can't deduce
that, so code is still emitted.
2019-12-28 00:05:39 +11:00
Damien George 09376f0e47 py: Introduce MP_ROM_NONE macro for ROM to refer to None object.
This helps to prevent mistakes, and allows easily changing the ROM value of
None if needed.
2019-12-27 22:51:17 +11:00
David Lechner 1605c7e584 Revert "lib/tinytest: Clean up test reporting in the presence of std..."
This reverts commit f4ed2dfa94.

This lets tinytest work as it was originally designed.  An alternate
solution for the reverted commit will be implemented in a future commit.
2019-12-19 17:53:46 +11:00
Damien George 4e1b03d45c lib/libc/string0: Add simple implementations of strspn and strcspn.
They are needed for littlefs.
2019-10-30 12:14:52 +11:00
Damien George 22bfc47977 lib/littlefs: Add README describing origin and how to gen lfs1/lfs2. 2019-10-29 12:55:34 +11:00
Damien George 2e66d83ca4 lib/littlefs: Add littlefs v2.1.3 source. 2019-10-29 12:55:34 +11:00
Damien George 669d1d20ab lib/littlefs: Add littlefs v1.7.2 source. 2019-10-29 12:55:34 +11:00
Jim Mussared 580a2656d1 stm32: Use hardware double sqrt on F7/H7 MCUs.
Identical to cd527bb324 but for doubles.
This gives a -2.754% improvement on bm_float.py, and -35% improvement on
calling sqrt in a loop.
2019-10-10 17:39:32 +11:00
Damien George 21507a6f62 lib/mynewt-nimble: Add Apache mynewt nimble as a submodule.
Tag nimble_1_1_0_tag.
2019-10-01 09:51:02 +10:00