Commit Graph

89 Commits

Author SHA1 Message Date
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 cdf978f3af
Fix a couple fake sleep bugs on nrf and esp
On ESP ctrl-c during fake sleep will now stop the sleep. A crash
on real deep sleep is now fixed as well. (Exception string saving
was crashing on reading the deep sleep exception.) Fixes #4010

This also fixes nRF fake sleep after the first time. The internal
variable wasn't being reset early enough. Fixes #4869
2021-07-28 13:27:48 -07:00
Scott Shawcroft 5a4a80336f
Merge pull request #4195 from askpatrickw/update-idf
Update esp-idf to v4.3
2021-06-25 11:15:40 -07:00
microDev e0eecd2f76 update idf to v4.3
- update idf submodule to release/v4.3
- finish todo tasks held due to idf@v4.2
- update SPI & I2C to make them v4.3 compatible
2021-06-24 23:14:08 +05:30
Scott Shawcroft a7e353b80e
Merge pull request #4897 from jepler/merge-1.16
Merge 1.16
2021-06-23 10:15:10 -07:00
Jeff Epler e1d7e46e88 fix keyboard interrupt 2021-06-18 11:15:51 -05:00
Jeff Epler 2cbdd18a20 esp32s2: Implement parallel image capture 2021-06-10 11:27:49 -05:00
Scott Shawcroft 59c2787702
Fix esp32s2 build 2021-05-05 18:27:21 -07:00
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
hierophect f88a896c03
Merge pull request #3854 from hierophect/esp-tcpserver
ESP32S2: Implement TCP Server bindings
2021-01-21 17:25:14 -05:00
dheera d43eb7e84b prevents going into safe mode for watchdog resets 2021-01-16 17:38:08 -08:00
Lucian Copeland 287770f885 Merge remote-tracking branch 'upstream/main' into esp-tcpserver 2021-01-14 10:21:08 -05:00
Lucian Copeland 37a8c1c575 Complete non-blocking implementations, add socket close checking 2021-01-13 19:05:07 -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
Jeff Epler 4735cf4747 esp32s2: audiobusio: move i2s_common inside
Originally, I believed the implementation might be shared with AudioOut,
as on the ESP32 (non-S2) the I2S peripheral was also used to drive the DAC.
However, this is not the case on ESP32-S2 and appears it will not be
the case with the ESP32-S3 or -C3, to the extent that there's skeletal
support for either of them in esp-idf master branch.

However, it could still be shared by I2SIn or PDMIn (the latter being
hypothetically implemented as I2SIn + digital postprocessing like we did
in the atmel-sam port, to my understanding), so I moved it to
the common-hal folder.
2021-01-09 14:02:47 -06:00
Jeff Epler 010a4e7b0f esp32s2: port: Ensure JTAG pins are available for debugging 2021-01-07 16:23:21 -06:00
Jeff Epler 30c6dd3f76 Merge remote-tracking branch 'origin/main' into audioout-esp32 2021-01-07 14:11:14 -06:00
microDev 28ce5e8988
Merge branch 'main' into touch-s2 2020-12-30 22:44:22 +05:30
Jeff Epler a7542598a0 esp32s2: add I2SOut 2020-12-29 14:46:38 -06:00
Dan Halbert 8061a2574d
Merge branch 'main' into pin_alarm 2020-12-23 22:05:02 -05:00
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
microDev a60fabdffa
add touch alarm support for esp32s2 2020-12-19 12:56:34 +05:30
microDev 4863413bc9
rename ota to dualbank 2020-12-18 00:34:56 +05:30
Scott Shawcroft 0dcc659d53
Swap to IDF release/4.2 branch for stability 2020-12-15 18:12:59 -08:00
Scott Shawcroft 1ad49d9a18
Add alarm.pin that wakes on pin level
Fixes #3787
2020-12-15 18:12:59 -08:00
microDev 37ee5e683d
Merge branch 'main' into ota-s2 2020-12-12 05:25:46 +05:30
microDev 6a4f74946f
reset ota module on every vm run 2020-12-10 16:48:58 +05:30
Scott Shawcroft 133013083a
Merge pull request #3808 from tannewt/panic_safe_mode
Enter safe mode after panic or brownout
2020-12-08 16:31:22 -08:00
Scott Shawcroft d0a806d797
Enter safe mode after panic or brownout
Uses the IDF's reset reason. Does nothing before reset.

Fixes #3389
2020-12-08 11:03:24 -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 44b56f76c4
Store safe mode state in the RTC.
Also print backtrace before reset when DEBUG. This will help debug
safe mode issues which calls reset.
2020-12-07 16:39:54 -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
Scott Shawcroft 5b3c930e38
Merge pull request #3738 from microDev1/fix-touch
ESP32S2: Fix multiple touchpad don't work simultaneously
2020-11-30 16:03:16 -08: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
microDev e90cb3ad86
Merge branch 'main' into fix-touch 2020-11-26 11:33:45 +05:30
microDev 6af48bb24c
reset touchin on every vm run 2020-11-26 11:22:44 +05:30
Dan Halbert ef0830bfe2 merge from upstream + wip 2020-11-25 17:52:06 -05:00
microDev 9dd1783da5
Merge branch 'main' into ps2io-S2 2020-11-24 11:11:11 +05:30
Scott Shawcroft c67f5892ff
Merge pull request #3704 from microDev1/frequencyio-S2
ESP32S2: Support for FrequencyIO
2020-11-23 14:59:27 -08:00
Dan Halbert a0f1ec3c4a wip 2020-11-22 19:10:09 -05:00
microDev b56645808c
fix crash on user code exit 2020-11-19 11:44:22 +05:30
microDev ff987e7496
add timer peripheral 2020-11-18 12:16:14 +05:30
Jeff Epler 9206925bf8 esp32s2: port_get_raw_ticks: Use a more efficient, monotonic routine
While trying to debug #3572, I noticed that I would frequently break in
the midst of gettimeofday and that the routine get_adjusted_boot_time
had to take and release locks.  Furthermore, we don't want "adjusted"
boot time, which could go forwards or backwards depending on the
adjustment (such as setting the clock used by gettimeofday() to the network
time)
2020-11-17 17:45:41 -06:00
Scott Shawcroft 66fb095069
Merge pull request #3667 from microDev1/watchdog-s2
ESP32S2: Support for WatchDog
2020-11-16 15:01:54 -08:00
microDev 146adca060
Add watchdog mode raise 2020-11-14 11:41:14 +05:30
microDev ff41180237
pcnt reset on reload 2020-11-12 16:30:30 +05:30
Scott Shawcroft ddb3590944
Merge pull request #3647 from DavePutz/issue3579
Issue3579 - Check for CTRL-C During sleep on esp32s2
2020-11-10 13:09:57 -08:00
root fe7ed99939 Split out extern declare to ports/esp32s2/supervisor/esp_port.h 2020-11-10 12:45:39 -06:00
root 44425b8d94 Requested review changes made 2020-11-10 11:32:59 -06:00
Jeff Epler 2d8ebfcf63 esp32s2: Correct port_stack_get_top()
Closes #3649
2020-11-10 10:42:53 -06:00