Wykres commitów

323 Commity (master)

Autor SHA1 Wiadomość Data
robert-hh a06f4c8df4 mimxrt/led: Fix LED init call from main, and simplify led_init.
led_init() was not called, and therefore the machine.LED class seemed not
to work.  led_init() now uses mp_hal_pin_output() to configure the pin.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-10-09 17:10:45 +11:00
Jim Mussared 65a3ce39a3 extmod/modnetwork: Forward if.config(hostname) to network.hostname.
This removes the duplicate code in cyw43, esp32, esp8266 that implements
the same logic as network.hostname.

Renames the `mod_network_hostname` (where we store the hostname value in
`.data`) to `mod_network_hostname_data` to make way for calling the shared
function `mod_network_hostname`.

And uses memcpy for mod_network_hostname_data, because the length of source
is already known and removes reliance on string data being null-terminated.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-04 12:39:51 +11:00
robert-hh 4e5611c55a mimxrt/machine_rtc: Improve the RTC init at boot.
By clearing the tamper bits and enabling access to the registers for all
code, just in case that this was set.  It keeps the clock running on
battery and the calibration setting.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-10-02 11:35:00 +11:00
robert-hh 6482eb142c mimxrt/mpbthciport: Allow disabling UART flow control for BLE.
Not all boards or BLE extensions have the flow control signals for BLE
available at suitable pins.  Actually none of the Adafruit extensions
match for flow control.

For consistency with the previous behaviour it is enabled by default.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-10-02 11:31:24 +11:00
robert-hh 51ca23e463 mimxrt/boards: Fix naming of SD-card config option.
Commit 552b0bbe12 did not define
MICROPY_PY_MACHINE_SDCARD properly, and thus building the firmware failed.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-10-02 11:29:53 +11:00
robert-hh abb44694d8 mimxrt/boards/MIMXRT1176_clock_config: Fix comments about UART clocks.
No functional change, and pretty obvious.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-09-29 23:43:31 +10:00
robert-hh 0701341e7f mimxrt/machine_uart: Set the UART clock to a fixed 40MHz value.
There is a single UART clock for all devices, so switching it for one will
affect all devices used at that time.  This commit fixes that issue by
keeping the clock at a fixed value.

This fixed clock still supports the common baud rates between 300 and
921600 baud.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-09-29 23:43:25 +10:00
iabdalkader 52e3da0a0b mimxrt/mbedtls: Enable certificate validity time validation.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-09-29 23:09:48 +10:00
iabdalkader 361ca7d5ee mimxrt/mpbthciport: Enable flow control for BT HCI UART.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-09-29 23:09:35 +10:00
iabdalkader 552b0bbe12 mimxrt: Remove SDCARD Makefile config option.
This is option is no longer needed as a Makefile option as the USDHC driver
is enabled for all supported series.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-09-29 23:09:14 +10:00
iabdalkader 9d1a1ed42d mimxrt/Makefile: Enable the FSL USDHC for supported MCU series.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-09-29 23:08:57 +10:00
iabdalkader 805c750164 mimxrt/mimxrt_sdram: Allow boards to override the default SDRAM config.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-09-29 23:08:48 +10:00
iabdalkader 4b9c459133 mimxrt/sdio: Add support for the 117x series.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-09-29 23:08:41 +10:00
Jim Mussared 79473691f2 {mimxrt,powerpc,samd}/mpconfigport: Don't override parse chunk alloc.
This was copied from minimal/mpconfigport.h, but it doesn't make sense
for general ports.

Add a comment to minimal/mpconfigport.h to explain why it specifically
overrides it.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-09-29 14:11:26 +10:00
iabdalkader 816b88ad07 mimxrt/Makefile: Update to work with latest TinyUSB.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-09-14 23:35:54 +10:00
Damien George 671b38f944 mimxrt/sdio: Move config guard so headers are only included if used.
Otherwise it's a build error on certain MCU series.

