Commit Graph

14462 Commits

Author SHA1 Message Date
Jim Mussared
8b27482692 top: Update Python formatting to black "2023 stable style".
See https://black.readthedocs.io/en/stable/the_black_code_style/index.html

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-02-02 12:51:03 +11:00
Damien George
fe2a8332ff stm32/boards/NUCLEO_H743ZI2: Refer to NUCLEO_H743ZI for frozen manifest.
Fixes build issue introduced by 6250337c9c

Signed-off-by: Damien George <damien@micropython.org>
2023-02-01 23:22:18 +11:00
Martin Milata
850f09b109 tools/mpy-tool.py: Initialize line_info_top.
Without it the line number mapping doesn't work.

Signed-off-by: Martin Milata <martin@martinmilata.cz>
2023-02-01 13:17:22 +11:00
stijn
6abf03b5d0 windows/msvc: Fix module freezing.
Make this more generally useful and in line with what the mingw
and unix ports do: 16bit dig size to work on 32bit ports, a
self-contained qstrdefs.preprocessed.h because makemanifest.py
uses that, and a dev variant which effectively puts this to use:
previously the uasyncio module wasn't frozen but instead tests
ran by importing it from the extmod/ directory.
2023-02-01 13:10:00 +11:00
stijn
7e9a15966a mpy-cross: Force forward slashes in paths.
Code in tools/mpy-tool.py and py/frozenmod.c relies on the source file
path encoded in a .mpy file to have forward slashes (e.g. by searching
for '/__init__.py').  Enforce that when creating these files, thereby
fixing import of .mpy files and frozen modules not working before
because they could have backslashes when built with the windows port.
2023-02-01 13:10:00 +11:00
stijn
e145318a81 windows/msvc: Fix qstr generation dependency.
The mpversion.h file must exist before py/ source can be preprocessed,
but this went unnoticed because micropython.vcxproj always calls
MakeVersionHdr before MakeQstrDefs.
2023-02-01 13:10:00 +11:00
stijn
65941ea0e5 windows/msvc: Make mpy-cross independent of micropython variant.
The variant.props may have incompatible build options which break
the mpy-cross build and in any case mpy-cross has nothing to do
with variant support.
2023-02-01 13:10:00 +11:00
stijn
55a76f4edd windows/msvc: Remove variant suffix from executable filename.
This is in line with the change made for other ports in d53c3b6a: since
the default output directory already includes the variant name in it
there's no need to add it to the executable as well.
2023-02-01 13:10:00 +11:00
Jim Mussared
6250337c9c ports: Make all network-capable boards use bundle-networking.
This will ensure that any board with networking support gets:
 - webrepl
 - mip
 - urequests
 - ntptime

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-02-01 12:42:06 +11:00
Damien George
c9baf498c8 lib/micropython-lib: Update submodule to latest.
This brings in the bundle-networking package.

Signed-off-by: Damien George <damien@micropython.org>
2023-02-01 12:42:06 +11:00
David Lechner
3446d440f6 shared/runtime/gchelper: Drop cpu directive from ARM asm helpers.
This drops the `.cpu` directive from the ARM gchelper_*.s files.  Having
this directive breaks the linker when targeting older CPUs (e.g. `-mthumb
-mthumb-interwork` for `-mcpu=arm7tdmi`).  The actual target CPU should be
determined by the compiler options.

The exact CPU doesn't actually matter, but rather the supported assembly
instruction set.  So the files are renamed to *_thumb1.s and *thumb2.s to
indicate the instruction set support instead of the CPU support.

Signed-off-by: David Lechner <david@pybricks.com>
2023-01-28 15:51:38 +11:00
robert-hh
c2ab1b5185 esp32/boards/OLIMEX_ESP32_POE: Remove id from and update board.json. 2023-01-28 15:29:01 +11:00
robert-hh
0baf6c80d9 nrf/mpconfigport: Enable seeding of the PRNG by the hardware RNG.
A suitable function already existed, so just the declaration was needed.
2023-01-28 15:23:26 +11:00
Jay Greco
be420bf9bb rp2/boards/NULLBITS_BIT_C_PRO: Add Bit-C PRO board. 2023-01-28 15:14:48 +11:00
Damien George
67fac4ebc5 rp2/machine_pin: Fix configuring OPEN_DRAIN with initial value.
Prior to this commit, Pin(Pin.OPEN_DRAIN, value=0) would not set the
initial value of the open-drain pin to low, instead it would be high.

