Skip to content

Commit 04459f5

Browse files
authored
Merge branch 'main' into ai_thinker_esp32-c3s
2 parents 01d7861 + 3988670 commit 04459f5

File tree

17 files changed

+335
-45
lines changed

17 files changed

+335
-45
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Supported Support status
213213
================ ============================================================
214214
atmel-samd ``SAMD21`` stable | ``SAMD51`` stable
215215
cxd56 stable
216-
espressif stable
216+
espressif ``ESP32-C3`` beta | ``ESP32-S2`` stable
217217
litex alpha
218218
mimxrt10xx alpha
219219
nrf stable

locale/zh_Latn_pinyin.po

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ msgstr ""
77
"Project-Id-Version: circuitpython-cn\n"
88
"Report-Msgid-Bugs-To: \n"
99
"POT-Creation-Date: 2021-01-04 12:55-0600\n"
10-
"PO-Revision-Date: 2021-09-04 23:34+0000\n"
10+
"PO-Revision-Date: 2021-10-01 02:38+0000\n"
1111
"Last-Translator: hexthat <[email protected]>\n"
1212
"Language-Team: Chinese Hanyu Pinyin\n"
1313
"Language: zh_Latn_pinyin\n"
1414
"MIME-Version: 1.0\n"
1515
"Content-Type: text/plain; charset=UTF-8\n"
1616
"Content-Transfer-Encoding: 8bit\n"
1717
"Plural-Forms: nplurals=1; plural=0;\n"
18-
"X-Generator: Weblate 4.8.1-dev\n"
18+
"X-Generator: Weblate 4.9-dev\n"
1919

2020
#: main.c
2121
msgid ""
@@ -1257,7 +1257,7 @@ msgstr "Nèibù dìngyì cuòwù"
12571257

12581258
#: ports/espressif/common-hal/paralleldisplay/ParallelBus.c
12591259
msgid "Internal error"
1260-
msgstr ""
1260+
msgstr "nèi bù cuò wù"
12611261

12621262
#: shared-module/rgbmatrix/RGBMatrix.c
12631263
#, c-format
@@ -1741,7 +1741,7 @@ msgstr "bù kě shè zhì"
17411741
#: ports/espressif/common-hal/paralleldisplay/ParallelBus.c
17421742
#, c-format
17431743
msgid "Number of data_pins must be 8 or 16, not %d"
1744-
msgstr ""
1744+
msgstr "data_pins shù bì xū wéi 8 huò 16, ér bù shì %d"
17451745

17461746
#: shared-bindings/util.c
17471747
msgid ""
@@ -2150,7 +2150,7 @@ msgstr "Yuán huǎnchōng qū hé mùbiāo huǎnchōng qū de chángdù bìxū x
21502150

21512151
#: shared-bindings/paralleldisplay/ParallelBus.c
21522152
msgid "Specify exactly one of data0 or data_pins"
2153-
msgstr ""
2153+
msgstr "zhǐ dìng data0 huò data_pins zhōng de yí gè"
21542154

21552155
#: extmod/modure.c
21562156
msgid "Splitting with sub-captures"
@@ -2239,6 +2239,8 @@ msgid ""
22392239
"This microcontroller only supports data0=, not data_pins=, because it "
22402240
"requires contiguous pins."
22412241
msgstr ""
2242+
"cǐ wēi kòng zhì qì jǐn zhī chí data0=, ér bú shì data_pins=, yīn wéi tā xū "
2243+
"yào lián xù yǐn jiǎo."
22422244

22432245
#: shared-bindings/displayio/TileGrid.c
22442246
msgid "Tile height must exactly divide bitmap height"
@@ -3453,7 +3455,7 @@ msgstr "wúxiào de cānshù"
34533455
#: shared-bindings/bitmaptools/__init__.c
34543456
#, c-format
34553457
msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32"
3456-
msgstr ""
3458+
msgstr "wú xiào bits_per_pixel %d, bì xū shì, 1, 2, 4, 8, 16, 24, huò 32"
34573459

34583460
#: shared-bindings/bitmaptools/__init__.c
34593461
#, c-format

ports/atmel-samd/common-hal/analogio/AnalogOut.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self,
8585
_pm_enable_bus_clock(PM_BUS_APBC, DAC);
8686
#endif
8787

