fdcavalcanti opened a new pull request, #18661:
URL: https://github.com/apache/nuttx/pull/18661

   ## Summary
   
   <!-- This field should contain a summary of the changes. It will be 
pre-filled with the commit's message and descriptions. Adjust it accordingly -->
   
   * arch/espressif: add flash encryption support on CMake
   
   Add support for burning flash encryption E-Fuses on target.
   
   
   * tools/espressif: add support for target flashing using CMake
   
   Support flashing target using cmake --build <build> -t flash.
   
   
   * espressif: add CMake build support for RISC-V devices
   
   Adds CMake build support. Touches arch and board at the same time to avoid
   creating a commit that is not able to build.
   
   
   * docs: add CMake documentation for RISC-V Espressif devices
   
   Update NuttX documentation with CMake usage instructions for Espressif 
devices.
   
   
   * cmake: add olddefconfig target for CMake builds
   
   Olddefconfig allows refreshing .config options if the user manually
   edit some entry on .config file.
   
   
   * cmake: add support for 3rdparty functions
   
   Adds support for checking git hash and creating nxtmpdir.
   This is already available for Make builds.
   
   
   -----
   
   This PR adds support for CMake builds on RISC-V Espressif devices.
   
   It supports the same configurations as Make build, with the exception of ULP.
   
   The CMake support shares the same NXTMPDIR strategy for caching builds and 
device flashing. There are examples on SoC documentation and on this summary.
   
   
   ## Impact
   <!-- Please fill the following sections with YES/NO and provide a brief 
explanation -->
   
   Impact on user: No.
   <!-- Does it impact user's applications? How? -->
   
   Impact on build: This features allows building Espressif RISC-V devices 
using CMake. Significantly decreases build times.
   <!-- Does it impact on building NuttX? How? (please describe the required 
changes on the build system) -->
   
   Impact on hardware: Espressif devices: ESP32-C3|C6|H2|P4
   <!-- Does it impact a specific hardware supported by NuttX? -->
   
   Impact on documentation: Yes, updates the documentation with instructions 
for CMake usage.
   <!-- Does it impact the existing documentation? Please provide additional 
documentation to reflect that -->
   
   Impact on security: No.
   <!-- Does it impact NuttX's security? -->
   
   Impact on compatibility: No.
   <!-- Does it impact compatibility between previous and current versions? Is 
this a breaking change? -->
   
   ## Testing
   <!-- Please provide all the testing procedure. Consider that upstream 
reviewers should be able to reproduce the same testing performed internally -->
   
   <!-- Provide how to build the test for each SoC being tested -->
   CMake build can be triggered as follows, for any of the affected SoCs:
   - `cmake -B build -DBOARD_CONFIG=esp32c6-devkitc:nsh -GNinja`
   - Or, to generate the 3rdparty cache (speeds up following builds by caching 
the HAL download):
     - `cmake -B build -DBOARD_CONFIG=esp32c6-devkitc:nsh -DNXTMPDIR=on -GNinja`
     - This is the recommended usage.
   - `cmake --build build`
   - To flash the device, use `ESPTOOL_PORT=/dev/ttyUSB0 cmake --build build -t 
flash`
   
   ### Configuring build
   <!-- Provide how to run the test for each SoC being tested -->
   ```
   $ cmake -B build -DBOARD_CONFIG=esp32c6-devkitc:nsh -DNXTMPDIR=on -GNinja
   -- Found Python3: /home/fdcavalcanti/work/venvs/nuttx/bin/python3 (found 
version "3.12.3") found components: Interpreter 
   -- nuttx_add_subdirectory: Skipping cxx-oot-build
   -- Initializing NuttX
   Loaded configuration 
'/home/fdcavalcanti/nuttxspace5/nuttx/build/.config.compressed'
   Minimal configuration saved to 
'/home/fdcavalcanti/nuttxspace5/nuttx/build/defconfig.tmp'
     Select HOST_LINUX=y
   --   CMake:  3.28.3
   --   Ninja:  1.11.1
   --   Board:  esp32c6-devkitc
   --   Config: nsh
   --   Appdir: /home/fdcavalcanti/nuttxspace5/nuttx-apps
   -- The C compiler identification is GNU 13.3.0
   -- Detecting C compiler ABI info
   -- Detecting C compiler ABI info - done
   -- Check for working C compiler: /usr/bin/cc - skipped
   -- Detecting C compile features
   -- Detecting C compile features - done
   -- NuttX Host Tools
   -- CMake C compiler: GNU
   -- CMake system name: Linux
   -- CMake host system processor: x86_64
      TOOLS_DIR path is "/home/fdcavalcanti/nuttxspace5/nuttx"
      HOST = Linux
   -- Configuring done (0.3s)
   -- Generating done (0.0s)
   -- Build files have been written to: 
/home/fdcavalcanti/nuttxspace5/nuttx/build/bin_host
   -- The C compiler identification is GNU 13.2.0
   -- The CXX compiler identification is GNU 13.2.0
   -- The ASM compiler identification is GNU
   -- Found assembler: 
/home/fdcavalcanti/work/toolchains/riscv-none-elf-gcc/bin/riscv-none-elf-gcc
   -- COMMIT SHA-1: a85ce2f1bad9f745090146eb30a18d91b8ddd309
   -- Copying from /home/fdcavalcanti/nuttxspace5/nxtmpdir/esp-hal-3rdparty to 
/home/fdcavalcanti/nuttxspace5/nuttx/build/arch/risc-v/src/common/espressif/esp-hal-3rdparty
   HEAD is now at 582ff4820 feat(drivers): ESP-HMAC opaque driver
   -- nuttx_add_subdirectory: Skipping cxx-oot-build
   -- Configuring done (6.0s)
   -- Generating done (0.2s)
   -- Build files have been written to: 
/home/fdcavalcanti/nuttxspace5/nuttx/build
   ```
   
   For MCUBoot usage, the `bootloader` target is available. In this case, it 
