Commit Graph

253 Commits

Author SHA1 Message Date
Dan Halbert 41168c8008
Merge pull request #5222 from Neradoc/nera-board-id-in-bootout
Make the board ID available in board and boot_out
2021-08-26 19:21:27 -04: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
Neradoc c70ec3fbbc add the Board ID to boot_out.txt 2021-08-26 23:11:55 +02: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
Jeff Epler 5c9f7e2fe4 simplify printing a compressed message 2021-08-23 20:23:23 -05:00
microDev 25437dcb33
Merge branch 'main' into atexit 2021-08-20 09:45:54 +05:30
microDev bdf8bc58ed
allow exception raise inside atexit callback 2021-08-16 22:35:04 +05:30
microDev 1c4a6c3667
atexit module refinements
- add test for atexit module
- add callback to gc collection
- fix callback memory allocation
- execute callback on both code and repl exit
2021-08-16 21:37:32 +05:30
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
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
Christian Walther 09e6846135 Fix empty boot_out.txt
A pointer to the FIL structure was kept after it went out of scope.
Apparently this happened to work until cf97793 added the `result`
variable that clobbered it.

Fixes #5062
2021-08-02 23:46:33 +02:00
microDev a3998d0626
add atexit module 2021-07-30 09:32:28 +05:30
Jeff Epler 4e786494dd Remove settings.py/txt as alternatives for boot.py
Closes: #5064
2021-07-26 13:04:41 -05: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
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
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 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
Lucian Copeland 372ddfd562 Fix deep sleep masking, cleanup 2021-06-20 17:20:47 -04:00
Lucian Copeland 2c30312dd4 Fix waitskip behavior 2021-06-20 16:57:20 -04:00
Lucian Copeland cf9741bd3a Merge remote-tracking branch 'upstream/main' into setnextcode 2021-06-20 15:25:37 -04:00
Dan Halbert 32eec85230 compiles 2021-06-14 20:54:43 -04:00
Scott Shawcroft 561ffec693
Merge remote-tracking branch 'adafruit/main' into simplify_status_led 2021-05-20 13:46:42 -07:00
Scott Shawcroft 5643355e90
Merge remote-tracking branch 'adafruit/main' into simplify_status_led 2021-05-20 08:35:15 -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 6164d44e6d
Turn off LED after REPL 2021-05-18 11:32:45 -07:00
Lucian Copeland 633d83cc3e Merge remote-tracking branch 'upstream/main' into sleep-revamp 2021-05-17 18:57:10 -04:00
Scott Shawcroft 5c33c9d597
Fix SAMD
RTC needed to wait for sync. NeoPixel on SAMD doesn't need disabled
caches. It just needed timing adjustment for 120mhz clock speed.
2021-05-14 16:14:24 -07:00
Scott Shawcroft 689ec86225
Merge pull request #4754 from dhalbert/fix-endpoint-checking
Fix endpoint checking; Clean up safe mode printing
2021-05-14 11:25:01 -07: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
Lucian Copeland 295103bb31 Merge remote-tracking branch 'upstream/main' into sleep-revamp 2021-05-13 16:22:12 -04:00
Dan Halbert 0651ef17dd Fix endpoint checking; Clean up safe mode printing. 2021-05-12 15:53:52 -04:00
Lucian Copeland 0d3c5222d8 Merge remote-tracking branch 'upstream/main' into stm-alarm 2021-05-10 17:30:33 -04:00
Dan Halbert 4b45c37516 Do USB init even in safe mode 2021-05-08 11:03:05 -04:00
Dan Halbert ebf9dcb47a
Merge pull request #4689 from dhalbert/dynamic-usb-descriptors
Dynamic USB descriptors
2021-05-06 13:51:38 -04:00
Lucian Copeland f38f5dbce6 Set reload reason when reloaded from repl 2021-05-05 17:02:32 -04: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 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
Lucian Copeland 9feef41c82 Merge remote-tracking branch 'upstream/main' into stm-alarm 2021-04-28 15:10:55 -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
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
jun2sak 7accb8b173 modify copyright notice. 2021-04-25 19:57:21 +09: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
Lucian Copeland 7eeea869ac Fix light sleep global alarms, API revisions 2021-04-15 15:02:42 -04:00
Dan Halbert 4a7e129287 wip: latent usb device enabling/disabling 2021-04-13 23:33:44 -04:00
jun2sak 6e9429d779 soft reboot for pretending deep sleep. 2021-04-12 20:53:14 +09:00
Lucian Copeland 15764b4c24 Merge remote-tracking branch 'upstream/main' into nrf52-sleep 2021-04-09 13:48:45 -04:00
Lucian Copeland 17585e1e07 Clean up API 2021-04-02 14:08:48 -04:00
Lucian Copeland d35a307ffa Merge branch 'sleep-api-update' into stm-alarm 2021-03-29 12:27:25 -04:00
Lucian Copeland 00178ca5e0 Sleep API changes, redundancy fix 2021-03-27 14:14:57 -04:00
Lucian Copeland 529fb52309 Style changes and wakeup detection 2021-03-27 13:16:12 -04:00
Lucian Copeland 6b2c9985ff Extract RTC, implement fake RTC deepsleep 2021-03-11 17:50:05 -05:00
jun2sak 3fab9f8b1b new wait-until-alarm design, don't use System OFF. 2021-03-07 01:09:54 +09:00
Lucian Copeland f1792c8474 Extract EXTI, create base sleep framework 2021-03-02 11:41:53 -05:00
jun2sak 7bb789625e use the original port_idle_until_interrupt() if not CIRCUITPY_ALARM. 2021-02-28 16:27:37 +09:00
jun2sak 3e47e00291 address the pretending-to-deep-sleep issue. 2021-02-28 15:57:37 +09:00
jun2sak fac86c8277 remove unused debug printf's. 2021-02-28 15:34:55 +09:00
jun2sak 9661d67cd3 replace MY_DEBUG_UART -> NRF_DEBUG_PRINT. 2021-02-25 01:49:57 +09:00
jun2sak 057682f776 cleanup. 2021-02-24 00:13:11 +09:00
jun2sak ec64fa6a29 move dump_xxx functions to debug_uart.c. 2021-02-23 12:16:37 +09:00
jun2sak 1da8b9900a Merge branch 'main' into nrf52-sleep 2021-02-21 13:35:06 +09:00
jun2sak 26f8f532f1 safe mode fix. 2021-02-21 00:47:07 +09: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 25d456a5b8 shrink a couple of builds 2021-02-04 22:15:32 -05:00
hathach 8d7b1f9e8c add usb_background_schedule()
unconditionally schedule usb background after
background_callback_reset()
2021-02-04 16:00:14 +07:00
Christian Walther 8889ac12e1 Add supervisor.set_next_code() function (prototype).
Part of #1084.
2021-01-23 23:05:31 +01:00
Scott Shawcroft fb1e0106b5
Fix press any key message 2021-01-20 19:16:56 -08:00
microDev 0bad6110d4
update wake-alarm implementation 2020-12-31 02:44:20 +05:30
Scott Shawcroft 1fca297a2d
A couple sleep fixes
* Better messaging when code is stopped by an auto-reload.
* Auto-reload works during sleeps on ESP32-S2. Ticks wake up the
  main task each time.