Signed-off-by: Damien George <damien@micropython.org>
2023-09-05 11:03:08 +10:00
robert-hh 297892c4f4 mimxrt/machine_uart: Add a helper function to change the baudrate.
And use it in the Bluetooth bindings instead of setting the baudrate by a
call to the NXP lib.

Also fixes machine_uart.c to work with a baud rate of 921600.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-09-05 10:54:49 +10:00
robert-hh 81c19d93bc mimxrt/machine_uart: Support slow baud rates for UART.
Down to 50 baud (in reverence to Jean-Maurice-Émile Baudot).  Implemented
for the MIMXRT10xx MCU's only.  The MIMXRT1176 runs down to 300 baud.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-09-01 00:41:23 +10:00
robert-hh c86b9ec8bd mimxrt/boards: Fix use of MICROPY_HW_SDRAM_AVAIL in MIMXRT1176.ld.
MICROPY_HW_SDRAM_AVAIL is always defined.

Thanks to Ibrahim Abdakader for noticing.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-09-01 00:40:44 +10:00
robert-hh ce38784fa8 mimxrt/machine_uart: Fix and complete UART.deinit and uart_deinit_all.
The code did not check at deinit whether a UART was initialized.  That did
not matter for all MCU's except MIMXRT1176, which crashes at the second
soft reset in a row.

But since it is a general problem to use UART methods of a UART which has
been deinitialized, checks were added to all applicable methods for a clear
response instead of e.g. a crash.

Deinitialize UART using software reset.  It resets the UART but keeps it
accessible for software, avoiding an exception when UART registers are
accessed after a DeInit.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-09-01 00:27:13 +10:00
iabdalkader 3f5976e14a mimxrt/irq: Move all IRQ related definitions to dedicated header.
Following other ports, IRQ priorities and related functions are moved to
their own header, to simplify mpconfigport.h.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-09-01 00:02:19 +10:00
iabdalkader fc495240a6 mimxrt: Integrate Bluetooth support with NimBLE bindings.
This commit adds the necessary functions to get NimBLE working with the
mimxrt port.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-08-31 23:42:10 +10:00
iabdalkader 772a36098f mimxrt: Integrate support for WiFi via the CYW43 driver.
This commit adds the necessary configuration and hooks to get the CYW43
driver working with the mimxrt port.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-08-31 23:40:49 +10:00
iabdalkader 46d83d9748 mimxrt/sdio: Add SDIO driver.
This is a basic SDIO driver for the mimxrt port, that was added mainly to
support the CYW43 WiFi driver, and as such it only supports the commands
required by the CYW43 driver (but more commands can be added easily). The
driver performs non-blocking DMA transfers, and can detect and recover from
errors.

Note: because the mimxrt port is missing static alternate functions, named
pins and other pin related functions, currently the alternate functions for
USDHC 1 and 2 are hard-coded in the driver.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-08-31 23:39:34 +10:00
iabdalkader 6b407d5600 mimxrt/machine_pin: Extend pin configuration functions.
Add portable pin config macros to mphalport.h.  And add a function to
configure pins with more pin options such as alt function, pull, speed,
drive, interrupt mode, etc.

Note: this new `machine_pin_config()` function can replace
`machine_pin_set_mode()`, but the latter is left as-is to avoid breaking
anything.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-08-31 23:36:20 +10:00
Jim Mussared f3eccb154c py/mpconfig: Enable SSL finalizers if finalizers are enabled.
The rp2 port was enabling SSL and had finalizers enabled via the "extra
features" level, but missed explicitly enabling `MICROPY_PY_SSL_FINALISER`
(like esp32, stm32, and mimxrt did).

