Commit Graph

62 Commits

Author SHA1 Message Date
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
root
d948e6570f Changes to handle Ctrl-C during sleep 2020-11-05 21:27:21 -06:00
root
c2aa54ae66 Check for Ctrl-C during sleeps 2020-11-05 11:10:40 -06:00
Lucian Copeland
b5f8321d37 Merge branch 'esp32-analogin' into esp32-analogout 2020-10-08 12:42:00 -04:00
hathach
e1fc85c56b fix usb issue with latest idf 2020-10-08 13:30:32 +07:00
Scott Shawcroft
8c428a3bdd
Merge pull request #3492 from hierophect/esp32-update-idf
ESP32S2: move to official IDF submodule
2020-10-06 16:53:32 -07:00
Lucian Copeland
d5c8e55769 Add AnalogIO 2020-10-06 15:13:50 -04:00
hierophect
e93a274f2f
Merge branch 'main' into esp32-analogin 2020-10-05 13:02:42 -04:00
Lucian Copeland
66b8559fd4 Change submodule, rework all includes 2020-09-30 11:26:07 -04:00
Jeff Epler
1dbb59271c esp32: Use esp_restart from reset_to_bootloader; redeclare it NORETURN 2020-09-28 18:56:01 -05:00
Jeff Epler
726dcdb60a Add some NORETURN attributes
I have a function where it should be impossible to reach the end, so I put in a safe-mode reset at the bottom:
```
int find_unused_slot(void) {
    // precondition: you already verified that a slot was available
    for (int i=0; i<NUM_SLOTS; i++) {
        if( slot_free(i)) {
            return i;
        }
    }
    safe_mode_reset(MICROPY_FATAL_ERROR);
}
```
However, the compiler still gave a diagnostic, because safe_mode_reset was not declared NORETURN.

So I started by teaching the compiler that reset_into_safe_mode never returned.  This leads at least one level deeper due to reset_cpu needing to be a NORETURN function.  Each port is a little different in this area.  I also marked reset_to_bootloader as NORETURN.
Additional notes:

 * stm32's reset_to_bootloader was not implemented, but now does a bare reset.  Most stm32s are not fitted with uf2 bootloaders anyway.
 * ditto cxd56
 * esp32s2 did not implement reset_cpu at all.  I used esp_restart().  (not tested)
 * litex did not implement reset_cpu at all.  I used reboot_ctrl_write.  But notably this is what reset_to_bootloader already did, so one or the other must be incorrect (not tested).  reboot_ctrl_write cannot be declared NORETURN, as it returns unless the special value 0xac is written), so a new unreachable forever-loop is added.
 * cxd56's reset is via a boardctl() call which can't generically be declared NORETURN, so a new unreacahble "for(;;)" forever-loop is added.
 * In several places, NVIC_SystemReset is redeclared with NORETURN applied.  This is accepted just fine by gcc.  I chose this as preferable to editing the multiple copies of CMSIS headers where it is normally declared.
 * the stub safe_mode reset simply aborts.  This is used in mpy-cross.
2020-09-28 18:55:56 -05:00
microDev
add230b4da
Update port.c 2020-09-22 11:37:12 +05:30
Scott Shawcroft
99f5011d74
Fix heap without PSRAM. Never set heap_size. 2020-09-08 17:06:09 -07:00
Scott Shawcroft
767ca5c3dc
Merge remote-tracking branch 'adafruit/main' into native_wifi 2020-08-27 11:42:31 -07:00
Dan Halbert
6100027243
Merge pull request #3315 from tannewt/add_psram
Add PSRAM support to ESP32S2
2020-08-27 11:58:59 -04:00
Scott Shawcroft
8b71e26abd
Merge remote-tracking branch 'adafruit/main' into native_wifi 2020-08-25 16:39:23 -07:00
Scott Shawcroft
f39708abb2
Add PSRAM support to ESP32S2
When configured the CircuitPython heap will be on the external RAM.
When not available, the heap will be 48k inside the IDF heap.
2020-08-21 16:20:58 -07:00
Scott Shawcroft
a5b01f7361
Merge remote-tracking branch 'adafruit/main' into add_pwmio 2020-08-21 11:13:53 -07:00
Scott Shawcroft
dcc42f6281
Remove debug prints 2020-08-19 14:23:28 -07:00
Scott Shawcroft
430530c74b
SSL works until it runs out of memory 2020-08-19 14:23:28 -07:00
Scott Shawcroft
ddcff85fa2
Add debugging. Scanning doesn't crash but returns no results. Need to config station. 2020-08-19 14:22:12 -07:00
Scott Shawcroft
1a6f4e0fe0
Scanning WIP. Need to sort out supervisor memory 2020-08-19 14:22:12 -07:00
Scott Shawcroft
6857f98426
Split pulseio.PWMOut into pwmio
This gives us better granularity when implementing new ports because
PWMOut is commonly implemented before PulseIn and PulseOut.

Fixes #3211
2020-08-18 13:08:33 -07:00
Lucian Copeland
88fcc19e24 Add PulseIn 2020-08-14 15:30:48 -04:00
Lucian Copeland
f9512983ff Add PulseOut 2020-08-14 12:21:41 -04:00
Scott Shawcroft
8488b31aa0
Init directly 2020-08-11 11:19:40 -07:00
Scott Shawcroft
87c78be8f4
Fix writing sector 0 as the first write.
This was the FS issue I saw when debugging wifi and only happens
when the first write is to sector 0. It causes issues because it
blanks all of sector 0 after the first block.

Fixes #3133
2020-08-10 17:14:49 -07:00
Lucian Copeland
61a2e4f94b Add PWMOut 2020-07-22 16:34:18 -04:00