Wykres commitów

1238 Commity (master)

Autor SHA1 Wiadomość Data
Matthias Urlichs e520fa2e0f py/binary: Support half-float 'e' format in struct pack/unpack.
This commit implements the 'e' half-float format: 10-bit mantissa, 5-bit
exponent.  It uses native _Float16 if supported by the compiler, otherwise
uses custom bitshifting encoding/decoding routines.

Signed-off-by: Matthias Urlichs <matthias@urlichs.de>
Signed-off-by: Damien George <damien@micropython.org>
2024-03-20 14:13:49 +11:00
Nicko van Someren 77f08b72ca docs/library/rp2.DMA: Add documentation for rp2 DMA support.
Signed-off-by: Nicko van Someren <nicko@nicko.org>
2024-03-19 17:10:54 +11:00
Damien George d92dff881c docs/library/collections: Update deque docs to describe new features.
Signed-off-by: Damien George <damien@micropython.org>
2024-03-19 10:09:11 +11:00
iabdalkader e5ca06a06f docs/library/openamp: Document the new openamp module.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2024-03-15 18:11:28 +11:00
Angus Gratton 9d0d262be0 extmod/machine_usb_device: Add support for Python USB devices.
This new machine-module driver provides a "USBDevice" singleton object and
a shim TinyUSB "runtime" driver that delegates the descriptors and all of
the TinyUSB callbacks to Python functions.  This allows writing arbitrary
USB devices in pure Python.  It's also possible to have a base built-in
USB device implemented in C (eg CDC, or CDC+MSC) and a Python USB device
added on top of that.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-03-15 14:22:11 +11:00
robert-hh cdfc6c159f esp32/network_lan: Add a separate argument to set PHY power pin.
Prior to this commit, the pin defined for power would be used by the
esp_idf driver to reset the PHY.  That worked, but sometimes the MDIO
configuration started before the power was fully settled, leading to an
error.

With the change in this commit, the power for the PHY is independently
enabled in network_lan.c with a 100ms delay to allow the power to settle.
A separate define for a reset pin is provided, even if the PHY reset
pin is rarely connected.

Fixes issue #14013.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-08 16:55:08 +11:00
Phil Howard dda9b9c6da all: Prune trailing whitespace.
Prune trailing whitespace across the whole project (almost), done
automatically with:

    grep -IUrl --color "[[:blank:]]$" --exclude-dir=.git --exclude=*.exp |\
        xargs sed -i 's/[[:space:]]*$//'

Exceptions:
- Skip third-party code in lib/ and drivers/cc3100/
- Skip generated code in bluetooth_init_cc2564C_1.5.c
- Preserve command output whitespace in docs, eg:
  docs/esp8266/tutorial/repl.rst

Signed-off-by: Phil Howard <phil@gadgetoid.com>
2024-03-07 16:25:17 +11:00
Angus Gratton decf8e6a8b all: Remove the "STATIC" macro and just use "static" instead.
The STATIC macro was introduced a very long time ago in commit
d5df6cd44a.  The original reason for this was
to have the option to define it to nothing so that all static functions
become global functions and therefore visible to certain debug tools, so
one could do function size comparison and other things.

This STATIC feature is rarely (if ever) used.  And with the use of LTO and
heavy inline optimisation, analysing the size of individual functions when
they are not static is not a good representation of the size of code when
fully optimised.

So the macro does not have much use and it's simpler to just remove it.
Then you know exactly what it's doing.  For example, newcomers don't have
to learn what the STATIC macro is and why it exists.  Reading the code is
also less "loud" with a lowercase static.

One other minor point in favour of removing it, is that it stops bugs with
`STATIC inline`, which should always be `static inline`.

Methodology for this commit was:

1) git ls-files | egrep '\.[ch]$' | \
   xargs sed -Ei "s/(^| )STATIC($| )/\1static\2/"

2) Do some manual cleanup in the diff by searching for the word STATIC in
   comments and changing those back.

3) "git-grep STATIC docs/", manually fixed those cases.

4) "rg -t python STATIC", manually fixed codegen lines that used STATIC.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-03-07 14:20:42 +11:00
Daniël van de Giessen 678707c8b0 docs/library/bluetooth: Add note that ESP32 supports pairing/bonding.
Pairing and bonding was fixed for the ESP32 in the two previous commits.

Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2024-02-29 14:33:22 +11:00
Damien George e2ff00e811 py/emitglue: Introduce mp_proto_fun_t as a more general mp_raw_code_t.
Allows bytecode itself to be used instead of an mp_raw_code_t in the simple
and common cases of a bytecode function without any children.

