Skip to content

esp32c6 support (IDF v5.2) #11869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 9, 2024
Merged

esp32c6 support (IDF v5.2) #11869

merged 12 commits into from
Oct 9, 2024

Conversation

andrewleech
Copy link
Contributor

@andrewleech andrewleech commented Jun 26, 2023

The is esp32c6 officially supported in IDF v5.1 but requires a number of changes to work...
Pulling together changes and generic board support needed here.

@andrewleech
Copy link
Contributor Author

I've hacked past a bunch of compile flags to get further in the compile, but still not complete.

Bluetooth is not working - #include "esp_nimble_hci.h" is not available unless cmake set(CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE "y") is set, but once that's enabled a bunch of other compile errors jump up.

ADC does not support the legacy api currently being used in idf v5 support.

/mpy/ports/esp32/machine_adcblock.h:13:5: error: unknown type name 'esp_adc_cal_characteristics_t'
   13 |     esp_adc_cal_characteristics_t *characteristics[ADC_ATTEN_MAX];
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mpy/ports/esp32/machine_adcblock.c: In function 'madcblock_bits_helper':
/mpy/ports/esp32/machine_adcblock.c:90:13: error: implicit declaration of function 'esp_adc_cal_characterize' [-Werror=implicit-function-declaration]
   90 |             esp_adc_cal_characterize(self->unit_id, atten, self->width, DEFAULT_VREF, self->characteristics[atten]);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~
/mpy/ports/esp32/machine_adcblock.c: In function 'madcblock_read_helper':
/mpy/ports/esp32/machine_adcblock.c:174:23: error: implicit declaration of function 'adc2_get_raw'; did you mean 'adc1_get_raw'? [-Werror=implicit-function-declaration]
  174 |         check_esp_err(adc2_get_raw(channel_id, self->width, &raw));
      |                       ^~~~~~~~~~~~
      |                       adc1_get_raw
/mpy/ports/esp32/machine_adcblock.c: In function 'madcblock_read_uv_helper':
/mpy/ports/esp32/machine_adcblock.c:181:5: error: unknown type name 'esp_adc_cal_characteristics_t'
  181 |     esp_adc_cal_characteristics_t *adc_chars = self->characteristics[atten];
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mpy/ports/esp32/machine_adcblock.c:183:35: error: 'esp_adc_cal_characteristics_t' undeclared (first use in this function)
  183 |         adc_chars = malloc(sizeof(esp_adc_cal_characteristics_t));
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mpy/ports/esp32/machine_adcblock.c:183:35: note: each undeclared identifier is reported only once for each function it appears in
/mpy/ports/esp32/machine_adcblock.c:187:19: error: implicit declaration of function 'esp_adc_cal_raw_to_voltage' [-Werror=implicit-function-declaration]
  187 |     mp_int_t uv = esp_adc_cal_raw_to_voltage(raw, adc_chars) * 1000;

@github-actions
Copy link

github-actions bot commented Jul 26, 2023

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS

@codecov
Copy link

codecov bot commented Jul 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.57%. Comparing base (e5eeaa7) to head (197becb).
Report is 12 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #11869   +/-   ##
=======================================
  Coverage   98.57%   98.57%           
=======================================
  Files         164      164           
  Lines       21336    21336           
=======================================
  Hits        21031    21031           
  Misses        305      305           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mattytrentini mattytrentini changed the title WIP: esp32c6 support WIP: esp32c6 support (IDF v5.1) Aug 21, 2023
@mattytrentini
Copy link
Contributor

Tried building with the recently-released ESP IDF v5.1.2 (currently aliased to release-v5.1) and the first error appears to be related to sleep modes:

> docker run -ti --rm -v $(pwd):/code -w /code espressif/idf:release-v5.1 bash -c "make -C mpy-cross && make -C ports/esp32 submodules all BOARD=GENERIC_C6"
[snip]
[346/1191] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/sleep_modes.c.objFAILED: esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/sleep_modes.c.obj
[snip]
/opt/esp/idf/components/esp_hw_support/sleep_modes.c: In function 'light_sleep_uart_prepare':
/opt/esp/idf/components/esp_hw_support/sleep_modes.c:153:61: error: 'CONFIG_ESP_CONSOLE_UART_BAUDRATE' undeclared (first use in this function); did you mean 'CONFIG_ESP_CONSOLE_UART_NUM'?
  153 | #define UART_FLUSH_US_PER_CHAR              (10*1000*1000 / CONFIG_ESP_CONSOLE_UART_BAUDRATE)
      |                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/esp/idf/components/esp_hw_support/sleep_modes.c:485:113: note: in expansion of macro 'UART_FLUSH_US_PER_CHAR'
  485 |             (sleep_duration < (int64_t)((UART_LL_FIFO_DEF_LEN - uart_ll_get_txfifo_len(CONSOLE_UART_DEV) + 1) * UART_FLUSH_US_PER_CHAR) + SLEEP_UART_FLUSH_DONE_TO_SLEEP_US)) {
      |                                                                                                                 ^~~~~~~~~~~~~~~~~~~~~~
/opt/esp/idf/components/esp_hw_support/sleep_modes.c:153:61: note: each undeclared identifier is reported only once for each function it appears in
  153 | #define UART_FLUSH_US_PER_CHAR              (10*1000*1000 / CONFIG_ESP_CONSOLE_UART_BAUDRATE)
      |                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/esp/idf/components/esp_hw_support/sleep_modes.c:485:113: note: in expansion of macro 'UART_FLUSH_US_PER_CHAR'
  485 |             (sleep_duration < (int64_t)((UART_LL_FIFO_DEF_LEN - uart_ll_get_txfifo_len(CONSOLE_UART_DEV) + 1) * UART_FLUSH_US_PER_CHAR) + SLEEP_UART_FLUSH_DONE_TO_SLEEP_US)) {
      |                                                                                                                 ^~~~~~~~~~~~~~~~~~~~~~

@andrewleech
Copy link
Contributor Author

I should rebase this on top of #12952 to include everything already fixed there.

@jschott780
Copy link

To resolve "error: 'CONFIG_ESP_CONSOLE_UART_BAUDRATE' undeclared"
add this to the sdkconfig file:
CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200

@mattytrentini
Copy link
Contributor

To resolve "error: 'CONFIG_ESP_CONSOLE_UART_BAUDRATE' undeclared" add this to the sdkconfig file: CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200

Thanks for the suggestion @jschott780 but I made the change and am having exactly the same error! Tried cleaning first too. Puzzling...

--- a/ports/esp32/boards/GENERIC_C6/sdkconfig.board
+++ b/ports/esp32/boards/GENERIC_C6/sdkconfig.board
@@ -2,5 +2,5 @@ CONFIG_ESP32C6_BROWNOUT_DET=y
 CONFIG_ESP32C6_BROWNOUT_DET_LVL_SEL_7=
 CONFIG_ESP32C6_BROWNOUT_DET_LVL_SEL_4=y
 CONFIG_ESP32C6_BROWNOUT_DET_LVL=4
 CONFIG_ESP_CONSOLE_UART_DEFAULT=
 CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
+CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200

@jschott780
Copy link

jschott780 commented Nov 25, 2023

To resolve "error: 'CONFIG_ESP_CONSOLE_UART_BAUDRATE' undeclared" add this to the sdkconfig file: CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200

Thanks for the suggestion @jschott780 but I made the change and am having exactly the same error! Tried cleaning first too. Puzzling...

--- a/ports/esp32/boards/GENERIC_C6/sdkconfig.board
+++ b/ports/esp32/boards/GENERIC_C6/sdkconfig.board
@@ -2,5 +2,5 @@ CONFIG_ESP32C6_BROWNOUT_DET=y
 CONFIG_ESP32C6_BROWNOUT_DET_LVL_SEL_7=
 CONFIG_ESP32C6_BROWNOUT_DET_LVL_SEL_4=y
 CONFIG_ESP32C6_BROWNOUT_DET_LVL=4
 CONFIG_ESP_CONSOLE_UART_DEFAULT=
 CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
+CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200

Maybe its the order in which sdkconfig files are resolved in mpconfigboard.cmake?
Here is mine:
set(IDF_TARGET esp32c6)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
boards/sdkconfig.ble
boards/ESP32_GENERIC_C6/sdkconfig.c6usb
)

I dont know if it matters. I seem to remember running into this problem and renaming sdkconfig to sdkconfig.c6usb resolve it. Though totally possible I incidentally resolved it in some other way, and the file name was irrelevant.

@mattytrentini
Copy link
Contributor

Seems similar here:

set(IDF_TARGET esp32c6)

set(SDKCONFIG_DEFAULTS
    boards/sdkconfig.base
    boards/GENERIC_C6/sdkconfig.board
)

Confusing!

@jschott780
Copy link

For anyone that is interested, i have a hacked up fork that appears to be working on C6. I havent done any robust testing yet. Use at your own risk. However, it may provide additional insight for the professional devs on here.
https://github.com/jschott780/micropython

@Drill-N-Bass
Copy link

Drill-N-Bass commented Dec 12, 2023

For anyone that is interested, i have a hacked up fork that appears to be working on C6. I havent done any robust testing yet. Use at your own risk. However, it may provide additional insight for the professional devs on here. https://github.com/jschott780/micropython

Can you guide me on how can I test your fork? I'm unable to find the proper firmware to esp32-c6 on https://micropython.org/download/?vendor=Espressif.

I haven't seen it in your repository either. Where to get it?

With my older boards, I was downloading FV from this page and then installing it with 'Thonny' IDE. Is there another way that I should attempt for this board?

I use:
#Thonny #Win10 x64 #VSC #python #micropython

@jschott780
Copy link

jschott780 commented Dec 13, 2023

For anyone that is interested, i have a hacked up fork that appears to be working on C6. I havent done any robust testing yet. Use at your own risk. However, it may provide additional insight for the professional devs on here. https://github.com/jschott780/micropython

Can you guide me on how can I test your fork? I'm unable to find the proper firmware to esp32-c6 on https://micropython.org/download/?vendor=Espressif.

I haven't seen it in your repository either. Where to get it?

With my older boards, I was downloading FV from this page and then installing it with 'Thonny' IDE. Is there another way that I should attempt for this board?

I use: #Thonny #Win10 x64 #VSC #python #micropython

That downloads list are the officially supported builds generated by cicd. To get this to work on C6 you have to build and compile the binaries yourself. You may want to first start with building the main branch by following these instructions. If you get that working, then take a whack at building my forked repo.
https://github.com/micropython/micropython/wiki/Getting-Started

@Drill-N-Bass
Copy link

Drill-N-Bass commented Dec 13, 2023

For anyone that is interested, i have a hacked up fork that appears to be working on C6. I havent done any robust testing yet. Use at your own risk. However, it may provide additional insight for the professional devs on here. https://github.com/jschott780/micropython

Can you guide me on how can I test your fork? I'm unable to find the proper firmware to esp32-c6 on https://micropython.org/download/?vendor=Espressif.
I haven't seen it in your repository either. Where to get it?
With my older boards, I was downloading FV from this page and then installing it with 'Thonny' IDE. Is there another way that I should attempt for this board?
I use: #Thonny #Win10 x64 #VSC #python #micropython

That downloads list are the officially supported builds generated by cicd. To get this to work on C6 you have to build and compile the binaries yourself. You may want to first start with building the main branch by following these instructions. If you get that working, then take a whack at building my forked repo. https://github.com/micropython/micropython/wiki/Getting-Started

