Commit Graph

60 Commits

Author SHA1 Message Date
Scott Shawcroft 3fdfb9bd32
Update ADC and I2S APIs for 5.1
This fixes ESP32 because the BufferedIn used the old ADC API and
I2S did too indirectly.

Fixes #8429
2023-09-26 16:06:54 -07:00
Scott Shawcroft 6649b17fb5
H2 works 2023-09-22 10:03:20 -07:00
Scott Shawcroft 7bad82a219
C6 compiles, runs but wifi crashes 2023-09-22 10:02:35 -07:00
Scott Shawcroft e22eefabd7
First stab at 5.1 update 2023-09-22 10:02:30 -07:00
Scott Shawcroft 0547ef61f9
Update dotclock for IDF 5.0 2023-09-15 14:43:37 -07:00
Scott Shawcroft 952118f6c3
Update new boards. Reduce memory use in S2 2023-09-14 11:19:38 -07:00
MicroDev a18e015888
update idf to v5.0 2023-09-13 11:33:51 -07:00
Jeff Epler 6153d23ed8
Fix build with no psram
these are conditionally-defined identifiers so have to use if defined.
2023-09-05 21:30:35 -05:00
Jeff Epler 5e26862b2c
Allow use of CONFIG_SPIRAM_USE_CAPS_ALLOC
.. and switch makerfabs tft7 over to it as a test.

We have our existing way of "reserving" PSRAM for esp-idf (we actually
control it all but add back the "reserved" part). However, this does
not work with off the shelf esp_lcd, which only will allocate a
framebuffer in PSRAM if CONFIG_SPIRAM_USE_CAPS_ALLOC (or CONFIG_SPIRAM_USE_ALLOC)
is defined, not if CONFIG_SPIRAM_USE_MEMMAP is.

This new way is possibly compatible with more esp-idf code, but it complicates
CircuitPython's initial startup since nothing until port_heap_init is
permitted to use the CP heap or supervisor allocator. In practice this
seems to be OK today.

Right now this doesn't change the setting across all boards with PSRAM and so
it does not revert esp-idf to its prior state. Instead, what I'm thinking is
that we can do it during or just after the IDF5 update when sdkconfig files
will be getting an overhaul anyway.
2023-09-05 12:43:22 -05:00
Jeff Epler 6784e0e720
Ensure debug is defined earlier 2023-09-05 12:06:57 -05:00
Jeff Epler 7dbf9a9b56
fix vprintf_adapter build error 2023-08-30 11:34:01 -05:00
Jeff Epler ed9cacf41d
Add DotClockFramebuffer 2023-08-30 10:30:15 -05:00
Dan Halbert b6a7613350
Merge pull request #7470 from microdev1/espnow
Add ESP-NOW Support
2023-03-10 12:21:56 -05:00
Dan Halbert d8231f1588 Implement safemode.py 2023-02-13 18:26:38 -05:00
MicroDev 14c3b52b8d
Merge branch 'main' into espnow 2023-02-03 01:37:07 +05:30
MicroDev cda5689263
move `esp32_camera` to `espcamera` 2023-01-27 22:05:43 +05:30
MicroDev f15e84de6c
update espnow module 2023-01-23 09:42:39 +05:30
MicroDev 7330c638b9
minimal changes to make espnow work 2023-01-20 14:12:55 +05:30
Scott Shawcroft f8ac1d9261
Rework the coproc API
It is now a generic `memorymap` API and an ESP specific `espulp` module.

Fixes #7218. Fixes #3234. Fixes #7300.
2022-12-19 14:08:38 -05:00
Jeff Epler 44f15d563d
Rename "environ" errors to "getenv" errors 2022-12-09 14:14:53 -06:00
Jeff Epler 3a92c079fc
Finish renaming os_environ_get_key to os_getenv
.. for consistency.
2022-12-09 14:07:23 -06:00
Jeff Epler 3459fe322b
Withdraw the _environ module
This existed solely for testing, so expose it a different way during
the unix coverage build

