Wykres commitów

14091 Commity (98ae3126402260eab306e846d01d12af317d96a2)

Autor SHA1 Wiadomość Data
robert-hh 98ae312640 samd/samd_isr: Extend systick_ms to 64 bit.
By adding a 32 bit overflow counter.  This allows it to be used for the
time functions.
2022-10-06 22:36:26 +11:00
robert-hh 3d9940bc28 samd/mphalport: Add pin open-drain funcs, and improve delay and ticks.
The changes in this commit are:
- Add an interface for pin open-drain mode.
- Improve ticks_us() by using the us-counter.
- Improve ticks_cpu() by using the CPU's SysTick.
2022-10-06 22:35:06 +11:00
robert-hh 5af54ad61f samd/modmachine: Allow changing the CPU freq with machine.freq(f).
SAMD51 only.  Accepted values are 48_000_000 to 200_000_000.  The range
specified by Atmel is 96_000_000 to 120_000_000.
2022-10-06 22:34:42 +11:00
robert-hh b4d29fd47a samd/clock_config: Set up the clock configuration.
Clock settings:
- GCLK0: 48 MHz (SAMD21) or 120 MHz(SAMD51).
- GCLK1: 32768 Hz for driving the PLL.
- GCLK2: 48 MHz for tzhe peripheral clock.
- GCLK3: 1 MHz (SAMD21) or 8 MHz (SAMD51) for the µs ticks timer.
- GCLK8: 1 kHz for WDT (SAMD21 only).

If a 32 kHz crystal is present, it will be used as clock source.  Otherwise
the DFLL48M in open-loop mode is used.

GCLK0 for SAM51 can be changed between 48 MHz and 200 MHz.  The specified
range is 96 MHz - 120 MHz.
2022-10-06 22:33:31 +11:00
robert-hh 949a808076 samd/boards: Add ADAFRUIT_FEATHER_M4_EXPRESS and _ITSYBITSY_M0_EXPRESS.
These two boards are used for testing, so it is favorable to have them
added early.

The full test set is:
- ADAFRUIT_FEATHER_M4_EXPRESS: SAMD51 with 32kHz crystal.
- ADAFRUIT_ITSYBITSY_M0_EXPRESS: SAMD21 without crystal.
- ADAFRUIT_ITSYBITSY_M4_EXPRESS: SAMD51 without crystal.
- SEEED_XIAO: SAM21 with 32kHz crystal.
2022-10-06 22:32:01 +11:00
robert-hh c4f7c0b8a2 samd/Makefile: Alphabetically sort the source code files in Makefile. 2022-10-06 22:31:03 +11:00
robert-hh a5d5ecbf84 samd/boards: Move mcu-specific settings into a mpconfig_samdXX.h file.
Located at the boards directory. That way, the mpconfigboard.h files are
almost empty, just setting the board name and the MCU name.
2022-10-06 22:30:37 +11:00
robert-hh 0420799a84 samd/boards: Replace pins.c and pins.h by pins.csv.
The files pins.c and pins.h are generated during the build process from
pins.csv, using a make-pins.py script.
2022-10-06 22:29:49 +11:00
robert-hh 85afed569d samd: Remove the existing provisional support for REPL on UART.
It was only partially working and will be rpelaced later by a full
machine.UART class implementation.
2022-10-06 22:29:06 +11:00
Damien George 46d02c2469 tools/mpremote: Bump version to 0.4.0.
Signed-off-by: Damien George <damien@micropython.org>
2022-10-06 01:02:39 +11:00
Jim Mussared f13134e403 tools/mpremote: Fix argument handling for follow and add help strings.
Fixes in this commit are:
- Make --follow the default for "run" (accidentally changed in 68d094358).
- Add help strings for "repl": --capture --inject-file --inject-code
- Update help strings for "run".
- Fix encoding for --inject-code (accidentally broken in 68d094358).
- Remove ability to --no-follow for "eval". It was there previously because
  it shared the same code path with "exec" and "run", but makes no sense
  for "eval", so might as well remove.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-06 00:58:31 +11:00