This commit makes `MICROPY_PY_SSL_FINALISER` default to enabled if
finalizers are enabled, and removes the explicit setting of this for
esp32, stm32, mimxrt (because they all use the "extra features" level).

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-30 12:38:13 +10:00
robert-hh a18d62e067
mimxrt: Fix UART RTS/CTS assignments for the OLIMEX and Adafruit boards.
At the Adafruit Metro M7 the pin GPIO_AD_13 is used for JTAG. Therefore
it is not configured for RTS at UART 2 and 3.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-08-16 10:06:59 +02:00
Kwabena W. Agyeman 00855eeb36 mimxrt/hal: Make flash clock frequency configurable.
Signed-off-by: "Kwabena W. Agyeman" <kwagyeman@live.com>
2023-08-15 23:45:22 +10:00
Kwabena W. Agyeman cb7e133dbe mimxrt/boards: Add support for GPIO control of SNVS pins.
Signed-off-by: "Kwabena W. Agyeman" <kwagyeman@live.com>
2023-08-15 23:35:33 +10:00
Kwabena W. Agyeman afe2ca1a0a mimxrt/machine_uart: Add support for UART hardware flow control.
Signed-off-by: "Kwabena W. Agyeman" <kwagyeman@live.com>
2023-08-15 23:21:33 +10:00
robert-hh e43c669b4a mimxrt/machine_uart: Add uart.deinit method and machine_uart_deinit_all.
The call to machine_uart_deinit_all() is needed to avoid a crash after soft
reset, if a UART had been used and data arrives before it is instantiated
again.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-08-15 23:08:30 +10:00
robert-hh a9a219d8bf mimxrt/hal/pwm_backport: Fix 0 and 65536 edge cases of PWM's duty_u16.
It should be that:
- duty_u16=0: output low, no pulse
- duty_u16=65536: output high, no pulse

That previously did not apply to all of the three PWM mechanisms of this
port.  This commit fixes it.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-08-15 23:06:12 +10:00
robert-hh a9821c0185 mimxrt/machine_pin: Fix bug when Pin.irq is called without a handler.
When called without a handler, the IRQ data was not cleared.  That caused a
crash at the second soft reset in a row.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-08-15 23:03:37 +10:00
Jim Mussared 24a6e951ec ports: Simplify board feature tags in board.json.
This commit:
- Finds a common set of board feature tags and maps existing features to
  that reduced set.
- Removes some less-useful board feature tags.
- Ensures all MCUs are specified correctly.
- Ensures all boards have a vendor (and fixes some vendor names).

This is to make the downloads page show a less intimidating set of filters.

Work done in conjunction with Matt Trentini <matt.trentini@gmail.com>.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-08-10 14:54:03 +10:00
Jim Mussared 975a687447 py/mpconfig: Add MICROPY_PY_PLATFORM, enabled at extra features level.
Previously this was explicitly enabled on esp32/stm32/renesas/mimxrt/samd,
but didn't get a default feature level because it wasn't in py/mpconfig.h.

With this commit it's now enabled at the "extra features" level, which adds
rp2, unix-standard, windows, esp8266, webassembly, and some nrf boards.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-07-24 23:53:20 +10:00
Jim Mussared 7979a4d267 ports: In machine_i2s.c, rename uasyncio to asyncio.
Mostly updates comments, but also renames the UASYNCIO enum value to
ASYNCIO.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-19 18:36:54 +10:00
Jim Mussared 2fbc08c462 extmod/asyncio: Rename uasyncio to asyncio.
The asyncio module now has much better CPython compatibility and
deserves to be just called "asyncio".

This will avoid people having to write `from uasyncio import asyncio`.

Renames all files, and updates port manifests to use the new path. Also
renames the built-in _uasyncio to _asyncio.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-19 17:33:03 +10:00
Damien George f01d5fb657 py/mkrules.mk: Automatically configure frozen options when manifest set.
Following how mkrules.cmake works.  This makes it easy for a port to enable
frozen code, by defining FROZEN_MANIFEST in its Makefile.

Signed-off-by: Damien George <damien@micropython.org>
2023-06-08 23:12:56 +10:00
Jim Mussared 2eba98f1e0 all: Use MP_REGISTER_EXTENSIBLE_MODULE for overrideable built-ins.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08 17:54:21 +10:00
Jim Mussared 45ac651d1a all: Rename *umodule*.c to remove the "u" prefix.
Updates any includes, and references from Makefiles/CMake.

