Commit Graph

1953 Commits

Author SHA1 Message Date
aziubin
7546d3cf73 stm32/boards/NUCLEO_L476RG: Add 5 remaining UARTs.
STM32L476RG MCU of NUCLEO_L476RG board has 6 UART/USART units in total
(USART1, USART2, USART3, UART4, UART5 and LPUART1), but only UART2,
connected to REPL, was defined and available in Python code.
Defined are all 5 remaining UART/USART units including LPUART1.

Signed-off-by: Alexander Ziubin aziubin@googlemail.com
2021-04-09 15:00:55 +10:00
Damien George
ab9d47e023 esp32: Enable btree module.
This was disabled with the move to CMake, and this commit reinstates it.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-09 13:33:26 +10:00
Damien George
212fe7f33e extmod/extmod.cmake: Add support to build btree module with CMake.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-09 13:33:26 +10:00
Damien George
5dcc9b3b16 py/py.cmake: Introduce MICROPY_INC_CORE as a list with core includes.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-09 13:08:35 +10:00
Damien George
0fabda31de py/py.cmake: Move qstr helper code to micropy_gather_target_properties.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-09 13:08:35 +10:00
Damien George
7b41d7f187 stm32/boardctrl: Give boards control over execution of boot.py,main.py.
This commit simplifies the customisation of the main MicroPython execution
loop (4 macros are reduced to 2), and allows a board to have full control
over the execution (or not) of boot.py and main.py.

For boards that use the default start-up code, there is no functional
change in this commit.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-09 12:44:19 +10:00
Damien George
4d9e657f0e stm32/mpconfigport.h: Add support for a board to specify root pointers.
A board can now define MICROPY_BOARD_ROOT_POINTERS to specify any custom
root pointers.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-08 17:00:26 +10:00
Damien George
cb396827f5 stm32/boards/pllvalues.py: Relax PLLQ constraints on STM32F413 MCUs.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-07 12:47:21 +10:00
Damien George
f4340b7e62 stm32/powerctrl: Support using PLLI2C on STM32F413 as USB clock source.
So SYSCLK can run at more varied frequencies, eg 100MHz.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-07 12:47:21 +10:00
Damien George
00963a4e69 stm32/powerctrl: Allow a board to configure AHB and APB clock dividers.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-07 12:47:09 +10:00
stijn
a66286f3a0 unix: Improve command line argument processing.
Per CPython everything which comes after the command, module or file
argument is not an option for the interpreter itself.  Hence the processing
of options should stop when encountering those, and the remainder be passed
as sys.argv.  Note the latter was already the case for a module or file but
not for a command.

This fixes issues like 'micropython myfile.py -h' showing the help and
exiting instead of passing '-h' as sys.argv[1], likewise for
'-X <something>' being treated as a special option no matter where it
occurs on the command line.
2021-04-07 12:41:25 +10:00
Tim Radvan
4f53f462ca rp2: Import uarray instead of array in rp2 module.
Some forum users noticed that `sm.exec()` took longer the more was present
on the flash filesystem connected to the RP2040.  They traced this back to
the `array` import inside `asm_pio()`, which is causing MicroPython to scan
the filesystem.

uarray is a built-in module, so importing it shouldn't require scanning the
filesystem.

We avoid moving the import to the top-level in order to keep the namespace
clean; we don't want to accidentally expose `rp2.array`.
2021-04-07 10:06:18 +10:00
Damien George
25ae169e6e stm32: Include .ARM section in firmware for C++ exception handling.
Support for C++ was added in 97960dc7de but
that commit didn't include the C++ exception handling table in the binary
firmware image.  This commit fixes that.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-06 12:11:15 +10:00
Damien George
2d8aecd2ad rp2/CMakeLists.txt: Enable USB enumeration fix.
This is a workaround for errata RP2040-E5, and is needed to make USB more
reliable on certain USB ports.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-06 11:40:02 +10:00
Damien George
d87f42b0e5 examples/usercmodules: Simplify user C module enabling.
It's a bit of a pitfall with user C modules that including them in the
build does not automatically enable them.  This commit changes the docs and
examples for user C modules to encourage writers of user C modules to
enable them unconditionally.  This makes things simpler and covers most use
cases.