Ok, that sounds doable. But, I need to clarify some things:

  1. I understand that you propose to first try to do a normal .bin file using the main/official micropython repo. The thing I don't understand is, what and how should be set for the sake of using this main repo in a way that it will work with a particular model of ESP32. The binary should be set up in a way that it will be compatible with a particular board. In other words, I know that for that practice I need to use another board because the official repo doesn't support ESP32-C6 and I have ESP32 WROOM 32D too, so it's not a problem, but what I don't know is what to do, to prepare files for compilation in a way that they will be compatible with, for example, ESP32 WROOM 32D. Where to find the most up-to-date documentation for this?
  2. Besides creating this binary, do I need to establish any Espressif IoT Development Framework firmware on ESP32, before I flash it with this binary we were speaking about before?
  3. Doing such actions as preparing my own binary, do I risk bricking the board in the process of flashing?
  4. Can you elaborate on the limitations of your version (fork) of micropython regarding ESP32-C6? Are you aware of what doesn't work, or - at least - what is working at this moment?

@jschott780
Copy link

Ok, that sounds doable. But, I need to clarify some things:

  1. I understand that you propose to first try to do a normal .bin file using the main/official micropython repo. The thing I don't understand is, what and how should be set for the sake of using this main repo in a way that it will work with a particular model of ESP32. The binary should be set up in a way that it will be compatible with a particular board. In other words, I know that for that practice I need to use another board because the official repo doesn't support ESP32-C6 and I have ESP32 WROOM 32D too, so it's not a problem, but what I don't know is what to do, to prepare files for compilation in a way that they will be compatible with, for example, ESP32 WROOM 32D. Where to find the most up-to-date documentation for this?
  2. Besides creating this binary, do I need to establish any Espressif IoT Development Framework firmware on ESP32, before I flash it with this binary we were speaking about before?
  3. Doing such actions as preparing my own binary, do I risk bricking the board in the process of flashing?
  4. Can you elaborate on the limitations of your version (fork) of micropython regarding ESP32-C6? Are you aware of what doesn't work, or - at least - what is working at this moment?

Take a look at this file. I set the build target and a couple CMake variables such that the build points to the correct sdkconfig files under ports/esp32/boards.
https://github.com/jschott780/micropython/blob/master/flash-build.sh

Yeah, you have to clone this repo, and follow the build instructions in the README.
https://github.com/espressif/esp-idf
Once you've built the esp-idf tools, you can do then execute "export.sh" which will place the build tool chain on your path (idf.py).

Yep, you can brick your board.

No idea of the limitations yet. I'm about to test my application in the next few weeks. Entirely possible nothing works.
For clarification, I'm not presenting this fork as a shrink wrapped bug free solution. I was able to get the build to a point where the micropython shell is accessible. Just providing this as a reference to help move the ball forward.

@IhorNehrutsa
Copy link
Contributor

Please rebase current branch to top of master

@andrewleech
Copy link
Contributor Author

I've finally rebased this up to current master, including a bunch of fixes recently contributed by @IhorNehrutsa
It was a rather complicated rebase as lots has changed in esp32 in master recently, I haven't tested this branch yet to see how close it is to working.

@andrewleech
Copy link
Contributor Author

andrewleech commented Jan 18, 2024

To build and flash:

cd micropython
docker run -it --rm -e BOARD=ESP32_GENERIC_C6 -e UID=$(id -u) -v $(pwd):/micropython -v /sys/bus:/sys/bus -v /dev:/dev --net=host -w /micropython espressif/idf:v5.1.2 bash -c '\
useradd -ms /bin/bash -g root -G sudo -u $UID esp;\
git config --global --add safe.directory /opt/esp/idf;\
su esp -m -c ". /opt/esp/entrypoint.sh; export HOME=/tmp; \
make -C mpy-cross && \
make -C ports/esp32 BOARD=$BOARD submodules && \
make -C ports/esp32 BOARD=$BOARD deploy PORT=/dev/ttyACM0; \
"'

This command looks nuts at first glance to be sure... it's starting a temporary docker container from the official esp idf image and running the build commands inside it. There's some mucking around with users (inside the container) so that the build can access the idf files correctly while not breaking the permissions on the micropython code shared into the container.

Using docker means though you don't need to install and configure anything esp / idf / compiler related on your PC, just docker. It also makes it easy to switch between different versions of IDF, just pick the appropriate image version!

@mattytrentini espressif/esp-idf#11924 - currently still broken in the v5.1 image, v5.1.2 was released ~ 1 week before that fix was merged.

There's also compile failures relating to ADC... probably closely related to what @IhorNehrutsa fixed previously which I've likely re-broken in the rebase to master where a lot of changes have been made to consolidate machine/adc functionality across ports.

@kdschlosser
Copy link

I am not sure why you are having such a hard hour getting it to compile properly using IDF5.1.2