This essentially reverts what was done long ago in commit
136b5cbd76

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08 17:54:17 +10:00
Jim Mussared f5f9edf645 all: Rename UMODULE to MODULE in preprocessor/Makefile vars.
This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08 17:54:11 +10:00
Jim Mussared 1bf2dcb15e all: Rename mp_umodule*, mp_module_umodule* to remove the "u" prefix.
This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08 17:54:04 +10:00
Jim Mussared 30628d1bb7 all: Rename MP_QSTR_umodule to MP_QSTR_module everywhere.
This renames the builtin-modules, such that help('modules') and printing
the module object will show "module" rather than "umodule".

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-08 17:53:57 +10:00
Jim Mussared 1d4b4f0ce2 ports: Standardise docs link in help text.
Updates all `help()` output to use the phrase:
`For online docs please visit http://docs.micropython.org/`

Some ports previously used different wording, some pointed to the wrong
link.  Also make all ports use `help.c` for consistency.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-06-02 11:48:46 +10:00
robert-hh 6c0af30e38 mimxrt/Makefile: Use a specific fsl_flexspi_nor_boot.c for mimxrt1062.
This one sets the flash image length properly for the teensy loader, such
that the file system is not erased.  It was already set in commit
8e54225140 but got lost when the MIMXRT1176
board was added.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-01 12:38:17 +10:00
robert-hh 8f6315a279 mimxrt/machine_pwm: Fix freq change, PWM print, and error checks.
Three bugs have been fixed in this commit:

1. When the duty was set with duty_u16(), changing the freq with pwm.freq()
   would not keep relative duty rate, but the absolute pulse duration.

2. Fix another inconsistency when displaying the PWM pin's properties of a
   QTMR channel.

3. Improve the error checks for the second channel being a PWM pin and pin
   pairs to be a FLEXPWM A/B pair.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-01 12:25:34 +10:00
robert-hh 73cc6b750e ports: Enable os.sync() for esp32, esp8266, rp2, mimxrt, samd51.
These have by default FAT support.  The SAMD21 build does not support FAT.
The nrf port also implements os.sync(), but has it's own copy of moduos.c.

Code size increases seen: 40 to 56 bytes.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-01 11:39:01 +10:00
robert-hh 5707fd74e5 mimxrt/boards/ADAFRUIT_METRO_M7: Add Adafruit Metro M7 board definition.
Support for WiFi and BLE is in progress.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-05-23 16:54:39 +10:00
iabdalkader 8d446b2ad5 mimxrt/led: Add support for up to four LEDs.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-05-23 10:54:23 +10:00
Yilin Sun 0f0dcec984 mimxrt/sdcard: Fix GCC 13 build error with sdcard_cmd_set_bus_width.
This updates the declaration of 'sdcard_cmd_set_bus_width()' to the same as
its definition.

Signed-off-by: Yilin Sun <imi415@imi.moe>
2023-05-23 10:38:13 +10:00
robert-hh 65d376b11d mimxrt/machine_pin: Perform full configuration in machine_pin_set_mode.
machine_pin_set_mode() is used by the internal mp_hal_pin_xxx() set of
functions to configure pins.
2023-05-09 16:15:05 +10:00
robert-hh 14b862f70f mimxrt/machine_spi: Ignore transfers with len=0.
It was treated as an error before.  The error surfaced when using the
NINAW10 drivers for WiFi support.  Even if this is a bad behavior of the
NINA driver, machine_spi can be forgiving in that situation.
2023-05-09 16:14:40 +10:00
robert-hh d2a02dcee3 mimxrt: Add missing UART defintion and remove obsolete config.
Changes in this commit:
- Add a missing UART defintion for MIMXRT1010_EVK.
- Remove an obsolete line from mpconfigport.h.
2023-05-09 16:13:51 +10:00
robert-hh facc51f3ea mimxrt/mpconfigport: Add back lost uos.urandom().
It got lost in a clean-up session recently.
2023-05-09 16:13:27 +10:00
Philipp Ebensberger a3f3b9045c mimxrt/flash: Separate low level driver code from flash object.
Separate low level flash access from mimxrt flash driver object.  Allows
better abstraction from hardware for testing and reuse in other areas (e.g.
bootloader).