Damien George 95c614e2b6 esp32/machine_hw_spi: Use auto DMA channel on S2, S3, C3 chips.
Auto DMA channel is supported in IDF v4.4, and is required to be used on S3
chips, so use this simpler configuration option where possible.

Fixes issue #8634.

Signed-off-by: Damien George <damien@micropython.org>
2022-10-04 17:43:48 +11:00
Angus Gratton 0e35c4de9b tools: Add pre-commit support.
Tweak the existing codeformat.py and verifygitlog.py to allow them to be
easily called by pre-commit.

(This turned out to be easier than using any existing pre-commit hooks,
without making subtle changes in the formatting.)

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2022-10-04 14:52:48 +11:00
Angus Gratton bdac8272d8 tools: Add note about uncrustify versions.
Uncrustify versions are not mutually compatible:

1. Version 0.73 or newer produce slightly different formatting. It may be
possible to tweak these by adding more config items, but this will cause
older versions to error out with 'Unknown option'.

2. Version 0.75 prints a range of deprecation warnings due to config file
changes, and returns a non-zero exit code. These are actually fixable
as most are the default value, and pp_indent has changed from 'true' to '1'
which is backwards compatible. However issue 1 remains, so probably better
to have it fail explicitly.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2022-10-04 14:34:54 +11:00
Damien George 0ee877a207 esp32/machine_i2s: Add I2S finaliser which calls deinit().
So that the FreeRTOS resources can be freed, eg on soft reset.

Fixes issue #9366.

Signed-off-by: Damien George <damien@micropython.org>
2022-10-04 11:47:06 +11:00
Jim Mussared 7705b9b9d5 tools/pyboard.py: Handle unsupported fs command.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-01 22:44:24 +10:00
Jim Mussared 12ca918eb2 tools/mpremote: Add `mpremote mip install` to install packages.
This supports the same package sources as the new `mip` tool.
 - micropython-lib (by name)
 - http(s) & github packages with json description
 - directly downloading a .py/.mpy file

The version is specified with an optional `@version` on the end of the
package name. The target dir, index, and mpy/no-mpy can be set through
command line args.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-01 22:44:24 +10:00
Jim Mussared 68d094358e tools/mpremote: Use argparse for command line parsing.
No functional change other than to allow slightly more flexibility in how
--foo arguments are specified.

This removes all custom handling for --foo args in all commands and
replaces it with per-command argparse configs.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-01 22:44:24 +10:00
Jim Mussared 413a69b94b tools/mpremote: Simplify dispatch of commands.
No functional change.

This makes each built-in command defined by just a handler method and
simplifies a lot of the logic around tracking the board state.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-01 22:44:24 +10:00
Jim Mussared 282401da5c tools/manifestfile.py: Replace recursive glob with os.walk.
Recursive glob isn't supported before Python 3.5.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-30 17:34:03 +10:00
Jim Mussared 924a3e03ec top: Replace upip with mip everywhere.
Updates all README.md and docs, and manifests to `require("mip")`.

Also extend and improve the documentation on freezing and packaging.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-30 17:34:03 +10:00
Jim Mussared ba3652f15d lib/micropython-lib: Update submodule to latest.
This brings in the `mip` tool for installing packages.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-30 00:46:26 +10:00
Jim Mussared 65ab0ec91c tools/manifestfile.py: Add `author` kwarg to metadata().
This allows future micropython-lib packages to specify an author.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-29 23:53:35 +10:00
Jim Mussared b76ddcbc83 docs/Makefile: Enable parallel compilation for Sphinx.
This has a fairly dramatic (nearly 3x on a 6-core machine) speedup for docs
compilation, with no impact on correctness.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-29 23:51:29 +10:00
stijn fecfbc3f67 py/mkenv.mk: Make CPP definition explicit for consistency. 2022-09-29 14:17:37 +02:00
Jim Mussared e4d90be680 mpy-cross/mpy_cross: Add docstrings to public methods. 2022-09-28 11:47:11 +10:00
Jim Mussared 370a87dd12 mpy-cross/mpy_cross: Add list of architectures to `__all__`.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-28 11:47:11 +10:00
Jim Mussared ee1b4a2026 mpy-cross/mpy_cross: Add a way to query the mpy version.
This returns the mpy version and sub-version for files compiled with this
mpy-cross binary.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-28 11:47:11 +10:00
Jim Mussared 71050870b8 mpy-cross/mpy_cross: Fix default path to mpy-cross binary.
Needed to be updated to use build/mpy-cross.