Click me to see build log.
make clean -j 32 -C lib/micropython/ports/esp32 LV_CFLAGS="-DLV_KCONFIG_IGNORE=1" LV_PORT=esp32 BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT USER_C_MODULES=../../../../../micropython.cmake FROZEN_MANIFEST="********/new_binding/lvgl_micropython/build/manifest.py"
make: Entering directory '********/new_binding/lvgl_micropython/lib/micropython/ports/esp32'
idf.py -D MICROPY_BOARD=ESP32_GENERIC_S3 -D MICROPY_BOARD_DIR=********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/boards/ESP32_GENERIC_S3 -DUSER_C_MODULES=../../../../../micropython.cmake -D MICROPY_FROZEN_MANIFEST=********/new_binding/lvgl_micropython/build/manifest.py -D MICROPY_BOARD_VARIANT=SPIRAM_OCT -B build-ESP32_GENERIC_S3-SPIRAM_OCT -p /dev/ttyUSB0 -b 460800 fullclean
Executing action: fullclean
Executing action: remove_managed_components
Done
make: Leaving directory '********/new_binding/lvgl_micropython/lib/micropython/ports/esp32'
********/new_binding/lvgl_micropython/driver/display/display_driver_framework.py
********/new_binding/lvgl_micropython/driver/fs_driver.py
********/new_binding/lvgl_micropython/utils/lv_utils.py
make -j 32 -C lib/micropython/ports/esp32 LV_CFLAGS="-DLV_KCONFIG_IGNORE=1" LV_PORT=esp32 BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT USER_C_MODULES=../../../../../micropython.cmake FROZEN_MANIFEST="********/new_binding/lvgl_micropython/build/manifest.py"
make: Entering directory '********/new_binding/lvgl_micropython/lib/micropython/ports/esp32'
idf.py -D MICROPY_BOARD=ESP32_GENERIC_S3 -D MICROPY_BOARD_DIR=********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/boards/ESP32_GENERIC_S3 -DUSER_C_MODULES=../../../../../micropython.cmake -D MICROPY_FROZEN_MANIFEST=********/new_binding/lvgl_micropython/build/manifest.py -D MICROPY_BOARD_VARIANT=SPIRAM_OCT -B build-ESP32_GENERIC_S3-SPIRAM_OCT build || (echo -e "See \033[1;31mhttps://github.com/micropython/micropython/wiki/Build-Troubleshooting\033[0m"; false)
Executing action: all (aliases: build)
Running cmake in directory ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DPYTHON=********/.espressif/python_env/idf5.1_py3.10_env/bin/python -DESP_PLATFORM=1 -DMICROPY_BOARD=ESP32_GENERIC_S3 -DMICROPY_BOARD_DIR=********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/boards/ESP32_GENERIC_S3 -DUSER_C_MODULES=../../../../../micropython.cmake -DMICROPY_FROZEN_MANIFEST=********/new_binding/lvgl_micropython/build/manifest.py -DMICROPY_BOARD_VARIANT=SPIRAM_OCT -DCCACHE_ENABLE=0 ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32"...
-- Found Git: /usr/bin/git (found version "2.34.1")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: ********/.espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-gcc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: ********/.espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: ********/.espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building ESP-IDF components for target esp32s3
Manifest files have changed, solving dependencies.
.......Updating lock file at ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/dependencies.lock
Processing 4 dependencies:
[1/4] espressif/esp_tinyusb (1.0.3)
[2/4] espressif/mdns (1.1.0)
[3/4] espressif/tinyusb (0.15.0~4)
[4/4] idf (5.1.2)
-- Project sdkconfig file ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/sdkconfig
Loading defaults file ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/sdkconfig.combined...
********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/sdkconfig.combined:100 CONFIG_ESP32_WIFI_IRAM_OPT was replaced with CONFIG_ESP_WIFI_IRAM_OPT
********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/sdkconfig.combined:101 CONFIG_ESP32_WIFI_RX_IRAM_OPT was replaced with CONFIG_ESP_WIFI_RX_IRAM_OPT
/tmp/kconfgen_tmpt99ihbsm:162 line was updated to CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n
/tmp/kconfgen_tmpt99ihbsm:164 line was updated to CONFIG_ESPTOOLPY_FLASHSIZE_16MB=n
/tmp/kconfgen_tmpt99ihbsm:168 line was updated to CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_40=n
/tmp/kconfgen_tmpt99ihbsm:169 line was updated to CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_80=n
/tmp/kconfgen_tmpt99ihbsm:170 line was updated to CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_160=n
/tmp/kconfgen_tmpt99ihbsm:174 line was updated to CONFIG_SPIRAM_MODE_QUAD=n
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of time_t
-- Check size of time_t - done
-- Found Python3: ********/.espressif/python_env/idf5.1_py3.10_env/bin/python (found version "3.10.12") found components: Interpreter
-- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS
-- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS - Success
-- App "micropython" version: v1.22.1-dirty
-- Adding linker script ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/esp-idf/esp_system/ld/memory.ld
-- Adding linker script ********/esp-idf-v5.1.2/components/esp_system/ld/esp32s3/sections.ld.in
-- Adding linker script ********/esp-idf-v5.1.2/components/esp_rom/esp32s3/ld/esp32s3.rom.ld
-- Adding linker script ********/esp-idf-v5.1.2/components/esp_rom/esp32s3/ld/esp32s3.rom.api.ld
-- Adding linker script ********/esp-idf-v5.1.2/components/esp_rom/esp32s3/ld/esp32s3.rom.libgcc.ld
-- Adding linker script ********/esp-idf-v5.1.2/components/esp_rom/esp32s3/ld/esp32s3.rom.newlib.ld
-- Adding linker script ********/esp-idf-v5.1.2/components/esp_rom/esp32s3/ld/esp32s3.rom.version.ld
-- Adding linker script ********/esp-idf-v5.1.2/components/soc/esp32s3/ld/esp32s3.peripherals.ld
-- Components: app_trace app_update bootloader bootloader_support bt cmock console cxx driver efuse esp-tls esp_adc esp_app_format esp_coex esp_common esp_eth esp_event esp_gdbstub esp_hid esp_http_client esp_http_server esp_https_ota esp_https_server esp_hw_support esp_lcd esp_local_ctrl esp_mm esp_netif esp_netif_stack esp_partition esp_phy esp_pm esp_psram esp_ringbuf esp_rom esp_system esp_timer esp_wifi espcoredump espressif__esp_tinyusb espressif__mdns espressif__tinyusb esptool_py fatfs freertos hal heap http_parser idf_test ieee802154 json log lwip main_esp32s3 mbedtls mqtt newlib nvs_flash openthread partition_table perfmon protobuf-c protocomm pthread sdmmc soc spi_flash spiffs tcp_transport touch_element ulp unity usb vfs wear_levelling wifi_provisioning wpa_supplicant xtensa
-- Component paths: ********/esp-idf-v5.1.2/components/app_trace ********/esp-idf-v5.1.2/components/app_update ********/esp-idf-v5.1.2/components/bootloader ********/esp-idf-v5.1.2/components/bootloader_support ********/esp-idf-v5.1.2/components/bt ********/esp-idf-v5.1.2/components/cmock ********/esp-idf-v5.1.2/components/console ********/esp-idf-v5.1.2/components/cxx ********/esp-idf-v5.1.2/components/driver ********/esp-idf-v5.1.2/components/efuse ********/esp-idf-v5.1.2/components/esp-tls ********/esp-idf-v5.1.2/components/esp_adc ********/esp-idf-v5.1.2/components/esp_app_format ********/esp-idf-v5.1.2/components/esp_coex ********/esp-idf-v5.1.2/components/esp_common ********/esp-idf-v5.1.2/components/esp_eth ********/esp-idf-v5.1.2/components/esp_event ********/esp-idf-v5.1.2/components/esp_gdbstub ********/esp-idf-v5.1.2/components/esp_hid ********/esp-idf-v5.1.2/components/esp_http_client ********/esp-idf-v5.1.2/components/esp_http_server ********/esp-idf-v5.1.2/components/esp_https_ota ********/esp-idf-v5.1.2/components/esp_https_server ********/esp-idf-v5.1.2/components/esp_hw_support ********/esp-idf-v5.1.2/components/esp_lcd ********/esp-idf-v5.1.2/components/esp_local_ctrl ********/esp-idf-v5.1.2/components/esp_mm ********/esp-idf-v5.1.2/components/esp_netif ********/esp-idf-v5.1.2/components/esp_netif_stack ********/esp-idf-v5.1.2/components/esp_partition ********/esp-idf-v5.1.2/components/esp_phy ********/esp-idf-v5.1.2/components/esp_pm ********/esp-idf-v5.1.2/components/esp_psram ********/esp-idf-v5.1.2/components/esp_ringbuf ********/esp-idf-v5.1.2/components/esp_rom ********/esp-idf-v5.1.2/components/esp_system ********/esp-idf-v5.1.2/components/esp_timer ********/esp-idf-v5.1.2/components/esp_wifi ********/esp-idf-v5.1.2/components/espcoredump ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/managed_components/espressif__esp_tinyusb ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/managed_components/espressif__mdns ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/managed_components/espressif__tinyusb ********/esp-idf-v5.1.2/components/esptool_py ********/esp-idf-v5.1.2/components/fatfs ********/esp-idf-v5.1.2/components/freertos ********/esp-idf-v5.1.2/components/hal ********/esp-idf-v5.1.2/components/heap ********/esp-idf-v5.1.2/components/http_parser ********/esp-idf-v5.1.2/components/idf_test ********/esp-idf-v5.1.2/components/ieee802154 ********/esp-idf-v5.1.2/components/json ********/esp-idf-v5.1.2/components/log ********/esp-idf-v5.1.2/components/lwip ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/main_esp32s3 ********/esp-idf-v5.1.2/components/mbedtls ********/esp-idf-v5.1.2/components/mqtt ********/esp-idf-v5.1.2/components/newlib ********/esp-idf-v5.1.2/components/nvs_flash ********/esp-idf-v5.1.2/components/openthread ********/esp-idf-v5.1.2/components/partition_table ********/esp-idf-v5.1.2/components/perfmon ********/esp-idf-v5.1.2/components/protobuf-c ********/esp-idf-v5.1.2/components/protocomm ********/esp-idf-v5.1.2/components/pthread ********/esp-idf-v5.1.2/components/sdmmc ********/esp-idf-v5.1.2/components/soc ********/esp-idf-v5.1.2/components/spi_flash ********/esp-idf-v5.1.2/components/spiffs ********/esp-idf-v5.1.2/components/tcp_transport ********/esp-idf-v5.1.2/components/touch_element ********/esp-idf-v5.1.2/components/ulp ********/esp-idf-v5.1.2/components/unity ********/esp-idf-v5.1.2/components/usb ********/esp-idf-v5.1.2/components/vfs ********/esp-idf-v5.1.2/components/wear_levelling ********/esp-idf-v5.1.2/components/wifi_provisioning ********/esp-idf-v5.1.2/components/wpa_supplicant ********/esp-idf-v5.1.2/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT
Running ninja in directory ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT
Executing "ninja all"...
[1/1893] Generating project_elf_src_esp32s3.c
[2/1893] Generating memory.ld linker script...
[3/1893] Building C object esp-idf/main_esp32s3/CMakeFiles/micropy_extmod_btree.dir********/new_binding/lvgl_micropython/lib/micropython/lib/berkeley-db-1.xx/btree/bt_debug.c.obj
....
[28/1893] Building C object esp-idf/driver/CMakeFiles/__idf_driver.dir/gptimer/gptimer_priv.c.obj
[29/1893] Generating ../../partition_table/partition-table.bin
Partition table binary generated. Contents:
*******************************************************************************
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,24K,
phy_init,data,phy,0xf000,4K,
factory,app,factory,0x10000,2444K,
vfs,data,fat,0x273000,5684K,
*******************************************************************************
[30/1893] Building C object esp-idf/mbedtls/mbedtls/library/CMakeFiles/mbedcrypto.dir/base64.c.obj
....
[1055/1893] Linking C static library esp-idf/esp_app_format/libesp_app_format.a
[1056/1893] Generating ********/new_binding/lvgl_micropython/lib/micropython/mpy-cross/build/mpy-cross
make[1]: Entering directory '********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/esp-idf/main_esp32s3'
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
GEN build/genhdr/mpversion.h
CC ../py/modsys.c
CC main.c
LINK build/mpy-cross
   text    data     bss     dec     hex filename
 326534   13784     872  341190   534c6 build/mpy-cross