Signed-off-by: Philipp Ebensberger <philipp.ebensberger@3bricks-software.de>
2023-05-09 15:18:36 +10:00
Damien George 38243cd8e0 extmod/machine_pwm: Remove PWM_INIT and PWM_DUTY_U16_NS config options.
All ports that enable MICROPY_PY_MACHINE_PWM now enable these two
sub-options, so remove these sub-options altogether to force consistency in
new ports that implement machine.PWM.

Signed-off-by: Damien George <damien@micropython.org>
2023-05-04 13:19:19 +10:00
robert-hh 9c7ad68165 mimxrt/machine_pwm: Start PWM only if freq and duty are set.
And also fix/improve the following:
- Simplify the duty handling a little bit.
- Allow duty_u16(65536), which sets the output high.
- Rename machine_pwm_start() to mp_machine_pwm_start(), in preparation for
  a possible start/stop method pair.
2023-05-04 13:09:39 +10:00
Christian Clauss 2a1db770ce all: Fix cases of Python variable assigned but never used.
This fixes ruff rule F841.
2023-05-02 16:36:05 +10:00
Damien George b1229efbd1 all: Fix spelling mistakes based on codespell check.
Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 18:03:06 +10:00
Damien George c234a26954 mimxrt/modutime: Use extmod version of time module.
No API or functional change.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:51 +10:00
Damien George 9955553001 extmod/modutime: Provide a generic time module.
Based on extmod/utime_mphal.c, with:
- a globals dict added
- time.localtime wrapper added
- time.time wrapper added
- time.time_ns function added

New configuration options are added for this module:
- MICROPY_PY_UTIME (enabled at basic features level)
- MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME
- MICROPY_PY_UTIME_TIME_TIME_NS

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:09:56 +10:00
Damien George 083dc1f082 ports: Use extmod version of mktime instead of port-specific one.
Apart from slight differences in the error message, the functionality of
all ports is unchanged.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 14:55:07 +10:00
iabdalkader 0acc73344a mimxrt: Fix the build for boards without ROM API. 2023-04-12 17:01:25 +02:00
iabdalkader bde222ce84 mimxrt/modmachine: Implement machine.bootloader().
If a board defines a custom bootloader entry function it will be called
first, if not and the ROM API supports RUN bootloader API, then
`machine.bootloader()` will jump to the ROM serial downloader in USB mode.
2023-04-11 17:40:18 +10:00
iabdalkader 8b72721b29 mimxrt/mpconfigport: Allow configuring different network interfaces.
This commit allows boards to disable Ethernet and keep the networking stack
enabled, to use an alternate networking interface, such as WiFi.

Note that the `network` and `socket` modules are now enabled by default for
a board.
2023-04-11 17:20:29 +10:00
iabdalkader 944b4c2058 mimxrt/boards/MIMXRT1064_EVK: Fix board config to use internal flash.
This commit is necessary to make MicroPython work on this eval kit out of
the box, as the eval kit ships with the HyperFlash physically disconnected
from the bus (refer to the schematics or the user guide) and the QSPI
connected instead, but the fuses/board/pins are configured to boot from
internal flash (on FlexSPI2).

Note that enabling the HyperFlash is not trivial, as it requires soldering
and desoldering of many small footprint resistors and changing fuses.
2023-04-11 17:04:21 +10:00
iabdalkader ed5e3598f1 mimxrt/Makefile: Fix internal flash configuration and build. 2023-04-11 17:03:28 +10:00
David Grayson c046b23ea2 shared/runtime/pyexec: Don't allow Ctrl+C to interrupt frozen boot code.
Helps prevent the filesystem from getting formatted by mistake, among other
things.  For example, on a Pico board, entering Ctrl+D and Ctrl+C fast many
times will eventually wipe the filesystem (without warning or notice).

