Commit Graph

83 Commits

Author SHA1 Message Date
Jim Mussared
693b927687 rp2: Enable optimisations (comp goto, map cache, fast attr).
Computed goto costs 1800 bytes for 5-10% performance.

Map caching and attr fast path costs 130 bytes for up to 30%.

Net effect of those three optimisations:
bm_chaos.py         +16.059% (+/-0.09%)
bm_fannkuch.py      +11.145% (+/-0.01%)
bm_fft.py           +14.604% (+/-0.01%)
bm_float.py         +26.849% (+/-0.08%)
bm_hexiom.py        +34.039% (+/-0.03%)
bm_nqueens.py       +18.333% (+/-0.06%)
bm_pidigits.py       +4.472% (+/-0.03%)
misc_aes.py         +28.765% (+/-0.09%)
misc_mandel.py      +27.116% (+/-0.05%)
misc_pystone.py     +40.299% (+/-0.20%)
misc_raytrace.py    +22.812% (+/-0.07%)

Also enable other EXTRA-level optimisations (module const, return_if_expr,
triple_tuple_assign, factorial, mpz bitwise).

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-01 15:25:45 +11:00
Damien George
c62351fbd6 py/mpconfig.h: Revert MICROPY_REPL_INFO to disabled at all levels.
This is an stm32-specific feature that's accessed via the pyb module, so
not something that will be widely enabled.

Signed-off-by: Damien George <damien@micropython.org>
2021-11-01 15:18:22 +11:00
Jim Mussared
b1a0ce46d1 rp2/mpconfigport.h: Use the "extra" feature level.
This commit is a no-op change to simplify existing config.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-11-01 15:02:58 +11:00
Mike Causer
7f14344428 ports: Add images, features and urls to board.json. 2021-10-28 15:25:38 +11:00
Jim Mussared
e359b077dd ports: Add board.json for all boards.
This will be used by https://micropython.org/download/ to generate the
full listing of boards and firmware files.

Optionally supports a board.md for additional customisation of the
download page, as well as deploy.md for flashing instructions.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-10-27 14:04:53 +11:00
iabdalkader
38f8e852e0 rp2: Add framework for networking.
MICROPY_PY_NETWORK and MICROPY_PY_USOCKET need to be enabled by a board to
get networking.  No NICs have yet been defined.
2021-09-19 23:20:13 +10:00
iabdalkader
c973cfd2f3 rp2: Add support for bluetooth module using NimBLE. 2021-09-19 23:09:59 +10:00
YoungJoon Chun
bbbdef4cc1 rp2/mpconfigport.h: Enable heapq module.
Fixes issue #7746.
2021-09-04 23:51:14 +10:00
Damien George
af64c2ddbd extmod/machine_pwm: Factor out machine.PWM bindings to common code.
This commit refactors machine.PWM and creates extmod/machine_pwm.c.  The
esp8266, esp32 and rp2 ports all use this and provide implementations of
the required PWM functionality.  This helps to reduce code duplication and
keep the same Python API across ports.

This commit does not make any functional changes.

Signed-off-by: Damien George <damien@micropython.org>
2021-09-04 16:31:17 +10:00
Damien George
d41f6dde56 extmod/modonewire: Make _onewire module configurable via macro option.
Signed-off-by: Damien George <damien@micropython.org>
2021-09-02 13:11:23 +10:00
Damien George
afe0634c98 extmod/machine_spi: Make SoftSPI configurable via macro option.
Signed-off-by: Damien George <damien@micropython.org>
2021-09-02 13:11:23 +10:00
Damien George
122d901ef1 extmod/machine_i2c: Make SoftI2C configurable via macro option.
The zephyr port doesn't support SoftI2C so it's not enabled, and the legacy
I2C constructor check can be removed.

Signed-off-by: Damien George <damien@micropython.org>
2021-09-02 13:11:23 +10:00
David Lechner
86371781e9 tools/uncrustify: Force 1 newline at end of file.
To keep things neat and tidy, we ensure that each file has 1 and only 1
newline at the end of each file.

