Commit Graph

2099 Commits

Author SHA1 Message Date
robert-hh
745b4319a2 mimxrt/boards/TEENSY40: Re-create the flash FS after deploy.
This is required since the Teensy Halfkay loader attempts to erase all of
the flash but fails to do so, at least in my tests.  Formatting brings it
back to a known state.
2021-06-01 23:52:45 +10:00
robert-hh
dfd4324eb1 mimxrt: Add flash storage support with VFS and littlefs filesystem.
This commit adds full support for a filesystem on all boards, with a block
device object mimxrt.Flash() and uos.VfsLfs2 enabled.

Main changes are:
- Refactoring of linker scripts to accomodate reserved area for VFS.  VFS
  will take up most of the available flash. 1M is reserved for code.  9K is
  reserved for flash configuration, interrupts, etc.
- Addition of _boot.py with filesystem init code, called from main.c.
- Definition of the mimxrt module with a Flash class in modmimxrt.[ch].
- Implementation of a flash driver class in mimxrt_flash.c.  All flashing
  related functions are stored in ITCM RAM.
- Addition of the uos module with filesystem functions.
- Implementation of uos.urandom() for the sake of completeness of the uos
  module.

It uses sample code from CircuitPython supplied under MIT license, which
uses the NXP SDK example code.

Done in collaboration with Philipp Ebensberger aka @alphaFred who
contributed the essential part to enable writing to flash while code is
executing, among other things.
2021-06-01 23:42:57 +10:00
robert-hh
c303b15f10 mimxrt: Enable frozen modules. 2021-06-01 22:57:09 +10:00
robert-hh
fdaf2b80d9 mimxrt: Add custom help text and enable help("modules"). 2021-06-01 22:52:44 +10:00
Joseph Chiu
c5d2095e59 esp32/espneopixel: Add support for GPIO32 and GPIO33.
Adds support for NeoPixels on GPIO32 and GPIO33 on ESP32.  Otherwise,
NeoPixels wired to GPIO32/33 wll silently fail without any hints to the
user.

With thanks to @robert-hh.

Fixes issue #7221.
2021-05-30 23:36:50 +10:00
IAMLIUBO
a18f695e29 esp32/boards: Add M5STACK_ATOM board definition.
ATOM is a very small ESP32 development board produced by M5Stack, with a
size of 24mm * 24mm, with peripherals such as WS2812, IR, button, MPU6886
(Only Matrix), and 8 GPIO extensions.  It also has a plastic shell.
2021-05-30 23:15:13 +10:00
Damien George
db8704ecbd esp8266,esp32: Update manifest to point to new dirs in micropython-lib.
Following a refactoring of micropython-lib.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-28 18:32:56 +10:00
Damien George
211c3e41f1 stm32/boards/PYBD_SF2: Disable GCC 11 warnings for array bounds.
With GCC 11 there is now a warning about array bounds of OTP-mac, due to
the OTP being a literal address.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-27 23:57:51 +10:00
Damien George
62f75376dd stm32/boards/NUCLEO_L432KC: Fix FS size and enable LFS1 filesystem.
Signed-off-by: Damien George <damien@micropython.org>
2021-05-27 12:18:41 +10:00
Damien George
0abf6f830c esp8266/boards/GENERIC_512K: Add custom manifest without FS modules.
The 512k build does not have a filesystem so there is no reason to include
the filesystem-related modules.  This commit provides a custom manifest.py
for this board which no longer includes: _boot.py, flashbdev.py,
inisetup.py, upip.py, upip_utarfile.py.  This cuts the build down by about
9k of flash.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-26 21:41:40 +10:00
Damien George
b84406f313 qemu-arm: Add support for Cortex-A9 via sabrelite board.
Signed-off-by: Damien George <damien@micropython.org>
2021-05-26 16:24:00 +10:00
robert-hh
c732b80f05 mimxrt: Extend the Pin module for SoftI2C, SoftSPI support.
This change consists mostly of changing and extending the required
definitions in mphalport.h.
2021-05-25 20:43:52 +02:00
Philipp Ebensberger
c326d9a67b mimxrt: Enable built-in help. 2021-05-26 00:12:45 +10:00
Philipp Ebensberger
ff5d39529c mimxrt: Implement machine.Pin class.
- modified pin type from pin_obj_t to machine_pin_obj_t
- created machine_pin.c
- implemented basic version of make-pins.py to genertate pins.c/.h files
  automatically; the only alternate function currently supported is GPIO