Further rationale: Ctrl+C is used a lot by automation scripts (eg mpremote)
and UI's (eg Mu, Thonny) to get the board into a known state.  If the board
is not responding for a short time then it's not possible to know if it's
just a slow start up (eg in _boot.py), or an infinite loop in the main
application.  The former should not be interrupted, but the latter should.
The only way to distinguish these two cases would be to wait "long enough",
and if there's nothing on the serial after "long enough" then assume it's
running the application and Ctrl+C should break out of it.  But defining
"long enough" is impossible for all the different boards and their possible
behaviour.  The solution in this commit is to make it so that frozen
start-up code cannot be interrupted by Ctrl+C.  That code then effectively
acts like normal C start-up code, which also cannot be interrupted.

Note: on the stm32 port this was never seen as an issue because all
start-up code is in C.  But now other ports start to put more things in
_boot.py and so this problem crops up.

Signed-off-by: David Grayson <davidegrayson@gmail.com>
2023-04-05 10:38:50 +10:00
iabdalkader db4b416ea8 mimxrt/pendsv: Clean up PendSV code.
The dispatch active flag is only set once and never reset, so it will
always call the dispatch handler (once enabled), and it's not really
needed because it doesn't make things more efficient.

Also remove unused included headers.
2023-04-05 10:16:22 +10:00
Damien George 38e7b842c6 ports: Implement simple write polling for stdout.
This is a best-effort implementation of write polling.  It's difficult to
do correctly because if there are multiple output streams (eg UART and USB
CDC) then some may not be writeable while others are.  A full solution
should also have a return value from mp_hal_stdout_tx_strn(), returning the
number of bytes written to the stream(s).  That's also hard to define.

The renesas-ra and stm32 ports already implement a similar best-effort
mechanism for write polling.

Fixes issue #11026.

Signed-off-by: Damien George <damien@micropython.org>
2023-03-23 13:51:17 +11:00
iabdalkader 9171cb91b1 mimxrt/pendsv: Add MICROPY_BOARD_PENDSV_ENTRIES for board customisation. 2023-03-07 15:57:58 +11:00
iabdalkader 4d3897f80e mimxrt: Enable ROM text compression.
To reduce size of firmware, by about 3k.
2023-03-07 15:09:07 +11:00
Jim Mussared a377302623 extmod/modnetwork: Add network.hostname() and network.country().
This provides a standard interface to setting the global networking config
for all interfaces and interface types.

For ports that already use either a static hostname (mimxrt, rp2) they will
now use the configured value. The default is configured by the port
(or optionally the board).

For interfaces that previously supported .config(hostname), this is still
supported but now implemented using the global network.hostname.

Similarly, pyb.country and rp2.country are now deprecated, but the methods
still exist (and forward to network.hostname).

Because ESP32/ESP8266 do not use extmod/modnetwork.c they are not affected
by this commit.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-03-01 01:26:17 +11:00
Jim Mussared 69b93527d5 ports: Make BOARD default from BOARD_DIR in Makefile's.
This allows:

    $ make BOARD_DIR=path/to/board

to infer BOARD=board, rather than the previous behavior that required
additionally setting BOARD explicitly.

Also makes the same change for VARIANT_DIR -> VARIANT on Unix.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
2023-02-23 09:47:08 +11:00
robert-hh 7198c25175 mimxrt/Makefile: Move the FROZEN_MANIFEST setting after board config.
Such that a respective statement in mpconfigboard.mk is executed first.
2023-02-17 14:29:04 +11:00
robert-hh de1f1dd164 shared/runtime/softtimer: Use consistently the same clock source.
Before, both uwTick and mp_hal_ticks_ms() were used as clock source.  That
assumes, that these two are synchronous and start with the same value,
which may be not the case for all ports.  If the lag between uwTick and
mp_hal_ticks_ms() is larger than the timer interval, the timer would either
rush up until the times are synchronous, or not start until uwTick wraps
over.

As suggested by @dpgeorge, MICROPY_SOFT_TIMER_TICKS_MS is now used in
softtimer.c, which has to be defined in a port's mpconfigport.h with
the variable that holds the SysTick counter.

