Commit Graph

736 Commits

Author SHA1 Message Date
Dan Halbert 24c6295ed4 Boot protocol and feature reports: compiles; needs to be tested 2021-10-04 22:48:18 -04:00
Matthew McGowan f936989c0b chore(usb_vendor): update non-movable memory enum 2021-10-04 07:36:08 -07:00
Matthew McGowan 295cc18190 style(swan_r5): pre-commit whitespace style changes 2021-09-28 18:52:03 -07:00
Brandon Satrom 48f67d007e feat: add Blues Swan R5 support
complete pin mapping for Feather pins

stubbed out files needed for complilation. still to be modified

0 out all CPY modules in mpconfigboard.mk until we get the build running

add csv for pin generation for STM32L4R5

add F4R5 references in peripherals files

refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX

took a guess at the number of USB endpoint pairs to get the build done

guess was close, but wrong. It is 8

clean up peripheral DEFs

Fixes build error:
```
In file included from ../../py/mpstate.h:33,
                 from ../../py/mpstate.c:27:
../../py/misc.h: In function 'vstr_str':
../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI
 static inline char *vstr_str(vstr_t *vstr) {
 ^~~~~~
```
Sleuthing steps:
* verify that the feather_stm32f4_express board builds correctly
* put a `#error` at the bottom of the `mpstate.c` file.
* build for the feather and swan boards, with V=2 to capture the build command for that file.
* use a differencing tool to inspect the differences between the two invocations
* inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.)

A grep through the sources revealed where this flag was being set for the stm ports.

With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away!

working build with minimal set of modules for the Blues Swan r5

chore:change header copyright name to Blues Wireless Contributors

USB operational.  Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.)

USART working

adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins.  I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output.  The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect.

short circuit implementation of backup memory for the STM32L4

all the ports

remove company name from board name to be consistent with the Arduino board definition.

add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected.  Confirmed I2C timing.

fix board name

fix incorrect pin definition. add test to allow manual check of each output pin

analog IO

code changes for WebUSB. Doesn't appear to work, will revisit later.

ensure that `sys.platform` is available

checkin missing file

feat: make room for a larger filesystem so the sensor tutorial will fit on the device.

fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data.

fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger

chore(Swan R5): update peripherals pins from `parse_af_csv.py` output

optimize flash sector access
2021-09-28 18:52:02 -07:00
Trammell Hudson 4ab00d7125 mp_hal_delay_ms: avoid overflow when scaling ticks
This patch casts the delay argument to mp_hal_delay_ms()
from mp_uint_t to uint64_t when scaling from milliseconds
to ticks to avoid 32-bit integer overflow when time.sleep()
is called with a duration of greater than 70 minutes.

Signed-off-by: Trammell Hudson <hudson@trmm.net>
2021-09-17 17:28:03 +00:00
Dan Halbert 59b1bedcda
Merge pull request #5333 from microDev1/patch
Make `next_code_allocation` and `prev_traceback_allocation` movable
2021-09-14 19:27:40 -04:00
Scott Shawcroft 4659102cfe
Factor out common code and comment it 2021-09-13 16:12:40 -07:00
Scott Shawcroft b0adf65d94
Bump to v4 with move and dir path tweaks 2021-09-13 14:46:14 -07:00
Scott Shawcroft 64ff8d9e19
v3 BLE file service: Add file modification times 2021-09-13 14:46:14 -07:00
microDev 7316c742cf
make `next_code_allocation` and `prev_traceback_allocation` movable 2021-09-12 18:06:03 +05:30
Scott Shawcroft 0d280fa83c
Two fixes, one for ble workflow, one for linking
BLE workflow had an incorrect list size for characteristics

Linking didn't advance . link it should have without extra ().
2021-09-01 12:43:43 -07:00
Scott Shawcroft 80675107cf
Merge pull request #5270 from pewpew-game/safe-mode-wait
Add a flag to skip waiting for safe mode
2021-08-31 09:56:29 -07:00
Radomir Dopieralski e4baefc593 Add a flag to skip waiting for safe mode
Sometimes we don't want the delay in the device's startup.

I used a simple flag, but now it also occurs to me that we could
instead make the wait time a define, and set it to 0 to disable it.
2021-08-31 09:53:30 +02:00
microDev d7a92f7fd6
Merge pull request #5271 from tannewt/switch_cp_serial_uuids
Switch CircuitPython serial off Nordic UUIDs
2021-08-31 09:14:03 +05:30
Scott Shawcroft 76cbd0d74a
Switch CircuitPython serial off Nordic UUIDs
This will un-break examples that got confused by the presence of
two Nordic UART Services. It also adds a version characteristic
that gives the CircuitPython build tag back.

Fixes #5252
2021-08-30 15:09:12 -07:00
Scott Shawcroft a8dd881ee5
Fix GPIOTE crashes by checking everything is ok
Fixes #5240 and fixes #5211
2021-08-27 16:07:29 -07:00
Dan Halbert fa63a41fc4
Merge pull request #5217 from tannewt/ble_workflow_api_v2
Two tweaks to BLE workflow
2021-08-26 17:34:06 -04:00
Scott Shawcroft f9f3894888
Support multiple status dotstars
Only supporting one left a white dotstar stranded.

