Commit Graph

42 Commits

Author SHA1 Message Date
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
Jeff Epler 872beeccfe
Merge remote-tracking branch 'origin/main' into espressif-serial-trick-uf2 2022-01-18 19:07:05 -06:00
Scott Shawcroft 679f4b30ba
Tweak heap sizes for different targets 2022-01-18 15:23:19 -08:00
Jeff Epler 49b8579bcd
Request UF2 bootloader when resetting using the 'serial trick' 2022-01-17 17:14:31 -06:00
Jeff Epler 1207bfced9 espressif: Use detected size of spiram 2021-12-04 09:14:22 -06:00
microDev 7ba5513f9a
update espressif port
- update esp-idf to v4.4
- add esp32s3 support
- add analogio on esp32c3
- disable rgbmatrix on all espressif soc

Co-authored-by: Scott Shawcroft <scott@adafruit.com>
Co-authored-by: Seon Rozenblum <seon@unexpectedmaker.com>
2021-11-24 18:01:34 +05:30
Jeff Epler c9475adb00
Enable -Werror=missing-prototypes on espressif port 2021-11-10 11:07:45 -06:00
Jeff Epler 6351de6ad1 espressif: Allow -DENABLE_JTAG=0 to force JTAG off
With the Kaluga devkit, the camera interferes with the JTAG function.
However, having DEBUG turned on e.g., to get extended debug information
on the UART debug connection remains useful.

Now, by arranging to add to CFLAGS += -DDEBUG -DENABLE_JTAG=0, this
configuration is easy to achieve.
2021-11-08 10:38:05 -06:00
microDev 3da86b0ac2
add initial esp32c3 support 2021-09-26 09:39:40 +05:30
microDev 1536ec0123
rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
Scott Shawcroft 973a90f2aa
Rename esp32s2 port to espressif
This is in preparation for ESP32-S3 support and potentially others.

Related to #4363
2021-09-13 16:44:55 -07:00