Note that it's not possible to switch everything in softtimer.c to use
mp_hal_ticks_ms() because the logic in SysTick_Handler that schedules
soft_timer_handler() uses (eg on mimxrt) the uwTick variable directly
(named systick_ms there), and mp_hal_ticks_ms() uses a different source
timer.  Thus it is made fully configurable.
2023-02-16 12:59:48 +11:00
Jim Mussared 8b27482692 top: Update Python formatting to black "2023 stable style".
See https://black.readthedocs.io/en/stable/the_black_code_style/index.html

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-02-02 12:51:03 +11:00
Jim Mussared 6250337c9c ports: Make all network-capable boards use bundle-networking.
This will ensure that any board with networking support gets:
 - webrepl
 - mip
 - urequests
 - ntptime

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-02-01 12:42:06 +11:00
David Lechner 3446d440f6 shared/runtime/gchelper: Drop cpu directive from ARM asm helpers.
This drops the `.cpu` directive from the ARM gchelper_*.s files.  Having
this directive breaks the linker when targeting older CPUs (e.g. `-mthumb
-mthumb-interwork` for `-mcpu=arm7tdmi`).  The actual target CPU should be
determined by the compiler options.

The exact CPU doesn't actually matter, but rather the supported assembly
instruction set.  So the files are renamed to *_thumb1.s and *thumb2.s to
indicate the instruction set support instead of the CPU support.

Signed-off-by: David Lechner <david@pybricks.com>
2023-01-28 15:51:38 +11:00
robert-hh 1583c1f670 mimxrt: Set MICROPY_GC_STACK_ENTRY_TYPE to uint32_t for large RAM.
It was uint16_t. The change sets it to uint32_t for devices with SDRAM.

Fixes issue #10366.
2023-01-16 12:26:39 +11:00
robert-hh b75b5c102c mimxrt/sdcard: Remove obsolete code already excluded by preprocessor. 2022-12-14 13:05:27 +11:00
robert-hh aea4174937 mimxrt/sdcard: Fix an error when writing large blocks.
Which happened when a read followed a large write.
2022-12-14 13:04:58 +11:00
robert-hh 913f9ad5ad mimxrt/machine_rtc: Set the microsecond value to 0.
Set the subsecond value reported by rtc.datetime() and rtc.now() to 0.
Synchronizing the roll-over with the second change was not precise.
2022-12-14 13:04:09 +11:00
robert-hh 28a5107d81 mimxrt/mpconfigport: Remove config options that are set by default.
Remove every setting that is already included in
MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES.
2022-11-18 15:06:37 +11:00
Jim Mussared 72817a179c mimxrt/Makefile: Set MPY_CROSS_FLAGS.
Otherwise this port will be unable to freeze `@native`/`@viper` code.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-11-17 22:10:40 +11:00
robert-hh 3459a4fa3d mimxrt/network: Rename the argument clock_mode to ref_clk_mode.
The definitions for LAN.IN and LAN.OUT are kept, but in the code Pin.IN
and Pin.OUT can be used as well as values for the ref_clk_mode argument.
2022-11-17 08:55:16 +01:00
robert-hh 2a4825848c mimxrt/usb: Change macro name MICROPY_HW_USB_STR_MANUF.
Change it into MICROPY_HW_USB_MANUFACTURER_STRING to be compatible with
other ports.
2022-11-17 08:27:33 +01:00
Patrick Joy f44246c4c9 mimxrt/README: Add build and flashing instructions. 2022-11-17 14:21:59 +11:00
robert-hh 5e990cc27f mimxrt: Add support for MIMXRT1176 MCUs, and MIMXRT1170_EVK board.
The RT1176 has two cores, but the actual firmware supports only the CM7.
There are currently no good plans on how to use the CM4.

The actual MIMXRT1170_EVK board is on par with the existing MIMXRT boards,
with the following extensions:
- Use 64 MB RAM for the heap.
- Support both LAN interfaces as LAN(0) and LAN(1), with LAN(1)
  being the 1GB interface.

The dual LAN port interface can eventually be adapted as well for the
RT1062 MCU.