Signed-off-by: David Lechner <david@pybricks.com>
2021-08-31 13:14:45 +10:00
iabdalkader
a3ce8f08ec rp2/mpconfigport.h: Allow boards to add root pointers. 2021-08-29 12:22:50 +10:00
iabdalkader
79baef843b rp2/CMakeLists.txt: Add option to enable double tap reset to bootrom.
* For boards a with reset switch, pressing twice resets into bootloader.
* Enabled by linking with the pico_bootsel_via_double_reset library.
2021-08-29 12:20:01 +10:00
iabdalkader
c82244a7c0 rp2/rp2_flash: Disable IRQs while calling flash_erase/program.
Flash erase/program functions disable the XIP bit.  If any code runs from
flash at the same time (eg an IRQ or code it calls) it will fail and cause
a lockup.
2021-08-29 12:15:01 +10:00
Jim Mussared
b352db7a63 rp2/Makefile: Add "submodules" target, to match other ports.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-19 22:54:57 +10:00
Jim Mussared
5733c49174 stm32,esp32,rp2: Enable MICROPY_PY_FSTRINGS by default.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-14 16:58:40 +10:00
iabdalkader
23531bca74 rp2/CMakeLists.txt: Allow a board's cmake to set the manifest path.
This allows boards to add frozen modules, or bypass the port manifest
entirely.
2021-08-10 11:05:33 +10:00
Mike Causer
71722c84ca rp2/boards: Add Pimoroni Tiny 2040. 2021-08-01 23:07:57 +10:00
Mike Causer
042a4bebc3 rp2/boards: Add Pimoroni Pico LiPo 16MB. 2021-08-01 23:07:05 +10:00
Mike Causer
95eff8d96a rp2/boards: Add Pimoroni Pico LiPo 4MB. 2021-08-01 23:06:06 +10:00
Mike Causer
02cbe018a5 rp2/boards: Add Adafruit QT Py RP2040. 2021-08-01 23:04:59 +10:00
Mike Causer
043848158d rp2/boards: Add Adafruit ItsyBitsy RP2040. 2021-08-01 23:03:30 +10:00
Mike Causer
e7a3e6ee6a rp2/boards/SPARKFUN_THINGPLUS: Configure I2C/SPI default pins. 2021-08-01 23:02:30 +10:00
Mike Causer
6986a8d680 rp2/boards/SPARKFUN_PROMICRO: Configure UART/I2C/SPI default pins. 2021-08-01 23:01:36 +10:00
Mike Causer
49497084f1 rp2/boards/ADAFRUIT_FEATHER_RP2040: Configure I2C/SPI default pins. 2021-08-01 17:15:18 +10:00
iabdalkader
23e2e00779 rp2/boards/ADAFRUIT_FEATHER_RP2040: Configure custom VID/PID. 2021-08-01 10:51:50 +10:00
iabdalkader
7ae9e6ef69 rp2/tusb_port: Allow boards to configure USB VID and PID.
By defining MICROPY_HW_USB_VID and MICROPY_HW_USB_PID.
2021-08-01 10:51:24 +10:00
robert-hh
ee49ae8f82 rp2/machine_uart: Fix read when FIFO has chars but ringbuf doesn't.
Prior to this fix, if the UART hardware FIFO had a few chars but still
below the FIFO trigger threshold, and the ringbuf was empty, the read
function would timeout if timeout==0 (the default timeout).