* Made internal naming consistent. CamelCase Python names are NOT
  separated by an underscore.
2020-12-22 16:13:02 -08:00
Dan Halbert d4e9eea397
mark alarm.wake_alarm during gc sweep 2020-12-22 08:11:01 -08:00
Scott Shawcroft 1ad49d9a18
Add alarm.pin that wakes on pin level
Fixes #3787
2020-12-15 18:12:59 -08:00
Dan Halbert cf938983e9 SleepMemory + set alarm.wake_alarm 2020-12-11 08:10:26 -05:00
Mike Causer eedcc98cc5 Fix some spelling mistakes 2020-12-10 02:52:18 +11: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
Dan Halbert 169b487509 Include wifi.radio singleton in gc 2020-12-07 11:07:56 -05: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
Dan Halbert 8b7c23c1ee address review comments 2020-12-01 20:01:14 -05: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 104a089677 deep sleep working; deep sleep delay when connected 2020-11-26 22:06:37 -05:00
Dan Halbert ef0830bfe2 merge from upstream + wip 2020-11-25 17:52:06 -05:00
Dan Halbert 9dbea36eac changed alarm.time API 2020-11-25 15:09:27 -05:00
Dan Halbert f868cc5dd0 some API renaming and bug fixes; fix docs 2020-11-24 23:37:05 -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
Dan Halbert 39e1f52e28 wip; not compiling yet 2020-11-19 17:47:12 -05:00
Dan Halbert 649c930536 wip 2020-11-19 15:43:39 -05:00
Dan Halbert bb77f1d130 wip: initial code changes, starting from @tannewt's sleepio branch 2020-11-16 11:56:20 -05:00
Scott Shawcroft 9a4efed8cb
Start tweaking the workflow to sleep 2020-10-27 17:55:03 -07:00
microDev 0e444f0de8
Implement sleep on code.py exit 2020-10-27 16:17:29 -07:00