make[1]: Leaving directory '********/new_binding/lvgl_micropython/lib/micropython/mpy-cross'
[1057/1893] Linking CXX static library esp-idf/mbedtls/mbedtls/library/libmbedtls.a
....
[1061/1893] Linking CXX static library esp-idf/mbedtls/mbedtls/3rdparty/everest/libeverest.a
[1062/1893] Linking C static library esp-idf/esp_pm/libesp_pm.a
....
[1088/1893] Linking C static library esp-idf/wifi_provisioning/libwifi_provisioning.a
[1089/1893] Generating ../../genhdr/qstr.i.last
[1090/1893] Building C object esp-idf/espressif__mdns/CMakeFiles/__idf_espressif__mdns.dir/mdns.c.obj
[1091/1893] Linking C static library esp-idf/espressif__mdns/libespressif__mdns.a
[1092/1893] Linking C static library esp-idf/esp_local_ctrl/libesp_local_ctrl.a
[1093/1893] Generating ../../genhdr/qstr.split
[1094/1893] Generating ../../genhdr/qstrdefs.collected.h
QSTR updated
[1095/1893] Generating ../../genhdr/qstrdefs.preprocessed.h
[1096/1893] Generating ../../genhdr/qstrdefs.generated.h
[1097/1893] Generating ../../genhdr/root_pointers.split
[1098/1893] Generating ../../genhdr/root_pointers.collected
Root pointer registrations updated
[1099/1893] Generating ../../genhdr/root_pointers.h
[1100/1893] Performing configure step for 'bootloader'
-- Found Git: /usr/bin/git (found version "2.34.1")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: ********/.espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-gcc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: ********/.espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: ********/.espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building ESP-IDF components for target esp32s3
-- Project sdkconfig file ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/sdkconfig
Compiler supported targets: xtensa-esp32s3-elf