Fixes #5170
2021-08-24 14:35:11 -07:00
Scott Shawcroft a5f2f6e1b1
Two tweaks to BLE workflow
1. Use autoreload for restarting after a write. This gives time for
   a follow up command before restarting BLE.
2. Switch to recursive deletion of directories. This greatly
   simplifies deleting directories with contents.

Fixes https://github.com/adafruit/Adafruit_CircuitPython_BLE_File_Transfer/issues/7
2021-08-24 13:57:42 -07:00
Scott Shawcroft d2860b58b0
Check background pending before sleep
There is a race between when we run background tasks and when we
sleep. If an interrupt happens between the two, then we may delay
executing the background task. On some ports we checked this for
TinyUSB already. On iMX RT, we didn't which caused USB issues.
This PR makes it more generic for all background tasks including
USB.

Fixes #5086 and maybe others.
2021-08-19 12:18:13 -07:00
Scott Shawcroft fdf49a4b2f
Increase tx power for BLE workflow pairing 2021-08-13 11:30:09 -07:00
Jeff Epler bfea6947e5 Improve mp_printf with support for compressed strings
* The new nonstandard '%S' format takes a pointer to compressed_string_t
   and prints it

 * The new mp_cprintf and mp_vcprintf take a format string that is a
   compressed_string_t
2021-08-09 08:27:28 -05:00
Jeff Epler d59a28db97 Compress word offset table
By storing "count of words by length", the long `wends` table can be
replaced with a short `wlencount` table.  This saves flash storage space.

Extend the range of string lengths that can be in the dictionary.
Originally it was to 2 to 9; at one point it was changed to 3 to 9.
Putting the lower bound back at 2 has a positive impact on the French
translation (a bunch of them, such as "ch", "\r\n", "%q", are used).
Increasing the maximum length gets 'mpossible', ' doit être ',
and 'CircuitPyth' at the long end.  This adds a bit of processing time
to makeqstrdata. The specific 2/11 values are again empirical based on
the French translation on the adafruit_proxlight_trinkey_m0.
2021-08-07 09:23:35 -05:00
Scott Shawcroft e3fa6e2c35
Merge pull request #5089 from tannewt/disable_ble_workflow
Add ability to disable BLE workflow
2021-08-05 11:21:17 -07:00
Dan Halbert 81833035fc raytac_mdbt50q-rx 2021-08-04 15:47:19 -04:00
Scott Shawcroft 713c8e7b3f
Fix builds without the ble workflow 2021-08-03 14:36:41 -07:00
Scott Shawcroft 1e225610cc
Add ability to disable BLE workflow
Call `supervisor.disable_ble_workflow()` and the BLE workflow will
be disabled until the chip is reset.

This also includes a couple fixes:
1. Terminals can now be deinit by setting the tilegrid to NULL. This
  prevents using the tilegrid before display is init.
2. Fix BLE serial send amount when sending more than a single packet.

Fixes #5049
2021-08-02 18:37:19 -07:00
Dan Halbert 901a6c27c0 remove gamepad; deprecate gamepadshift 2021-07-26 22:15:09 -04:00
Scott Shawcroft e7fe0d9a71
Fix single neopixel status boards 2021-07-23 15:42:06 -07:00
Scott Shawcroft 70cbb4eddb
Support multiple status neopixels
Use the 10 neopixels on the playgrounds for status.

Fixes #5039
2021-07-23 15:17:09 -07:00
microDev e790ff7327
Merge pull request #5036 from tannewt/esp_oserror0
Remove OSError(0) and old network modules
2021-07-23 11:00:56 +05:30
Scott Shawcroft beda1f7998
Merge pull request #5037 from hierophect/getprevtraceback
Add supervisor.get_previous_traceback() function.
2021-07-22 17:00:14 -07:00
Lucian Copeland ace04ef600 Formatting fixes 2021-07-22 12:57:10 -04:00
Christian Walther cf97793af8 Add supervisor.get_previous_traceback() function.
Useful for #1084.
2021-07-22 12:23:55 -04:00
Scott Shawcroft f84cb94819
Remove OSError(0) and old network modules
The newer modules are `socketpool` and `ssl`.

Fixes #3924, related to #2021, closes #1880, closes #2273, closes #2274
2021-07-21 17:33:40 -07:00
Dan Halbert ce7301527a
Merge pull request #5024 from tannewt/rp2_ble_wait
Don't blink blue on non-BLE workflow boards
2021-07-19 23:51:27 -04:00
Scott Shawcroft f8290e746b
Don't blink blue on non-BLE workflow boards
This includes any boards that have _bleio implemented via HCI.

Fixes #4969
2021-07-19 18:40:37 -07:00
Scott Shawcroft ca2cb9af2b
Remove MICROPY_PORT_* macros used for never reset
Now we use never_reset which is generally more correct and easier
to get right.

Fixes #5001 and fixes #4997
2021-07-15 16:20:04 -07:00
Scott Shawcroft 4d3a355f0a
Tweak blink and treat SWD reset like reset button 2021-07-14 16:45:47 -07:00
Scott Shawcroft 0fadf028ef
Create first BLE-only board, Micro:Bit v2
This fixes build issues with USB off, tweaks the README to allow
for BLE-only boards and adds the Micro:Bit v2 definition.