See discussion in issue #6960, and also #7086.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-01 16:27:38 +11:00
Michael O'Cleirigh
ec79e44502 esp32: Fix multiple definition errors with mp_hal_stdout_tx functions.
It was noticed that the esp32 port didn't build ulab correctly.  The
problem was a multiple defintion of the 'mp_hal_stdout_tx_str' and
'mp_hal_stdout_tx_strn_cooked' functions.

They were defined in stdout_helpers.c but also in the
ports/esp32/mphalport.c.

Fixed by removing stdout_helpers.c from the build.

Signed-off-by: Michael O'Cleirigh <michael.ocleirigh@rivulet.ca>
2021-04-01 15:44:25 +11:00
Michael O'Cleirigh
0ccd9e08aa esp32: Restore USER_C_MODULE support with new CMake build system.
Support for User C and C++ modules was lost due to upgrading the esp32 to
the latest CMake based IDF from the GNUMakefile build process.

Restore the support for the esp32 port by integrating with the approach
recently added for the rp2 port.

Signed-off-by: Michael O'Cleirigh <michael.ocleirigh@rivulet.ca>
2021-04-01 15:43:15 +11:00
Liam Fraser
ca3d51f122 rp2: Don't advertise remote wakeup for USB serial.
This USB feature is currently not supported.  With this flag enabled (and
the feature not implemented) the USB serial will stop working if there is a
delay of more than about 2 seconds between messages, which can occur with
USB autosuspend enabled.

Fixes issue #6866.
2021-03-31 13:50:21 +11:00
Phil Howard
0cf12dd59c rp2: Add support for USER_C_MODULES to CMake build system.
The parts that are generic are added to py/ so they can be used by other
ports that use CMake.

py/usermod.cmake:

* Creates a usermod target to hang user C/CXX modules from.
* Gathers sources from user C/CXX modules and libs for QSTR scan.

ports/rp2/CMakeLists.txt:

* Includes py/usermod.cmake.
* Links the resulting usermod library to the MicroPython target.

py/mkrules.cmake:

Add cxxflags to qstr.i.last custom command for CXX modules:

* MICROPY_CPP_FLAGS so CXX modules will find includes.
* -DNO_QSTR to fix fatal error missing "genhdr/qstrdefs.generated.h".

Usage:

The rp2 port can be linked against user C modules by running:

make USER_C_MODULES=/path/to/module/micropython.cmake

CMake will print a list of included modules.

Co-authored-by: Graham Sanderson <graham.sanderson@raspberrypi.org>
Co-authored-by: Michael O'Cleirigh <michael.ocleirigh@rivulet.ca>
Signed-off-by: Phil Howard <phil@pimoroni.com>
2021-03-31 00:26:01 +11:00
Phil Howard
ccc388f157 rp2/mpthreadport.h: Cast core_state to _mp_state_thread_t.
Required for user C++ code to build successfully against ports/rp2.

Signed-off-by: Phil Howard <phil@pimoroni.com>
2021-03-31 00:25:51 +11:00
Damien George
4fc2866f45 bare-arm: Clean up the code, make it run on an F405, and add a README.
This commit simplifies and cleans up the bare-arm port, and adds just
enough system and library code to make it execute on an STM32F405 MCU.

The mpconfigport.h configuration is simplified to just specify those
configuration values that are different from the defaults.  And the
addition of -fdata-sections and -ffunction-sections means the final
firmware is smaller than it previously was, by about 4200 bytes.

A README is also added.

Signed-off-by: Damien George <damien@micropython.org>
2021-03-19 14:20:26 +11:00
Damien George
6e5aea08a9 stm32/Makefile: Allow QSTR_DEFS,QSTR_GLOBAL_DEPENDENCIES to be extended.
So a board can provide custom qstr definitions if needed.