This can be used to further reduce frozen code size, and has the potential
to optimise other areas like importing.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-16 14:17:01 +11:00
Damien George 35dd959133 tools/manifestfile.py: Change library search to use a list of paths.
This commit changes how library packages are searched for when a manifest
file is loaded: there is now simply a list of library paths that is
searched in order for the given package.  This list defaults to the
main directories in micropython-lib, but can be added to -- either appended
or prepended -- by using `add_library()`.

In particular the way unix-ffi library packages are searched has changed,
because the `unix_ffi` argument to `require()` is now removed.  Instead, if
a build wants to include packages from micropython-lib/unix-ffi, then it
must explicitly add this to the list of paths to search using:

    add_library("unix-ffi", "$(MPY_LIB_DIR)/unix-ffi")

Work done in collaboration with Jim Mussared.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-08 17:16:10 +11:00
Jos Verlinde 2bdaa1bede docs/library/sys.rst: Document implementation.version.releaselevel.
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
2024-02-07 15:51:25 +11:00
Damien George 4c56b39051 docs: Use vfs module instead of os.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:25:10 +11:00
Damien George 5804aa0204 docs/reference/micropython2_migration.rst: Add info about os and vfs.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:25:09 +11:00
Damien George 45f99cb445 docs/library: Move vfs functions and classes from os to vfs module docs.
Signed-off-by: Damien George <damien@micropython.org>
2024-02-07 13:25:09 +11:00
Damien George ac8e7f7b67 docs/library/ssl: Change wrap_socket args keyfile/certfile to key/cert.
So they match the code in extmod/modssl_*.c.

Signed-off-by: Damien George <damien@micropython.org>
2024-02-05 13:05:29 +11:00
Angus Gratton 307ecc5707 docs: Add note about position-only arguments in CPython vs MicroPython.
Required modifying the gen-cpydiff.py code to allow a "preamble" section to
be inserted at the top of any of the generated files.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-01-25 11:56:38 +11:00
Damien George f9df08d8ee docs/develop/porting: Fix argument type of mp_lexer_new_from_file().
Follow up to 5015779a6f.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-16 11:42:47 +11:00
Damien George ee226a8b43 all: Fix "reuse" and "overridden" spelling mistakes.
Codespell doesn't pick up "re-used" or "re-uses", and ignores the tests/
directory, so fix these manually.

Signed-off-by: Damien George <damien@micropython.org>
2024-01-05 15:08:33 +11:00
robert-hh 8498b0b13e docs/samd/pinout: Update pinout docs with fixed pin assignment.
Fixes a wrong assignment for Sparkfun SAMD51 Thing Plus, and updates the
sample script for printing the pin info table.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-01-02 18:44:45 +11:00
Carlosgg 05d3b22301 docs/library: Document SSLContext cert methods and asyncio support.
Add `load_cert_chain`, `load_verify_locations`, `get_ciphers` and
`set_ciphers` SSLContext methods in ssl library, and update asyncio
`open_connection` and `start_server` methods with ssl support.

Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
2023-12-14 13:06:39 +11:00
Ihor Nehrutsa e423b3c0ba docs/esp32/quickref: Add DAC example.
Signed-off-by: IhorNehrutsa <Ihor.Nehrutsa@gmail.com>
2023-12-11 12:58:22 +11:00
Angus Gratton a800ed5ae3 docs/library/esp: Correct the description of esp.osdebug().
The behaviour described in the docs was not correct for either port.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-11-22 16:48:35 +11:00
Mark Blakeney 2888c5b230 esp32/esp32_rmt: Add RMT.PULSE_MAX constant.
If you have a variable frequency and pulse width, and you want to optimize
pulse resolution, then you must do a calculation beforehand to ensure you
normalize the array to keep all list values within bound.  That calculation
requires RMT.source_freq(), RMT.clock_div(), and this 32767 constant.

Signed-off-by: Mark Blakeney <mark.blakeney@bullet-systems.net>
2023-11-09 13:51:52 +11:00
Mark Blakeney fbb7c32040 esp32/esp32_rmt: Change RMT.source_freq() to class method.
To create an esp32.RMT() instance with an optimum (i.e. highest resolution)
clock_div is currently awkward because you need to know the source clock
frequency to calculate the best clock_div, but unfortunately that is only
currently available as an source_freq() method on the instance after you
have already created it.  So RMT.source_freq() should really be a class
method, not an instance method.  This change is backwards compatible for
existing code because you can still reference that function from an
instance, or now also, from the class.