Signed-off-by: Damien George <damien@micropython.org>
2023-01-24 17:29:45 +11:00
Damien George
8a0353525f rp2/main: Use mp_printf in nlr_jump_fail.
The mp_plat_print output is already being used by the subsequent call to
mp_obj_print_exception().  And this eliminates all references to printf for
this port (at least in non-debug builds).

Signed-off-by: Damien George <damien@micropython.org>
2023-01-24 16:58:29 +11:00
Damien George
1978b838b7 shared/runtime: Use mp_printf consistently, instead of printf.
Signed-off-by: Damien George <damien@micropython.org>
2023-01-24 16:57:26 +11:00
Damien George
31139b437a py/mkrules: Support mpy-tool-flags in cmake frozen code generation.
Signed-off-by: Damien George <damien@micropython.org>
2023-01-24 16:55:23 +11:00
Damien George
d387ae3444 py/objint_mpz: Catch and reject @ and @= operating on big integers.
This will also catch / and /= when float support is disabled.

Fixes issue #10544.

Signed-off-by: Damien George <damien@micropython.org>
2023-01-23 13:03:51 +11:00
robert-hh
d4a4cde42e rp2: Fix crash in a pin.irq handler.
When accessing the argument of the irq function.
2023-01-22 17:49:10 +01:00
Damien George
4f3780a156 examples/embedding: Rework example to use ports/embed.
Signed-off-by: Damien George <damien@micropython.org>
2023-01-20 22:28:50 +11:00
Damien George
a8a1ad1391 embed: Add new "embed" port which builds a simple C package.
Signed-off-by: Damien George <damien@micropython.org>
2023-01-20 22:28:50 +11:00
Alex Riesen
abaa4abd2d py: Add parenthesis to default impl of MP_OBJ_TO_PTR, MP_OBJ_FROM_PTR.
Unless MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D, these macros only work with
values and "->"/"." expressions as their sole argument.  In other words,
the macros are broken with expressions which contain operations of lower
precedence than the cast operator.

Depending on situation, the old code either results in compiler error:

 MP_OBJ_TO_PTR(flag ? o1 : o2) expands into "(void *)flag ? o1 : o2",
 which some compiler configurations will reject (e.g. GCC -Wint-conversion
 -Wint-to-pointer-cast -Werror)

Or in an incorrect address calculation:

 For ptr declared as "uint8_t *" the MP_OBJ_FROM_PTR(ptr + off)
 expands into ((mp_obj_t)ptr) + off, resulting in an obviously
 wrong address.

Signed-off-by: Alex Riesen <alexander.riesen@cetitec.com>
2023-01-20 21:59:49 +11:00
小权一句两句
94ee1b629a unix/main: Free pathbuf when there's an error opening a file. 2023-01-20 19:38:14 +11:00
Jim Mussared
fb8792c095 py/lexer: Wrap in parenthesis all f-string arguments passed to format.
This is important for literal tuples, e.g.

    f"{a,b,}, {c}" --> "{}".format((a,b), (c),)

which would otherwise result in either a syntax error or the wrong result.

Fixes issue #9635.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-01-20 17:54:32 +11:00
Andrew Leech
5c4153ea37 py/objarray: Raise error on out-of-bound memoryview slice start.
32-bit platforms only support a slice offset start of 24 bit max due to the
limited size of the mp_obj_array_t.free member.  Similarly on 64-bit
platforms the limit is 56 bits.

This commit adds an OverflowError if the user attempts to slice a
memoryview beyond this limit.