88-
// SAMD21: This clock should be <= 12 MHz, per datasheet section 47.6.3.
89-
// SAMD51: This clock should be <= 350kHz, per datasheet table 37-6.
88+
// SAMD21: This clock should be <= 350 kHz, per datasheet table 36-7.
89+
// SAMD51: This clock should be <= 12 MHz, per datasheet section 47.6.3.
9090
_gclk_enable_channel(DAC_GCLK_ID, CONF_GCLK_DAC_SRC);
9191

9292
// Don't double init the DAC on the SAMD51 when both outputs are in use. We use the free state

ports/atmel-samd/common-hal/microcontroller/Pin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ void reset_all_pins(void) {
5252
uint32_t pin_mask[PORT_COUNT] = PORT_OUT_IMPLEMENTED;
5353

5454
// Do not full reset USB lines.
55+
#if CIRCUITPY_USB
5556
pin_mask[0] &= ~(PORT_PA24 | PORT_PA25);
57+
#endif
5658

5759
// Do not reset SWD when a debugger is present.
5860
if (DSU->STATUSB.bit.DBGPRES == 1) {

ports/espressif/README.rst

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
Circuitpython on ESP32-S2
1+
CircuitPython on Espressif SoCs
22
=======================================
33

4-
This port adds the ESP32-S2 line of modules from Espressif to Circuitpython. ESP32-S2 modules are low power, single-core Wi-Fi microcontroller SoCs designed for IoT applications.
4+
This port adds the Espressif line of SoCs to CircuitPython.
5+
6+
Support Status:
7+
---------------------------------------
8+
9+
.. csv-table::
10+
:header: SoC, Status
11+
12+
ESP32-C3, "beta"
13+
ESP32-S2, "stable"
514

615
How this port is organized:
716
---------------------------------------
@@ -10,32 +19,69 @@ How this port is organized:
1019
- **boards/** contains the configuration files for each development board and breakout available on the port.
1120
- **common-hal/** contains the port-specific module implementations, used by shared-module and shared-bindings.
1221
- **esp-idf/** contains the Espressif IoT development framework installation, including all the drivers for the port.
13-
- **modules/** contains information specific to certain ESP32-S2 hardware modules, such as the pins used for flash and RAM on the WROVER and WROOM.
22+
- **modules/** contains information specific to certain Espressif SoC based hardware modules, such as the pins used for flash and RAM on the WROVER and WROOM.
1423
- **peripherals/** contains peripheral setup files and peripheral mapping information, sorted by family and sub-variant. Most files in this directory can be generated with the python scripts in **tools/**.
1524
- **supervisor/** contains port-specific implementations of internal flash, serial and USB, as well as the **port.c** file, which initializes the port at startup.
1625
- **tools/** includes useful python scripts for debugging and other purposes.
1726

1827
At the root level, refer to **mpconfigboard.h** and **mpconfigport.mk** for port specific settings and a list of enabled circuitpython modules.
1928

29+
Connecting to the ESP32-C3
30+
---------------------------------------
31+
32+
**USB Connetion:**
33+
34+
On ESP32-C3 REV3 chips, a USB Serial/JTAG Controller is available. Note: The USB connection cannot be used for a ``CIRCUITPY`` drive.
35+
36+
Depending on the board you have the USB port may or may not be connected to native USB, if it isn't connected to native USB then following connections need to be made to get serial console, REPL interface, flashing CircuitPython and JTAG debugging.
37+
38+
.. csv-table::
39+
:header: GPIO, USB
40+
41+
19, "D+ (green)"
42+
18, "D- (white)"
43+
GND, "GND (black)"
44+
5V, "5V (red)"
45+
46+
Connect these pins using a `USB adapter <https://www.adafruit.com/product/4090>`_ or `breakout cable <https://www.adafruit.com/product/4448>`_.
47+
48+
**UART Connection:**
49+
50+
A `USB to UART convertor <https://www.adafruit.com/product/3309>`_ can be used for connecting to ESP32-C3 to get serial console, REPL interface and flashing CircuitPython. Following connections need to be made in this case.
51+
52+
.. csv-table::
53+
:header: GPIO, UART
54+
55+
21, "RX"
56+
20, "TX"
57+
GND, "GND"
58+
5V, "5V"
59+
60+
**BLE Connection:**
61+
62+
This feature is not yet available and currently under development.
63+
2064
Connecting to the ESP32-S2
2165
---------------------------------------
2266

23-
The USB port built into ESP32-S2 boards such as the Saola is not the native USB of the board, but a debugging and programming interface. The actual ESP32-S2 native USB which exposes the Circuitpython drive and CDC connection is located on IO pins 19 and 20:
67+
**USB Connetion:**
68+
69+
Depending on the board you have the USB port may or may not be connected to native USB, if it isn't connected to native USB then following connections need to be made to get CircuitPython working.
2470

2571
.. csv-table::
2672
:header: GPIO, USB
2773

2874
20, "D+ (green)"
2975
19, "D- (white)"
3076
GND, "GND (black)"
31-
5V, "+5V (red)"
77+
5V, "5V (red)"
3278

33-
Connect these pins using a `USB adapter <https://www.adafruit.com/product/4090>`_ or `breakout cable <https://www.adafruit.com/product/4448>`_ to access the Circuitpython drive.
79+
Connect these pins using a `USB adapter <https://www.adafruit.com/product/4090>`_ or `breakout cable <https://www.adafruit.com/product/4448>`_ to access the CircuitPython drive.
3480

3581
Building and flashing
3682
---------------------------------------
3783

38-
Before building or flashing the ESP32-S2, you must `install the esp-idf <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/get-started/index.html>`_. This must be re-done every time the esp-idf is updated, but not every time you build. Run ``cd ports/esp32s2`` from ``circuitpython/`` to move to the esp32s2 port root, and run:
84+
Before building or flashing the, you must `install the esp-idf <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/index.html>`_. This must be re-done every time the esp-idf is updated, but not every time you build. Run ``cd ports/espressif`` from ``circuitpython/`` to move to the espressif port root, and run:
3985

4086
.. code-block::
4187
@@ -47,24 +93,28 @@ After this initial installation, you must add the esp-idf tools to your path. Yo
4793
4894
. esp-idf/export.sh
4995
50-
When Circuitpython updates the ESP-IDF to a new release, you may need to run this installation process again. The exact commands used may also vary based on your bash environment.
96+
When CircuitPython updates the ESP-IDF to a new release, you may need to run this installation process again. The exact commands used may also vary based on your bash environment.
5197

52-
Building boards such as the Saola is typically done through ``make flash``. The default port is ``tty.SLAB_USBtoUART``, which will only work on certain Mac setups. On most machines, both Mac and Linux, you will need to set the port yourself by running ``ls /dev/tty.usb*`` and selecting the one that only appears when your development board is plugged in. An example make command with the port setting is as follows:
98+
Building boards is typically done through ``make BOARD=board_id``. The default port is ``tty.SLAB_USBtoUART``, which will only work on certain Mac setups. On most machines, both Mac and Linux, you will need to set the port yourself by running ``ls /dev/tty.usb*`` and selecting the one that only appears when your development board is plugged in. An example make command with the port setting is as follows:
5399

54100
.. code-block::
55101
56-
make BOARD=espressif_saola_1_wrover flash PORT=/dev/tty.usbserial-1421120
102+
make BOARD=board_id PORT=/dev/tty.usbserial-1421120 flash
103+
104+
``board_id`` is the unique board identifier in CircuitPython. It is the same as the name of board in ``boards`` directory.
57105

58106
Debugging
59107
---------------------------------------
60108

109+
TODO: Add documentation for ESP32-C3 JTAG feature.
110+
61111
The ESP32-S2 supports JTAG debugging over OpenOCD using a JLink or other probe hardware. The official tutorials can be found on the Espressif website `here <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/jtag-debugging/index.html>`_, but they are mostly for the ESP32-S2 Kaluga, which has built-in debugging.
62112

63113
OpenOCD is automatically installed and added to your bash environment during the esp-idf installation and setup process. You can double check that it is installed by using ``openocd --version``, as per the tutorial. Attach the JTAG probe pins according to the `instructions for JTAG debugging <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/jtag-debugging/configure-other-jtag.html>`_ on boards that do not contain an integrated debugger.
64114

65115
Once the debugger is connected physically, you must run OpenOCD with attached configuration files specifying the **interface** (your debugger probe) and either a **target** or a **board** (targets are for SoCs only, and can be used when a full board configuration file doesn't exist). You can find the path location of these files by checking the ``OPENOCD_SCRIPTS`` environmental variable by running ``echo $OPENOCD_SCRIPTS`` in bash. Interfaces will be in the ``interface/`` directory, and targets and boards in the ``target/`` and ``board/`` directories, respectively.
66116

67-
**Note:** Unfortunately, there are no board files for the esp32-s2 other than the Kaluga, and the included ``target/esp32s2.cfg`` target file will not work by default on the Jlink for boards like the Saola 1, as the default speed is incorrect. In addition, these files are covered under the GPL and cannot be included in Circuitpython. Thus, you must make a copy of the esp32s2.cfg file yourself and add the following line manually, under ``transport select jtag`` at the start of the file:
117+
**Note:** Unfortunately, there are no board files for the esp32-s2 other than the Kaluga, and the included ``target/esp32s2.cfg`` target file will not work by default on the Jlink for boards like the Saola 1, as the default speed is incorrect. In addition, these files are covered under the GPL and cannot be included in CircuitPython. Thus, you must make a copy of the esp32s2.cfg file yourself and add the following line manually, under ``transport select jtag`` at the start of the file:
68118

69119
.. code-block::
70120
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2021 microDev
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "shared-bindings/microcontroller/Pin.h"
28+
29+
void board_init(void) {
30+
// USB
31+
common_hal_never_reset_pin(&pin_GPIO18);
32+
common_hal_never_reset_pin(&pin_GPIO19);
33+
34+
// Debug UART
35+
#ifdef DEBUG
36+
common_hal_never_reset_pin(&pin_GPIO20);
37+
common_hal_never_reset_pin(&pin_GPIO21);
38+
#endif
39+
40+
// SPI Flash
41+
common_hal_never_reset_pin(&pin_GPIO11);
42+
common_hal_never_reset_pin(&pin_GPIO12);
43+
common_hal_never_reset_pin(&pin_GPIO13);
44+
common_hal_never_reset_pin(&pin_GPIO14);
45+
common_hal_never_reset_pin(&pin_GPIO15);
46+
common_hal_never_reset_pin(&pin_GPIO16);
47+
common_hal_never_reset_pin(&pin_GPIO17);
48+
}
49+
50+
bool board_requests_safe_mode(void) {
51+
return false;
52+
}
53+
54+
void reset_board(void) {
55+
}
56+
57+
void board_deinit(void) {
58+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2021 microDev
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
// Board setup
28+
#define MICROPY_HW_BOARD_NAME "MicroDev microC3"
29+
#define MICROPY_HW_MCU_NAME "ESP32-C3FN4"
30+
31+
// Status LED
32+
#define MICROPY_HW_NEOPIXEL (&pin_GPIO7)
33+
#define MICROPY_HW_NEOPIXEL_COUNT (2)
34+
35+
// Default bus pins
36+
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO4)
37+
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO5)
38+
39+
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO1)
40+
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO2)
41+
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO3)
42+
43+
#define DEFAULT_UART_BUS_RX (&pin_GPIO20)
44+
#define DEFAULT_UART_BUS_TX (&pin_GPIO21)
45+
46+
// Serial over UART
47+
#define DEBUG_UART_RX DEFAULT_UART_BUS_RX
48+
#define DEBUG_UART_TX DEFAULT_UART_BUS_TX
49+
50+
// For entering safe mode
51+
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9)
52+
53+
// Explanation of how a user got into safe mode
54+
#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CIRCUITPY_CREATOR_ID = 0x6d446576
2+
CIRCUITPY_CREATION_ID = 0x006d4333
3+
4+
IDF_TARGET = esp32c3
5+
6+
INTERNAL_FLASH_FILESYSTEM = 1
7+
8+
CIRCUITPY_ESP_FLASH_MODE=qio
9+
CIRCUITPY_ESP_FLASH_FREQ=80m
10+
CIRCUITPY_ESP_FLASH_SIZE=4MB

0 commit comments

Comments
 (0)