Also fixes some other issues in the Python wrapper:
 - Rename find_mpy_cross_binary to _find_mpy_cross_binary
 - Fix passing of -march arg.
 - Decode stdout from subprocess.
 - Print stdout from mpy-cross in __main__.py.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-28 11:37:22 +10:00
Matt Trentini bdbc44474f rp2/boards/WEACTSTUDIO: Add WEACTSTUDIO with multiple variants.
This supports 2, 4, 8 and 16MB flash variants.
2022-09-26 12:40:14 +10:00
Matt Trentini 0bc1d10557 rp2/Makefile: Add support for BOARD_VARIANTS.
Following stm32.  This allows a single board definition to define variants
of its configuration.
2022-09-26 12:38:58 +10:00
Jim Mussared 9d6f474ea4 py/objstr: Don't treat bytes as unicode in str.count.
`b'\xaa \xaa'.count(b'\xaa')` now (correctly) returns 2 instead of 1.

Fixes issue #9404.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-26 00:54:18 +10:00
Damien George dd9dcb594c esp32/machine_pwm: Don't use LEDC_USE_REF_TICK on ESP32-C3 variants.
Because it's not supported by this particular MCU (since IDF v4.4.2).

Signed-off-by: Damien George <damien@micropython.org>
2022-09-26 00:11:42 +10:00
Damien George 3abcfb9aec esp32/modsocket: Use mp_obj_is_integer to test port type.
Because the value may be a big integer, which is still a valid type to use.

Fixes issue #9410.

Signed-off-by: Damien George <damien@micropython.org>
2022-09-26 00:07:58 +10:00
yn386 e6d3513187 stm32/boards/NUCLEO_L152RE: Add NUCLEO-L152RE board support.
This change adds NUCLEO-L152RE support to the STM32 port.
NUCLEO-L152RE: https://www.st.com/en/evaluation-tools/nucleo-l152re.html
This board use STM32L152RE:
https://www.st.com/en/microcontrollers-microprocessors/stm32l152re.html
2022-09-25 23:56:41 +10:00
yn386 427d72667f stm32: Add support for STM32L1 MCUs.
This change adds STM32L1 support to the STM32 port.
2022-09-25 23:56:41 +10:00
yn386 ae0b0e7018 lib/stm32lib: Update library to get L1 v1.10.3, and some other fixes.
Changes in this new library version are:
- Add L1 HAL at v1.10.3.
- H7_HAL/rcc_ex: Add SPI45 to HAL_RCCEx_GetPeriphCLKFreq.
- L4_HAL/gpio_ex: Add #define for GPIO_AF14_TIM2 on L4P5/L4Q5.
- F4_HAL/i2c: Fix I2C frequency calculation macros.
- L1_HAL/utils: Fix compile error when USE_HAL_DRIVER is defined.
2022-09-25 23:56:20 +10:00
Jatty_ 30e50ab195 stm32/make-stmconst.py: Support TypeDef's with a single char prefix.
Update the regex to support parsing files from the STM32CubeU5 library.
2022-09-23 16:09:38 +10:00
Angus Gratton 25ff5b52d9 py/parse: Allow const types other than int to optimise as true/false.
Allows optimisation of cases like:

    import micropython
    _DEBUG = micropython.const(False)
    if _DEBUG:
        print('Debugging info')

Previously the 'if' statement was only optimised out if the type of the
const() argument was integer.

The change is implemented in a way that makes the compiler slightly smaller
(-16 bytes on PYBV11) but compilation will also be very slightly slower.

