In case there is a power failure after during this operation, the key must
be the last thing that is written, to indicate valid data.
Signed-off-by: Damien George <damien@micropython.org>
The default CYW43 WiFi AP settings were missing the security mode, leaving
the AP in open mode by default. That's changed by this commit to use
WPA/WPA2 by default.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
The C-based SPI flash driver is needed because the
`_copy_file_to_raw_filesystem()` function must copy from a filesystem (eg
FAT) to another part of flash, and the same C code must be used for both
reading (from FAT) and writing (to flash).
Signed-off-by: Damien George <damien@micropython.org>
This is enabled by default if MBOOT_FSLOAD is enabled, although a board
can explicitly disable it by `#define MBOOT_VFS_RAW (0)`.
Signed-off-by: Damien George <damien@micropython.org>
Disabled by default, but enabled on all boards that previously had
`MICROPY_PY_MACHINE_BARE_METAL_FUNCS` enabled.
Signed-off-by: Damien George <damien@micropython.org>
Adds Dx and Ax named pins for Arduino Gigi, Arduino Nicla Vision and
Arduino Portenta H7. The analog pins include the dual-pad _C pins.
Signed-off-by: Sebastian Romero <s.romero@arduino.cc>
This commit adds support for the dual-analog-pads on STM32H7 parts. These
pads/pins are called PA0_C/PA1_C/PC2_C/PC3_C in the datasheet. They each
have an analog switch that can optionally connect them to their normal pin
(eg PA0). When the switch is open, the normal and _C pin are independent
pins/pads.
The approach taken in this commit to make these _C pins available to Python
is:
- put them in their own, independent row in the stm32h7_af.csv definition
file, with only the ADC column defined (they are separate machine.Pin
entities, and doing it this way keeps make-pins.py pretty clean)
- allow a board to reference these pins in the board's pins.csv file by the
name PA0_C etc (so a board can alias them, for example)
- these pins (when enabled in pins.csv) now become available like any other
machine.Pin through both machine.Pin.board and machine.Pin.cpu
- BUT these _C pins have a separate pin type which doesn't have any
methods, because they don't have any functionality
- these _C pins can be used with machine.ADC to construct the appropriate
ADC object, either by passing the string as machine.ADC("PA0_C") or by
passing the object as machine.ADC(machine.Pin.cpu.PA0_C)
- if a board defines both the normal and _C pin (eg both PA0 and PA0_C) in
pins.csv then it must not define the analog switch to be closed (this is
a sanity check for the build, because it doesn't make sense to close the
switch and have two separate pins)
Signed-off-by: Damien George <damien@micropython.org>
This new DMA API corrects possible cache coherency issues on chips with
D-Cache, when working with buffers at arbitrary memory locations (i.e.
supplied by Python code).
The API is used by SPI to fix an issue with corrupt data when reading from
SPI using DMA in certain cases. A regression test is included (it depends
on external hardware connection).
Explanation:
1) It's necessary to invalidate D-Cache after a DMA RX operation completes
in case the CPU reads (or speculatively reads) from the DMA RX region
during the operation. This seems to have been the root cause of issue
#13471 (only when src==dest for this case).
2) More generally, it is also necessary to temporarily mark the first and
last cache lines of a DMA RX operation as "uncached", in case the DMA
buffer shares this cache line with unrelated data. The CPU could
otherwise write the other data at any time during the DMA operation (for
example from an interrupt handler), creating a dirty cache line that's
inconsistent with the DMA result.
Fixes issue #13471.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
The existing MPU_CONFIG_DISABLE macro enables the MPU region but disables
all access to it.
The rename is necessary to support an MPU_CONFIG_DISABLE macro that
actually disables the MPU region entirely.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
With LAN8742, LAN8720, LAN83825 and DP83848 as possible options, and the
symbols PHY_LAN8720, PHY_LAN8742, PHY_DP83825 and PHY_DP8348. The default
is PHY_LAN8742 which is the existing behaviour.
The eth_init() parameters for the Portenta H7 board are set to phy_addr=0
and phy_type=LAN8742, which matches the previous defaults and the
schematics.
Tested with LAN8720 and DP83848 breakout boards at 10M Duplex and 100M
Duplex modes.
Signed-off-by: robert-hh <robert@hammelrath.com>
The default value is 0, which is compatible with the existing behaviour.
Implementing that required changes to eth.c as well. The value of phy_addr
is added to the eth_t data type.
Tested with a STM32F767 and a STM32H750 device.
Signed-off-by: robert-hh <robert@hammelrath.com>
The STATIC macro was introduced a very long time ago in commit
d5df6cd44a. The original reason for this was
to have the option to define it to nothing so that all static functions
become global functions and therefore visible to certain debug tools, so
one could do function size comparison and other things.
This STATIC feature is rarely (if ever) used. And with the use of LTO and
heavy inline optimisation, analysing the size of individual functions when
they are not static is not a good representation of the size of code when
fully optimised.
So the macro does not have much use and it's simpler to just remove it.
Then you know exactly what it's doing. For example, newcomers don't have
to learn what the STATIC macro is and why it exists. Reading the code is
also less "loud" with a lowercase static.
One other minor point in favour of removing it, is that it stops bugs with
`STATIC inline`, which should always be `static inline`.
Methodology for this commit was:
1) git ls-files | egrep '\.[ch]$' | \
xargs sed -Ei "s/(^| )STATIC($| )/\1static\2/"
2) Do some manual cleanup in the diff by searching for the word STATIC in
comments and changing those back.
3) "git-grep STATIC docs/", manually fixed those cases.
4) "rg -t python STATIC", manually fixed codegen lines that used STATIC.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Because `mpthreadport.h` is included by `mpthread.h`.
Also remove unnecessary include of `mpthreadport.h` in esp32's `main.c`.
Signed-off-by: Damien George <damien@micropython.org>
The patch enables SDRAM banks 1 and 2 to be accessible at 0xC0000000 and
0xD0000000 respectively (default mapping) or remapped to addresses
0x60000000 and 0x70000000.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
The size of the flash varies among MCU variants. Instead of requiring a
build-time variable to configure this, compute it at runtime using the
special device information word accessible through the FLASH_SIZE macro.
This feature is currently only implemented for H5 MCUs, but can be extended
to others.
Signed-off-by: Damien George <damien@micropython.org>
Currently, only the processor's SPI2 bus is enabled (though the related
pins are labeled SPI1 in the Portenta H7 documentation). This commit
enables the processor's SPI1 bus, which is accessible via the board's
high-density connectors.
Signed-off-by: Jim Lipsey <github@lipsey.org>
Changes include:
- Some mbedtls source files renamed or deprecated.
- Our `mbedtls_config.h` files are renamed to `mbedtls_config_port.h`, so
they don't clash with mbedtls's new default configuration file named
`mbedtls_config.h`.
- MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE is deprecated.
- MBEDTLS_HAVE_TIME now requires an `mbedtls_ms_time` function to be
defined but it's only used for TLSv1.3 (currently not enabled in
MicroPython so there is a lazy implementation, i.e. seconds * 1000).
- `tests/multi_net/ssl_data.py` is removed (due to deprecation of
MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE), there are the existing
`ssl_cert_rsa.py` and `sslcontext_server_client.py` tests which do very
similar, simple SSL data transfer.
- Tests now use an EC key by default (they are smaller and faster), and the
RSA key has been regenerated due to the old PKCS encoding used by openssl
rsa command, see
https://stackoverflow.com/questions/40822328/openssl-rsa-key-pem-and-der-conversion-does-not-match
(and `tests/README.md` has been updated accordingly).
Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
The standard Arduino pinout uses LEDR/G/B and LED_BUILTIN (if available).
This patch adds aliases to match the standard pinout, while retaining
LED_RED/GREEN/BLUE for compatibility with existing scripts and examples.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Sets MICROPY_QSTR_BYTES_IN_HASH==0 on stm32x0 boards.
This saves e.g. 2kiB on NUCLEO_F091.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This reverts the change from ce2058685b.
Without abspath, the build artefacts (object files) for boards with source
files are placed outside the build directory, because the BOARD_DIR
variable starts with "..". For the list of source files added to SRC_C,
none of them can start with "..". The usual fix for that would be to make
the files relative to the top of the MicroPython repo (because of the vpath
rule), eg ports/stm32/boards/$(BOARD). But then the $(wildcard ...)
pattern won't find files in this directory.
So abspath is necessary, although it will prevent building when there is a
space in the path. A better solution for spaces needs to be found.
Signed-off-by: Damien George <damien@micropython.org>
Make can't handle paths with spaces, see https://savannah.gnu.org/bugs/?712
The following workarounds exist:
- When using make's built-in functions:
- Use relative paths wherever possible to avoid spaces in the first
place.
- All spaces in paths can be escaped with backslashes; quotes don't
work.
- Some users use the shell to temporarily rename directories, or to
create symlinks without spaces.
- When using make to pass commands to the system's shell, enclose paths in
quotes. While make will still interpret quoted strings with spaces as
multiple words, the system's shell will correctly parse the resulting
command.
This commit contains the following fixes:
- In ports/stm32/mboot/Makefile: Use relative paths to avoid spaces when
using built-in functions.
- In all other files: Use quotes to enclose paths when make is used to call
shell functions.
All changes have been tested with a directory containing spaces.
Signed-off-by: Iksas <iksas@mailbox.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>