- added af.csv files for all supported MCUs
- replaced pins.c/pins.h files with pin.csv for all boards
- implemented on/off/high/low/value/init methods
- Implemented IN/OUT/OPEN_DRAIN modes
- modified LDFLAGS for DEBUG build to get usefull .elf file for debugging

Signed-off-by: Philipp Ebensberger
2021-05-26 00:12:42 +10:00
Damien George
ea81bcf1c0 stm32/mboot: Leave bootloader from thread mode, not from IRQ.
Leaving the bootloader from an IRQ (eg USB or I2C IRQ) will not work if
MBOOT_LEAVE_BOOTLOADER_VIA_RESET is disabled, ie if mboot jumps directly to
the application.  This is because the CPU will still be in IRQ state when
the application starts and IRQs of lower priority will be blocked.

Fix this by setting a flag when the bootloader should finish, and exit the
bootloader always from the main (top level) thread.

This also improves the USB behaviour of mboot: it no longer abruptly
disconnects when the manifest command is sent.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-21 00:46:01 +10:00
Damien George
748339b281 stm32/uart: Configure pull-up only on RX and CTS, not TX and RTS.
RX and CTS are the input pins and pull-ups are enabled so they don't cause
a problem if left unconnected.  But the output pins don't need a pull up
(they were originally all configured with pull up in commit
8f7491a109).

If needed, the pull-ups can be disabled in Python using machine.Pin after
the UART is constructed.

See issue #4369.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-21 00:38:04 +10:00
Damien George
a96afae90f stm32/sdio: Fix case of SDIO DMA turning off mid transfer.
The DMA driver will turn off DMA if it hasn't been used for an amount of
time (to save power).  The SDIO driver for cyw43 WLAN was not informing the
DMA driver that it was using DMA and there was a chance that the DMA would
turn off in the middle of an SDIO DMA transfer.  The symptoms of this would
be printing of SDIO error messages and a failure to communicate with the
cyw43 WLAN module.

This commit fixes this issue by changing the SDIO driver to use the
dma_nohal_XXX API to initialise and start the DMA.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-21 00:08:13 +10:00
Mike Causer
47b778332a all: Replace busses with buses.
"buses" is the widely accepted plural form of "bus".
2021-05-20 23:22:03 +10:00
Mike Causer
1ca66efbf7 stm32/boards: Add VCC_GND_F407ZG board. 2021-05-20 23:17:51 +10:00
Mike Causer
c24003abec stm32/boards: Add VCC_GND_F407VE board. 2021-05-20 23:15:56 +10:00
Damien George
7408ca1d78 mimxrt: Improve ticks and sleep functions using GPT.
SysTick cannot wake the CPU from WFI/WFE so a hardware timer is needed to
keep track of ticks/delay (similar to the nrf port).