Also turn off os.getenv support on samd21.
2022-12-08 15:33:10 -06:00
Jeff Epler ef2bfdb5db
dotenv becomes settings.toml 2022-12-08 12:44:20 -06:00
Scott Shawcroft f1053fb963
Introduce port_yield()
This allows the web workflow send code to yield briefly when
waiting for more room to send in a socket. Waiting for an "interrupt"
could wait forever because the select task only waits for read and
error. Adding wait on write is tricky because much of the time we
don't care if the sockets are ready to write. Using yield avoids
this trickiness.
2022-08-11 11:25:34 -07:00
Jeff Epler 1da8065d6b
Merge remote-tracking branch 'origin/main' into espressif-camera-2 2022-08-05 16:38:51 -05:00
Dan Halbert 8c10e09ba0
Merge pull request #6667 from jepler/esp-reserve-heap-for-idf
Add ability to reserve psram
2022-08-05 15:06:44 -04:00
Jeff Epler d1b89fca91
Reset camera when interpreter is reset 2022-08-04 15:11:55 -05:00
Jeff Epler 5db6db0128
add esp32-camera
This uses the esp32-camera code instead of our own homebrewed camera code.
In theory it supports esp32, esp32-s2 and esp32-s3, as long as they have
PSRAM.

This is very basic and doesn't support changing any camera parameters,
including switching resolution or pixelformat.

This is tested on the Kaluga (ESP32-S2) and ESP32-S3-Eye boards.

First, reserve some PSRAM by putting this line in `CIRCUITPY/_env`:
```
CIRCUITPY_RESERVED_PSRAM=524288
```
and hard-reset the board for it to take effect.

Now, the following script will take a very low-resolution jpeg file and print
it in the REPL in escape coded form:

```python
import board
import esp32_camera

c = esp32_camera.Camera(
    data_pins=board.CAMERA_DATA,
    external_clock_pin=board.CAMERA_XCLK,
    pixel_clock_pin=board.CAMERA_PCLK,
    vsync_pin=board.CAMERA_VSYNC,
    href_pin=board.CAMERA_HREF,
    pixel_format=esp32_camera.PixelFormat.JPEG,
    i2c=board.I2C(),
    external_clock_frequency=20_000_000)

m = c.take()
if m is not None:
    print(bytes(m))
```

Then on desktop open a python repl and run something like
```python
>>> with open("my.jpg", "wb") as f: f.write(<BIG PASTE FROM REPL>)
```
and open my.jpg in a viewer.
2022-08-04 15:11:50 -05:00
Dan Halbert 202fac59f8 ESP32 fixes for no PSRAM; some cleanup 2022-08-04 13:44:52 -04:00
Jeff Epler 82be75adb5 Add ability to reserve psram
.. the primary user of which will be the camera, since the framebuffers
must be allocated via esp-idf allocation function and never from the
gc heap.

A board can have a default value, and the value can also be set in the
/.env file using the key CIRCUITPY_RESERVED_PSRAM with the value being
the reserved size in bytes.

Co-authored-by: Dan Halbert <halbert@adafruit.com>
2022-08-03 16:19:40 -05:00
Scott Shawcroft 74e841d835
Read fuses to know what flash and ram pins to never reset 2022-08-02 12:01:42 -07:00
Scott Shawcroft d6344812e8
Lots of web workflow, C3 and title bar fixes
* Fixes #6221 - C3 hang on `import wifi`. Enabling the WiFi PHY was
  disabling USB. Now boards that use it set CONFIG_ESP_PHY_ENABLE_USB
  explicitly.
* Fixes #6655 - Allows pasting into the web serial page. Fixes reading
  more than 0xf bytes at a time.
* Fixes #6653 - Fixes web socket encoding of payloads >125 bytes. Can
  happen when printing a long string.
* Fixes C3 responsiveness when waiting for key to enter REPL. (It
  now correctly stops sleeping.)
* Disables title bar updates when in raw REPL. Related to #6548.
* Adds version to title bar.
2022-07-28 16:06:56 -07:00
Scott Shawcroft e9dd254127
Add socket select task to wake CP
This fixes the web workflow on boards without a display.

