The `_start` function prototype is now declared as no-return, so `main()`
can't return.
To fix this, `main()` is replaced with `_start`.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
In CMSIS 5.9.0, the compiler headers define `__VECTOR_TABLE`, which will be
substituted with its corresponding value (e.g., `__Vectors` for gcc).
However, the linker script in this port can't include compiler headers when
it's processed, so `__VECTOR_TABLE` is used as the literal variable name,
which results in an undefined linker error.
To fix this, the two possible values of `__VECTOR_TABLE` are both defined
in the linker script.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Adds support to asyncio.gather() for the case that one or more (or all)
sub-tasks finish and/or raise an exception before the gather starts.
Signed-off-by: Damien George <damien@micropython.org>
Switch the RTC clock source to Sub-clock (XCIN). This board has an
accurate LSE crystal, and it should be used for the RTC clock
source.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
No longer require importlib_metadata on new Python versions as it is
included in the standard distribution.
Signed-off-by: Jochen Sprickerhof <git@jochen.sprickerhof.de>
- Completes a longstanding TODO in the code, to not ignore
the optional family, type, proto and flags arguments to
socket.getaddrinfo().
- Note that passing family=socket.AF_INET6 will now cause queries
to fail (OSError -202). Previously this argument was ignored so
IPV4 results were returned instead.
- Optional 'type' argument is now always copied into the result. If not
set, results have type SOCK_STREAM.
- Fixes inconsistency where previously querying mDNS local suffix (.local)
hostnames returned results with socket type 0 (invalid), but all other
queries returned results with socket type SOCK_STREAM (regardless of
'type' argument).
- Optional proto argument is now returned in the result tuple, if supplied.
- Optional flags argument is now passed through to lwIP. lwIP has handling
for AI_NUMERICHOST, AI_V4MAPPED, AI_PASSIVE (untested, constants for
these are not currently exposed in the esp32 socket module).
- Also fixes a possible memory leak in an obscure code path
(lwip_getaddrinfo apparently sometimes returns a result structure with
address "0.0.0.0" instead of failing, and this structure would have been
leaked.)
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This was originally needed because the .c --> .o rule is:
$(BUILD)/%.o: %.c
and because the generated frozen_content.c is inside build-FOO, it must
therefore generate build-FOO/build-FOO/frozen_content.o.
But 2eda513870 added a new build rule for
pins.c that can also be used for frozen_content.c.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
CPython says thread identifier is a "nonzero integer", so rp2 should use a
1-indexed core number rather than 0-indexed. This fixes the
thread/thread_ident1 test failure on rp2 port.
Unfortunately this may be a breaking change for rp2 code which makes a
hard-coded comparison of thread identifier to 0 or 1.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
If there are any free chunks found then it's better to sweep the filesystem
and use the available chunks, rather than error out with ENOSPC when there
is in fact a bit of space remaining.
Signed-off-by: Damien George <damien@micropython.org>
Compare the full absolute path instead of relying on the path form
passed by the user.
For instance, this will make
python3 run-tests.py -d basics
python3 run-tests.py -d ./basics
python3 run-tests.py -d ../tests/basics
python3 run-tests.py -d /full/path/to/basics
all behave the same by correctly treating the bytes_compare3 and
builtin_help tests as special, whereas previously only the first
invocation would do that and hence result in these tests to fail
when called with a different path form.
Signed-off-by: stijn <stijn@ignitron.net>
Increases firmware size by +140 bytes and uses +4 extra bytes of RAM, but
allows the test suite to run without crashing.
Signed-off-by: Damien George <damien@micropython.org>
Flash sectors should start counting at 0 for each bank. This commit makes
sure that is the case on all H5 and H7 MCUs, by using `get_page()` instead
of `flash_get_sector_info()`.
Signed-off-by: Damien George <damien@micropython.org>
This commit removes the need for a separate `flash_cache_sector_id`
variable, instead using `flash_cache_sector_start` to indicate which sector
is curretly cached (and -1 indicates no sector).
Signed-off-by: Damien George <damien@micropython.org>
An erase sector sits in a given flash bank and some MCUs have two flash
banks. If trying to erase a range of sectors and that range crosses from
one flash bank into the next, the original implementation of
`flash_erase()` would not handle this case and would do the wrong thing.
This commit changes `flash_erase()` to only erase a single sector, which
sidesteps the need to handle flash-bank-crossing. Most callers of this
function only need to erase a single sector anyway.
Signed-off-by: Damien George <damien@micropython.org>
Newer STM32 parts have homogeneous flash layout, and in this case the MCU
configuration and page/sector calculation can be simplified. The affected
functions are `flash_is_valid_addr()` and `flash_get_sector_info()`, which
are now simpler for homogeneous flash.
Signed-off-by: Damien George <damien@micropython.org>
This commit replaces the linker symbol `_mboot_writable_flash_start` with
`_mboot_protected_flash_start` and `_mboot_protected_flash_end_exclusive`,
to provide better configuration of the protected flash area.
Signed-off-by: Damien George <damien@micropython.org>
Following ad806df857 where the
MICROPY_PY_PENDSV_ENTER/REENTER/EXIT macro definitions were moved to
mphalport.h.
Signed-off-by: Damien George <damien@micropython.org>
Codespell doesn't pick up "re-used" or "re-uses", and ignores the tests/
directory, so fix these manually.
Signed-off-by: Damien George <damien@micropython.org>
Implement the typical 're-run the failed tests' most test runners have, for
convenience. Accessible via the new --run-failures argument, and
implemented using a json file containing a list of the failed tests.
Signed-off-by: stijn <stijn@ignitron.net>
Otherwise running the tests can take a long time when the server is a slow
target (RP2040 takes 23 seconds for a handshake when using 4096-bit RSA).
Also add instructions on how to generate elliptic curve key/certs.
Signed-off-by: Damien George <damien@micropython.org>
This matches the behaviour of run-tests.py, which sets cwd to the directory
containing the test script, which helps to isolate the filesystem.
It means that the SSL tests no longer need to know the name of their
containing directory to find the certificate files, and helps to run these
tests on bare-metal.
Signed-off-by: Damien George <damien@micropython.org>
The existing thread_sleep1.py test only tests execution, not accuracy, of
time.sleep. Also the existing test only tests sleep(0) on targets like rp2
that can only create a single thread.
The new test in this commit checks for timing accuracy on the main thread
and one other thread when they run at the same time.
Signed-off-by: Damien George <damien@micropython.org>
The aim of this commit is to make it so that the existing thread tests can
be used to test the _thread module on the rp2 port. The rp2 port only
allows up to one thread to be created at a time, and does not have the GIL
enabled.
The following changes have been made:
- run-tests.py skips mutation tests on rp2, because there's no GIL.
- run-tests.py skips other tests on rp2 that require more than one thread.
- The tests stop trying to start a new thread after there is an OSError,
which indicates that the system cannot create more threads.
- Some of these tests also now run the test function on the main thread,
not just the spawned threads.
- In some tests the output printing is adjusted so it's the same regardless
of how many threads were spawned.
- Some time.sleep(1) are replaced with time.sleep(0) to make the tests run
a little faster (finish sooner when the work is done).
For the most part the tests are unchanged for existing platforms like esp32
and unix.
Signed-off-by: Damien George <damien@micropython.org>
Prior to this commit there is a potential deadlock in
mp_thread_begin_atomic_section(), when obtaining the atomic_mutex, in the
following situation:
- main thread calls mp_thread_begin_atomic_section() (for whatever reason,
doesn't matter)
- the second core is running so the main thread grabs the mutex via the
call mp_thread_mutex_lock(&atomic_mutex, 1), and this succeeds
- before the main thread has a chance to run save_and_disable_interrupts()
a USB IRQ comes in and the main thread jumps off to process this IRQ
- that USB processing triggers a call to the dcd_event_handler() wrapper
from commit bcbdee2357
- that then calls mp_sched_schedule_node()
- that then attempts to obtain the atomic section, calling
mp_thread_begin_atomic_section()
- that call then blocks trying to obtain atomic_mutex
- core0 is now deadlocked on itself, because the main thread has the mutex
but the IRQ handler (which preempted the main thread) is blocked waiting
for the mutex, which will never be free
The solution in this commit is to use mutex enter/exit functions that also
atomically disable/restore interrupts.
Fixes issues #12980 and #13288.
Signed-off-by: Damien George <damien@micropython.org>