Fixes issue #7234.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-18 22:36:32 +10:00
Bruno Martins
ea2d83e961 nrf/boards: Add support for evk_nina_b3 board. 2021-05-18 12:14:57 +10:00
Bruno Martins
94fb5e7f5a nrf: Add machine.memXX, and allow boards to customise some features. 2021-05-18 12:01:51 +10:00
Mike Causer
605b74f390 esp32/boards: Fix spelling mistakes in comments for UM_xxx boards. 2021-05-14 22:26:29 +10:00
Mike Causer
9e65662a11 esp32/boards: Set default I2C and SPI pins on UM_xxx boards.
And fix incorrect I2C and SPI pins in the feathers2 module.
2021-05-14 22:26:05 +10:00
Mike Causer
538b9a9be5 esp32/machine_i2c: Allow boards to configure I2C pins using new macros.
Following how SPI is configured (and how stm32 does it).
2021-05-14 22:22:13 +10:00
Damien George
9a0bca2c2a stm32/mboot: Make LEDs and reset-mode selection more configurable.
A board can now customise mboot with:
- MBOOT_LED1, MBOOT_LED2, MBOOT_LED3, MBOOT_LED4: if it needs to have
  different LEDs for mboot compared to the application
- MBOOT_BOARD_LED_INIT: if it needs a fully customised LED init function
- MBOOT_BOARD_LED_STATE: if it needs a fully customised LED state-setting
  function
- MBOOT_BOARD_GET_RESET_MODE: if it needs a fully customised function to
  get the reset mode

With full customisation, the only requirement is a single LED to show the
status of the bootloader (idle, erasing, flashing, etc), which can be
configured to do nothing if needed.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-12 13:44:57 +10:00
Damien George
6639e282c7 stm32/mboot: Add MBOOT_LEAVE_BOOTLOADER_VIA_RESET option.
It is enabled by default to get the standard behaviour of doing a reset
after it is finished, but can be disabled by a board to jump straight to
the application (likely the board needs to use MBOOT_BOARD_CLEANUP to make
this work).

The application is passed a reset mode of BOARDCTRL_RESET_MODE_BOOTLOADER
if the bootloader was active and entered via a jump.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-12 13:44:52 +10:00
Damien George
9ee116c452 stm32/boardctrl: Adjust logic for running boot.py, main.py.
This new logic is equivalent to the old logic when the only possibilities
for reset_mode are NORMAL, SAFE_MODE and FILESYSTEM, which is the standard
case.  But the new logic also allows other reset_mode values (eg
BOOTLOADER) to run boot.py and main.py.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-12 13:44:47 +10:00
Damien George
ee4ffc1804 stm32/powerctrl: Add MICROPY_HW_ENTER_BOOTLOADER_VIA_RESET option.
When disabled the bootloader is entered via a direct jump.  When enabled
the bootloader is entered via a system reset then a jump.  It's enabled by
default to retain the existing behaviour, which is the recommended way.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-12 13:44:41 +10:00
Damien George
4404dababb rp2/CMakeLists.txt: Include tinyusb_common in PICO_SDK_COMPONENTS.
So the TinyUSB headers can be found during qstr processing.

Fixes issue #7236.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-11 12:46:18 +10:00
Chris Greening
cce7096d1a esp32/boards/UM_TINYPICO: Fix include of sdkconfig fragment.
This was broken by 32ec07a350
2021-05-11 09:36:41 +10:00
Damien George
0e87459e2b esp32/boards: Add UM_FEATHERS2 and UM_TINYS2 board definitions.
Based on original commit made by Seon Rozenblum aka @UnexpectedMaker.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-10 16:56:53 +10:00
Seon Rozenblum
32ec07a350 esp32/boards: Rename TINYPICO board to UM_TINYPICO.
And add default hardware SPI 0 pins in mpconfigboard.h, and
CONFIG_LWIP_LOCAL_HOSTNAME in sdkconfig.board.
2021-05-10 16:56:53 +10:00
Damien George
5093d49fae esp32: Extend support for S2 series, and S3 where applicable.
Improvements made:
- PSRAM support for S2
- partition definition for 16MiB flash
- correct ADC and DAC pins
- correct GPIO and IRQ pins
- S3 components in CMakeLists

Based on original commit made by Seon Rozenblum aka @UnexpectedMaker.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-10 16:56:53 +10:00
Damien George
d0de16266f rp2/mpthreadport: Add mp_thread_deinit to reset core1 on soft reset.
Any code running on core1 should be stopped on soft-reset (the GC heap is
reset so if code continues to run on core1 it will see corrupt memory).