-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of time_t
-- Check size of time_t - done
-- Adding linker script ********/esp-idf-v5.1.2/components/soc/esp32s3/ld/esp32s3.peripherals.ld
-- App "bootloader" version: v5.1.2
-- Adding linker script ********/esp-idf-v5.1.2/components/esp_rom/esp32s3/ld/esp32s3.rom.ld
-- Adding linker script ********/esp-idf-v5.1.2/components/esp_rom/esp32s3/ld/esp32s3.rom.api.ld
-- Adding linker script ********/esp-idf-v5.1.2/components/esp_rom/esp32s3/ld/esp32s3.rom.libgcc.ld
-- Adding linker script ********/esp-idf-v5.1.2/components/esp_rom/esp32s3/ld/esp32s3.rom.newlib.ld
-- Adding linker script ********/esp-idf-v5.1.2/components/bootloader/subproject/main/ld/esp32s3/bootloader.ld
-- Adding linker script ********/esp-idf-v5.1.2/components/bootloader/subproject/main/ld/esp32s3/bootloader.rom.ld
-- Components: bootloader bootloader_support efuse esp_app_format esp_common esp_hw_support esp_rom esp_system esptool_py freertos hal log main micro-ecc newlib partition_table soc spi_flash xtensa
-- Component paths: ********/esp-idf-v5.1.2/components/bootloader ********/esp-idf-v5.1.2/components/bootloader_support ********/esp-idf-v5.1.2/components/efuse ********/esp-idf-v5.1.2/components/esp_app_format ********/esp-idf-v5.1.2/components/esp_common ********/esp-idf-v5.1.2/components/esp_hw_support ********/esp-idf-v5.1.2/components/esp_rom ********/esp-idf-v5.1.2/components/esp_system ********/esp-idf-v5.1.2/components/esptool_py ********/esp-idf-v5.1.2/components/freertos ********/esp-idf-v5.1.2/components/hal ********/esp-idf-v5.1.2/components/log ********/esp-idf-v5.1.2/components/bootloader/subproject/main ********/esp-idf-v5.1.2/components/bootloader/subproject/components/micro-ecc ********/esp-idf-v5.1.2/components/newlib ********/esp-idf-v5.1.2/components/partition_table ********/esp-idf-v5.1.2/components/soc ********/esp-idf-v5.1.2/components/spi_flash ********/esp-idf-v5.1.2/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/bootloader
[1101/1893] cd ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/esp-idf/main_esp32s3 && ********/.espressif/python_env/idf5.1_py3.10_env/bin/python ********/new_binding/lvgl_micropython/lib/micropython/tools/makemanifest.py -o ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/frozen_content.c -v BOARD_DIR=********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/boards/ESP32_GENERIC_S3 -v MPY_DIR=********/new_binding/lvgl_micropython/lib/micropython -v MPY_LIB_DIR=********/new_binding/lvgl_micropython/lib/micropython/lib/micropython-lib -v PORT_DIR=********/new_binding/lvgl_micropython/lib/micropython/ports/esp32 -b ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT -f-march=xtensawin --mpy-tool-flags= ********/new_binding/lvgl_micropython/build/manifest.py
MPY apa106.py
MPY _boot.py
MPY flashbdev.py
MPY inisetup.py
MPY espnow.py
MPY asyncio/__init__.py
MPY asyncio/core.py
MPY asyncio/event.py
MPY asyncio/funcs.py
MPY asyncio/lock.py
MPY asyncio/stream.py
MPY uasyncio.py
MPY requests/__init__.py
MPY mip/__init__.py
MPY ntptime.py
MPY webrepl.py
MPY webrepl_setup.py
MPY urequests.py
MPY aioespnow.py
MPY dht.py
MPY onewire.py
MPY ds18x20.py
MPY neopixel.py
MPY umqtt/robust.py
MPY umqtt/simple.py
MPY upysh.py
MPY display_driver_framework.py
MPY fs_driver.py
MPY lv_utils.py
GEN ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/frozen_content.c
[1102/1893] Performing build step for 'bootloader'
[1/110] Generating project_elf_src_esp32s3.c
[2/110] Building C object esp-idf/xtensa/CMakeFiles/__idf_xtensa.dir/eri.c.obj
....
[60/110] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp_efuse_fields.c.obj
[61/110] Building ASM object esp-idf/esp_rom/CMakeFiles/__idf_esp_rom.dir/patches/esp_rom_longjmp.S.obj
[62/110] Building C object esp-idf/esp_system/CMakeFiles/__idf_esp_system.dir/esp_err.c.obj
[63/110] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/esp32s3/esp_efuse_rtc_calib.c.obj
[64/110] Building ASM object esp-idf/esp_rom/CMakeFiles/__idf_esp_rom.dir/patches/esp_rom_cache_writeback_esp32s3.S.obj
[65/110] Building C object esp-idf/esp_common/CMakeFiles/__idf_esp_common.dir/src/esp_err_to_name.c.obj
....
[108/110] Linking C executable bootloader.elf
[109/110] Generating binary image from built executable
esptool.py v4.7.0
Creating esp32s3 image...
Merged 1 ELF section
Successfully created esp32s3 image.
Generated ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/bootloader/bootloader.bin
[110/110] cd ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/bootloader/esp-idf/esptool_py && ********/.espressif/python_env/idf5.1_py3.10_env/bin/python ********/esp-idf-v5.1.2/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x0 ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/bootloader/bootloader.bin
Bootloader binary size 0x4a20 bytes. 0x35e0 bytes (42%) free.
[1103/1893] No install step for 'bootloader'
[1104/1893] Completed 'bootloader'
[1105/1893] Generating ../../genhdr/moduledefs.split
[1106/1893] Generating ../../genhdr/moduledefs.collected
Module registrations updated
[1107/1893] Generating ../../genhdr/moduledefs.h
[1108/1893] Building C object esp-idf/main_esp32s3/CMakeFiles/__idf_main_esp32s3.dir********/new_binding/lvgl_micropython/lib/micropython/py/asmthumb.c.obj
....
[1611/1893] Linking C static library esp-idf/main_esp32s3/libmain_esp32s3.a
[1612/1893] Generating ld/sections.ld
[1613/1893] Building C object CMakeFiles/micropython.elf.dir/project_elf_src_esp32s3.c.obj
....
[1891/1893] Linking CXX executable micropython.elf
[1892/1893] Generating binary image from built executable
esptool.py v4.7.0
Creating esp32s3 image...
Merged 3 ELF sections
Successfully created esp32s3 image.
Generated ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin
[1893/1893] cd ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/esp-idf/esptool_py && ********/.espressif/python_env/idf5.1_py3.10_env/bin/python ********/esp-idf-v5.1.2/components/partition_table/check_sizes.py --offset 0x8000 partition --type app ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/partition_table/partition-table.bin ********/new_binding/lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin
micropython.bin binary size 0x23cb70 bytes. Smallest app partition is 0x263000 bytes. 0x26490 bytes (6%) free.