Fixes #4546
2021-07-14 09:55:51 -07:00
Scott Shawcroft 3940878695
Shrink builds and handle 0-length writes 2021-07-01 12:49:11 -07:00
Scott Shawcroft f2ef586331
clean up 2021-06-29 11:54:15 -07:00
Scott Shawcroft b36858daa0
Fix advertisement 2021-06-25 16:40:23 -07:00
Scott Shawcroft 3177973843
Add BLE serial service 2021-06-25 15:00:10 -07:00
Scott Shawcroft d67fb852a1
Merge pull request #3454 from cwalther/setnextcode
Add supervisor.set_next_code_file()
2021-06-25 11:00:53 -07:00
Scott Shawcroft dc76306cfa
Enable a BLE workflow
nRF CircuitPython boards will now provide the file transfer
service defined here: https://github.com/adafruit/Adafruit_CircuitPython_BLE_File_Transfer

USB capable boards will only advertise if previously bonded to a
device or if the reset button is pressed during the fast blue
flashes on start up. When pressed, the board will restart again but
the blue period will not flash.

Boards without USB will always advertise.

When previously bonded, the advertisement is private so that no
other peers can connect. If advertising publicly, the tx power is
lowered to reduce the likelihood of bonding from a distance.

This PR also fixes issues with loading identities of bonded peers
so that our address can now be resolved and we can resolve others'
addresses when scanning.
2021-06-24 12:59:14 -07:00
Scott Shawcroft b81573d439
Merge pull request #4891 from dhalbert/keypad-scanning-events
keypad: support for vector and matrix key scanning
2021-06-24 10:25:21 -07:00
Scott Shawcroft a7e353b80e
Merge pull request #4897 from jepler/merge-1.16
Merge 1.16
2021-06-23 10:15:10 -07:00
Dan Halbert ed41acd879 merge from upstream to fix translations 2021-06-21 08:26:44 -04:00
Lucian Copeland 626e4e9748 Fix missed precommit formatting 2021-06-20 17:00:56 -04:00
Lucian Copeland cf9741bd3a Merge remote-tracking branch 'upstream/main' into setnextcode 2021-06-20 15:25:37 -04:00
Jeff Epler e1d7e46e88 fix keyboard interrupt 2021-06-18 11:15:51 -05:00
Dan Halbert f97e0ec631 fix ulab commit 2021-06-15 11:51:28 -04:00
Dan Halbert 32eec85230 compiles 2021-06-14 20:54:43 -04:00
Jeff Epler 1d03ec12b5 supervisor: Fix assertion error in supervisor_move_memory
It was possible for _only_ a low allocation to be performed.
In this case, `high_head` is NULL, and the comparison
`MP_STATE_VM(first_embedded_allocation) < high_head` would fail.