downloads the required MCUBoot source during configure stage.
   ```
   $ cmake -B build -DBOARD_CONFIG=esp32c6-devkitc:mcuboot_nsh -DNXTMPDIR=on 
-GNinja
   ...
   -- Cloning Espressif HAL for 3rd Party Platforms (MCUBoot build)
   -- Populating esp_hal_3rdparty_mcuboot
   -- Configuring done (0.0s)
   -- Generating done (0.0s)
   -- Build files have been written to: 
/home/fdcavalcanti/nuttxspace5/nuttx/build/_deps/esp_hal_3rdparty_mcuboot-subbuild
   [1/9] Creating directories for 'esp_hal_3rdparty_mcuboot-populate'
   [1/9] Performing download step (git clone) for 
'esp_hal_3rdparty_mcuboot-populate'
   Cloning into 'esp-hal-3rdparty-mcuboot'...
   HEAD is now at 911dbec8e4a change(version): Update version to 5.1.6
   [2/9] Performing update step for 'esp_hal_3rdparty_mcuboot-populate'
   [3/9] No patch step for 'esp_hal_3rdparty_mcuboot-populate'
   [5/9] No configure step for 'esp_hal_3rdparty_mcuboot-populate'
   [6/9] No build step for 'esp_hal_3rdparty_mcuboot-populate'
   [7/9] No install step for 'esp_hal_3rdparty_mcuboot-populate'
   [8/9] No test step for 'esp_hal_3rdparty_mcuboot-populate'
   [9/9] Completed 'esp_hal_3rdparty_mcuboot-populate'
   -- nuttx_add_subdirectory: Skipping cxx-oot-build
   -- Configuring done (26.5s)
   -- Generating done (0.3s)
   -- Build files have been written to: 
/home/fdcavalcanti/nuttxspace5/nuttx/build
   ```
   
   ### Building
   <!-- Provide tests' results and runtime logs -->
   Build output for `nsh` defconfig:
   ```
   $ cmake --build build
   [1359/1359] Running utility command for nuttx_post_build
   -- Generate NuttX image (esptool elf2image)
   esptool v5.2.0
   Creating ESP32-C6 image...
   Image has only RAM segments visible. ROM segments are hidden and SHA256 
digest is not appended.
   Note: Inserting 63840 bytes padding between .flash.text and .flash.rodata
   Merged 1 ELF section.
   Successfully created ESP32-C6 image.
   -- Generated: nuttx.bin
   ```
   
   Build output for bootloader target (MCUBoot):
   ```
   $ cmake --build build -t bootloader
   [2/8] Performing download step (git clone) for 'bootloader'
   Cloning into 'mcuboot'...
   HEAD is now at 8a07053d bootutil: Fix log module registration
   ...
   esptool v5.2.0
   Creating ESP32-C6 image...
   Merged 3 ELF sections.
   Successfully created ESP32-C6 image.
   [8/8] Completed 'bootloader'
   ```
   
   ### Flashing device
   ```
   $ ESPTOOL_PORT=/dev/ttyUSB0 cmake --build build -t flash
   [7/8] Running utility command for nuttx_post_build
   -- Generate NuttX image (esptool elf2image)
   esptool v5.2.0
   Creating ESP32-C6 image...
   Image has only RAM segments visible. ROM segments are hidden and SHA256 
digest is not appended.
   Note: Inserting 63716 bytes padding between .flash.text and .flash.rodata
   Merged 1 ELF section.
   Successfully created ESP32-C6 image.
   -- Generated: nuttx.bin
   [8/8] Flashing firmware via esptool to
   esptool v5.2.0
   Connected to ESP32-C6 on /dev/ttyUSB0:
   Chip type:          ESP32-C6 (QFN40) (revision v0.0)
   Features:           Wi-Fi 6, BT 5 (LE), IEEE802.15.4, Single Core + LP Core, 
160MHz, Unknown Embedded Flash
   Crystal frequency:  40MHz
   MAC:                60:55:f9:00:00:f6:06:04
   BASE MAC:           60:55:f9:f6:06:04
   MAC_EXT:            00:00
   
   Stub flasher running.
   Changing baud rate to 921600...
   Changed.
   
   Configuring flash size...
   Flash will be erased from 0x00000000 to 0x0004bfff...
   Wrote 308416 bytes (117650 compressed) at 0x00000000 in 2.8 seconds (873.1 
kbit/s).
   Hash of data verified.
   
   Hard resetting via RTS pin...
   -- Flash completed successfully.
   ```
   
   ### Conclusion
   All defconfigs build properly and were been tested using Espressif's 
internal CI. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to