This work was done in collaboration with @alphaFred.
2022-11-17 14:11:50 +11:00
iabdalkader 71881116e6 extmod/extmod.mk: Set default mbedtls config file in extmod Makefile. 2022-11-09 18:43:13 +01:00
robert-hh 8afa6df23d mimxrt/modmachine: Move dht_readinto() to the machine module. 2022-11-09 15:56:43 +11:00
robert-hh 5d473d3093 mimxrt/mphalport: Add a timeout to mp_hal_stdout_tx_strn().
If USB CDC is connected and the board sends data, but the host does not
receive the data, the device locks up.  This is fixed in this commit by
having a timeout of 500ms, after which time the transmission is skipped.
2022-11-09 11:16:25 +11:00
Damien George 98cbace299 mimxrt/machine_timer: Use extmod version of machine.Timer.
Signed-off-by: Damien George <damien@micropython.org>
2022-10-27 14:43:03 +11:00
robert-hh 65fa7fd8bb mimxrt/machine_timer: Use soft-timer implementation for machine.Timer.
This releases the hardware timers for other tasks, which need a higher
resolution and faster response.  And it is less port-specific code.
2022-10-27 14:09:29 +11:00
robert-hh 9d2e179fa5 mimxrt: Fix CPU freeze when calling __WFE() in MICROPY_EVENT_POLL_HOOK.
This issue affected i.MX RT 1052, 1062 and 1064.  It seems to be addressed
by Errata ERR006223, which also mentions i.MX RT101x and 102x, but these
devices worked well even without the change.  As a side effect, the current
consumption at an idle REPL drops significantly with this fix.

Fixes issue #7235.
2022-10-27 14:06:12 +11:00
robert-hh e20bb98392 mimxrt/machine_pin: Add the Pin.toggle() method.
For consistency with other ports, even if this method is undocumented at
the moment.
2022-10-27 14:05:33 +11:00
Damien George 8874a09119 extmod/mbedtls: Enable elliptic curve DH and DSA cryptography.
This is necessary to access sites that only support these protocols.

The rp2 port already has ECDH enabled, so this just adds ECDSA there.  The
other ports now gain both ECDH and ECDSA.  The code size increase is:

- rp2 (PICO_W): +2916 bytes flash, +24 bytes BSS
- stm32 (PYBD_SF6): +20480 bytes flash, +32 bytes data, +48 bytes BSS
- mimxrt (TEENSY41): +20708 bytes flash, +32 bytes data, +48 bytes BSS
- unix (standard x86-64): +39344 executable, +1744 bytes data, +96 BSS

This is obviously a large increase in code size.  But there doesn't seem to
be any other option because without elliptic curve cryptography devices are
partially cut off from the internet.  For use cases that require small
firmware size, they'll need to build custom firmware with a custom mbedtls
config.

Signed-off-by: Damien George <damien@micropython.org>
2022-10-22 19:08:21 +11:00
Damien George b337678964 extmod/mbedtls: Add common configuration file, and use it in all ports.
This is a no-op change.

Signed-off-by: Damien George <damien@micropython.org>
2022-10-22 19:06:21 +11:00
Jim Mussared 43bcfb148b mimxrt/Makefile: Split up SRC_C variables.
This improves clarity a bit, but also ensures that only the required files
are added to SRC_QSTR.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-12 00:08:49 +11:00
Jim Mussared d6d8722558 extmod: Make extmod.mk self-contained.
This makes it so that all a port needs to do is set the relevant variables
and "include extmod.mk" and doesn't need to worry about adding anything to
OBJ, CFLAGS, SRC_QSTR, etc.

Make all extmod variables (src, flags, etc) private to extmod.mk.

Also move common/shared, extmod-related fragments (e.g. wiznet, cyw43,
bluetooth) into extmod.mk.

Now that SRC_MOD, CFLAGS_MOD, CXXFLAGS_MOD are unused by both extmod.mk
(and user-C-modules in a previous commit), remove all uses of them from
port makefiles.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-11 23:31:49 +11:00