Signed-off-by: Mark Blakeney <mark.blakeney@bullet-systems.net>
2023-11-09 13:51:47 +11:00
robert-hh f07f90f1ab mimxrt/boards/OLIMEX_RT1010: Adjust the UART pin assignment.
Olimex asked for that, getting a UART at the UEXT1 connector as well.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-11-09 13:41:44 +11:00
Damien George 03eae48847 extmod/machine_adc_block: Factor esp32 ADCBlock bindings to common code.
This is a code factoring to have the Python bindings in one location, and
all the ports use those same bindings.  At this stage only esp32 implements
this class, so the code for the bindings comes from that port.

The documentation is also updated to reflect the esp32's behaviour of
ADCBlock.connect().

Signed-off-by: Damien George <damien@micropython.org>
2023-11-07 16:44:35 +11:00
robert-hh 6866d17d8f docs/samd: Fix the pinout for SAMD21 Itsy Bitsy Express M0.
And the "Pin", "GPIO" and "Name" key explanations.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-11-06 11:09:09 +11:00
robert-hh e63d7189bc docs/mimxrt: Change the examples which denote a Pin with a number.
This option was removed in PR #12211.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-11-05 08:30:34 +11:00
Jim Mussared bbd8760bd9 all: Update Python formatting to ruff-format.
This updates a small number of files that change with ruff-format's (vs
black's) rules.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-11-03 13:30:41 +11:00
Jim Mussared 6cd99910cd docs/reference/micropython2_migration: Add migration guide.
This is just scaffolding for now, but the idea is that there should be an
addition to this file for every commit that uses the
`MICROPY_PREVIEW_VERSION_2` macro.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-27 15:28:46 +11:00
Thomas Ackermann ac4f79592b docs/library/io: Remove io.FileIO and io.TextIOWrapper.
FileIO and TextIOWrapper were removed in
e65d1e69e8.  Remove them also from the
documentation.

Signed-off-by: Thomas Ackermann <th.acker@arcor.de>
2023-10-16 23:07:13 +11:00
Damien George a1be5e1439 docs/reference/mpyfiles: Document change in .mpy sub-version.
Signed-off-by: Damien George <damien@micropython.org>
2023-10-16 11:28:32 +11:00
Jim Mussared 69e34b6b6b all: Switch to new preview build versioning scheme.
See https://github.com/micropython/micropython/issues/12127 for details.

Previously at the point when a release is made, we update mpconfig.h
and set a git tag. i.e. the version increments at the release.

Now the version increments immediately after the release. The workflow is:
1. Final commit in the cycle updates mpconfig.h to set (X, Y, 0, 0) (i.e.
   clear the pre-release state).
2. This commit is tagged "vX.Y.0".
3. First commit for the new cycle updates mpconfig.h to set (X, Y+1, 0, 1)
   (i.e. increment the minor version, set the pre-release state).
4. This commit is tagged "vX.Y+1.0-preview".

The idea is that a nightly build is actually a "preview" of the _next_
release. i.e. any documentation describing the current release may not
actually match the nightly build. So we use "preview" as our semver
pre-release identifier.

Changes in this commit:
 - Add MICROPY_VERSION_PRERELEASE to mpconfig.h to allow indicating that
   this is not a release version.
 - Remove unused MICROPY_VERSION integer.
 - Append "-preview" to MICROPY_VERSION_STRING when the pre-release state
   is set.
 - Update py/makeversionhdr.py to no longer generate MICROPY_GIT_HASH.
 - Remove the one place MICROPY_GIT_HASH was used (it can use
   MICROPY_GIT_TAG instead).
 - Update py/makeversionhdr.py to also understand
   MICROPY_VERSION_PRERELEASE in mpconfig.h.
 - Update py/makeversionhdr.py to convert the git-describe output into
   semver-compatible "X.Y.Z-preview.N.gHASH".
 - Update autobuild.sh to generate filenames using the new scheme.
 - Update remove_old_firmware.py to match new scheme.
 - Update mpremote's pyproject.toml to handle the "-preview" suffix in the
   tag. setuptools_scm maps to this "rc0" to match PEP440.
 - Fix docs heading where it incorrectly said "vvX.Y.Z" for release docs.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-06 12:10:14 +11:00
