This lwIP configuration file has options that are common to all ports, and
the ports are updated to use this file. This change is a no-op, the lwIP
configuration remains the same for the four ports using this common file.
This reduces code duplication, keeps the ports in sync, and makes it easier
to update the configuration for all ports at once.
Signed-off-by: Damien George <damien@micropython.org>
The memory bank addresses used for these are independent, can (and must)
enable both.
Also looks like no need to shrink these if FDCAN2 is added, the Reference
Manual is a bit unclear but looks like the peripheral's RAM multiplies out
for each additional controller.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This is redundant for bxCAN, but for CAN-FD with BRS it's otherwise unclear
which set of parameters (baudrate & sample_point or brs_baudrate &
brs_sample_point) failed to match. This makes finding a valid combination
extra annoying.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Not every baudrate or sample point combination has an exact match,
but getting within 1% on sample point and .1% on baud rate should
always be good enough.
Because the search goes from shorter bit periods (lowest brp) and
increases, the first match which meets this criteria should still mostly be
the best available.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Previously micros with the 'FDCAN' peripheral (as opposed to the older
'CAN' peripheral) needed to rename these pins in the CSVs for the CAN
driver to work.
The following CSVs in MicroPython still had FDCAN in them:
$ rg -t csv -l FDCAN boards
boards/stm32h7b3_af.csv
boards/stm32h743_af.csv
boards/stm32h573_af.csv
boards/stm32h723_af.csv
boards/stm32g0b1_af.csv
Confirmed that this allows CAN to work on NUCLEO_H723ZG board, and that at
least one board based on each of the other chips can still compile. Some of
these boards could possibly have MICROPY_HW_ENABLE_CAN set and work, now.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Reserved and static SPI buses must remain initialized during a soft reboot
as they may be used for SPI flash storage or XIP.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
A board should make this return true if the specified SPI instances should
not be deinitialized on soft-reboot.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Adds a configurable version string to a known location at the end of mboot
flash section. Also stores the options mboot was built with, eg usb and
which filesystems are supported.
A board can override the defaults, or disable the version string entirely
by setting MBOOT_VERSION_ALLOCATED_BYTES=0.
Signed-off-by: Victor Rajewski <victor@allumeenergy.com.au>
The expressions for the `micropy_hw_hse_value` etc variables may contain
parenthesis, eg `micropy_hw_hse_value = ((25) * 1000000)`. To handle such
a case, simplify the regex and always use `eval(found)` to evaluate the
expression.
Signed-off-by: Damien George <damien@micropython.org>
Adds board profile for the WeAct F411 'blackpill' which is a quite popular
low cost ST dev board. This board also has optional spiflash so can be
purchased in a few different configurations.
Builds for v3.1 with no SPI Flash by default. Includes variants for
different board versions and spi flash sizes.
Signed-off-by: Andrew Leech <andrew@alelec.net>
The existing EXTI IRQ handlers are moved from `stm32_it.c` to `extint.c` to
keep them with related code. A macro is defined to make it easier to
define the handler function that handles one line, and correct handlers
added for STM32H5xx MCUs.
Also, to prevent errors in the future, `MP_STATIC_ASSERT(<irqn> > 0)` is
added to each handler function to check that the correct `IRQn` constant is
used, which corresponds to the handler function name.
Signed-off-by: Damien George <damien@micropython.org>
This is enabled by default, but disabled when MICROPY_PREVIEW_VERSION_2 is
enabled. The intention is that these methods and constants are deprecated
in MicroPython 2.x.
Signed-off-by: Damien George <damien@micropython.org>
LFN type 2 uses the stack to allocate the internal working buffer for LFN,
which is thread-safe and saves about 512 bytes of BSS memory (at the
expense of needing that much memory on the stack).
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
I2C objects can remain active after a soft-reboot because they are
statically allocated and lack a finalizer to collect and deinitialize them.
This commit adds a `pyb_i2c_deinit_all()` function for I2C, similar to
other peripherals such as UART, DAC, etc.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
SPI objects can remain active after a soft-reboot because they are
statically allocated and lack a finalizer to collect and deinitialize them.
This commit adds a `spi_deinit_all()` functions for SPI, similar to other
peripherals such as UART, DAC, etc.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Refresh count calculations were using a hard-coded SDRAM frequency and
refresh cycles, so change them to values that can be set by a board.
And set these options to their existing values on STM32F769DISC and
STM32F7DISC boards.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This reverts commit c94a3205b0.
The idea behind this reverted commit was that it allowed to reconfigure the
UART to change only the baudrate, which is important in the context of a
PPP connection where the baudrate may be changed as part of the protocol.
Also, other ports like the rp2 port have this behaviour, where individual
parameters of the UART can be changed with the `.init()` method.
But this commit was no good for a few reasons:
1. It's a subtle breaking change to the UART API, because existing code
that constructs or initialises a UART with just the baudrate would
expect all other parameters to be reset to their defaults. But with
this commit those parameters would remain unchanged.
2. Constructing a UART like `UART(1, 9600)` also hits this code path of
only changing the baudrate and does not reset other parameters, which is
unexpected.
3. It doesn't support setting the baudrate via keyword, eg
`UART.init(baudrate=9600)`.
4. The `timeout_char` field is not updated when changing only the baudrate,
which can lead to unexpected timeouts when reading/writing.
Due to point (4), this commit broke the `tests/ports/stm32/uart.py` test,
the `uart.writechar(1)` has a timeout because the `uart.init(2400)` does
not set the `timeout_char` for the new baudrate.
Points (2)-(4) could be fixed, but point (1) (being a breaking change)
would remain as an issue. So the commit is reverted.
Signed-off-by: Damien George <damien@micropython.org>
Since the very beginning, the stm32 port (first called stm, then stmhal now
stm32) has had a special keyboard interrupt feature which works by using
PendSV to break out of any running code. This preemptive ctrl-C was added
long ago in commit 01156d510c.
The stm32 port still uses that code, and current does this:
- If ctrl-C is received on UART or USB then `mp_sched_keyboard_interrupt()`
is called (like all other ports) to set a flag for the VM to see, and
then the VM (or any loop calling `mp_handle_pending(true)`) will
eventually handle the `KeyboardInterrupt` exception, raising it via NLR.
- If another ctrl-C is received while the existing scheduled keyboard
interrupt is still pending (ie the VM has not yet processed it) then a
special hard NLR jump will activate, that preempts the calling code.
Within the PendSV interrupt the stack is adjusted and an NLR jump is made
to the most recent `nlr_push()` location. This is like a normal NLR
except it is called from an interrupt context and completely annihilates
the code that was interrupted by the IRQ.
The reason for the preemptive interrupt was to handle ctrl-C before the VM
was able to handle it. Eventually a mechanism (that's in use today by all
ports) was added to the VM and runtime to be able to check for pending
interrupts. Then the stm32 port was updated to use this mechanism, with a
fallback to the old preemptive way if a second ctrl-C was received (without
the first one being processed).
This preemptive NLR jump is problematic because it can interrupt
long-running instructions (eg store multiple, usually used at the end of a
function to restore registers and return). If such an instruction is
interrupted the CPU remembers that with some flags, and can resume the
long-running instruction when the interrupt finishes. But the preemptive
NLR does a long jump to different code at thread level and so the
long-running interrupt is never resumed. This leads to a CPU fault.
This fault has been previously reported in issues #3807 and #3842 (see also
issue #294). It's now possible to easily reproduce this problem, since
commit 69c25ea865. Running the test suite
over and over again on any stm32 board will eventually crash the board (it
can happen on a PYBv1.x, but it happens more regularly on PYBD-SF2/6).
The point is, a skipped test now soft resets the board and so the board
must run `boot.py` again. The test runner may then interrupt the execution
of `boot.py` with the double-ctrl-C that it sends (in `tools/pyboard.py`,
`enter_raw_repl()`) in order to get the board into a known good state for
the next test. If the timing is right, this can trigger the preemptive
PendSV in an unfortunate location and hard fault the board.
The fix in this commit is to just remove the preemptive NLR jump feature.
No other port has this feature and it's not needed, ctrl-C works very well
on those ports. Preemptive NLR jump is a very dangerous thing (eg it may
interrupt and break out of an external SPI flash operation when reading
code from a filesystem) and is obviously buggy.
With this commit, stm32 borads no longer hard fault when running the test
suite (but it does leave an issue, the tests can still interrupt `boot.py`
with a single ctrl-C; that will be fixed separately).
An alternative to this commit would be to clear the CPU state for the
long-running instruction as suggested in issue #3842. But it's much
simpler to just remove this code, which is now unnecessary and can have
other problems as per issue #294.
Signed-off-by: Damien George <damien@micropython.org>
lwIP was recently updated in a89ac9e24a
to STABLE-2_2_0_RELEASE, and this introduced a change in the configuration
variable `DHCP_DOES_ARP_CHECK`, renaming it to `LWIP_DHCP_DOES_ACD_CHECK`.
This commit fixes the ports lwIP settings to use the new configuration
option.
Without this option, connecting to a WiFi access-point takes about 12.5
seconds. With this option (ie disabling DHCP ARP checks) connecting takes
about 4 seconds.
Tested on an RPI_PICO_W and PYBD_SF2.
Signed-off-by: Damien George <damien@micropython.org>
The UART driver enables a pull-up on RX/CTS pins by default. This can
cause UART to fail to receive in certain situations, eg with RS485
transceivers.
This commit adds compile-time configuration options to set the pull mode on
the RX and CTS pins of each UART.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
The STM32F429DISC board definition did not have DAC enabled, however the
micro/board supports it so this commit enables the feature.
Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
Allows mpremote file transfer to work correctly when mpremote is used over
the ST-link USB/UART REPL port.
Fixes issue #8386.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
This allows UART RX to function while flash erase/writes operations are
under way, preventing lost serial data so long as it fits in the UART RX
buffer.
This enables (among other things) mpremote to successfully copy files to
boards that use a UART REPL.
Enable via the following option placed in `mpconfigboard.mk`:
MICROPY_HW_ENABLE_ISR_UART_FLASH_FUNCS_IN_RAM = 1
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
This allows enabling lwIP debugging output. For example, to enable PPP
debugging add the following to `mpconfigboard.h`:
#define LWIP_DEBUG 1
#define PPP_DEBUG LWIP_DBG_ON
Signed-off-by: Damien George <damien@micropython.org>
When timeout=0 (non-blocking mode) the UART should still wait for each
character to go out. Otherwise non-blocking mode with CTS enabled is
useless because it can only write one character at a time.
Signed-off-by: Damien George <damien@micropython.org>