This fix follows the suggestion of @iabdalkader.
2021-07-25 17:48:50 +10:00
iabdalkader
2e62e13455 rp2/machine_uart: Fix poll ioctl to also check hardware FIFO.
The RX IRQ does not trigger if the FIFO is less than the trigger level, in
which case characters may be available in the FIFO, yet not in the ringbuf,
and the ioctl returns false.
2021-07-25 17:11:03 +10:00
Mike Causer
cc77b30639 rp2/machine_spi: Allow boards to configure SPI pins using new macros. 2021-07-19 23:16:11 +10:00
Mike Causer
79da7757cc rp2/machine_i2c: Allow boards to configure I2C pins using new macros. 2021-07-19 23:16:11 +10:00
iabdalkader
4f2a10bfc9 rp2/machine_uart: Allow overriding default machine UART pins. 2021-07-19 23:14:02 +10:00
iabdalkader
8599f7a68d rp2/machine_uart: Add hardware flow control support. 2021-07-19 23:13:57 +10:00
Damien George
136369d72f all: Update to point to files in new shared/ directory.
Signed-off-by: Damien George <damien@micropython.org>
2021-07-12 17:08:10 +10:00
Damien George
0613d3e356 rp2/tusb_config.h: Set CFG_TUD_CDC_EP_BUFSIZE to 256.
This improves the speed of data going out of the MCU.

See related #7479.

Signed-off-by: Damien George <damien@micropython.org>
2021-07-08 13:20:53 +10:00
Damien George
031fe0f144 rp2/CMakeLists.txt: Suppress compiler errors for pico-sdk and tinyusb.
These warnings appear with GCC 11.  Keep them as warnings but not as
compiler errors so they can be dealt with properly in the future.

Signed-off-by: Damien George <damien@micropython.org>
2021-07-05 16:18:28 +10:00
Krzysztof Adamski
feb7e2e864 rp2/machine_rtc: In RTC.datetime, compute weekday automatically.
Calculating the weekday each time you want to set a date is error prone and
tiresome.  MicroPython can do it on its own - hardware on some ports do not
support storing weekday in hardware and always computes it on the fly,
ignoring the value given to the constructor.

During discussion for #7432 the conclusion was that there seems to be no
obvious reason to let user set the weekday to an incorrect value so it
makes sense to just ignore the provided weekday value and always compute
the correct value.  This patch introduces this change for the rp2 port.

Signed-off-by: Krzysztof Adamski <k@japko.eu>
2021-06-25 10:29:45 +10:00
Krzysztof Adamski
35b1359a3a rp2: Use 0=Monday datetime convention in RTC.
The RTC in rp2 can store any, even wrong, number as a weekday in RTC.  It
was, however, discussed in #7394 that we would like to unify all ports and
use 0 as Monday, not Sunday in the machine.RTC implementation.

This patch makes sure that the default date set in RTC is adheres to this
convention.  It also fixes the example in quickref to use proper weekday to
avoid confusion.

Signed-off-by: Krzysztof Adamski <k@japko.eu>
2021-06-25 10:29:12 +10:00
Krzysztof Adamski
e7f7094ef6 rp2/machine_rtc: Check return value from rtc_set_datetime.
The rtc_set_datetime() from pico-sdk will validate the values in the
datetime_t structure and refuse to set the time if they aren't valid. It
makes sense to raise an exception if this happens instead of failing
silently which might be confusing (as an example, see:
https://github.com/micropython/micropython/pull/6928#issuecomment-860166044
).
2021-06-15 00:06:26 +10:00
Krzysztof Adamski
37d01d4be3 rp2/machine_rtc: Add initial support for RTC.
Initial support for machine.RTC on rp2 port. It only supports datetime()
method and nothing else. The method gets/returns a tuple of 8 items, just
like esp32 port, for example, but the usec parameter is ignored as the RP2
RTC only works up to seconds precision.

The Pico RTC isn't very useful as the time is lost during reset and there
seems to be no way to easily power up just the RTC clock with a low current
voltage, but still there seems to be use-cases for that, see issues #6831,
and a Thonny issue #1592. It was also requested for inclusion on v1.15
roadmap on #6832.

Signed-off-by: Krzysztof Adamski <k@japko.eu>
2021-06-12 23:02:54 +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
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
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
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
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
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