Commit 7ea06a3e26 moved the
`rmt_write_items()` call to fix RMT looping for ESP32-S3, but broke it for
the other ESP32s. This commit conditionally compiles the location of that
call.
Signed-off-by: Mark Blakeney <mark.blakeney@bullet-systems.net>
Prior to this change, after calling connect() the status() method for the
STA interface would either return STAT_GOT_IP or STAT_CONNECTION. The
latter would be returned because wifi_sta_connect_requested==true and
conf_wifi_sta_reconnects==0 by default. As such there was no way to know
anything about errors when attempting to connect, such as a bad password.
Now, status() can return STAT_NO_AP_FOUND and STAT_WRONG_PASSWORD when
those conditions are met.
Fixes issue #12930.
Signed-off-by: IhorNehrutsa <Ihor.Nehrutsa@gmail.com>
In ESP-IDF, enabling SPIRAM in menuconfig sets some Kconfig options:
- "Wi-Fi Cache TX Buffers" enabled. By default this tries to allocate 32 of
these when Wi-Fi is initialised, which requires 54,400 bytes of free heap.
- Switches "Type of WiFi TX buffers" from Dynamic to Static. This
pre-allocates all of the Wi-Fi transmit buffers.
Not a problem if PSRAM is initialised, but it's quite a lot of RAM if PSRAM
failed to initialise! As we use the same config for PSRAM & no-PSRAM builds
now, this either causes Wi-Fi to fail to initialise (seen on S2) or will
eat quite a lot of RAM.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
In commit 7c929d44 the console UART was changed to use the UART HAL.
Starting the UART HAL will change the UART clock from whatever it was
already configured at to UART_SCLK_DEFAULT. There is no "initialize at
existing settings" option.
This clock doesn't work with DFS.
The ESP-IDF code already takes this into account, and when DFS is enabled
it will configure the console UART to use the correct platform-specific
clock that will work with DFS.
The UART HAL init undoes this and sets it back to default.
This change will query the clock before the HAL init, then use the HAL
function to restore it back. Thus keeping the clock at the "correct"
value, which depends on platform, DFS status, and so on.
The clock frequency will be found using the UART driver function ESP-IDF
code uses for this. The existing code hard-coded a path that worked if the
clock was the APB clock and would fail otherwise.
The UART_NUM_0 define is removed because driver/uart.h already provides
this same macro.
Signed-off-by: Trent Piepho <tpiepho@gmail.com>
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>
At some point the config changed such that no messages above Error level
were compiled into the final binary.
Fixes issue #12815.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
If the hard socket limit (default 16) is reached then it's possible that
socket allocation fails but garbage collection would allow it to succeed.
Perform a GC pass and try again before giving up, similar to the logic
elsewhere in MicroPython that tries a GC pass before raising MemoryError.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
LWIP doesn't implement a timeout for blocking connect(), and such a timeout
is not required by POSIX. However, CPython will use the socket timeout for
blocking connect on most platforms. The "principle of least surprise"
suggests we should support it on ESP32 as well (not to mention it's
useful!).
This provides the additional improvement that external exceptions (like
KeyboardInterrupt) are now handled immediately if they happen during
connect(). Previously Ctrl-C would not terminate a blocking connect until
connect() returned, but now it will.
Fixes issue #8326.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit changes the Arduino board identifiers to correspond to their
official names. This helps to identify boards at runtime. At the moment
the Arduino Portenta H7 is reported as PORTENTA which is unfortunate as now
there is another Portenta board (Portenta C33) supported in MicroPython.
Also made the other identifiers for flash and network name consistent,
removed the incorrectly used MICROPY_PY_SYS_PLATFORM identifiers, and added
missing MICROPY_PY_NETWORK_HOSTNAME_DEFAULT identifiers.
Boards affected:
- stm32: ARDUINO_PORTENTA_H7, ARDUINO_GIGA, ARDUINO_NICLA_VISION
- renesas-ra: ARDUINO_PORTENTA_C33
- esp32: ARDUINO_NANO_ESP32
- rp2: ARDUINO_NANO_RP2040_CONNECT
Signed-off-by: Sebastian Romero <s.romero@arduino.cc>
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>
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>
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>
For now, this implements the functionality required for esp32 and rp2,
including support for numeric pins, rp2 alternate functions, and rp2
extended pins.
This also updates the rp2 port to use the same structure for pins.h and
pins.csv as for esp32, and moves the pin definitions directly into the
table (rather than having a table of pointers), which is a small code size
improvement.
Support for "hidden" pins in pins.csv is added (matching the stm32
implementation).
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
All ports now use `--board-csv`, `--prefix`, `--output-souce`,
`--output-header` and no longer write to stdout. This matches the esp32
implementation.
Ports that have an AF input use `--af-csv` (to match `--board-csv`).
Any additional output files are now prefixed with `output-` (e.g.
`--output-af-const`).
Default arguments are removed (all makefiles should always specify all
arguments, using default values is likely an error).
Replaced the `af-defs-cmp-strings` and `hdr-obj-decls` args for stm32 with
just `mboot-mode`. Previously they were set on the regular build, now the
logic is reversed so mboot sets it.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This improves (decreases) the latency on stdin, on SoCs with built-in USB
and using TinyUSB, like S2 and S3.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
ESP32-C3 is not Xtensa-based, so build settings are now tailored a bit
better following that fact. ESP-IDF 5.x already adds architecture-specific
modules by itself so there is no need to specify either the `xtensa` or the
`riscv` module in the build settings.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Commit c4e63ace66 enabled the SPI Ethernet
driver and that cost about 13k of firwmare size, pushing the firmware over
the limit of the D2WD and OTA board variants available size.
To fix, disable SPI Ethernet on the D2WD variant, and build the OTA variant
with size optimisation rather than performance optimisation.
Signed-off-by: Damien George <damien@micropython.org>
nic.isconnected() returns now "True", if a) the physical link is up and b)
an IP address is assigned. The latter happens often by DHCP, in which case
an active connection can be assumed. If the IP address is set manually,
nic.isconnected() would report "True" as well, if at least the physical
link is up. This matches WLAN behaviour which returns "True" when the WLAN
has an IP address.
Before, the behaviour of nic.isconneceted() was erratic, returning "True"
sometimes even without a Ethernet cable attached.
Fixes issue #12741.
Signed-off-by: robert-hh <robert@hammelrath.com>
SPI support was not enabled, and was not adapted for esp-idf v5.x. This
change enables SPI ethernet for all boards and adapts the code for esp-idf
v5.x. The change follows the sample implementation of @hemakumarm72, but
adds the changes for the other adapters as well. Further, it simplifies
the code by removing actions from netwwork_lan.c which are done in the
esp-idf drivers later, like setting the default values for .command_bits
and .address_bits, and registering the SPI interface.
Tested with a Wiznet W5500 breakout.
Signed-off-by: robert-hh <robert@hammelrath.com>
Reduces the CPU usage by the PPP thread by sleeping for one tick if
there was nothing to read; preventing the loop using 100% CPU when the
read operation has a zero timeout and immediately returns.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
Instead use the generic default defined in modbluetooth_nimble.c.
This then also allows custom boards to easily override the default
Bluetooth GAP name.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
If data is pushed over serial/JTAG too fast we may fill up stdin_ringbuf
and not be able to read all the data out of the serial/JTAG buffer. Thus
we need to explicitly poll and read the serial/JTAG RX buffer to prevent
blocking (since if the serial/JTAG buffer is already filled, we will not
get another interrupt to transfer it to the stdin ringbuffer).
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
PPP code assumes that IPv6 support is enabled. Whilst this is the default,
certain applications may want to disable IPv6 support if not needed (or to
reduce code size).
This makes the code build with CONFIG_LWIP_IPV6 disabled, reducing code by
about 30k in that case.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This provides a way to enable features and changes slated for MicroPython
2.x, by running `make MICROPY_PREVIEW_VERSION_2=1`. Also supported for
the cmake ports (except Zephyr).
This is an alternative to having a 2.x development branch (or equivalently,
keeping a 1.x release branch). Any feature or change that needs to be
"hidden" until 2.x can use this flag (either in the Makefile or the
preprocessor).
A good example is changing function arguments or other public API features,
in particular to aid in improving consistency between ports.
When `MICROPY_PREVIEW_VERSION_2` is enabled, the REPL banner is amended to
say "MicroPython (with v2.0 preview) vX.Y.Z", and sys.implementation gets a
new field `_v2` set to `True`.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The contents of machine_mem.h, machine_i2c.h and machine_spi.h have been
moved into extmod/modmachine.h.
Signed-off-by: Damien George <damien@micropython.org>
The contents of machine_bitstream.h, machine_pinbase.h, machine_pulse.h and
machine_signal.h have been moved into extmod/modmachine.h.
Signed-off-by: Damien George <damien@micropython.org>
The machine_i2c_type, machine_spi_type and machine_timer_type symbols are
already declared in extmod/modmachine.h and should not be declared anywhere
else.
Also move declarations of machine_pin_type and machine_rtc_type to the
common header in extmod.
Signed-off-by: Damien George <damien@micropython.org>
This is a code factoring to have the Python bindings in one location, and
all the ports use those same bindings. For all ports except the two listed
below there is no functional change.
The nrf port has UART.sendbreak() removed, but this method previously did
nothing.
The zephyr port has the following methods added:
- UART.init(): supports setting timeout and timeout_char.
- UART.deinit(): does nothing, just returns None.
- UART.flush(): raises OSError(EINVAL) because it's not implemented.
- UART.any() and UART.txdone(): raise NotImplementedError.
Signed-off-by: Damien George <damien@micropython.org>
No functional change, just code factoring to have the Python bindings in
one location, and all the ports use those same bindings.
Signed-off-by: Damien George <damien@micropython.org>
This factors the basic top-level I2S class code from the ports into
extmod/machine_i2s.c:
- I2S class definition and method table.
- The init and deinit method wrappers.
- The make_new code.
Further factoring will follow.
Signed-off-by: Damien George <damien@micropython.org>
With public declarations moved to extmod/modmachine.h. It's now mandatory
for a port to define MICROPY_PY_MACHINE_PWM_INCLUDEFILE if it enables
MICROPY_PY_MACHINE_PWM. This follows how extmod/machine_wdt.c works.
All ports have been updated to work with this modified scheme.
Signed-off-by: Damien George <damien@micropython.org>
There are currently 7 ports that implement machine.WDT and a lot of code is
duplicated across these implementations. This commit factors the common
parts of all these implementations to a single location in
extmod/machine_wdt.c. This common code provides the top-level Python
bindings (class and method wrappers), and then each port implements the
back end specific to that port.
With this refactor the ports remain functionally the same except for:
- The esp8266 WDT constructor now takes keyword arguments, and accepts the
"timeout" argument but raises an exception if it's not the default value
(this port doesn't support changing the timeout).
- The mimxrt and samd ports now interpret the argument to WDT.timeout_ms()
as signed and if it's negative truncate it to the minimum timeout (rather
than it being unsigned and a negative value truncating to the maximum
timeout).
Signed-off-by: Damien George <damien@micropython.org>
That can be caused e.g. by an exception. This feature is implemented in
some way already for the stm32, renesas-ra, mimxrt and samd ports. This
commit adds it for the rp2, esp8266, esp32 and nrf ports. No change for
the cc3200 and teensy ports.
Signed-off-by: robert-hh <robert@hammelrath.com>