Signed-off-by: Damien George <damien@micropython.org>
2021-05-09 00:08:30 +10:00
Damien George
864e4ecc47 esp32/mpthreadport: Use binary semaphore instead of mutex.
So a lock can be acquired on one Python thread and then released on
another.  A test for this is added.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-08 22:47:03 +10:00
Damien George
31e0b8c71c esp32/mpthreadport: Don't explicitly free thread struct in TCB cleanup.
Because vPortCleanUpTCB runs on the FreeRTOS idle task and cannot execute
any VM or runtime related code like freeing memory.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-08 22:47:03 +10:00
mishafarms
8ff3520f67 esp32/esp32_rmt: Clear config struct before filling it out.
Or unset entries will have garbage in them.

Signed-off-by: mishafarms <github@mishafarms.us>
2021-05-06 15:53:56 +10:00
Damien George
9e29217c73 unix/modffi: Use a union for passing/returning FFI values.
This fixes a bug where double arguments on a 32-bit architecture would not
be passed correctly because they only had 4 bytes of storage (not 8).  It
also fixes a compiler warning/error in return_ffi_value on certian
architectures: array subscript 'double[0]' is partly outside array bounds
of 'ffi_arg[1]' {aka 'long unsigned int[1]'}.

Fixes issue #7064.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-06 12:17:10 +10:00
Damien George
8172c2e9c5 rp2: Move manifest.py to boards directory.
To match other ports.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-04 23:39:24 +10:00
David Lechner
ca0c75f504 stm32/boards: Change default LSI_VALUE to 32000 for F4 MCUs.
In the STM32 HAL libraries, the default value for LSI_VALUE for F4 MCUs is
32 kHz.

Signed-off-by: David Lechner <david@pybricks.com>
2021-05-04 16:53:40 +10:00
robert-hh
1e2f0d2809 rp2/tusb_port: Add the device unique-id to the USB id.
The number shown in the USB id is now the same as that returned by
machine.unique_id().  All 8 bytes are inserted as hex into the USB id.  A
usb id at /dev/serial/by-id then looks like:

    usb-MicroPython_Board_in_FS_mode_e469b03567342f37-if00
2021-05-02 23:38:01 +10:00
Jan Jurgen Griesfeller
d80a037e6b rp2/boards: Add board definition for SparkFun Pro Micro board. 2021-05-02 23:23:27 +10:00
Jan Jurgen Griesfeller
3c918d0f58 rp2/boards: Add board definition for SparkFun Thing Plus RP2040. 2021-05-02 23:22:46 +10:00
Artyom Skrobov
ca35c0059c py/repl: Autocomplete builtin modules.
Doing "import <tab>" will now complete/list built-in modules.

Originally at adafruit#4548 and adafruit#4608