Damien George 040a96d00e docs,tools: Change remaining "urequests" references to "requests".
Signed-off-by: Damien George <damien@micropython.org>
2023-10-05 14:04:45 +11:00
Jim Mussared b329fdcb73 extmod/modnetwork: Increase max hostname length to 32.
This changes from the previous limit of 15 characters.  Although DHCP and
mDNS allow for up to 63, ESP32 and ESP8266 only allow 32, so this seems
like a reasonable limit to enforce across all ports (and avoids wasting the
additional memory).

Also clarifies that `MICROPY_PY_NETWORK_HOSTNAME_MAX_LEN` does not include
the null terminator (which was unclear before).

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-04 12:39:23 +11:00
Damien George cf490a7091 all: Fix various spelling mistakes found by codespell 2.2.6.
Signed-off-by: Damien George <damien@micropython.org>
2023-10-03 11:24:50 +11:00
Jos Verlinde a93ebd0e03 docs: Add requirements.txt file with dependencies for Sphinx.
Signed-off-by: Jos Verlinde <Jos.Verlinde@Microsoft.com>
2023-10-02 12:35:12 +11:00
Jos Verlinde 58c2c503a9 tools/mpremote: Add support for rfc2217, serial over TCP.
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
2023-09-29 14:40:17 +10:00
Damien George 9dd40d1b60 docs/conf.py: Add sphinxcontrib.jquery to extensions.
This is needed by recent versions of sphinx-rtd-theme.

Signed-off-by: Damien George <damien@micropython.org>
2023-09-18 11:02:27 +10:00
Angus Gratton 92f379cce4 docs/library/gc: Clarify mem_alloc and mem_free only for Python heap.
As raised in discussions of the ESP32 memory management changes.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-09-15 12:19:13 +10:00
Angus Gratton 26160e8ed5 docs/library/esp32: Update ESP32 idf_heap_info docs to match behaviour.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-09-15 12:19:13 +10:00
Glenn Moloney 0bafdaf5f0 esp32: Skip validation of image on boot from deepsleep.
sdkconfig.base: Add CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y.
This reduces time to boot from deepsleep by at least 200ms and can
provide significant power savings for deepsleep-based battery
applications.

docs/library/esp32.rst: Add note cautioning not to enter deepsleep after
changing the boot partition, without first performing a hard reset.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2023-09-05 22:36:06 +10:00
IhorNehrutsa 1a5bfa5024 docs/esp32/tutorial: Add example for pin access via registers.
Synchronous access to pins directly via registers.

Signed-off-by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com>
2023-09-04 23:21:50 +10:00
Jim Mussared 304f13a74e docs/library/network: Clarify network.hostname() behaviour.
This must be called before the interface connects.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-09-04 22:45:37 +10:00
Francis Dela Cruz d00105494f docs/library/platform: Add docs for the platform library.
Signed-off-by: Francis Dela Cruz <rainyworlds1@outlook.com>
2023-09-04 22:40:56 +10:00
Andy Piper 845d0c79ff docs/library/neopixel: Change link to a micropython-lib reference.
Signed-off-by: Andy Piper <andypiperuk@gmail.com>
2023-09-01 13:56:34 +10:00
Jim Mussared 32db4c58f7 extmod/moddeflate: Change default window size.
The primary purpose of this commit is to make decompress default to
wbits=15 when the format is gzip (or auto format with gzip detected). The
idea is that someone decompressing a gzip stream should be able to use the
default `deflate.DeflateIO(f)` and it will "just work" for any input
stream, even though it uses a lot of memory.

This is done by making uzlib report gzip files as having wbits set to 15
in their header (where it previously only set the wbits out parameter for
zlib files), and then fixing up the logic in `deflateio_init_read`.

Updates the documentation to match.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-09-01 12:23:37 +10:00
Angus Gratton 02620c2236 stm32/subghz: Add STM32WL55 subghz radio interface to stm module.
This is the minimum C interface to allow a modem driver to be built in
Python.  Interface is simple, with the intention that the micropython-lib
driver is the main (only) consumer of it.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-23 11:58:11 +10:00
Angus Gratton 05dcb8be99 esp32: Enable automatic Python heap growth.
Via MICROPY_GC_SPLIT_HEAP_AUTO feature flag added in previous commit.

Tested on ESP32 GENERIC_SPIRAM and GENERIC_S3 configurations, with some
worst-case allocation patterns and the standard test suite.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-08-15 10:50:46 +10:00