Fixes #6552
2022-07-13 17:35:35 -07:00
Jeff Epler 09b754ffa0
espressif: Set heap size automatically, like micropython
rather than setting the heap size statically, micropython allocates
the biggest contiguous chunk possible, but in no event more than half the
total internal sram. On esp32 this gives 123728 bytes of `gc.mem_free`
in the repl.
2022-07-13 14:00:59 -05:00
Jeff Epler 09d1c846c4
Set heap size to 0 when heap allocation fails 2022-07-13 13:53:22 -05:00
Jeff Epler c1b6c367ff
esp32 can allocate 88kB successfully 2022-07-13 13:53:08 -05:00
Jeff Epler 13be10ef14
rename function to avoid confusion 2022-07-13 13:28:51 -05:00
Jeff Epler f620c2901c
Set a small but working heap size for esp32 without psram 2022-07-13 11:10:00 -05:00
Jeff Epler 953f44b46e
Fix spiram limit calculation on esp32
esp32 places the psram start at SOC_EXTRAM_DATA_LOW and it can extend
up to SOC_EXTRAM_DATA_SIZE. This is different than esp32-s2 and later,
which place the end at EXTRAM_DATA_HIGH and the limitation of
SOC_EXTRAM_DATA_SIZE was not previously identified as important.
Additionally, the esp32 has a reserved area within himem which was
not being accounted for.

With this change, the Feather ESP32 V2 feather can be used via thonny,
and the other "quick memory corruption tests" I was performing
also all succeed instead of failing.

Before this change, the incorrect address being used for spiram was
0x3fa00000..0x3fc00000 (2MiB). Now, it's 0x3f800000..0x3f9c0000 (1.75MiB)
due to the reserved area and the changed start address.

This is intended to be a no-effect change for other espressif chips besides
original esp32.
2022-07-13 10:52:15 -05:00
Dan Halbert c316b950c7 merge from adafruit/main 2022-07-08 15:42:19 -04:00
Dan Halbert 4e88d795e1 Thonny causing crash emitglue.c:199: 2022-07-06 23:01:19 -04:00
Scott Shawcroft d42c811fb9
Safe mode when ESP interrupt watchdog fires
This makes us enter safe mode when sleep on the S3 fails. The
task watchdog is used for the user watchdog.
2022-06-29 12:31:18 -07:00
Dan Halbert 780c4963cb wip; change never-ever reset pin mechanism 2022-06-28 23:06:49 -04:00
Dan Halbert 55784c93de wip; compiles 2022-06-26 21:22:22 -04:00
Scott Shawcroft 6446010753
Wi-Fi autoconnect and title bar status
This adds support for CIRCUITPY_WIFI_SSID and CIRCUITPY_WIFI_PASSWORD
in `/.env`. When both are defined, CircuitPython will attempt to
connect to the network even when user code isn't running. If the
user code attempts to a network with the same SSID, it will return
immediately. Connecting to another SSID will disconnect from the
auto-connected network. If the user code initiates the connection,
then it will be shutdown after user code exits. (Should match <8
behavior.)

This PR also reworks the default displayio terminal. It now supports
a title bar TileGrid in addition to the (newly renamed) scroll area.
The default title bar is the top row of the display and is positioned
to the right of the Blinka logo when it is enabled. The scroll area
is now below the Blinka logo.

The Wi-Fi auto-connect code now uses the title bar to show its
state including the IP address when connected. It does this through
the "standard" OSC control sequence `ESC ] 0 ; <s> ESC \` where <s>
is the title bar string. This is commonly supported by terminals
so it should work over USB and UART as well.

Related to #6174
2022-06-09 14:55:54 -07:00
Scott Shawcroft 269d51d023
Add two stage reset for BLE
This lets the BLE stack run through the wait period after a VM run
when it may be waiting for more writes due to an auto-reload.

User BLE functionality will have their events stopped. Scanning and
advertising is also stopped.
2022-05-12 13:20:44 -07:00
Scott Shawcroft 5a6f456dbb
Add BLE scanning for S3 and C3.
Everything else should raise NotImplementedError.

First step in #5926
2022-01-25 16:28:46 -08:00
MicroDev dab35f7c72
Merge pull request #5880 from jepler/espressif-serial-trick-uf2
Request ROM bootloader when resetting using the 'serial trick'
2022-01-21 09:56:12 +05:30
Jeff Epler ea30a8ac04
Reboot into the ROM bootloader from 1200 baud
Per Scott, the purpose of this trick is to make the board programmable from Arduino even when CP is installed, so my convenience of escaping into UF2 is not going to work out.
2022-01-20 18:50:50 -06:00
Scott Shawcroft 78942112c7
Ensure supervisor_tick is run on the same core as CP 2022-01-19 11:36:40 -08:00