Project build complete. To flash, run this command:
********/.espressif/python_env/idf5.1_py3.10_env/bin/python ../../../../../../esp-idf-v5.1.2/components/esptool_py/esptool/esptool.py -p (PORT) -b 460800 --before default_reset --after no_reset --chip esp32s3  write_flash --flash_mode dio --flash_size 8MB --flash_freq 80m 0x0 build-ESP32_GENERIC_S3-SPIRAM_OCT/bootloader/bootloader.bin 0x8000 build-ESP32_GENERIC_S3-SPIRAM_OCT/partition_table/partition-table.bin 0x10000 build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin
or run 'idf.py -p (PORT) flash'
bootloader  @0x000000    18976  (   13792 remaining)
partitions  @0x008000     3072  (    1024 remaining)
application @0x010000  2345840  (  156816 remaining)
total                  2411376
make: Leaving directory '********/new_binding/lvgl_micropython/lib/micropython/ports/esp32'
Compiler supported targets: xtensa-esp32s3-elf

Including User C Module(s) from ../../../../../micropython.cmake
Found User C Module(s): usermod_lcd_bus, usermod_heap_caps, usermod_lvgl, lvgl_interface

note the [4/4] idf (5.1.2) in the build log.

I know I am not compiling for the C6 is the ESP-IDF API different for the C6 vs the S3?

@mattytrentini
Copy link
Contributor

I know I am not compiling for the C6 is the ESP-IDF API different for the C6 vs the S3?

Yes. Some APIs are deprecated but still supported (as legacy) on the S3 and other micros. Those legacy APIs don't exist for the C6. So some components need to be rewritten.

@kdschlosser
Copy link

ahhh OK. That makes sense then.

@mancausoft
Copy link
Contributor

mancausoft commented Mar 12, 2024

I was able to compile micropython using the code from: #11869 (andrewleech:esp32c6)
I rebase it to: #13775 (DvdGiessen:esp32_idf52)

and fix ADC calibration and a problem with UART name.

The code is here: https://github.com/mancausoft/micropython/tree/esp32c6

I also have the image to test here: https://github.com/mancausoft/micropython/releases/tag/0.0.0

EDIT: I forgot to say that I'm using idf 5.2.0 to compile it

@agatti
Copy link
Contributor

agatti commented Sep 26, 2024

say it's just "good practice" to not give more permission than is really required

It may even be required for compliance reasons in certain scenarios.

I couldn't find any obvious issues relating to this on the IDF GitHub issue tracker so it's probably worth raising something there too.

Even so, I think that's going to be tricky to solve properly. If the chip really doesn't allow overlapping PMP regions then there are two options: either make the region permissions overridable and weaken the overall security (the flags they use only allow to write to those registers once), or make a section of IRAM executable whose size is set at compile time (less than ideal for applications like MicroPython, where the maximum size for such a region is not known at compile time).

For the detail-inclined, more information about this feature is here: https://github.com/riscv/riscv-isa-manual/blob/main/src/machine.adoc#physical-memory-protection

@dpgeorge
Copy link
Member

I'd disable CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT just for compatibility's sake, and have a HARDENED board variant with the emitter disabled and CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT enabled.

Yes, I think for now we can disable CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT so that native code (and all its variations, inline assembler and native in .mpy files) can work.

Then provide a way to easily reenable that option which also automatically disables the native emitter. That should be easy, just a few lines it mpconfigport.h. Eg:

#if CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT
#define MICROPY_EMIT_RV32                   (0)
#else
#define MICROPY_EMIT_RV32                   (1)
#endif

And also:

#if CONFIG_IDF_TARGET_ESP32C6
// On this target all RAM is executable so no need for a custom commit function.
#else
void *esp_native_code_commit(void *, size_t, void *);                                                               
#define MP_PLAT_COMMIT_EXEC(buf, len, reloc) esp_native_code_commit(buf, len, reloc)
#endif

@andrewleech
Copy link
Contributor Author

I've added a commit to disable along with the other suggestions @dpgeorge thanks.

I made this change in the base sdkconfig as from my understanding of it the setting will do nothing in chips that don't support it and are therefore not impacted by it. I was wary of just setting it in board folders as it's not a very discoverable limitation and could easily be missed for those other new chips that will need this change when added here.

With the change as pushed the test suite is looking reasonable

867 tests passed
54 tests skipped: builtin_next_arg2 builtin_range_binop cexample_class cexample_
module cexample_subclass cryptolib_aes128_ctr deflate_compress deflate_stream_er
ror exception_chain float2int_doubleprec_intbig f_binop cexample_class cexample_module cexample_subclass cryptolib_aes128_ctr deflate_compress deflate_stream_error exception_chain float2int_doubleprec_intbig float_divmod float_format_ints_doubleprec float_parse_doubleprec heap_locked heapalloc_bytesio2 import_mpy_native_gc machine_i2s_rate machine_pinbase machine_pulse machine_signal machine_soft_timer machine_uart_irq_txidle machine_uart_tx meminfo memoryview_itemsize memstats namedtuple_asdict nanbox_smallint re_debug re_groups re_span select_poll_fd ssl_ioctl ssl_poll subclass_native_call sys_atexit sys_exc_info sys_getsizeof
sys_path sys_settrace_features sys_settrace_generator sys_settrace_loop sys_tracebacklimit vfs_fat_ramdisklarge vfs_lfs vfs_lfs_corrupt vfs_lfs_error vfs_lfs_file vfs_lfs_mount vfs_posix vfs_posix_enoent vfs_posix_ilistdir_del vfs_posix_ilistdir_filter vfs_posix_paths

@dpgeorge
Copy link
Member

dpgeorge commented Oct 9, 2024

Thanks @andrewleech , this looks good now.

Can you please rebase on master, because there are conflicts with the recent TinyUSB changes.

@andrewleech
Copy link
Contributor Author

That's fixed now thanks @dpgeorge

pi-anl and others added 12 commits October 9, 2024 23:29
This commit adds general support for ESP32-C6 SoCs.

Signed-off-by: Andrew Leech <andrew@alelec.net>
Signed-off-by: IhorNehrutsa <IhorNehrutsa@gmail.com>
Signed-off-by: IhorNehrutsa <Ihor.Nehrutsa@gmail.com>
Signed-off-by: IhorNehrutsa <Ihor.Nehrutsa@gmail.com>
Signed-off-by: Andrew Leech <andrew@alelec.net>
Signed-off-by: Andrew Leech <andrew@alelec.net>
In idf v5.2.1 if the port flag is set it's validated even on jobs that
don't access hardware like clean.  This causes the job to fail if device
isn't connected.

Signed-off-by: Andrew Leech <andrew@alelec.net>
Signed-off-by: Andrew Leech <andrew@alelec.net>
Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
Signed-off-by: Andrew Leech <andrew@alelec.net>
Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge merged commit 197becb into micropython:master Oct 9, 2024
30 checks passed
@dpgeorge
Copy link
Member

dpgeorge commented Oct 9, 2024

I tested again on C3 and C6 and the test suite (and new mpremote tests) pass.

Merged!!

@mzakharocsc
Copy link
Contributor

Workarounds for stack guard are still needed on C6. #15771 only covers C3 boards.

@dpgeorge
Copy link
Member

dpgeorge commented Oct 9, 2024

Workarounds for stack guard are still needed on C6

@mzakharocsc are you able to reproduce the stack pointer issue on a C6 board?

@andrewleech
Copy link
Contributor Author

Thanks to everone here who contributed to the commits in the MR along with all the testing and discussions!

@mzakharocsc
Copy link
Contributor

Workarounds for stack guard are still needed on C6

@mzakharocsc are you able to reproduce the stack pointer issue on a C6 board?

My original issue submission was discovered on C6 board. #15667. As per https://github.com/espressif/esp-idf/releases/tag/v5.2, stack guard is enabled by default on esp32c2/esp32c3/esp32c6/esp32h2 targets. So yes, C6 needs a fix as well.

@dpgeorge
Copy link
Member

My original issue submission was discovered on C6 board. #15667

OK, let's reopen that issue and continue the discussion there.

@vshymanskyy
Copy link
Contributor

Does anyone know why ESP32-C6 build is so much bigger than ESP32-C3?
i.e. v1.24.0-preview.447.g838f21298 (this is only .app-bin):

esp32-c3: 1673.6 KiB
esp32-c6: 1848.7 KiB

@projectgus
Copy link
Contributor

Does anyone know why ESP32-C6 build is so much bigger than ESP32-C3?

Good question... looks like the Wi-Fi and Bluetooth stacks on the C6 are both a bit bigger (makes particular sense for Wi-Fi given the Wi-Fi 6 support). Building some ESP-IDF examples with idf.py size:

Example Total Size C3 Total Size C6
get-started/hello_world 172624 148876
bluetooth/nimble/bleprph 602562 642022
bluetooth/nimble/bleprph_wifi_coex 1019914 1144458

So that's +124KB for the Wi-Fi/Bluetooth peripheral coexistence example, compared to +175KB for MicroPython. MicroPython probably pulls in even more of each stack, though, due to supporting more functions at runtime.

C6 is new so Espressif might get this number down over time, it might even be lower in ESP-IDF master branch (these numbers are from v5.2.2 as used in MicroPython).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.