Signed-off-by: Artyom Skrobov <tyomitch@gmail.com>
2021-05-02 23:11:14 +10:00
Damien George
888664130c zephyr/boards: Add config for nucleo_wb55rg board.
This board does not work with CONFIG_NETWORKING enabled.  And
CONFIG_CONSOLE_SUBSYS is enabled so that ctrl-C works.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 15:32:16 +10:00
Damien George
b46a033e25 zephyr/modmachine: Add machine.idle().
Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 15:32:16 +10:00
Damien George
d120859857 zephyr: Run scheduled callbacks at REPL and during mp_hal_delay_ms.
And ctrl-C can now interrupt a time.sleep call.  This uses Zephyr's k_poll
API to wait efficiently for an event signal, and an optional semaphore.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 15:32:16 +10:00
Damien George
e9e9c76ddf all: Rename mp_keyboard_interrupt to mp_sched_keyboard_interrupt.
To match mp_sched_exception() and mp_sched_schedule().

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 15:13:43 +10:00
Damien George
bd54eb566f nrf/boards/microbit: Use mp_sched_exception() where appropriate.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 15:13:43 +10:00
Damien George
7cbf826a95 py/scheduler: Add mp_sched_exception() to schedule a pending exception.
This helper is added to properly set a pending exception, to mirror
mp_sched_schedule(), which schedules a function.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 15:13:43 +10:00
Damien George
a41cd150be esp8266/modnetwork: Use mp_handle_pending() to raise pending exception.
If MICROPY_ENABLE_SCHEDULER is enabled then MP_STATE_VM(sched_state) must
be updated after handling the pending exception, which is done by the
mp_handle_pending() function.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 15:13:43 +10:00
iabdalkader
a1111b83ed stm32/sdio: Allow configuring the SDMMC periph used for SDIO.
This can now be selected by setting MICROPY_HW_SDIO_SDMMC, which defaults
to 1, ie SDMMC1.  The pins can also be selected and default to the standard
C8/C9/C10/C11/C12/D2.
2021-04-30 11:26:04 +10:00
iabdalkader
baa712b7f0 stm32/boards/PYBD_SF2: Enable RF switch compile option. 2021-04-30 10:16:15 +10:00
iabdalkader
80788154b3 stm32/sdio: Add functions to re/enable SDIO/SDIOIT. 2021-04-30 01:12:08 +10:00
iabdalkader
4d96786823 stm32/uart: Enable HW flow control for UART 1/5/7/8. 2021-04-30 01:10:02 +10:00
Damien George
cf7e71fa43 stm32/sdcard: Allow configuring the SDMMC periph used for SD/MMC card.
This can now be selected by setting MICROPY_HW_SDCARD_SDMMC, which defaults
to 1, ie SDMMC1.  This commit also renames the SD pin configuration macros
from MICROPY_HW_SDMMC2_xxx to MICROPY_HW_SDCARD_xxx, as well as renaming
MICROPY_HW_SDMMC_BUS_WIDTH to MICROPY_HW_SDCARD_BUS_WIDTH.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 00:58:17 +10:00
Damien George
37494b8c8a stm32/mboot: Allow mboot to be placed at any location in flash.
A board can now define MBOOT_TEXT0_ADDR to place mboot at a location other
than 0x08000000.  This can be useful if, for example, there is already a
different bootloader on the device.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 00:42:59 +10:00
Damien George
58be5a5aa3 stm32/mboot: Allow a board to customise the linker scripts.
A board can now define MBOOT_LD_FILES (at the Makefile-level) to specify
custom linker scripts.  And stm32_generic.ld has been split into 2 pieces
so one or the other can be reused (usually stm32_sections.ld wolud be
reused by a board, and stm32_memory.ld redefined).

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 00:42:59 +10:00
Damien George
97f09fda3e stm32/mboot: Fix mp_hal_delay_us() and add mp_hal_ticks_ms().
Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 00:42:59 +10:00
Damien George
fd01b6c779 stm32/adc: Allow mboot to use basic ADC functions.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 00:42:59 +10:00
Damien George
ef2896bdea stm32/mboot: Allow a board to add source files to the build.
A board can now use BUILDING_MBOOT at the Makefile-level to do things
conditional on building mboot, for example add source files to SRC_C.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 00:42:59 +10:00
Damien George
885b246ca9 stm32/boardctrl: Show first reset-mode state on LEDs when selecting.
Commit 1e297c8898 introduced a bug where the
very first reset-mode state on the LEDs was not shown, because prior to
that commit the first reset-mode state was the same as the initial LED
state (green on, others off) and update_reset_mode() was called after
setting this initial LED state.

This is fixed in this commit by changing the update_reset_mode() loop so
that it displays the current reset mode before doing the delay.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 00:32:12 +10:00
Damien George
a72b8443ca stm32/boardctrl: Add constants for reset mode values.
And use the same boardctrl.h header for both the application and mboot so
these constants are consistent.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 00:31:35 +10:00
Damien George
647fa63f9c stm32/softtimer: Support static soft timer instances.
This adds support for making static (ie not on the Python GC heap) soft
timers.  This can be useful for a board to define a custom background
handler, or eventually for BLE/network processing to use instead of systick
slots; it will be more efficient using soft timer for this.