Signed-off-by: Damien George <damien@micropython.org>
2021-03-17 10:25:16 +11:00
stijn
d53a6d58b0 stm32/Makefile: Fix C++ linker flags when toolchain has spaces in path.
The GNU Make dir command uses spaces as item separator so it does not
work for e.g building the STM32 port on Cygwin with a default Arm
installation in "c:/program files (x86)/GNU Arm Embedded Toolchain".
Fix by using POSIX dirname on a quoted path instead.
2021-03-16 12:54:16 +11:00
Damien George
a9140ab09b rp2: Use core-provided cmake fragments instead of custom ones.
Signed-off-by: Damien George <damien@micropython.org>
2021-03-14 15:53:18 +11:00
Damien George
eccd73a403 extmod/extmod.cmake: Add modonewire.c to MICROPY_SOURCE_EXTMOD list.
Signed-off-by: Damien George <damien@micropython.org>
2021-03-14 15:51:28 +11:00
Damien George
dcaf702578 rp2/modmachine: Enable machine.Signal class.
Fixes issue #6863.

Signed-off-by: Damien George <damien@micropython.org>
2021-03-14 00:19:04 +11:00
Damien George
8010b15968 rp2: Enabled more core Python features.
This brings the port's configuration closer to the stm32 and esp32 ports.

Signed-off-by: Damien George <damien@micropython.org>
2021-03-14 00:17:22 +11:00
Kevin Köck
af45d511f1 rp2: Enable uerrno module.
Fixes #6991.
2021-03-13 23:34:50 +11:00
Damien George
6129b8e401 tests: Rename run-tests to run-tests.py for consistency.
Signed-off-by: Damien George <damien@micropython.org>
2021-03-12 19:56:09 +11:00
Damien George
b24fcd7aec esp32/machine_hw_spi: Use default pins when making SPI if none given.
The default pins can be optionally configured by a board.

Fixes issue #6974.

Signed-off-by: Damien George <damien@micropython.org>
2021-03-12 10:56:25 +11:00
Andrew Scheller
b6489425c6 rp2/rp2_flash: Prevent MICROPY_HW_FLASH_STORAGE_BASE being set negative. 2021-03-12 00:57:29 +11:00
robert-hh
c675452566 rp2/modmachine: Re-init UART for REPL on frequency change.
When UART is used for REPL and the MCU frequency is changed, the UART
has to be re-initialised.  Besides that the UART may have to be recreated
after a frequency change, but with USB REPL this is not a problem.

Thanks to @HermannSW for spotting and providing the change.
2021-03-12 00:49:30 +11:00
robert-hh
11cf742524 rp2/modmachine: Allow changing CPU clock frequency.
Using the standard machine.freq().

The safe ranges tested were 10 and 12-270MHz, at which USB REPL still
worked.  Requested settings can be checked with the script:
pico-sdk/src/rp2_common/hardware_clocks/scripts/vcocalc.py.  At frequencies
like 300MHz the script still signaled OK, but USB did not work any more.
2021-03-12 00:48:46 +11:00
robert-hh
0461640983 rp2/rp2_pio: Fix sm.get(buf) to not wait after getting last item.
sm.get(buf) was waiting for one item more than the length of the supplied
buffer.  Even if this item was not stored, sm_get would block trying to get
an item from the RX fifo.

As part of the fix, the edge case for a zero length buffer was moved up to
the section where the function arguments are handled.  In case of a zero
length buffer, sm.get() now returns immediately that buffer.
2021-03-12 00:39:26 +11:00
robert-hh
a075e0b7d8 rp2/rp2_pio: Allow more than 8 consecutive pins for PIO out/set/sideset.
The bitmasks supplied for initialization of out/set/sideset were only 8 bit
instead of 32.  This resulted in an error, that not more than 8 consecutive
pins would get initialized.

