Changes are:
- Disable internal flash storage and use the external QSPI for storage.
- Disable default bootloader entry mode. The bootloader entry function
exists in board_init.c.
- Remove OSC enable/disable macros (this board doesn't have an OSC).
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This was previously hard-coded to "Micropy" / "Mass Storage" / "1.0".
Now allow it to be overridden by a board.
Also change "Micropy" to "MicroPy" and "1.0" to "1.00" to match stm32.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This was previously hard-coded to "MicroPy" / "pyboard Flash" / "1.00".
Now allow it to be overridden by a board.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Add "CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y" to
ports/esp32/boards/sdkconfig.base so that all micropython esp32 images
support OTA rollback in the bootloader. These images can then be converted
to OTA-capable images as required by user tools.
Also remove CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y from board-specific
sdkconfig files as this is now the default.
Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
While cyw43 is deinitialized, an interrupt occurs. That is handled with
these lines: ports/rp2/mpnetworkport.c#L59-L61 and as pendsv is disabled
while in network code, the poll function then just waits there.
When deinit has finished, the poll func is executed, but skipped:
src/cyw43_ctrl.c#L222-L225 this skips the `CYW43_POST_POLL_HOOK` which
would re-enable interrupts, but also reset `cyw43_has_pending`.
And in that state, the lightsleep code, will skip sleeping as it thinks
there is a network packet pending to be handled.
With this change applied, lightsleep works as expected when the wifi chip
is enabled, and when it's powered off.
Applies to newly-added ARDUINO_PORTENTA_C33 and UM_NANOS3.
Makes the list match the standard features defined in
24a6e951ec.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This was copied from minimal/mpconfigport.h, but it doesn't make sense
for general ports.
Add a comment to minimal/mpconfigport.h to explain why it specifically
overrides it.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This provides a way to build a non-DEBUG host binary that still has symbols
and debug information.
Document this for the unix port, and update a comment in the unix port
Makefile.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This gets the calculation working properly for H5 MCUs, and fixes the
switch statement to switch on csel&7 instead of csel&3.
Signed-off-by: Damien George <damien@micropython.org>
The include of HAL headers should come after the HAL configuration defines,
so that the headers can see whether the defines were made or not, to
provide defaults and configure various things.
Signed-off-by: Damien George <damien@micropython.org>
Integrate DAC support for STM32H5. Implement STM32H5 GPDMA driver. The DMA
driver is largely different from other STM32 variants. To support the DAC
circular mode, memory based linked list DMA descriptors are used.
Signed-off-by: Rene Straub <rene@see5.ch>
Changes are:
- Run ADC on PCLK/16.
- Verify and optimize timings (ADC_STAB_DELAY_US, ADC_SAMPLETIME_DEFAULT).
- Add support for STM32H5 VBAT and COREVDD channels on ADC2.
- Replace ADC constants in machine_adc_locals_dict_table.
- Convert STM32 literal to channel numbers in adc_config_channel with
corresponding STM32 LL library functions (__LL_ADC_IS_CHANNEL_INTERNAL(),
__LL_ADC_CHANNEL_TO_DECIMAL_NB()).
Reasoning for the second last point: the STM32 driver literals are uint32_t
that don't work with MP_ROM_INT() which handles signed 31 bit integers
only. Introduce enumerator machine_adc_internal_ch_t to define external
channels (0..19), internal channels (256..) and the special channel VREF
(0xffff). Values are converted to STM32 literals with adc_ll_channel()
when required in adc_config_and_read_u16().
Signed-off-by: Rene Straub <rene@see5.ch>
Select ADC instance based on pin information to support ADC2 inputs.
Display ADC instance number similar to machine_adc (STM32H5 only):
<ADC2 on Pin(Pin.cpu.F14, mode=Pin.ANALOG) channel=6>
Signed-off-by: Rene Straub <rene@see5.ch>
Fixed the preliminary STM32H5 ADC support for pyb.ADC:
- Run ADC on PCLK/16.
- Use STM32 ADC library channel literals (__HAL_ADC_DECIMAL_NB_TO_CHANNEL).
- Use correct temperature conversion for H5 (30C, 130C calibration points).
Signed-off-by: Rene Straub <rene@see5.ch>
To simulate a partial erase, the code reads a native block, erases it,
and writes back the data before and after the erased area. However, the
current logic was filling the area after the erased block with data
from the beginning of the native block-aligned data, instead of applying
the proper offset.
Fixes#12474.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
If a board needs these outputs then it can define MICROPY_HW_CLK_PLLQ/R.
It saves power to not enable them if they are not needed.
Signed-off-by: Damien George <damien@micropython.org>
Currently, check_esp_err() raises an exception without a location in the
source code, eg:
Traceback (most recent call last):
File "<stdin>", line 8, in <module>
OSError: (-258, 'ESP_ERR_INVALID_ARG')
This commit allows additional error reporting (function, line and file) to
be enabled via detailed exceptions. Change the error reporting config to
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED)
and then exception messages from IDF errors look like:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: (-258, "0x0102 ESP_ERR_INVALID_ARG in function 'set_duty_u16'
at line 342 in file './machine_pwm.c'")
Signed-off-by: Ihor Nehrutsa <IhorNehrutsa@gmail.com>
Fixes are:
- The baudrate argument is a keyword arg, it was passed before as a
positional arg.
- Use the port and baudrate arguments passed from higher level code instead
of the hard-coded port ID and baudrate, which would allow HCI drivers to
change baudrates.
- Increase UART char timeout and RX buffer size.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This patch generates a binary firmware image (*.bin) and removes the split
TEXT1/0_ADDR/SECTIONS because it's not configured for this port so it
generates broken binaries.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Newer MCU series have additional fields in the struct which need to be
initialised to zero, eg Break2AFMode on WB55.
This work was funded by Planet Innovation.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
.. and switch makerfabs tft7 over to it as a test.
We have our existing way of "reserving" PSRAM for esp-idf (we actually
control it all but add back the "reserved" part). However, this does
not work with off the shelf esp_lcd, which only will allocate a
framebuffer in PSRAM if CONFIG_SPIRAM_USE_CAPS_ALLOC (or CONFIG_SPIRAM_USE_ALLOC)
is defined, not if CONFIG_SPIRAM_USE_MEMMAP is.
This new way is possibly compatible with more esp-idf code, but it complicates
CircuitPython's initial startup since nothing until port_heap_init is
permitted to use the CP heap or supervisor allocator. In practice this
seems to be OK today.
Right now this doesn't change the setting across all boards with PSRAM and so
it does not revert esp-idf to its prior state. Instead, what I'm thinking is
that we can do it during or just after the IDF5 update when sdkconfig files
will be getting an overhaul anyway.
With DEBUG build and a consle UART, this would occur early during startup on makerfabs tft7:
```
I (0) cpu_start: Starting scheduler on APP CPU.
I (10) uart: queue free spaces: 20
***ERROR*** A stack overflow in task uart_event_task has been detected.
Backtrace: 0x403786f2:0x3fce9f40 0x403820a9:0x3fce9f60 0x403850da:0x3fce9f80 0x40383a7d:0x3fcea000 0x40382158:0x3fcea030 0x4038214e:0xa5a5a5a5 |<-CORRUPTED
```
Decoded backtrace was not enlightening:
```
0x403786f2: panic_abort at /home/jepler/src/circuitpython/ports/espressif/build-makerfabs_tft7/esp-idf/../../esp-idf/components/esp_system/panic.c:408
0x403820a9: esp_system_abort at /home/jepler/src/circuitpython/ports/espressif/build-makerfabs_tft7/esp-idf/../../esp-idf/components/esp_system/esp_system.c:137
0x403850da: vApplicationStackOverflowHook at /home/jepler/src/circuitpython/ports/espressif/build-makerfabs_tft7/esp-idf/../../esp-idf/components/freertos/port/xtensa/port.c:407
0x40383a7d: vTaskSwitchContext at /home/jepler/src/circuitpython/ports/espressif/build-makerfabs_tft7/esp-idf/../../esp-idf/components/freertos/tasks.c:3505
0x40382158: _frxt_dispatch at /home/jepler/src/circuitpython/ports/espressif/build-makerfabs_tft7/esp-idf/../../esp-idf/components/freertos/port/xtensa/portasm.S:436
0x4038214e: _frxt_int_exit at /home/jepler/src/circuitpython/ports/espressif/build-makerfabs_tft7/esp-idf/../../esp-idf/components/freertos/port/xtensa/portasm.S:231
0x00000000: ?? ??:0
```
Adding an additional 512 bytes of stack allowed CircuitPython to start
successfully.
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>
And use it in the Bluetooth bindings instead of setting the baudrate by a
call to the NXP lib.
Also fixes machine_uart.c to work with a baud rate of 921600.
Signed-off-by: robert-hh <robert@hammelrath.com>
- Superfluous comments in MP_DEFINE_CONST_OBJ_TYPE stop correct macro
expanding.
- MP_ERROR_TEXT now gives mp_rom_error_text_t, but we want plain const
char *.
Signed-off-by: David Yang <mmyangfl@gmail.com>
In CPython, `_thread.start_new_thread()` returns an ID that is the same ID
that is returned by `_thread.get_ident()`. The current MicroPython
implementation of `_thread.start_new_thread()` always returns `None`.
This modifies the required functions to return a value. The native thread
id is returned since this can be used for interop with other functions, for
example, `pthread_kill()` on *nix. `_thread.get_ident()` is also modified
to return the native thread id so that the values match and avoids the need
for a separate `native_id` attribute.
Fixes issue #12153.
Signed-off-by: David Lechner <david@pybricks.com>
When calling ppp.active(False) we could get a crash due to immediately
returning after asking FreeRTOS to delete the current task.
This commit adds a simple blocking loop, the same as used in all other
places where we call vTaskDelete(NULL).
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
Showing the period alway as microsecond quantities, since tick_hz is
assumed as 1_000_000 if the period is given by freq=xxx. If the period is
larger than 0xffffffff, the value is divided by 1000 and "000" is appended
in the display. That works for periods up to about 50 days.
Signed-off-by: robert-hh <robert@hammelrath.com>
Needed for mip to find a default location to install to.
Like esp32, samd uses "/" as the mount point for the flash. Make _boot.py
add the entry after successfully mounting.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
If we're reading from an UART with a non-zero timeout, we can release the
GIL so that other threads/tasks may run while we are sleeping waiting for
data to arrive.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
CONFIG_USB_OTG_SUPPORTED is automatically set by the ESP-IDF when the chip
supports USB-OTG, which is the case for the ESP32-S2 and ESP32-S3.
When trying to use the JTAG console with these chips, it would not work
because our USB implementation will take over control over the USB port,
breaking the JTAG console in the process.
Thus, when the board is configured to use the JTAG console, we should not
enable our USB console support.
Additionally, this change also frees up UART0 when an USB-based console is
configured, since there's no reason to prevent (re)configuration of UART0
for other uses in that case.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
This implements support for SO_BINDTODEVICE, which allows telling a socket
to use a specific interface instead of lwIP automatically selecting one.
This allows devices that have multiple connections (for example cellular
over PPP in addition to WLAN) to explicitly choose which data is send over
which connection, which may have different reliability and or (mobile data)
costs associated with using them.
The used lwIP network stack already has support for this, so all that was
needed was to expose this functionality in MicroPython. This commit
exposes a new constant SO_BINDTODEVICE which can be set as an socket
option. As a value it expects the name of the interface to bind to. These
names can be retrieved using `.config('ifname')` implemented on each
interface type (including adding in this commit a `.config()` method to
PPP, which it didn't have before), which returns a string with the
interface name:
>>> import machine
>>> import network
>>> network.WLAN(network.AP_IF).config('ifname')
'lo0'
>>> wlan = network.WLAN(network.AP_IF)
>>> wlan.active(True) and wlan.config('ifname')
'ap1'
>>> wlan = network.WLAN(network.STA_IF)
>>> wlan.active(True) and wlan.config('ifname')
'st1'
>>> ppp = network.PPP(machine.UART(0))
>>> ppp.active(True) and ppp.config('ifname')
'pp1'
>>> ppp = network.PPP(machine.UART(0))
>>> ppp.active(True) and ppp.config('ifname')
'pp2'
>>> ppp = network.PPP(machine.UART(0))
>>> ppp.active(True) and ppp.config('ifname')
'pp3'
Note that lo0 seems to be returned by lwIP if the interface is not yet
active. The method can also return None in the case of PPP where the
entire lwIP interface doesn't yet exist before being activated. Currently
no effort is made to unify those cases; it is expected that whatever we
receive from lwIP is valid.
When the socket option is set, this forces using a specific device:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, 'st1')
setsockopt will throw (OSError: [Errno 19] ENODEV) if the specified
interface does not exist.
Tested with LAN, WLAN, and PPP; can specify which interface should be used
and when testing with, for example, HTTP requests to ifconfig.co the
returned IP address confirms a specific interface was used.
Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
With using UART FIFO, the timeout should be long enough that FIFO becomes
empty. Since previous data transfer may be ongoing, the timeout must be
timeout_char multiplied by FIFO size + 1.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
Since commit 3533924c36 the zlib module has
been replaced by the new deflate module. This commit updates the script
fwupdate.py to use the new deflate module.
Signed-off-by: Oliver Joos <oliver.joos@hispeed.ch>
Down to 50 baud (in reverence to Jean-Maurice-Émile Baudot). Implemented
for the MIMXRT10xx MCU's only. The MIMXRT1176 runs down to 300 baud.
Signed-off-by: robert-hh <robert@hammelrath.com>
The code did not check at deinit whether a UART was initialized. That did
not matter for all MCU's except MIMXRT1176, which crashes at the second
soft reset in a row.
But since it is a general problem to use UART methods of a UART which has
been deinitialized, checks were added to all applicable methods for a clear
response instead of e.g. a crash.
Deinitialize UART using software reset. It resets the UART but keeps it
accessible for software, avoiding an exception when UART registers are
accessed after a DeInit.
Signed-off-by: robert-hh <robert@hammelrath.com>
Following other ports, IRQ priorities and related functions are moved to
their own header, to simplify mpconfigport.h.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit allows other ports to reuse the CYW43 HCI driver, by replacing
all Bluetooth UART and control named pins with defines in config files and
using `mpbthci` abstract functions (i.e. `mp_bluetooth_hci_*`) instead of
the STM32 specific UART functions.
Note: the function `cywbt_wait_cts_low` does not need to switch the CTS
pin from alternate function to GPIO to read it. At least on stm32, mimxrt
it's possible to just read the pin input. For example, see the STM32F7
RM0410 section 6.3.11, and the `SION` for IMXRT. So this function can
also be available for other ports if the pin mode switching is removed.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit adds the necessary configuration and hooks to get the CYW43
driver working with the mimxrt port.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This is a basic SDIO driver for the mimxrt port, that was added mainly to
support the CYW43 WiFi driver, and as such it only supports the commands
required by the CYW43 driver (but more commands can be added easily). The
driver performs non-blocking DMA transfers, and can detect and recover from
errors.
Note: because the mimxrt port is missing static alternate functions, named
pins and other pin related functions, currently the alternate functions for
USDHC 1 and 2 are hard-coded in the driver.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Add portable pin config macros to mphalport.h. And add a function to
configure pins with more pin options such as alt function, pull, speed,
drive, interrupt mode, etc.
Note: this new `machine_pin_config()` function can replace
`machine_pin_set_mode()`, but the latter is left as-is to avoid breaking
anything.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This is not working/tested. The display requires an initialization sequence,
and its SPI bus is on the other side of an I2C GPIO expander making things
more difficult.
The rp2 port was enabling SSL and had finalizers enabled via the "extra
features" level, but missed explicitly enabling `MICROPY_PY_SSL_FINALISER`
(like esp32, stm32, and mimxrt did).
This commit makes `MICROPY_PY_SSL_FINALISER` default to enabled if
finalizers are enabled, and removes the explicit setting of this for
esp32, stm32, mimxrt (because they all use the "extra features" level).
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The only reason that const had to be disabled was to make the test output
match CPython when const was involved. Instead, this commit fixes the test
to handle the lines where const is used.
Also:
- remove the special handling for MICROPY_PERSISTENT_CODE_SAVE in
unix/mpconfigport.h, and make this automatic.
- move the check for MICROPY_PERSISTENT_CODE_SAVE to where it's used (like
we do for other similar checks) and add a comment explaining it.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
It was just disabled, possibly because of size considerations, but it's
useful to be able to enable it explicitly for selected boards.
This requires some of the settings to use ?= instead of =, and fixing
a bug in the traceback module, where the chain variable is unused if
exception chaining is not enabled.
This allows the cc3200 port to be build with the standard autobuild script
rather than the custom build-cc3200-latest.sh (which is now removed).
This also fixes the path inside the zip file (by using the `-j` flag to
zip).
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This should have been added in 4815af75bc
when the variants were combined. The original non-USB variant got this
implicitly, and therefore was not in mpconfigvariant.h
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
PICO might not always be a unique name across all ports, and the
convention generally for other boards is to do VENDOR_BOARD.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This merges the existing GENERIC, GENERIC_1M, and GENERIC_512k boards
into variants of the new ESP8266_GENERIC board (renamed from GENERIC so
as not to clash with other ports).
Also moves the generation of the "OTA" variant (previously generated by
autobuild/build-esp8266-latest.sh) into the variant.
Following the convention established for the WEACTSTUDIO rp2 board, the
names of the variants are FLASH_1M and FLASH_512K (but rename the .ld files
to use MiB and kiB).
Updates autobuild to build esp8266 firmware the same way as other ports.
This requires renaming the output from firmware-combined.bin to just
firmware.bin.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Board names need to be unique across ports, and GENERIC clashes with
the ESP8266 (which will be renamed to ESP8266_GENERIC).
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This allows switching between variants without clobbering the build
output.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>