Closes: #4871
2021-06-10 11:10:27 -05:00
Dan Halbert 95cbf3faa5 handle CIRCUITPY_USB_CDC = 0 properly (fix simmel build) 2021-06-02 15:27:20 -04:00
Dan Halbert 3930440bc5 Fix usb_cdc.enable(console=False, data=True) 2021-06-02 11:29:56 -04:00
Jeff Epler b0dd0e344c
Merge pull request #4772 from EmergReanimator/atmel-samd
[resolves #4771] DEBUG UART supported on ATMSAME5x
2021-05-28 20:05:06 -06:00
Scott Shawcroft 20946d97a1
Merge pull request #4743 from tannewt/simplify_status_led
Simplify the status LED to save power
2021-05-21 10:55:11 -07:00
Neradoc a8b6232402 don't print out "hard crash" when USER_SAFE_MODE demanded 2021-05-20 21:23:25 +02:00
Scott Shawcroft 5643355e90
Merge remote-tracking branch 'adafruit/main' into simplify_status_led 2021-05-20 08:35:15 -07:00
Scott Shawcroft 499a4388cf
Handle inverted neopixel power 2021-05-19 17:29:02 -07:00
Scott Shawcroft 642fbcf87a
Handle status led power
This no longer turns on status LED power before running user code.
Therefore, use of the status LED on some boards will also have to
enable the power.
2021-05-19 10:57:14 -07:00
Scott Shawcroft 9dabe882f1
Fix safe mode on rp2040 2021-05-19 10:18:43 -07:00
EmergReanimator 2b64b1d335 [resolves #4771] DEBUG UART supported on ATMSAME5x 2021-05-17 21:22:24 +02:00
Dan Halbert fa6c06fb38 count in/out endpoints; allow more usb modules on low-endpoint boards 2021-05-13 21:59:02 -04:00
Scott Shawcroft 1a0b4193b7
Simplify the status LED to save power
This also removes the need to pin share because we don't use the
status LED while user code is running.

The status flashes fallback to the HW_STATUS LED if no RGB LED is
present. Each status has a unique blink pattern as well.

One caveat is the REPL state. In order to not pin share, we set the
RGB color once. PWM and single color will be shutoff immediately but
DotStars and NeoPixels will hold the color until the user overrides
it.

Fixes #4133
2021-05-13 14:41:20 -07:00
Dan Halbert 0651ef17dd Fix endpoint checking; Clean up safe mode printing. 2021-05-12 15:53:52 -04:00
Scott Shawcroft 4eb4f14840
Merge pull request #4734 from dhalbert/dynamic-usb-fixes
fix HID; fix interface name table creation
2021-05-10 12:55:29 -07:00
Dan Halbert f504af3127 fix HID; fix interface name table creation 2021-05-09 00:42:45 -04:00
Jeff Epler aca9d5bc40 Fix up all natmod examples
* modframebuf: _mp_framebuf_p_t is not "really" a protocol, but the
   QSTR assignment caused problems when building as a dynamic module
 * modure: str_index_to_ptr is not in the natmod API, disable URE match
   spans when dynamic.  mp_obj_len() is a bugfix, we should throw here
   if the object is not string-like
 * moduzlib: Correct paths to uzlib headers & sources.  this relative
   path (from moduzlib.c to the referenced file) works in all cases,
   the other only worked from ports/PORTNAME.
 * dynruntime: Handle 2-arg m_malloc, assert_native_inited, add a
   micropythonish mp_arg_check_num_mp, fix mp_raise_msg to use dumb
   strings, add mp_raise_arg1
 * nativeglue: ad assert_native_inited
 * translate: MP_ERROR_TEXT evaluates to its argument for DYNRUNTIME
 * mpy-tool: A straggling magic number change
 * mpy_ld: Have to renumber manually after dynruntime change
 * import_mpy_native_gc.py: Update copy of features0 baked into this test
2021-05-08 20:17:16 -05:00
Scott Shawcroft 42f4065c8a
Merge remote-tracking branch 'adafruit/main' into merge_1.13 2021-05-06 11:17:53 -07:00
Dan Halbert ebf9dcb47a
Merge pull request #4689 from dhalbert/dynamic-usb-descriptors
Dynamic USB descriptors
2021-05-06 13:51:38 -04:00
Scott Shawcroft 3fda0c0a1b
Fix board builds and use MP_ERROR_TEXT in py and extmod 2021-05-05 17:51:52 -07:00
Dan Halbert 579cdf30f1 fix more build errors 2021-05-05 16:49:29 -04:00
Dan Halbert fc8e1c4c2e address review comments 2021-05-05 12:35:12 -04:00
Scott Shawcroft f0bb26d70f
Merge MicroPython 1.13 into CircuitPython 2021-05-04 18:06:33 -07:00
Lucian Copeland 17ee507f09 Remove overwrite of run_reason in main
When `reload_requested` is detected, the run reason will no longer be
automatically overwritten as an AUTO_RELOAD, making SUPERVISOR_RELOAD a
detectable reload reason. Autoreload now sets the reload reason itself.
2021-05-04 17:04:24 -04:00
Dan Halbert adc3d7d55e update Python API according to review comments 2021-05-03 22:29:02 -04:00
Dan Halbert 3e2236be8e missed an uncrustify 2021-05-03 20:59:50 -04:00
Dan Halbert d2b558993e merge from main, including MicroPython 1.12 merge 2021-05-03 20:56:04 -04:00
Scott Shawcroft b35fa44c8a
Merge MicroPython 1.12 into CircuitPython 2021-05-03 14:01:18 -07:00
Artyom Skrobov 9a5fb44c76 `workflow_active` was never defined or used
`supervisor_workflow_active` needs to be stubbed for when there's no USB
2021-05-01 13:34:28 -04:00
Jeff Epler dfa7c3d32d codeformat: Fix handling of `**`
After discussing with danh, I noticed that `a/**/b` would not match `a/b`.

After correcting this and re-running "pre-commit run --all", additional
files were reindented, including the codeformat script itself.
2021-04-30 15:30:13 -05:00
Jeff Epler e95e921ca1 codeformat: Fix filename matching
In #4683, tannewt noticed that uncrustify was not running on some
file in common-hal.

I investigated and found that it was not being run on a bunch of paths.

Rather than make incremental changes, I rewrote list_files to work
bsaed on regular expressions; these regular expressions are created from
the same git-style glob patterns.

I spot-checked some specific filenames after this change, and all looks good:

```
$ python3 tools/codeformat.py -v --dry-run tests/basics/int_small.py ports/raspberrypi/common-hal/pulseio/PulseIn.c extmod/virtpin.c tests/thread/thread_exit1.py  ports/raspberrypi/background.h extmod/re1.5/recursiveloop.c
tools/codeformat.py -v --dry-run tests/basics/int_small.py ports/raspberrypi/common-hal/pulseio/PulseIn.c extmod/virtpin.c tests/thread/thread_exit1.py ports/raspberrypi/background.h extmod/re1.5/recursiveloop.c
uncrustify -c /home/jepler/src/circuitpython/tools/uncrustify.cfg -lC --no-backup extmod/virtpin.c ports/raspberrypi/background.h ports/raspberrypi/common-hal/pulseio/PulseIn.c
black --fast --line-length=99 -v tests/thread/thread_exit1.py
```
recursiveloop and int_small are excluded, while PulseIn, virtpin,
and background are included.

Testing running from a subdirectory (not _specifically_ supported though):
```
(cd ports && python3 ../tools/codeformat.py -v --dry-run raspberrypi/common-hal/pulseio/PulseIn.c ../extmod/virtpin.c)
../tools/codeformat.py -v --dry-run raspberrypi/common-hal/pulseio/PulseIn.c ../extmod/virtpin.c
uncrustify -c /home/jepler/src/circuitpython/tools/uncrustify.cfg -lC --no-backup ../extmod/virtpin.c raspberrypi/common-hal/pulseio/PulseIn.
```

As a side-effect, a bunch more files are re-formatted now. :-P
2021-04-30 10:48:08 -05:00
Dan Halbert be7b2b00a8 uncrustify with newer version of uncrustify 2021-04-30 10:40:12 -04:00
Dan Halbert 71a8cadb09 working! 2021-04-29 22:26:38 -04:00
Dan Halbert abfb020d41 MSC, CDC, HID keyboard definitely working 2021-04-29 17:41:43 -04:00
Dan Halbert f06d54524d merge from adafruit 2021-04-28 23:48:26 -04:00
Dan Halbert 587aedd14f rework storage allocation 2021-04-28 13:00:44 -04:00
Dan Halbert d4d96bb25f
Merge pull request #4236 from jun2sak/nrf52-sleep
sleep and wakeup for nrf52
2021-04-28 12:11:31 -04:00
Dan Halbert 8500e846c6 partially working 2021-04-27 23:53:23 -04:00
Dan Halbert f98a54628b wip: compiles 2021-04-27 14:37:36 -04:00
Scott Shawcroft 17fcd499b2
Merge pull request #4649 from tannewt/merge_1.11_2
Merge MicroPython v1.11 into CircuitPython
2021-04-27 11:02:02 -07:00
Dan Halbert 7a40b4daec very much WIP 2021-04-26 23:54:01 -04:00
Scott Shawcroft 76033d5115
Merge MicroPython v1.11 into CircuitPython 2021-04-26 15:47:41 -07:00
Dan Halbert c26e49c2e6 wip: starting to try to compile 2021-04-25 23:17:41 -04:00
Dan Halbert 9d1fcc3b14 merge from main 2021-04-25 10:27:52 -04:00
Dan Halbert aea3c4d3ab wip 2021-04-25 10:23:59 -04:00
jun2sak 7accb8b173 modify copyright notice. 2021-04-25 19:57:21 +09:00
jun2sak a17fcb6d1a add copyright notice. remove obsolete comments. 2021-04-25 19:19:11 +09:00
Dan Halbert 556a126917 wip: getting closer 2021-04-23 21:44:13 -04:00
Artyom Skrobov 4e3c1d4a4c [build] Allow USB to be set to 0
Unify USB-related makefile var and C def as CIRCUITPY_USB.

Always define it as 0 or 1, same as all other settings.

USB_AVAILABLE was conditionally defined in supervisor.mk,
but never actually used to #ifdef USB-related code.

Loosely related to #4546
2021-04-23 11:13:34 -04:00
Dan Halbert 2b4c88d633 wip: partial HID, still needs rework 2021-04-23 00:18:05 -04:00
Dan Halbert 64e0958916 wip: descriptor building 2021-04-21 23:25:36 -04:00
Dan Halbert 6b18a51d57 wip: working on descriptor templates 2021-04-20 22:20:34 -04:00
Dan Halbert 51ccf8dc30 wip: revert usb_descriptor changes; use raw descriptors instead 2021-04-19 23:24:18 -04:00
Dan Halbert 4a7e129287 wip: latent usb device enabling/disabling 2021-04-13 23:33:44 -04:00
Scott Shawcroft bd5a3a3ba4
Merge pull request #4583 from tyomitch/patch-2
[qstr] Separate hash and len from string data
2021-04-12 15:06:40 -07:00
Dan Halbert c333acdbad
Merge pull request #4589 from hugodahl/feature/Remove-MicroPython-mention-in-error-messages
Make error messages platform agnostic
2021-04-10 21:30:17 -04:00
Hugo Dahl 36f3897fe3 Make error messages platform agnostic
Remove mentions of 'MicroPython' in error messages as they could lead to confusion in lesser-experienced users
2021-04-10 18:36:53 -05:00
Scott Shawcroft eacb7dbe58
Don't block serial output in interrupt
The interrupt may have a higher priority than the serial output's
(USB) interrupt and may never make room. This makes prints from
interrupts (like the BLE event calls) best effort for what can be
queued up. The rest of the output will be dropped.
2021-04-09 12:56:03 -07:00
Lucian Copeland 15764b4c24 Merge remote-tracking branch 'upstream/main' into nrf52-sleep 2021-04-09 13:48:45 -04:00
Artyom Skrobov c3e40d50ab [qstr] Separate hash and len from string data
This allows the compiler to merge strings: e.g. "update",
"difference_update" and "symmetric_difference_update"
will all point to the same memory.

Shaves ~1KB off the image size, and potentially allows
bigger savings if qstr attrs are initialized in qstr_init(),
and not stored in the image.
2021-04-06 12:58:42 -04:00
Jeff Epler 234fa2a226 decompress: Fix decompression when length takes 7 bits
This manifested as incorrect error messages from mpy-cross, like
```
$ mpy-cross doesnotexist.py
OSError: [Errno 2] cno such file/director
```

The remaining bits in `b` must be shifted to the correct position before
entering the loop.

For most (all?) actual builds, compress_max_length_bits was 8 and the
problem went unnoticed.
2021-04-04 11:15:33 -05:00
Jonny Bergdahl 1afd204828 Changed error message to display the generic term 'system firmware' instead of the Nordic specific term 'soft device' 2021-04-02 20:34:37 +02:00
Scott Shawcroft 01c153cd7e
Fix devices include by splitting type from defines 2021-03-25 11:37:08 -07:00
Scott Shawcroft aec0ef3cbf
Switch devices.h to nvm.toml data 2021-03-25 09:57:18 -07:00
Dan Halbert c81007afb0
Merge pull request #4446 from tannewt/rp2040_flash
Switch RP2040 flash settings to nvm.toml
2021-03-23 15:18:29 -04:00
Artyom Skrobov 3b613ff97c [spi_flash] handle reentrance gracefully
Report failure instead of deadlocking the device
2021-03-23 02:11:54 -04:00
Scott Shawcroft d52662856b
Merge pull request #4462 from jepler/disable-usb-cdc
storage: Correct when we check for USB mounts
2021-03-22 15:52:10 -07:00
Scott Shawcroft 7867632a81
Merge remote-tracking branch 'adafruit/main' into rp2040_flash 2021-03-22 15:29:43 -07:00
Jeff Epler 904e94abeb make declatations of usb_msc_ routines conditional
.. as suggested by @dhalbert
2021-03-22 15:04:57 -05:00
Linar Yusupov 76c1ae7194 fix for MX25R1635F QSPI mode of operation 2021-03-22 09:12:26 +03:00
Scott Shawcroft 5d2b60cbf6
Redo RP2040 flash settings
This switches stage2 to C and uses Jinja to change the C code based
on flash settings from https://github.com/adafruit/nvm.toml. It
produces the fastest settings for the given set of external flashes.
Flash size is no longer hard coded so switching flashes with similar
capabilities but different sizes should *just work*.

This PR also places "ITCM" code in RAM to save the XIP cache for
code execution. Further optimization is possible. A blink code.py
still requires a number of flash fetches every blink.

Fixes #4041
2021-03-18 16:55:42 -07:00
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Jeff Epler 1e5ffe1a53 Revert "circuitpy_mpconfig: Disable flash multi-partition"
This reverts commit 156ee4833a.
2021-03-09 11:08:36 -06:00
Scott Shawcroft b5a955a168
Merge pull request #4354 from jepler/disable-fat-partition
circuitpy_mpconfig: Disable flash multi-partition
2021-03-08 15:25:58 -08:00
Jeff Epler 32475ce98c Automatically count EXTERNAL_FLASH_DEVICES (mk2)
Instead of counting words in make, which is slightly awful, notice that
possible_devices is local to external_flash.c, so we can declare the array
with an automatic bound, and then get the count as the element-count
(MP_ARRAY_SIZE) of the array.

Since EXTERNAL_FLASH_DEVICE_COUNT is no longer a global macro, switch
a few sites to using EXTERNAL_FLASH_DEVICES in `#if` checks instead.
2021-03-07 12:51:47 -06:00
Jeff Epler f1ada8e880 Automatically count EXTERNAL_FLASH_DEVICES 2021-03-07 11:48:39 -06:00
Jeff Epler 156ee4833a circuitpy_mpconfig: Disable flash multi-partition
This adds some additional code in mkfs which doesn't seem necessary, and
Disabling it saves 172 bytes flash.

Testing performed: Using a Feather M0 Adalogger, checked that
 * an sdcard could still be mounted (using adafruit_sdcard)
 * os.listdir() of "/" and "/sd" worked
 * CIRCUITPY still mounted
2021-03-07 09:37:18 -06:00
jun2sak 51c7a49853 Merge branch 'main' into nrf52-sleep 2021-03-07 20:50:53 +09:00
Dan Halbert cd48c5ee83
Merge pull request #4315 from dhalbert/rp2040-i2c-short-writes
RP2040: Implement short I2C writes (2 bytes or less) using bitbangio
2021-03-03 12:42:47 -05:00
Dan Halbert 0a58d451ad
Merge pull request #4306 from Neradoc/fix-reset-to-safe
press reset to safe mode on ports where reset reason is not implemented
2021-03-02 15:44:52 -05:00
Dan Halbert f31b472309 Merge remote-tracking branch 'adafruit/main' into rp2040-i2c-short-writes 2021-03-02 15:17:12 -05:00
Dan Halbert 9939c59caa wip 2021-03-02 15:16:55 -05:00
Neradoc 7441625f37 allow the safe mode danse if RESET_REASON_UNKNOWN 2021-03-02 00:41:43 +01:00
Radomir Dopieralski 121c6bcc9b Replace displaio.Group.children with a python list
This is a first go at it, done by naive replacing of all array
operations with corresponding operations on the list. Note that
there is a lot of unnecessary type conversions, here. Also, list_pop
has been copied, because it's decalerd STATIC in py/objlist.h
2021-02-27 20:52:38 +01:00
Radomir Dopieralski 6e0ce23f3e displaio: don't store group children native object
Since we want to expose the list of group's children to the user,
we should only have the original objects in it, without any other
additional data, and compute the native object as needed.
2021-02-27 20:52:38 +01:00
Radomir Dopieralski 8c8d60fb80 Fix for CIRCUITPY_USB_MSC=0
Avoid undefined functions when MSC is disabled.
2021-02-27 15:05:00 +01:00
Kamil Tomaszewski ef3a61432b Add the missing argument to the HID functions 2021-02-24 19:09:17 +01:00
jun2sak 9661d67cd3 replace MY_DEBUG_UART -> NRF_DEBUG_PRINT. 2021-02-25 01:49:57 +09:00
jun2sak 105042e870 move dump_xxx functions to debug_uart.c. 2021-02-23 12:22:33 +09:00
Jeff Epler aa1de69645 fix length of generated serial number descriptor 2021-02-22 07:33:04 -06:00
Jeff Epler 144acfcb98 USB descriptors: Save flash storage for serial number
This saves about 60 bytes (Feather M4 went from 45040 -> 45100 bytes free)
66 bytes of data eliminated, but 6 bytes paid back to initialize the length
field.
2021-02-21 21:24:49 -06:00
jun2sak 1da8b9900a Merge branch 'main' into nrf52-sleep 2021-02-21 13:35:06 +09:00
jun2sak d659c2ce34 move port-specific debug functions from supervisor/shared/serial.c to ports/nrf/supervisor/port.c 2021-02-21 09:55:10 +09:00
jun2sak 26f8f532f1 safe mode fix. 2021-02-21 00:47:07 +09:00
Dan Halbert e344c6d684 fix some builds 2021-02-18 14:24:58 -05:00
jun2sak e6350ff834 Initial commit. 2021-02-17 20:53:18 +09:00
Dan Halbert 0b8f1b9a90 wip: usb_cdc.serials 2021-02-15 20:06:18 -05:00
Dan Halbert d54b5861a3 wip 2021-02-12 19:01:14 -05:00
Dan Halbert f0564b4986 merge from upstream; complicated webusb merge 2021-02-11 18:50:02 -05:00
Dan Halbert 1b7f3d11e7 wip 2021-02-08 10:57:41 -05:00
Dan Halbert 5bb722b927
Merge pull request #4122 from hathach/fix-3986
Fix 3986 background reset remove existing usb callback
2021-02-05 09:13:28 -05:00
Dan Halbert 0802b22ed6 usb descriptors all set; rework of enabling for USB devices 2021-02-04 19:23:40 -05:00
Kevin Banks c4a795b1e7 Changed URL 2021-02-04 16:31:18 -06:00
hathach 8d7b1f9e8c add usb_background_schedule()
unconditionally schedule usb background after
background_callback_reset()
2021-02-04 16:00:14 +07:00
Kevin Banks 215a56c920 Merge branch 'main' into webusb (trying to get CI back online) 2021-02-03 16:48:28 -06:00
hathach e699a59890 hack to fix 3986
just a proof to show that issue analysis is correct
2021-02-03 11:01:33 +07:00
Kevin Banks 1b031508e1 BOS and MS_OS_2.0 descriptors have been added. Still more descriptor work TODO. 2021-01-26 20:43:19 -06:00
Kevin Banks fbfb7b68cc Most of the code we need has been pulled in from the tinyusb webusb_serial demo. Still LOTS to do regarding descriptors. 2021-01-25 20:37:58 -06:00
Christian Walther 8889ac12e1 Add supervisor.set_next_code() function (prototype).
Part of #1084.
2021-01-23 23:05:31 +01:00
Scott Shawcroft b73b30ff9f
Switch to upstream TinyUSB 2021-01-21 11:33:13 -08:00
Scott Shawcroft af8cc9345d
Fix ESP build 2021-01-21 10:24:21 -08:00
Scott Shawcroft 733094aead
Add initial RP2040 support
The RP2040 is new microcontroller from Raspberry Pi that features
two Cortex M0s and eight PIO state machines that are good for
crunching lots of data. It has 264k RAM and a built in UF2
bootloader too.

Datasheet: https://pico.raspberrypi.org/files/rp2040_datasheet.pdf
2021-01-20 19:16:56 -08:00
Jeff Epler 1ca29ec47c Merge remote-tracking branch 'origin/main' into audioout-esp32 2021-01-12 09:23:07 -06:00
Dan Halbert 047708e36e
Merge pull request #3973 from kattni/update-code-py
Update created code.py file formatting.
2021-01-11 19:56:18 -05:00
Kattni Rembor 09596ddca2 Adding escape characters. 2021-01-11 16:26:27 -05:00
Kattni Rembor 9e9291777f Update created code.py file formatting. 2021-01-11 16:09:05 -05:00
Jeff Epler e20c65d8f0 background tasks: Add, use port_wake_main_task
Some ports need an extra operation to ensure that the main task is
awoken so that a queued background task will execute during an ongoing
light sleep.

This removes the need to enable supervisor ticks while I2SOut is operating.

Closes: #3952
2021-01-09 14:02:47 -06:00
Dan Halbert 255ffa979c avoid inline compile errors 2021-01-08 23:07:21 -05:00
DavePutz ce55822680
Fix size of memset in board_reset_user_neopixels() 2021-01-04 15:50:09 -06:00
Dan Halbert 938a0fa2fc
Add include to tick.c for mp_hal_is_interrupted() 2020-12-26 13:39:48 -05:00
Dan Halbert 8061a2574d
Merge branch 'main' into pin_alarm 2020-12-23 22:05:02 -05:00
Scott Shawcroft 8b5b602ea7
Merge pull request #3862 from dhalbert/storage-remount
unmounted filesystems start as ejected
2020-12-22 10:11:54 -08:00
Dan Halbert f226f4a233
Merge pull request #3864 from djix123/w25q64fv
Add support for Winbond W25Q64FV
2020-12-22 09:29:22 -05:00
Jonathan Giles 17e7973ff2 Add support for Winbond W25Q64FV 2020-12-22 07:50:56 -05:00
Dan Halbert 3b4c14f3ec unmounted filesystems start as ejected 2020-12-21 20:43:46 -05:00
Dan Halbert 233ccaac58
Merge pull request #3824 from skerr92/add_more_spi_flash
Adding Support for AT25DF641A SPI Flash
2020-12-21 14:48:36 -05:00
Hany Elkomy 70a9c601a8
Update devices.h
Correct capacity value for the MX25R1635F from 0x18 to 0x15 (tested and working)
refer to 
https://github.com/adafruit/circuitpython/issues/3558
2020-12-17 12:52:51 +08:00
Seth Kerr ca757f2ead removed comments on 64MiB SPI flash causing build test issues 2020-12-16 10:25:20 -05:00
Scott Shawcroft 1ad49d9a18
Add alarm.pin that wakes on pin level
Fixes #3787
2020-12-15 18:12:59 -08:00
Seth Kerr 6d8642bf41 fixing line comment issue with CI build tests 2020-12-14 17:17:28 -05:00
Seth Kerr 731cdefe80 this should be it. 2020-12-14 16:25:33 -05:00
Scott Shawcroft 0b4bcd9599
Fix build and more comments 2020-12-08 13:05:21 -08:00
Scott Shawcroft 40118bcf57
Add `board_deinit` for use with sleep
This changes lots of files to unify `board.h` across ports. It adds
`board_deinit` when CIRCUITPY_ALARM is set. `main.c` uses it to
deinit the board before deep sleeping (even when pretending.)

Deep sleep is now a two step process for the port. First, the
port should prepare to deep sleep based on the given alarms. It
should set alarms for both deep and pretend sleep. In particular,
the pretend versions should be set immediately so that we don't
miss an alarm as we shutdown. These alarms should also wake from
`port_idle_until_interrupt` which is used when pretending to deep
sleep.

Second, when real deep sleeping, `alarm_enter_deep_sleep` is called.
The port should set any alarms it didn't during prepare based on
data it saved internally during prepare.

ESP32-S2 sleep is a bit reorganized to locate more logic with
TimeAlarm. This will help it scale to more alarm types.

Fixes #3786
2020-12-08 10:52:25 -08:00
Scott Shawcroft d7ba641ff6
Merge pull request #3767 from dhalbert/sleep
Initial alarm and sleep PR: time alarms with light and deep sleep; PinAlarms not yet implemented
2020-12-02 12:51:43 -08:00
Christian Walther d6f8a43f6c Eliminate goto. 2020-11-30 23:33:38 +01:00
Christian Walther 11ed6f86f0 Optimize out allocation moving code on boards that don't need it.
When no features are enabled that use movable allocations, supervisor_move_memory() is not needed.
2020-11-29 16:27:36 +01:00
Christian Walther 9ecaa16ece Unify redundant low/high_address computation to save a bit of code size. 2020-11-29 16:04:31 +01:00
Christian Walther 993a581f5e Make CIRCUITPY_SUPERVISOR_ALLOC_COUNT dependent on enabled features.
Avoids wasted memory and makes it easier to keep track of who needs how much for future additions.
2020-11-28 17:54:34 +01:00
Christian Walther 7ca36d45a4 Fix align32_size().
It not only caused crashes with requests larger than 64K (can happen with RGBMatrix), but also generated a lot longer code than necessary.
2020-11-28 17:54:34 +01:00
Christian Walther 2ba9805f84 Use movable allocation system for terminal tilegrid.
Moving memory is now done by the infrastructure and neither necessary nor correct here anymore.
2020-11-28 17:54:34 +01:00
Christian Walther c7404a3ff8 Add movable allocation system.
This allows calls to `allocate_memory()` while the VM is running, it will then allocate from the GC heap (unless there is a suitable hole among the supervisor allocations), and when the VM exits and the GC heap is freed, the allocation will be moved to the bottom of the former GC heap and transformed into a proper supervisor allocation. Existing movable allocations will also be moved to defragment the supervisor heap and ensure that the next VM run gets as much memory as possible for the GC heap.

By itself this breaks terminalio because it violates the assumption that supervisor_display_move_memory() still has access to an undisturbed heap to copy the tilegrid from. It will work in many cases, but if you're unlucky you will get garbled terminal contents after exiting from the vm run that created the display. This will be fixed in the following commit, which is separate to simplify review.
2020-11-28 17:50:23 +01:00
Dan Halbert e308a9ec11 working! PinAlarm not implemented yet. 2020-11-27 16:03:37 -05:00
Dan Halbert ef0830bfe2 merge from upstream + wip 2020-11-25 17:52:06 -05:00
Dan Halbert 7a45afc549 working, but need to avoid deep sleeping too fast before USB ready 2020-11-23 22:44:53 -05:00
Dan Halbert a0f1ec3c4a wip 2020-11-22 19:10:09 -05:00
Dan Halbert 75559f35cc wip: ResetReason to microcontroller.cpu 2020-11-21 23:29:52 -05:00