Signed-off-by: Damien George <damien@micropython.org>
2023-01-20 16:31:37 +11:00
robert-hh
d6bc34a13a esp32: Add a small delay before leaving wlan.active().
The delay is 1 ms. It avoids the crashes reported by the
issues #8289, #8792 and #9236 with esp-idf versions >= 4.2, but does
not solve an underlying problem in the esp-idf.
2023-01-19 21:31:46 +01:00
ma-lalonde
30db33d1e0 esp32/network_lan: Add support for Ethernet PHY KSZ8081.
This is available since ESP-IDF v4.4.

Signed-off-by: Damien George <damien@micropython.org>
2023-01-19 22:50:41 +11:00
Clayton Cronk
54e85fe212 esp32/boards/GENERIC_UNICORE: Add board definition for unicore chips.
Tested to work on an ESP32-MINI-1, which is a single core ESP32-U4DWH.

Signed-off-by: Clayton Cronk <awesomecronk@gmail.com>
2023-01-19 22:38:02 +11:00
robert-hh
32a858e254 esp32/boards: Add board definition for Olimex ESP32 PoE boards.
The major setting is about the PHY interface configuration.  The
configuration matches the Olimex ESP32 Gateway as well.

Tested with esp-idf v4.2.4 and Olimex ESP32 POE boards.
2023-01-19 20:24:06 +11:00
iabdalkader
3b5cafc716 stm32/Makefile: Leave DFU mode after download when using dfu-util.
Not all DFU bootloaders exit after download, this modifier is required for
some boards to reset, otherwise they sit idle in DFU mode.
2023-01-19 16:23:22 +11:00
Angus Gratton
36347817ec CODECONVENTIONS: Explain uncrustify dependency for pre-commit setup.
pre-commit manages its own dependencies otherwise (including Black), but
this one is a C/C++ binary so needs to be installed independently.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2023-01-19 16:10:21 +11:00
enriquezgarc
5c10727b68 docs/zephyr/quickref: Fix zsensor module usage examples.
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
2023-01-19 16:04:24 +11:00
Chris Overgaauw
23ef29706e docs/reference/constrained: Add missing heap-dump symbols to mem_info(). 2023-01-19 15:59:29 +11:00
LiaoJingyi_winY7kp
7f6345a973 docs/library/machine.Timer: Add freq argument to machine.Timer.
Based on and tested on the rp2 port.

Signed-off-by: Liao Jingyi <liaojingyi2@gmail>
Signed-off-by: Damien George <damien@micropython.org>
2023-01-19 15:47:45 +11:00
Juan Francisco Cantero Hurtado
720f2cfba9 unix/Makefile: Disable building the shared library of libffi.
MicroPython doesn't need the shared library and disabling it in the
configure could ease the build of a static version of MicroPython.
2023-01-19 15:24:43 +11:00
Damien George
4eb7063608 esp8266/README: Remove notice about port being "experimental".
It has been around for a long time and the API is mature enough.