The main issue with using the existing code for static soft timers is that
it would combine heap allocated and statically allocated soft_timer_entry_t
instances in the same pairing-heap data structure.  This would prevent the
GC from tracing some of the heap allocated entries (because the GC won't
follow pointers outside the heap).

This commit makes it so that soft timer entries are explicitly marked,
instead of relying on implicit marking by having the root of the pairing
heap in the root pointer section.  Also, on soft reset only the heap-
allocated soft timers are deleted from the pairing heap, leaving the
statically allocated ones.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-29 16:54:35 +10:00
Damien George
89b64478c7 stm32/softtimer: Add support for having a C-based callback.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-29 16:54:35 +10:00
Steve App
21fee92be6 esp32: Restore FROZEN_MANIFEST support with new CMake build system.
This commit re-enables the command-line make option "FROZEN_MANIFEST".  The
boards/*/mpconfigboard.cmake will now use the command-line FROZEN_MANIFEST
value if supplied.

Usage: make FROZEN_MANIFEST=~/foo/my-manifest.py
2021-04-29 12:34:00 +10:00
iabdalkader
a708848b0c stm32/uart: Fix H7 UART clock source configuration.
Previously to this commit, Usart16ClockSelection was overwritten and
Usart234578ClockSelection was not set.
2021-04-28 00:46:48 +10:00
plan-do-break-fix
4dc802400f stm32,teensy: Correct typos in project README files. 2021-04-28 00:29:18 +10:00
Daniel Maslowski
f452b9c265 pic16bit/Makefile: Make the XC compiler version user-configurable. 2021-04-28 00:18:04 +10:00
Damien George
43a8c8178e bare-arm: Switch to use MICROPY_ERROR_REPORTING_NONE to reduce size.
Reduces size of this port by about 3300 bytes, and demonstrates how to use
this feature.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-27 23:52:40 +10:00
Damien George
65b90cd0f9 teensy: Provide own implementation of gc_collect, to not use stm32.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-27 12:08:00 +10:00
stijn
bb2007b05c windows/mpconfigport.h: Enable features also present in unix port. 2021-04-23 23:15:10 +10:00
Damien George
df4e9bdf5c esp32/CMakeLists.txt: Require CMake version 3.12.
Because "find_package(Python3 ...)" requires at least this version of
CMake.  And other features like GREATER_EQUAL and COMMAND_EXPAND_LISTS need
at least CMake 3.7 and 3.8 respectively.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-23 23:03:03 +10:00
David Michieli
5669a60954 stm32/mboot: Allow unpacking dfu without secret key.
- unpack-dfu command no longer requies a secret key to be present
- pack-dfu command raises an exception if no secret key is found
2021-04-23 11:04:37 +10:00
Damien George
00d6a79b3d stm32/machine_timer: Improve usability of Timer constructor and init.
Improvements are:
- Default period is 1000ms with callback disabled.
- if period is not specified then it's not updated (previously, if period
  was not specified then it was set to -1 and running the timer callback as
  fast as possible, making the REPL unresponsive).
- Use uint64_t to compute delta_ms, and raise a ValueError if the period is
  too large.
- If callback is not specified then it's not updated.
- Specifying None for the callback will disable the timer.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-21 14:22:09 +10:00
Damien George
6e0f9b9262 stm32/boards/pllvalues.py: Support wider range of PLL values for F413.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-20 23:33:33 +10:00
Tim Radvan
f842a40df4 rp2/rp2_pio: Add fifo_join support for PIO.
The PIO state machines on the RP2040 have 4 word deep TX and RX FIFOs.  If
you only need one direction, you can "merge" them into either a single 8
word deep TX or RX FIFO.

We simply add constants to the PIO object, and set the appropriate bits in
`shiftctrl`.

Resolves #6854.

Signed-off-by: Tim Radvan <tim@tjvr.org>
2021-04-17 00:45:38 +10:00
Damien George
e5d2ddde25 esp32/machine_pin: Use rtc_gpio_deinit instead of gpio_reset_pin.
Commit 8a917ad252 added the gpio_reset_pin()
call to make sure that pins that were used as ADC inputs could subsequently
be used as digital IO.  But calling gpio_reset_pin() will enable the
pull-up on the pin and so pull it high for a brief period.  Instead use
rtc_gpio_deinit() which will just reconfigure the pin as a digital IO and
do nothing else.

Fixes issue #7079 (see also #5771).

Signed-off-by: Damien George <damien@micropython.org>
2021-04-15 13:06:05 +10:00
Damien George
d97b8daf1a esp32/boards: Add GENERIC_S2 board definition.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-15 10:31:06 +10:00
Damien George
c81d048bb3 esp32: Add support for USB with CDC ACM.
The REPL will be available on the USB serial port.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-15 10:31:06 +10:00
Damien George
66a86a0615 esp32: Add initial support for ESP32S2 SoCs.
Builds against IDF v4.3-beta2.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-15 10:31:06 +10:00
Damien George
7f366a2190 esp32/modsocket: Correctly handle poll/read of unconnected TCP socket.
For an unconnected TCP socket, poll should return WR|HUP and read should
raise ENOTCONN.  This is implemented by this commit and now the following
tests pass on esp32: extmod/usocket_tcp_basic.py,
net_hosted/connect_poll.py.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-14 15:35:31 +10:00
Damien George
d0e014aa41 mimxrt: Enable CPYTHON_COMPAT, PY_ASYNC_AWAIT, PY_ATTRTUPLE options.
This change allows running the tests in tests/basics/ without any failures
(but some tests are still skipped).

Signed-off-by: Damien George <damien@micropython.org>
2021-04-14 12:55:53 +10:00
8bitgeek
fc6ea28d00 stm32/sdram: Make MICROPY_HW_FMC_BA1,MICROPY_HW_FMC_A11 optional pins.
This supports SDRAM having only 2 internal banks (using BA0 only), and only
11 (A0-A10) bits of address, such as IS42S16100H (512K x 16bit x 2bank).
2021-04-14 11:06:32 +10:00
Marian Buschsieweke
9c9bfe1968 unix/main: Make static variable that's potentially clobbered by longjmp.
This fixes `error: variable 'subpkg_tried' might be clobbered by 'longjmp'
or 'vfork' [-Werror=clobbered]` when compiling on ppc64le and aarch64 (and
possibly other architectures/toolchains).
2021-04-14 10:45:26 +10:00
Damien George
2ac09c2694 stm32/uart: Use LL_USART_GetBaudRate to compute baudrate.
This function includes the UART prescaler in the calculation (if it has
one, eg on H7 and WB MCUs).

Signed-off-by: Damien George <damien@micropython.org>
2021-04-13 23:59:01 +10:00
Damien George
25c029ce9f stm32/boards: Split UARTx_RTS_DE into UARTx_RTS/UARTx_DE in pin defs.
So these alternate functions can be parsed by the build scripts and used in
application code.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-13 23:58:20 +10:00
Damien George
2668337f36 stm32/rfcore: Intercept addr-resolution HCI cmd to work around BLE bug.
The STM32WB has a problem when address resolution is enabled: under certain
conditions the MCU can get into a state where it draws an additional 10mA
or so and eventually ends up with a broken BLE RX path in the silicon.  A
simple way to reproduce this is to enable address resolution (which is the
default for NimBLE) and start the device advertising.  If there is enough
BLE activity in the vicinity then the device will at some point enter the
bad state and, if left long enough, will have permanent BLE RX damage.

STMicroelectronics are aware of this issue.  The only known workaround at
this stage is to not enable address resolution, which is implemented by
this commit.

Work done in collaboration with Jim Mussared aka @jimmo.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-12 21:51:11 +10:00
Damien George
dd62c52a36 stm32/rfcore: Fix race condition with C2 accessing free buffer list.
Prior to this commit, if C2 was busy (eg lots of BLE activity) then it may
not have had time to respond to the notification on the IPCC_CH_MM channel
by the time additional memory was available to put on that buffer.  In such
a case C1 would modify the free buffer list while C2 was potentially
accessing it, and this would eventually lead to lost memory buffers (or a
corrupt linked list).  If all buffers become lost then ACL packets
(asynchronous events) can no longer be delivered from C2 to C1.

This commit fixes this issue by waiting for C2 to indicate that it has
finished using the free buffer list.

Work done in collaboration with Jim Mussared aka @jimmo.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-12 21:43:04 +10:00
jahr
7ca686684e rp2: Add support for building different board configurations.
This change allows to build firmware for different rp2-based boards,
following how it is done in other ports like stm32 and esp32.  So far only
the original Pico and Adafruit Feather RP2040 are added.  Board names
should match (sans case) those in pico-sdk/src/boards/include/boards/.

Usage: Pico firmware can be build either using make as previously (it is
the default board) or by `make BOARD=PICO`.  Feather is built by `make
BOARD=ADAFRUIT_FEATHER_RP2040`.  Only the board name and flash drive size
is set, pin definition is taken from the appropriate pico-sdk board
definition.  Firmware is saved in the directory build-BOARD_NAME.
2021-04-12 21:40:32 +10:00
robert-hh
1be74b94b6 rp2/machine_uart: Add buffered transfer of data with rxbuf/txbuf kwargs.
Instantiation and init now support the rxbuf and txbuf keywords for setting
the buffer size.  The default size is 256 bytes.  The minimum and maximum
sizes are 32 and 32766 respectively.

uart.write() still includes checks for timeout, even if it is very unlikely
to happen due to a) lack of flow control support and b) the minimal timeout
values being longer than the time it needs to send a byte.
2021-04-12 21:31:08 +10:00
robert-hh
22554cf8e2 rp2/rp2_pio: Add StateMachine restart,rx_fifo,tx_fifo helper functions.
StateMachine.restart: Restarts the state machine
StateMachine.rx_fifo: Return the number of RX FIFO items, 0 if empty
StateMachine.tx_fifo: Return the number of TX FIFO items, 0 if empty

restart() seems to be the most useful one, as it resets the state machine
to the initial state without the need to re-initialise/re-create.  It also
makes PIO code easier, because then stalling as an error state can be
unlocked.

rx_fifo() is also useful, for MP code to check for data and timeout if no
data arrived.  Complex logic is easier handled in Python code than in PIO
code.

tx_fifo() can be useful to check states where data is not processed, and is
mostly for symmetry.
2021-04-11 22:41:54 +10:00
robert-hh
6f06dcaee5 rp2/moduos: Implement uos.urandom().
The implementation samples rosc.randombits at a frequency lower than the
oscillator frequency.  This gives better random values.  In addition, for
an 8-bit value 8 samples are taken and fed through a 8-bit CRC,
distributing the sampling over the byte.  The resulting sampling rate is
about 120k/sec.

The RNG does not include testing of error conditions, like the ROSC being
in sync with the sampling or completely failing.  Making the interim value
static causes it to perform a little bit better in short sync or drop-out
situations.

The output of uos.urandom() performs well with the NIST800-22 test suite.
In my trial it passed all tests of the sts 2.1.2 test suite.  I also ran a
test of the random data with the Common Criteria test suite AIS 31, and it
passed all tests too.
2021-04-09 18:24:38 +10:00
Damien George
2c9af1c1d7 rp2/rp2_pio: Validate state machine frequency in constructor.
Fixes issue #7025.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-09 18:06:10 +10:00
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