As a bonus, if const support is enabled then the compiler can now optimise
const truthy/falsey expressions of other types, like:

    while "something":
        pass

... unclear if that is useful, but perhaps it could be.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2022-09-23 16:04:13 +10:00
Angus Gratton f91ebf6fa9 tests: Allow 'special' tests to output "SKIP" on a single line. 2022-09-23 16:02:59 +10:00
Damien George f2ad152e7e extmod/modbluetooth: Run BLE IRQ callback in protected NLR context.
The call to invoke_irq_handler_run() always needs to run in a protected NLR
context, to catch exceptions from the Python handler, and the m_new's (and
also mp_local_alloc when PYSTACK is enabled).  With
MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS_WITH_INTERLOCK enabled there was
already an explicit nlr_push, and that is now used in all cases.

Without this change, on stm32 (for example), the callbacks from the BLE
stack to invoke_irq_handler() were made via static scheduled nodes which do
not have any NLR protection, and hence would lead to a hard fault (uncaught
NLR) if an exception was raised in the Python BLE IRQ handler.  This was a
regression introduced by 8045ac07f5, which is
fixed by this commit.

Signed-off-by: Damien George <damien@micropython.org>
2022-09-23 15:21:54 +10:00
Damien George db668742a5 extmod/modbluetooth: Do GATTC reassembly in protected uPy context.
The calls to m_new and m_del require an exclusive uPy (really a GC)
context.  In particular these functions cannot be called directly from a
FreeRTOS task on esp32.

Fixes issue #9369.

Signed-off-by: Damien George <damien@micropython.org>
2022-09-22 11:49:58 +10:00
Damien George ed41d51746 extmod/modbluetooth: Change data_len type from size_t to uint16_t.
For consistency, and to remove the need for additional conversion of types.

Signed-off-by: Damien George <damien@micropython.org>
2022-09-22 11:47:03 +10:00
Andrew Leech 13c4470fd0 tests/run-multitests: Make paths more deterministic.
Allows running from a different directory, etc.

This work was funded by Planet Innovation.
2022-09-20 09:07:18 +10:00
Andrew Leech 7589d86b6b tests/run-multitests: Extend usage information. 2022-09-20 09:07:02 +10:00
Jim Mussared 920da9c5e3 unix/variants/coverage: Add test for manifest freeze_mpy().
This uses the frozentest.mpy that is also used by ports/minimal.

Also fixes two bugs that these new tests picked up:
 - File extension matching in manifestfile.py.
 - Handling of freeze_mpy results in makemanifest.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 23:51:10 +10:00
Jim Mussared 6ecdf1a240 tests/frozen: Move frozentest.mpy from ports/ to tests/.
frozentest.mpy was previously duplicated in ports/minimal and
ports/powerpc.

This needs to be re-generated on every .mpy version increase, so might as
well just have a single copy of it.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-19 23:51:10 +10:00
stijn 9ae8d38204 extmod/vfs_posix_file: Implement finaliser for files.
Prevent handle leaks when file objects aren't closed explicitly and
fix some MICROPY_CPYTHON_COMPAT issues: this wasn't properly adhered
to because #ifdef was used so it was always on, and closing files
multiple times should be avoided unconditionally.
2022-09-19 23:44:50 +10:00
Damien George fb77be1506 py: Include filename in errors from loading/saving files via "open".
This improves error messages in mpy-cross:
- When loading a .py file that doesn't exist (or can't be opened) it now
  includes the filename in the OSError.
- When saving a .mpy file that can't be opened it now raises an exception
  (prior, it would silently fail), and includes the filename in the
  OSError.

Signed-off-by: Damien George <damien@micropython.org>
2022-09-19 23:27:08 +10:00
Damien George cc588ac3a9 py/runtime: Add mp_raise_OSError_with_filename helper function.
Useful when more detail is needed for an OSError associated with a file.

Signed-off-by: Damien George <damien@micropython.org>
2022-09-19 23:25:26 +10:00