This commit unifies the configuration of MICROPY_PY_CRYPTOLIB,
MICROPY_PY_HASHLIB_MD5 and MICROPY_PY_HASHLIB_SHA1, so they are enabled by
default if MICROPY_PY_SSL is enabled. This matches the existing
configuration of most of the ports.
With this change, all ports remain the same except:
- reneses-ra now enables MICROPY_PY_CRYPTOLIB, MICROPY_PY_HASHLIB_MD5 and
MICROPY_PY_HASHLIB_SHA1.
- rp2 now enables MICROPY_PY_HASHLIB_MD5.
Signed-off-by: Damien George <damien@micropython.org>
This is a very minor code simplification, which reduces code size by about
-8 bytes. It should have no functional change.
Signed-off-by: Damien George <damien@micropython.org>
This commit fixes the encoding of conditional branch opcodes emitted for
ARMv7-M targets, when the emitter decides to use the T3 encoding for
said operation.
Fields J1 and J2 are now present in the generated opcode word, along
with correcting some minor issues in bitmasks and shifts computation.
This fixes#17940.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Necessary on the unix port when running with sanitizers, as the newly
increased stack size can run all tests at N=5000 without raising
RuntimeError, and increasing N to fix this causes issues on other
configurations.
This way the test progressively builds a deeper data structure until it
fails with RuntimeError. This is theoretically slower, but not noticeably
so in reality.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
The specific problem seems to be that the runtime "Python stack frame"
function call is several times more expensive in stack usage when running
with UBSan on older GCC (observed on gcc 11.4 as used in CI, would get
'RuntimeError: maximum recursion depth exceeded' when running some tests
with UBSan enabled.)
Other stack usage (i.e. from pushing things on the stack in Python) stays
the same. Whatever causes the usage seems to be mostly gone in later GCC
versions.
Includes a refactor to apply the same stack size multipliers
for the default thread stack size same as the main stack size.
This goes in a new port-specific header as it depends on macros
in misc.h, so can't be in mpconfigport.h.
A side effect of this is that the default thread stack size is
now doubled on ARM, same as the main stack size.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Clang and gcc>=14 can use __has_feature() to detect if a sanitizer
is enabled, but older GCC has no mechanism - need to set a macro
explicitly for this to be recognised.
Necessary for increasing some resource limits in sanitizer builds.
Important not to use to avoid real issues!
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Also rewrite the sanitizer argument variables to not assume a variant.
longlong variant currently fails in this config, due to a bug fixed
in follow-up commit.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Typo on line 29 (PYH instead of PHY).
Compilation failing, here is the output:
eth_phy.h:28: error: header guard 'MICROPY_INCLUDED_STM32_PHY_H'
followed by '#define' of a different macro [Werror=header-guard]
28 | #ifndef MICROPY_INCLUDED_STM32_PHY_H
eth_phy.h:29: note: 'MICROPY_INCLUDED_STM32_PYH_H' is defined here;
did you mean 'MICROPY_INCLUDED_STM32_PHY_H'?
29 | #define MICROPY_INCLUDED_STM32_PYH_H
Signed-off-by: Tico06 <e.grammatico@gmail.com>
The generated binary file was missing this section, which caused a hard
fault when loading bin or dfu firmware (eg on ARDUINO_GIGA).
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
For STM32H5, to use 12-bit DAC, the DMA parameter should set:
- Actual DMA source datawidth to CTR1.
- The length is the amount of data to be transferred from source to
destination in bytes.
Also, this commit modifies the (dummy) definition of DMA_CIRCULAR for
STM32H5 to prevent conflict with data width specification.
Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
Updates the Zephyr port build instructions and CI to use the latest
Zephyr release tag.
Tested on max32690fthr and frdm_k64f.
Signed-off-by: Maureen Helm <maureen.helm@analog.com>
The lwIP includes are now port-specific.
The `sys_arch_{,un}protect` functions are not used according to line 34
of `extmod/lwip-include/lwipopts_common.h`.
Neither have been touched in nearly a decade.
Signed-off-by: Thomas Watson <twatson52@icloud.com>
The HP and HE CPUs have double-precision hardware floating point, so can
use the armv7emdp architecture.
This allows frozen code to use native/viper/asm_thumb decorators.
Fixes issue #17896.
Signed-off-by: Damien George <damien@micropython.org>
They are enabled when SSL/mbedTLS is included in the firmware. These new
features cost around +1400 bytes of code size.
Signed-off-by: Damien George <damien@micropython.org>
The LPRTC peripheral is a 32-bit counter with a 16-bit prescaler. It's
configured here to count at 1Hz (to get maximum date range) and then the
prescaler value is used to get 30 microsecond resolution. That's
essentially a 32+15=47-bit counter.
Signed-off-by: Damien George <damien@micropython.org>
This factors code out of the ports and into the common `time.localtime`
implementation in `extmod/modtime.c`. That helps to reduce code
duplication, prevent errors in implementation, and reduce code size on
some ports (mimxrt and stm32 at least).
Signed-off-by: Damien George <damien@micropython.org>
It's only used once, in the same file it's defined, and making it static
reduces code size.
Along with this, the associated example code comment in `ports/unix/main.c`
has been removed.
Signed-off-by: Damien George <damien@micropython.org>
They are instead checked by `binary_op_maybe()`, which catches exceptions
for invalid int/float operations.
This is a follow-up to 69ead7d98e
Signed-off-by: Damien George <damien@micropython.org>
CMake builds relied upon the parent Makefile removing the entire
build directory to successfully clean build artifacts.
py/mkrules.cmake: Add ADDITIONAL_CLEAN_FILES properties to ensure a
"make clean" from within the build directory removes
the genhdr and frozen_mpy directories.
Signed-off-by: Phil Howard <github@gadgetoid.com>
ringbuffer.size must be at least 2, and is a 16-bit quantity.
This fixes several cases including the one the fuzzer discovered, which
would lead to a fatal signal when accessing the object.
Fixes issue #17847.
Signed-off-by: Jeff Epler <jepler@gmail.com>
There's a slight code size increase paid for by using setpixel_checked for
the last pixel of a line, instead of repeating the checks inline.
Signed-off-by: Jeff Epler <jepler@gmail.com>
If mp_int_t is wider than int, then the tests such as `xend < 0` can fail
even when the amount of scrolling requested is out of range. This resulted
in a segmentation fault when attempting an out-of-bounds access to the
framebuffer.
Signed-off-by: Jeff Epler <jepler@gmail.com>
Previously, any test needing an SSL certificate file would automatically
skip if the file could not be found. But that makes it too easy to
accidentally skip tests.
Instead, change it so that the test fails if the certificate file doesn't
exist. That matches, for example, the fact that the test fails if
networking (LAN, WiFi) is not active.
Signed-off-by: Damien George <damien@micropython.org>
There are currently a few tests that are excluded when using the native
emitter because they test printing of exception tracebacks, which includes
line numbers. And the native emitter doesn't store line numbers, so gets
these tests wrong.
But we'd still like to run these tests using the native emitter, because
they test useful things even if the line number info is not in the
traceback (eg that threads which crash print out their exception).
This commit adds support for native-specific .exp files, which are of the
form `<test>.py.native.exp`. If such an .exp file exists then it take
precedence over any normal `<test>.py.exp` file.
(Actually, the implementation here is general enough that it also supports
`<test>.py.bytecode.exp` as well, if bytecode ever needs a specific exp
file.)
Signed-off-by: Damien George <damien@micropython.org>
This cleans up the test to remove all unused code, making it smaller,
a bit faster to deploy to a target to run, and also use less RAM on the
target (which may help it run on targets that are just slightly out of
memory running it).
Signed-off-by: Damien George <damien@micropython.org>
This gets the recursive stress-tests working on this port.
For relatively small Python functions the maximum recursive depth is about
150 nested calls.
Signed-off-by: Damien George <damien@micropython.org>
Because these ports run tests as part of CI, and need to be run if any of
the tests change, to check those changes.
Signed-off-by: Damien George <damien@micropython.org>
Instead of using a feature check. This is more consistent with how other
optional modules are skipped.
Signed-off-by: Damien George <damien@micropython.org>
The unicode tests are now run on all targets that enable unicode. And
other unicode tests (namely `extmod/json_loads.py`) are now properly
skipped if the target doesn't have unicode support.
Signed-off-by: Damien George <damien@micropython.org>
Ports that now run the stress tests, that didn't prior to this commit are:
cc3200, esp8266, minimal, nrf, renesas-ra, samd, qemu, webassembly.
Signed-off-by: Damien George <damien@micropython.org>
This simplifies the code by removing the explicit addition of the "float/"
test directory for certain targets. It also means the tests won't be added
incorrectly, eg on a unix build without float.
Signed-off-by: Damien George <damien@micropython.org>
Macros in misc.h depend on values defined by including mpconfig.h.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This adds a compile-time flag to disable some "unsafe" and non-standard
typecodes in struct, array and related modules.
This is useful to turn off when fuzzing, as improper use of these typecodes
can crash MicroPython.
Signed-off-by: Jeff Epler <jepler@gmail.com>
This commit simplifies the emitter code in charge of generating opcodes
performing less-than and less-than-or-equal comparisons.
By rewriting the SLT/SLTU opcode generator (handling less-than
comparisons) and de-inlining the less-than comparison generator call in
the less-than-or-equal generator, the output binary is ~80 bytes smaller
(measurements taken from the QEMU port).
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>