Signed-off-by: Damien George <damien@micropython.org>
2023-01-19 14:59:18 +11:00
Antonello Margottini
e30e543a75 esp8266/modnetwork: Add ability to set tx power for WLAN interface. 2023-01-19 13:39:05 +11:00
Maripo GODA
fb0dd86b39 esp32/machine_sdcard: Change dma_channel to SPI_DMA_CH_AUTO for ESP32S3.
Specifying DMA channel 2 causes an "invalid dma channel" error.  In
ESP-IDF, the only available channel for ESP32S3 is SPI_DMA_CH_AUTO=3.
2023-01-19 13:13:42 +11:00
Damien George
67097d8c2b esp32/network_lan: Fix compilation on IDF lower than v4.4.
Signed-off-by: Damien George <damien@micropython.org>
2023-01-18 13:47:10 +11:00
Damien Tournoud
c7301b8d03 esp32/network_lan: Fix setting MAC address of ethernet devices.
`esp_eth_ioctl(ETH_CMD_S_MAC_ADDR)` sets the MAC address of the hardware
device, but we also need to notify the upper layers of the change so that
e.g. DHCP work properly.
2023-01-18 11:19:12 +11:00
Damien Tournoud
e982c1d8de esp32/network_lan: Add support for SPI-based ethernet chips.
Add support for various SPI-based ethernet chips (W5500, KSZ8851SNL,
DM9051) to the ESP32 port.  This leverages the existing support in ESP-IDF
for these chips -- which configures these chips in "MAC raw" mode -- and
the existing support for network.LAN in the ESP32 port.  In particular,
this doesn't leverage the wiznet5k support that is used on the rp2 and
stm32 ports (because that's for native use of lwIP).

Tested on the POE Featherwing (with the SJIRQ solder jumper bridged) and a
ESP32-S3 feather.

A note about the interrupt pin: The W5500 implementation within ESP-IDF
relies on hardware interrupt, and requires the interrupt pin from the W5500
to be wired to a GPIO.  This is not the case by default on the Adafruit
Ethernet FeatherWing, which makes it not directly compatible with this
implementation.
2023-01-18 11:16:09 +11:00
robert-hh
30bac47b12 docs/esp32/quickref: Add docs for the LAN interface constructor.
Incorporating PR #7356.
2023-01-18 10:06:53 +11:00
robert-hh
4b52003fb8 esp32/network_lan: Support configuration of ETH ref_clk pin.
Both the direction and the Pin used for ref_clk can now be configured.  It
Requires at least idf v4.4.  The new keyword arguments to the constructor
are:

- ref_clk_mode=mode: with mode being Pin.IN or Pin.OUT.  If it is not set,
  then the default configuration is used, which may be configured by
  kconfig settings.

- ref_clk=pin_obj: which defines the Pin used for ref_clk.  This is either
  Pin(0), Pin(16) or Pin(17).  No check is done for the pin number.  If it
  is the wrong one, it simply will not work.  Besides that, no harm.
2023-01-18 10:05:13 +11:00
robert-hh
efb4bd3555 esp32/network_lan: Add support for LAN8710 PHY.
LAN8710 uses the same drivers as LAN8720, so this commit just adds the
names.  Alternatively, both could be summarised under LAN87xx, like the
esp-idf does.
2023-01-18 10:04:31 +11:00
Damien George
fc745d85fe tests/extmod/ure_namedclass: Add tests for named classes in class sets.
Signed-off-by: Damien George <damien@micropython.org>
2023-01-18 09:15:32 +11:00
Damien George
64193c7de9 lib/re1.5: Add support for named classes in class sets.
Total code size change of this and previous commit:

   bare-arm:    +0 +0.000%
minimal x86:    +0 +0.000%
   unix x64:   +32 +0.004% standard
      stm32:   +24 +0.006% PYBV10
     cc3200:   +16 +0.009%
    esp8266:   +20 +0.003% GENERIC
      esp32:   +44 +0.003% GENERIC[incl +8(data)]
     mimxrt:   +32 +0.009% TEENSY40
 renesas-ra:   +24 +0.004% RA6M2_EK
        nrf:    +0 +0.000% pca10040
        rp2:   +24 +0.005% PICO
       samd:   +32 +0.012% ADAFRUIT_ITSYBITSY_M4_EXPRESS

Addresses issue #7920.

Signed-off-by: Damien George <damien@micropython.org>
2023-01-18 09:15:32 +11:00
Damien George
bd86ce5f82 lib/re1.5: Reduce code size when checking for named class char.
Signed-off-by: Damien George <damien@micropython.org>
2023-01-18 09:15:32 +11:00
robert-hh
1583c1f670 mimxrt: Set MICROPY_GC_STACK_ENTRY_TYPE to uint32_t for large RAM.
It was uint16_t. The change sets it to uint32_t for devices with SDRAM.

Fixes issue #10366.
2023-01-16 12:26:39 +11:00
robert-hh
e78e0b7418 py/gc: Increase the address length in gc_dump_alloc_table().
Showing 8 digits instead of 5, supporting devices with more than 1 MByte of
RAM (which is common these days).  The masking was never needed, and the
related commented-out line can go.
2023-01-16 12:09:20 +11:00