Fixes issue #6933.
2021-03-12 00:26:32 +11:00
robert-hh
da85cb014a rp2/machine_uart: Add support for inverted TX and RX lines.
Usage as in the other ports:

    keyword "invert"
    constants: INV_TX and INV_RX

Sample: uart = UART(1, invert=UART.INV_TX | UART.INV_RX)
2021-03-11 18:27:53 +11:00
robert-hh
8ade163fff rp2/machine_uart: Add timeout/timeout_char to read and write. 2021-03-11 18:19:15 +11:00
StereoRocker
8610bababe rp2: Enable VfsFat class for FAT filesystem support.
Allows interfacing with SD cards, for example.
2021-03-11 17:56:21 +11:00
svetelna
23ce25a7c3 mimxrt/boards: Add MIMXRT1050_EVK board, based on MIMXRT1060_EVK. 2021-03-11 16:42:38 +11:00
Mike Causer
8785acac22 esp32/Makefile: Specify port and baud on erase_flash command. 2021-03-11 15:49:10 +11:00
Damien George
c33c749f64 stm32/boardctrl: Add MICROPY_BOARD_STARTUP hook.
Signed-off-by: Damien George <damien@micropython.org>
2021-03-11 09:04:36 +11:00
Reinhard Feger
79c186f5c9 stm32/spi: Fix baudrate calculation for H7 series.
Fixes issue #6342.
2021-03-11 01:06:52 +11:00
Peter Hinch
0facd891e7 stm32/powerctrl: Save and restore EWUP state when configuring standby.
This allows the user to enable wake-up sources using the EWUP bits, on F7
MCUs.

Disabling the wake-up sources while clearing the wake-up flags follows the
reference manual and ST examples.
2021-03-11 00:56:01 +11:00
Braiden Kindt
85ea4ac0e5 stm32/main: Fix passing state.reset_mode to init_flash_fs.
state.reset_mode is updated by `MICROPY_BOARD_BEFORE_SOFT_RESET_LOOP` but
not passed to `init_flash_fs`, and so factory reset is not executed on
boards that do not have a bootloader.  This bug was introduced by
4c3976bbca

Fixes #6903.
2021-03-10 23:50:40 +11:00
Herwin Grobben
35c602d3b8 stm32/make-stmconst.py: Allow "[]" chars when parsing source comments.
For STM32WB MCUs, EXTI offset addresses were not parsed due to the
appearance of "[31:0]" in a comment in the .h file.
2021-03-10 23:44:02 +11:00
Andrew Leech
59a129f22f stm32/storage: Prevent attempts to read/write invalid block addresses.
A corrupt filesystem may lead to a request for a block which is out of
range of the block device limits.  Return an error instead of passing the
request down to the lower layer.
2021-03-09 15:32:50 +11:00
Damien George
680ce45323 stm32/rfcore: Allow BLE settings to be changed by a board.
Two of the defaults have also changed in this commit:

- MICROPY_HW_RFCORE_BLE_LSE_SOURCE changed from 1 to 0, which configures
  the LsSource to be LSE (needed due to errata 2.2.1).

- MICROPY_HW_RFCORE_BLE_VITERBI_MODE changed from 0 to 1, which enables
  Viterbi mode, following all the ST examples.

Signed-off-by: Damien George <damien@micropython.org>
2021-03-02 12:14:54 +11:00
Damien George
53f5bb05a9 rp2,stm32: Enable MICROPY_PY_UBINASCII_CRC32 to get ubinascii.crc32().
These ports already have uzlib enabled so this additional ubinascii.crc32
function only costs about 90 bytes of flash.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-23 10:13:25 +11:00
Damien George
75db0b9079 esp32: Define MICROPY_QSTRDEFS_PORT to include special qstrs.
Fixes issue #6942.

Signed-off-by: Damien George <damien@micropython.org>
2021-02-21 15:56:54 +11:00
Damien George
03a64f2077 stm32/boards/NUCLEO_WB55: Enable LPUART1 on PA2/PA3.
Signed-off-by: Damien George <damien@micropython.org>
2021-02-21 15:49:33 +11:00