This commit changes the cc3200 port to use the common machine
implementation of machine.disable_irq() and machine.enable_irq(). This
eliminates its dependency on the stm32 port's code. The behaviour of
cc3200 for these functions is changed:
- disable_irq() now returns an (opaque) integer rather than a bool
- enable_irq(state) must be passed and argument, which is the return value
of disable_irq() rather than a bool
Signed-off-by: Damien George <damien@micropython.org>
The ports esp32, mimxrt, rp2 and samd all shared exactly the same
implementation of machine.disable_irq() and machine.enable_irq(),
implemented in terms of MICROPY_{BEGIN,END}_ATOMIC_SECTION. This commit
factors these implementations into extmod/modmachine.c.
The cc3200, esp8266, nrf, renesas-ra and stm32 ports do not yet use this
common implementation.
Signed-off-by: Damien George <damien@micropython.org>
Minor changes for consistency are:
- nrf gains: unique_id(), freq() [they do nothing]
- samd: deepsleep() now resets after calling lightsleep()
- esp32: lightsleep()/deepsleep() no longer take kw arg "sleep", instead
it's positional to match others. also, passing 0 here will now do a 0ms
sleep instead of acting like nothing was passed.
reset_cause() no longer takes any args (before it would just ignore them)
- mimxrt: freq() with an argument and lightsleep() both raise
NotImplementedError
Signed-off-by: Damien George <damien@micropython.org>
And use it in all ports. The ports are unchanged, except esp8266 which now
just returns None from this function instead of the time elapsed (to match
other ports), and qemu-arm which gains this function.
Signed-off-by: Damien George <damien@micropython.org>
This is a code factoring to have the dict for the machine module in one
location, and all the ports use that same dict. The machine.soft_reset()
function implementation is also factored because it's the same for all
ports that did already implement it. Eventually more functions/bindings
can be factored.
All ports remain functionally the same, except:
- cc3200 port: gains soft_reset, mem8, mem16, mem32, Signal; loses POWER_ON
(which was a legacy constant, replaced long ago by PWRON_RESET)
- nrf port: gains Signal
- qemu-arm port: gains soft_reset
- unix port: gains soft_reset
- zephyr port: gains soft_reset, mem8, mem16, mem32
Signed-off-by: Damien George <damien@micropython.org>
Prior to this change, if a board did not define any hardware I2C pins, via
MICROPY_HW_I2Cx_SCL, then machine.I2C would alias to machine.SoftI2C.
That doesn't really make sense, and SoftI2C should always be used if there
is no hardware implementation. So this commit makes it so that machine.I2C
is only available if at least one set of I2C hardware pins are defined via
the MICROPY_HW_I2Cx_SCL/SDA macros.
For all boards that define at least one set of I2C hardware pins (which is
most of them) this commit is a no-op. The only boards that change are:
LEGO_HUB_NO6, LEGO_HUB_NO7, STM32H7B3I_DK.
Signed-off-by: Damien George <damien@micropython.org>
MICROPY_PY_MACHINE_SPI is defined in mpconfigport.h to be equal to
MICROPY_PY_MACHINE_HW_SPI, so they are equivalent options. The former one
is preferred because it's used by all other ports.
The default in mpconfigport.h is to enable this option, and all boards that
enable SPI have this removed from their mpconfigboard.h file so they pick
up the default.
Signed-off-by: Damien George <damien@micropython.org>
best_effort_wfe_or_timeout() already calls time_reached() and returns the
result of it, so no need to call it again.
Signed-off-by: Damien George <damien@micropython.org>
If a port defines MICROPY_SOFT_TIMER_TICKS_MS then soft_timer assumes a
SysTick back end, and provides a soft_timer_next variable that sets when
the next call to soft_timer_handler() should occur.
Otherwise, a port should provide soft_timer_get_ms() and
soft_timer_schedule_at_ms() with appropriate semantics (see comments).
Existing users of soft_timer should continue to work as they did.
Signed-off-by: Damien George <damien@micropython.org>
This allows e.g. a board (or make command line) to set
MICROPY_MANIFEST_MY_VARIABLE = path/to/somewhere
set(MICROPY_MANIFEST_MY_VARIABLE path/to/somewhere)
and then in the manifest.py they can query this, e.g. via
include("$(MY_VARIABLE)/path/manifest.py")
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
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>
Otherwise passing in a non-integer can lead to an invalid memory access.
Thanks to Junwha Hong and Wonil Jang @S2Lab, UNIST for finding the issue.
Fixes issue #13007.
Signed-off-by: Damien George <damien@micropython.org>
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>
Configuration:
- Clock is HSE, CPU runs at 250MHz.
- REPL on USB and UART connected to the ST-Link interface.
- Storage is configured for internal flash memory.
- Three LEDs and one user button.
- Ethernet is enabled.
Signed-off-by: Rene Straub <rene@see5.ch>
Replaces the previous all-zeroes "TODO" serial number.
Requires refactoring the low-level unique_id routine out from modmachine.c.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Change the rp2 and renesas-ra ports to use the helper function.
Saves copy-pasta, at the small cost of one more function call in the
firmware (if not using LTO).
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Functionality and code size don't really change, but removes port-specific
code in favour of shared code.
(The MSC implemented in shared/tinyusb depends on some functions in the
pico-sdk, so this change doesn't make this available for samd.)
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
See the commit a00c9d56db for a detailed description of the problem, a
regression introduced in 26d503298.
Same approach here as the linked fix for rp2 (applied unconditionally here
as this port only supports USB-CDC for stdin/stdout).
Signed-off-by: Angus Gratton <angus@redyak.com.au>