2023-01-06 10:50:54 +08:00
==================
Espressif ESP32-C6
==================
The ESP32-C6 is an ultra-low-power and highly integrated SoC with a RISC-V
core and supports 2.4 GHz Wi-Fi 6, Bluetooth 5 (LE) and the 802.15.4 protocol.
* Address Space
- 800 KB of internal memory address space accessed from the instruction bus
- 560 KB of internal memory address space accessed from the data bus
- 1016 KB of peripheral address space
- 8 MB of external memory virtual address space accessed from the instruction bus
- 8 MB of external memory virtual address space accessed from the data bus
- 480 KB of internal DMA address space
* Internal Memory
- 320 KB ROM
- 512 KB SRAM (16 KB can be configured as Cache)
- 16 KB of SRAM in RTC
* External Memory
- Up to 16 MB of external flash
* Peripherals
- 35 peripherals
* GDMA
- 7 modules are capable of DMA operations.
ESP32-C6 Toolchain
==================
2023-10-06 04:39:49 +08:00
A generic RISC-V toolchain can be used to build ESP32-C6 projects. It's recommended to use the same
toolchain used by NuttX CI. Please refer to the Docker
`container <https://github.com/apache/nuttx/tree/master/tools/ci/docker/linux/Dockerfile> `_ and
check for the current compiler version being used. For instance:
.. code-block ::
2024-04-19 23:41:51 +08:00
###############################################################################
# Build image for tool required by RISCV builds
###############################################################################
FROM nuttx-toolchain-base AS nuttx-toolchain-riscv
# Download the latest RISCV GCC toolchain prebuilt by xPack
RUN mkdir riscv-none-elf-gcc && \
curl -s -L "https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v13.2.0-2/xpack-riscv-none-elf-gcc-13.2.0-2-linux-x64.tar.gz" \
| tar -C riscv-none-elf-gcc --strip-components 1 -xz
2023-10-06 04:39:49 +08:00
2024-04-19 23:41:51 +08:00
It uses the xPack's prebuilt toolchain based on GCC 13.2.0-2.
2023-10-06 04:39:49 +08:00
Installing
----------
First, create a directory to hold the toolchain:
.. code-block :: console
2024-04-19 23:41:51 +08:00
$ mkdir -p /path/to/your/toolchain/riscv-none-elf-gcc
2023-10-06 04:39:49 +08:00
Download and extract toolchain:
.. code-block :: console
2024-04-19 23:41:51 +08:00
$ curl -s -L "https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v13.2.0-2/xpack-riscv-none-elf-gcc-13.2.0-2-linux-x64.tar.gz" \
| tar -C /path/to/your/toolchain/riscv-none-elf-gcc --strip-components 1 -xz
2023-10-06 04:39:49 +08:00
Add the toolchain to your `PATH` :
.. code-block :: console
2024-04-19 23:41:51 +08:00
$ echo "export PATH=/path/to/your/toolchain/riscv-none-elf-gcc/bin:$PATH" >> ~/.bashrc
2023-10-06 04:39:49 +08:00
You can edit your shell's rc files if you don't use bash.
2023-01-06 10:50:54 +08:00
2024-06-20 03:39:56 +08:00
Building and flashing NuttX
===========================
2023-01-06 10:50:54 +08:00
2024-06-20 03:39:56 +08:00
Bootloader and partitions
-------------------------
NuttX can boot the ESP32-C6 directly using the so-called "Simple Boot".
2024-04-19 23:41:51 +08:00
An externally-built 2nd stage bootloader is not required in this case as all
2024-06-20 03:39:56 +08:00
functions required to boot the device are built within NuttX. Simple boot does not
2024-04-19 23:41:51 +08:00
require any specific configuration (it is selectable by default if no other
2nd stage bootloader is used). For compatibility among other SoCs and future options
of 2nd stage bootloaders, the commands `` make bootloader `` and the `` ESPTOOL_BINDIR ``
option (for the `` make flash `` ) are kept (and ignored if Simple Boot is used).
2023-01-06 10:50:54 +08:00
2024-06-28 16:34:45 +08:00
If other features are required, an externally-built 2nd stage bootloader is needed.
The bootloader is built using the `` make bootloader `` command. This command generates
the firmware in the `` nuttx `` folder. The `` ESPTOOL_BINDIR `` is used in the
`` make flash `` command to specify the path to the bootloader. For compatibility
among other SoCs and future options of 2nd stage bootloaders, the commands
`` make bootloader `` and the `` ESPTOOL_BINDIR `` option (for the `` make flash `` )
can be used even if no externally-built 2nd stage bootloader
is being built (they will be ignored if Simple Boot is used, for instance)::
$ make bootloader
.. note :: It is recommended that if this is the first time you are using the board with NuttX to
perform a complete SPI FLASH erase.
.. code-block :: console
$ esptool.py erase_flash
2023-01-06 10:50:54 +08:00
Building and flashing
2024-06-20 03:39:56 +08:00
---------------------
2023-01-06 10:50:54 +08:00
2024-04-19 23:41:51 +08:00
First, make sure that `` esptool.py `` is installed. This tool is used to convert
2023-01-06 10:50:54 +08:00
the ELF to a compatible ESP32-C6 image and to flash the image into the board.
2024-05-23 16:36:29 +08:00
It can be installed with: `` pip install esptool==4.8.dev4 `` .
2023-01-06 10:50:54 +08:00
2024-04-19 23:41:51 +08:00
Configure the NuttX project: `` ./tools/configure.sh esp32c6-devkitc:nsh ``
Run `` make `` to build the project. Note that the conversion mentioned above is
included in the build process.
The `` esptool.py `` is used to flash all the binaries. However, this is also
included in the build process and we can build and flash with::
2023-01-06 10:50:54 +08:00
2024-04-19 23:41:51 +08:00
make flash ESPTOOL_PORT=<port> ESPTOOL_BINDIR=./
2023-01-06 10:50:54 +08:00
2024-04-19 23:41:51 +08:00
Where `` <port> `` is typically `` /dev/ttyUSB0 `` or similar and `` ./ `` is
the path to the folder containing the externally-built 2nd stage bootloader for
the ESP32-C6 as explained above.
2023-03-24 22:44:03 +08:00
2024-08-15 00:18:04 +08:00
Debugging with `` openocd `` and `` gdb ``
======================================
2024-01-23 18:51:44 +08:00
2024-08-15 00:18:04 +08:00
Espressif uses a specific version of OpenOCD to support ESP32-C6: `openocd-esp32 <https://github.com/espressif/> `_ .
Please check `Building OpenOCD from Sources <https://docs.espressif.com/projects/esp-idf/en/release-v5.1/esp32c6/api-guides/jtag-debugging/index.html#jtag-debugging-building-openocd> `_
for more information on how to build OpenOCD for ESP32-C6.
2024-01-23 18:51:44 +08:00
2024-04-19 23:41:51 +08:00
You do not need an external JTAG to debug, the ESP32-C6 integrates a
2024-01-23 18:51:44 +08:00
USB-to-JTAG adapter.
2024-08-15 00:18:04 +08:00
.. note :: One must configure the USB drivers to enable JTAG communication. Please check
`Configure USB Drivers <https://docs.espressif.com/projects/esp-idf/en/release-v5.1/esp32c6/api-guides/jtag-debugging/configure-builtin-jtag.html#configure-usb-drivers> `_
for more information.
2024-01-23 18:51:44 +08:00
OpenOCD can then be used::
2024-06-20 03:39:56 +08:00
openocd -c 'set ESP_RTOS hwthread; set ESP_FLASH_SIZE 0' -f board/esp32c6-builtin.cfg
2024-01-23 18:51:44 +08:00
If you want to debug with an external JTAG adapter it can
2024-08-15 00:18:04 +08:00
be connected as follows:
2024-01-23 18:51:44 +08:00
2024-08-15 00:18:04 +08:00
============ ===========
ESP32-C6 Pin JTAG Signal
============ ===========
GPIO4 TMS
GPIO5 TDI
GPIO6 TCK
GPIO7 TDO
============ ===========
2024-01-23 18:51:44 +08:00
Furthermore, an efuse needs to be burnt to be able to debug::
espefuse.py -p <port> burn_efuse DIS_USB_JTAG
2024-08-15 00:18:04 +08:00
.. warning :: Burning eFuses is an irreversible operation, so please
consider the above option before starting the process.
2024-01-23 18:51:44 +08:00
OpenOCD can then be used::
2024-06-20 03:39:56 +08:00
openocd -c 'set ESP_RTOS hwtread; set ESP_FLASH_SIZE 0' -f board/esp32c6-ftdi.cfg
2024-01-23 18:51:44 +08:00
2024-08-15 00:18:04 +08:00
Once OpenOCD is running, you can use GDB to connect to it and debug your application::
riscv-none-elf-gdb -x gdbinit nuttx
whereas the content of the `` gdbinit `` file is::
target remote :3333
set remote hardware-watchpoint-limit 2
mon reset halt
flushregs
monitor reset halt
thb nsh_main
c
.. note :: `` nuttx `` is the ELF file generated by the build process. Please note that `` CONFIG_DEBUG_SYMBOLS `` must be enabled in the `` menuconfig `` .
Please refer to :doc: `/quickstart/debugging` for more information about debugging techniques.
2023-03-24 22:44:03 +08:00
Peripheral Support
==================
The following list indicates the state of peripherals' support in NuttX:
============== =======
Peripheral Support
============== =======
ADC No
AES No
Bluetooth No
2024-04-02 23:49:57 +08:00
CAN/TWAI Yes
2024-06-12 23:52:14 +08:00
DMA Yes
2023-03-24 22:44:03 +08:00
ECC No
eFuse No
2024-01-23 18:51:44 +08:00
GPIO Yes
2023-03-24 22:44:03 +08:00
HMAC No
2024-06-20 21:21:06 +08:00
I2C Yes
2023-03-24 22:44:03 +08:00
I2S No
Int. Temp. No
LED No
2024-01-23 18:51:44 +08:00
LED_PWM Yes
2024-07-03 20:49:11 +08:00
MCPWM Yes
2023-03-24 22:44:03 +08:00
Pulse Counter No
RMT No
RNG No
RSA No
2024-01-23 18:51:44 +08:00
RTC Yes
2023-03-24 22:44:03 +08:00
SD/MMC No
SDIO No
SHA No
2024-05-28 15:51:43 +08:00
SPI Yes
2024-03-07 00:28:42 +08:00
SPIFLASH Yes
2024-01-23 18:51:44 +08:00
Timers Yes
2023-03-24 22:44:03 +08:00
UART Yes
Watchdog Yes
2024-04-06 00:59:49 +08:00
Wifi Yes
2023-03-24 22:44:03 +08:00
XTS No
============== =======
Supported Boards
================
.. toctree ::
2024-04-19 23:41:51 +08:00
:glob:
:maxdepth: 1
2023-03-24 22:44:03 +08:00
2024-04-19 23:41:51 +08:00
boards/*/*