SAMD21: set the filesystem type to LFS1.
SAMD51: the type is already set to LFS2, support is now dropped for LFS1.
It has not been used and dropping it saves 10 k of flash.
Signed-off-by: robert-hh <robert@hammelrath.com>
This commit adds support for a new processor RA6M5. It also adds the
following classes to the machine module: PWM, DAC, SDCard.
Signed-off-by: mbedNoobNinja <novoltage@gmail.com>
* Use R_SCI_UART_BaudCalculate() of fsp/src/r_sci_uart/r_sci_uart.c
* Support UART.init(baudrate)
Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
The config header files with the same name have the same contents, so they
don't need to be repeated for each board in the board's source directory.
Signed-off-by: Damien George <damien@micropython.org>
IDF v5.0 provides access to rssi value for received espnow packets via
recv_info arg to recv_cb().
Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
This commit updates the esp32 port to work exclusively with ESP-IDF v5.
IDF v5 is needed for some of the newer ESP32 SoCs to work, and it also
cleans up a lot of the inconsistencies between existing SoCs (eg S2, S3,
and C3).
Support for IDF v4 is dropped because it's a lot of effort to maintain both
versions at the same time.
The following components have been verified to work on the various SoCs:
ESP32 ESP32-S2 ESP32-S3 ESP32-C3
build pass pass pass pass
SPIRAM pass pass pass N/A
REPL (UART) pass pass pass pass
REPL (USB) N/A pass pass N/A
filesystem pass pass pass pass
GPIO pass pass pass pass
SPI pass pass pass pass
I2C pass pass pass pass
PWM pass pass pass pass
ADC pass pass pass pass
WiFi STA pass pass pass pass
WiFi AP pass pass pass pass
BLE pass N/A pass pass
ETH pass -- -- --
PPP pass pass pass --
sockets pass pass pass pass
SSL pass ENOMEM pass pass
RMT pass pass pass pass
NeoPixel pass pass pass pass
I2S pass pass pass N/A
ESPNow pass pass pass pass
ULP-FSM pass pass pass N/A
SDCard pass N/A N/A pass
WDT pass pass pass pass
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This function was made private/static in IDF commit
c67f4c2b4c2bb4b7740f988fc0f8a3e911e56afe, so it add back here.
Signed-off-by: Damien George <damien@micropython.org>
Mostly updates comments, but also renames the UASYNCIO enum value to
ASYNCIO.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The asyncio module now has much better CPython compatibility and
deserves to be just called "asyncio".
This will avoid people having to write `from uasyncio import asyncio`.
Renames all files, and updates port manifests to use the new path. Also
renames the built-in _uasyncio to _asyncio.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Commit c046b23ea2 prevented frozen boot code
from being interrupted by Ctrl-C, but that means a corrupt filesystem will
forever lock up an esp32/esp8266 board. This commit fixes that by
explicitly enabling Ctrl-C before running the forever loop.
Signed-off-by: Damien George <damien@micropython.org>
This commit adds initial support for STM32H5xx MCUs. The following
features have been confirmed to be working on an STM32H573:
- UART over REPL and USB CDC
- USB CDC and MSC
- internal flash filesystem
- machine.Pin
- machine.SPI transfers with DMA
- machine.ADC
- machine.RTC
- pyb.LED
- pyb.Switch
- pyb.rng
- mboot
Signed-off-by: Damien George <damien@micropython.org>
The G0 USB peripheral behaves more like MICROPY_HW_USB_IS_MULTI_OTG=0 than
that config =1. This fixes the configuration of the PMA FIFO buffers.
Signed-off-by: Damien George <damien@micropython.org>
For debugging purposes, to see output from other peripherals.
Also reset the pyb_stdio_uart state at the end of soft reset, in case it
points to a heap-allocated object.
Signed-off-by: Damien George <damien@micropython.org>
This change enables the ULP (FSM) for all ESP32 variants rather than
requiring it to be enabled for each board specifically.
It also ensures the correct header file is included for each variant.
Lastly, it updates the IDF version we're builing against to v4.4.2, as that
version contains important fixes to make the ULP actually work on S2/S3
chips. See: https://github.com/espressif/esp-idf/commit/a0e3d48
Signed-off-by: Wilko Nienhaus <wilko.nienhaus@gmail.com>
In 5fe2a3f1 the ESP32 port underwent a change to how `MICROPY_PORT_DIR`
is defined. This commit normalizes the `rp2` port to use the same
underlying variable mechanism (`CMAKE_CURRENT_LIST_DIR`).
Signed-off-by: Brian 'redbeard' Harrington <redbeard@dead-city.org>
This migrates the CMake variable `MICROPY_PORT_DIR` from the ESP-IDF
defined project to the component. Previously used instances of the variable
within the project definition have been migrated to
`CMAKE_CURRENT_LIST_DIR`. Within the component (the `main` subdirectory in
the ESP32 port) we define `MICROPY_PORT_DIR` using `CMAKE_CURRENT_LIST_DIR`
and subsequently use the `MICROPY_PORT_DIR` value in all locations where
`PROJECT` had previously been used.
Context:
In commit 9b90882146, initial support was added for building with the newly
introduced CMake support provided by the ESP-IDF.
Specifically, the commit message states:
> This commit adds support for building the esp32 port with CMake, and in
particular, it builds MicroPython as a component within the ESP-IDF. Using
CMake and the ESP-IDF build infrastructure makes it much easier to maintain
the port, especially with the various new ESP32 MCUs and their required
toolchains.
`PROJECT_DIR` is a variable populated by the ESP-IDF specifically and is
not stable when used with "[Pure CMake components][1]" as documented in the
ESP-IDF. It is intended to be used in the scope of the parent of the
current file (the "project") as opposed to the current file ("the
component"). Crossing into the parent scope like this works solely when the
"project" is MicroPython, but not when used as a component by other ESP-IDF
projects.
Analyzing this file, the intention is to reference the "Project" which in
the example is the parent directory. Within the [CMake variables][2]
documentation, there is one specifically defined for referencing the
directory for the CMake listfile currently being processed:
[`CMAKE_CURRENT_LIST_DIR`][3].
After making the change from `PROJECT_DIR` to `CMAKE_CURRENT_LIST_DIR`, the
reach into the parent scope defined by the ESP-IDF and the resulting CMake
interface violation is removed.
Similar to the component definition, the project `CMakeLists.txt` uses the
variable `CMAKE_SOURCE_DIR` which CMake defines as "The path to the top
level of the source tree." This commit changes the variable to
`CMAKE_CURRENT_LIST_DIR` for the reasons cited above.
[1]: https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/build-system.html#writing-pure-cmake-components
[2]: https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html
[3]: https://cmake.org/cmake/help/latest/variable/CMAKE_CURRENT_LIST_DIR.html
Signed-off-by: Brian 'redbeard' Harrington <redbeard@dead-city.org>
Following how mkrules.cmake works. This makes it easy for a port to enable
frozen code, by defining FROZEN_MANIFEST in its Makefile.
Signed-off-by: Damien George <damien@micropython.org>
This is a MicroPython-specific module that existed to support the old
version of uasyncio. It's undocumented and not enabled on all ports and
takes up code size unnecessarily.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Applies to drivers/examples/extmod/port-modules/tools.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Previously sys.path could be modified by append/pop or slice assignment.
This allows `sys.path = [...]`, which can be simpler in many cases, but
also improves CPython compatibility.
It also allows sys.path to be set to a tuple which means that you can
clear sys.path (e.g. temporarily) with no allocations.
This also makes sys.path (and sys.argv for consistency) able to be disabled
via mpconfig. The unix port (and upytesthelper) require them, so they
explicitly verify that they're enabled.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Otherwise you can get into the confusing state where e.g. sys.ps1 is
enabled in config (via `MICROPY_PY_SYS_PS1_PS2`) but still doesn't actually
get enabled.
Also verify that the required delegation options are enabled in modsys.c.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Updates any includes, and references from Makefiles/CMake.
This essentially reverts what was done long ago in commit
136b5cbd76
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
In order to keep "import umodule" working, the existing mechanism is
replaced with a simple fallback to drop the "u".
This makes importing of built-ins no longer touch the filesystem, which
makes a typical built-in import take ~0.15ms rather than 3-5ms.
(Weak links were added in c14a81662c)
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This renames the builtin-modules, such that help('modules') and printing
the module object will show "module" rather than "umodule".
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The QSPI driver provides the interface for using an on-board QSPI flash for
the filesystem. It provides the same methods as the driver for the
internal flash and uses the same name. Therefore, only one of the drivers
for internal flash, SPI flash and QSPI flash must be enabled at a time.
Signed-off-by: robert-hh <robert@hammelrath.com>
The SPI flash driver includes the block device for being used as a
filesystem. It provides the same methods as the driver for the internal
flash.
Signed-off-by: robert-hh <robert@hammelrath.com>
For SAMD21 devices, the board flash signals must be named in pins.csv as
FLASH_MOSI, FLASH_MISO, FLASH_SCK, FLASH_CS for creating the SPI object.
And rename the QSPI pins to QSPI_xxxx instead of FLASH_xxx.
Signed-off-by: robert-hh <robert@hammelrath.com>
Updates all `help()` output to use the phrase:
`For online docs please visit http://docs.micropython.org/`
Some ports previously used different wording, some pointed to the wrong
link. Also make all ports use `help.c` for consistency.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This makes it so that sub-packages are resolved relative to their parent's
`__path__`, rather than re-resolving each parent's filesystem path.
The previous behavior was that `import foo.bar` would first re-search
`sys.path` for `foo`, then use the resulting path to find `bar`.
For already-loaded and u-prefixed modules, because we no longer need to
build the path from level to level, we no longer unnecessarily search
the filesystem. This should improve startup time.
Explicitly makes the resolving process clear:
- Loaded modules are returned immediately without touching the filesystem.
- Exact-match of builtins are also returned immediately.
- Then the filesystem search happens.
- If that fails, then the weak-link handling is applied.
This maintains the existing behavior: if a user writes `import time` they
will get time.py if it exits, otherwise the built-in utime. Whereas `import
utime` will always return the built-in.
This also fixes a regression from a7fa18c203
where we search the filesystem for built-ins. It is now only possible to
override u-prefixed builtins. This will remove a lot of filesystem stats
at startup, as micropython-specific modules (e.g. `pyb`) will no longer
attempt to look at the filesystem.
Added several improvements to the comments and some minor renaming and
refactoring to make it clearer how the import mechanism works. Overall
code size diff is +56 bytes on STM32.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This one sets the flash image length properly for the teensy loader, such
that the file system is not erased. It was already set in commit
8e54225140 but got lost when the MIMXRT1176
board was added.
Signed-off-by: robert-hh <robert@hammelrath.com>
Three bugs have been fixed in this commit:
1. When the duty was set with duty_u16(), changing the freq with pwm.freq()
would not keep relative duty rate, but the absolute pulse duration.
2. Fix another inconsistency when displaying the PWM pin's properties of a
QTMR channel.
3. Improve the error checks for the second channel being a PWM pin and pin
pairs to be a FLEXPWM A/B pair.
Signed-off-by: robert-hh <robert@hammelrath.com>
These have by default FAT support. The SAMD21 build does not support FAT.
The nrf port also implements os.sync(), but has it's own copy of moduos.c.
Code size increases seen: 40 to 56 bytes.
Signed-off-by: robert-hh <robert@hammelrath.com>
The hal_entry.c code is duplicated across all boards, so consolidate it to
a common ra_hal.c file. And remove the hal_entry() function because it
simply calls main().
Signed-off-by: Damien George <damien@micropython.org>
Also fix MAX_ENDPOINT definition for G0, which follows G4.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
By specifying rts=pin(x) and/or cts=Pin(x) in the constructor. The pad
numbers for the UART pins are fix in this case: TX must be at pad 0, RX at
pad 1, RTS at pad 2 and CTS at pad 3.
repr(uart) shows the pin names for rts and cts, if set. In case of a RX
overflow, the rx interrupt will be disabled instead of just discarding the
data. That allows RTS to act.
If RTS is inactive, still 2 bytes can be buffered in the FIFO.
Signed-off-by: robert-hh <robert@hammelrath.com>
With Crystal: set the crystal startup wait time to 1 second. It was 2
seconds before, and that seeemed too long.
With USB-Sync: scan for up to 1 second for the USB to be registered and
carry on with boot as soon as it it. Before, the code just waited for
500ms.
Side change: improve related comments.
Signed-off-by: robert-hh <robert@hammelrath.com>
These include ADC, DAC, I2C, SoftI2C, SPI, SoftI2C, PWM, UART, pulse. This
is useful for devices like the Adafruit Trinket series which have almost no
accessible GPIO pins.
Signed-off-by: robert-hh <robert@hammelrath.com>
If sockets were open when calling soft reset, gc_sweep_all() would try to
close them. In case of e.g. the NINA WiFi handler, connected through SPI,
spi_transfer() would be called for command exchange with the NINA module.
But at that time SerCom was already disabled.
Moving sercom_deinit_all() behind gc_sweep_all() solves this issue.
Signed-off-by: robert-hh <robert@hammelrath.com>
Such that they are easier to adapt. The maximum code size is set by:
MICROPY_HW_CODESIZE=xxxK
in mpconfigmcu.mk for the MCU family as default or in mpconfigboard.mk for
a specific board. Setting the maximum code size allows the loader to error
out if the code gets larger than the space dedicated for it.
Signed-off-by: robert-hh <robert@hammelrath.com>
Change UART clock source on S3/C3 so the UART can operate when CPU
frequency is below 80MHz. This allows the UART to remain operational when
using Dynamic Frequency Scaling (DFS).
Signed-off-by: Patrick Joy <patrick@joytech.com.au>
This commit enables the ULP for the S2 and S3 chips.
Note this is the FSM (Finite State Machine) ULP.
Signed-off-by: Patrick Joy <patrick@joytech.com.au>
Once all the firmware has been flashed and the final signatures checked,
mboot writes the "all good" byte into the header of the application. This
step uses the buffer firmware_head which, if unaligned in the build, fails
when cast to a uint64_t* in flash.c.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
These were incorrectly added in d995c01042.
The fix here includes the full differential ADC definitions.
Signed-off-by: brave ulysses <brave_ulysses@email.com>
When the network module was first introduced in the esp8266 port in
ee3fec3167 there was only one interface (STA)
and, to save flash, the WLAN object was aliased to the network module,
which had just static methods for WLAN operations. This was subsequently
changed in 9e8396accb when the AP interface
was introduced, and the WLAN object became a true class.
But, network.WLAN remained a function that returned either the STA or AP
object and was never upgraded to the type itself. This scheme was then
copied over to the esp32 port when it was first introduced.
This commit changes network.WLAN from a function to a reference to the WLAN
type. This makes it consistent with other ports and network objects, and
allows accessing constants of network.WLAN without creating an instance.
Signed-off-by: Damien George <damien@micropython.org>
Building the Pico-W needs the MICROPY_PY_NETWORK_CYW43 flag to be set in
order to include building the CYW43 Wifi driver. But then mp_hal_get_mac()
handles the MAC assignment for all nics the "CYW43 way", copying the real
MAC provided by the WiFi hardware. This will fail for all other NIC types,
resulting in an invalid MAC address.
The solution in this commit is to add a check for the NIC type parameter
idx and handle the MAC address respectively.
Convert to an absolute path to always reliably locate manifest.py. This is
already done in Makefile, but is also needed in CMakeLists.txt if cmake is
invoked directly.
Signed-off-by: Phil Howard <phil@pimoroni.com>
Currently rp2.StateMachine.exec(instr_in) requires that the instr_in
parameter be a string representing the PIO assembly language instruction
to be encoded by rp2.asm_pio_encode(). This commit allows the parameter
to also be of integral type. This is useful if the exec() method is
being called often where the use of pre-encoded machine code is
desireable.
This commit still supports calls like:
sm.exec("set(0, 1)")
It also now supports calls like:
# Performed once earlier, maybe in __init__()
assembled_instr = rp2.asm_pio_encode("out(y, 8)", 0)
# Performed multiple times later as the PIO state machine is
# configured for its next run.
sm.exec(assembled_instr)
The existing examples/rp2/pio_exec.py and examples/rp2/pio_pwm.py that
exercise the rp2.StateMachine.exec() method still work with this change.
Signed-off-by: Adam Green <adamgrym@yahoo.com>
FSP v4.4.0 refers to CMSIS V5.4.1, and __COMPILER_BARRIER() is used in bsp.
On the other hand, lib/cmsis is V5.1.0 and the macro is not defined.
Therefore, compile error happens.
As the workaround, the macro definition is added.
If lib/cmsis is updated in the future, this addition can be removed.
Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
This modifies the windows port Makefile to use += for QSTR_DEFS and
QSTR_GLOBAL_DEPENDENCIES so that variants can add additional files if
needed (similar to stm32 port).
Signed-off-by: David Lechner <david@pybricks.com>
This modifies the unix port Makefile to use += for QSTR_DEFS and
QSTR_GLOBAL_DEPENDENCIES so that variants can add additional files if
needed (similar to stm32 port).
Signed-off-by: David Lechner <david@pybricks.com>