ports/risc-v32/gnu: Add initial ESP32-C6 bare-metal ThreadX bring-up … - #576
Open
alieissa-commits wants to merge 2 commits into
Open
ports/risc-v32/gnu: Add initial ESP32-C6 bare-metal ThreadX bring-up …#576alieissa-commits wants to merge 2 commits into
alieissa-commits wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds an initial bare-metal Eclipse ThreadX bring-up example for the Espressif ESP32-C6 microcontroller (
ESP32-C6-DevKitC-1) underports/risc-v32/gnu/example_build/esp32c6/.It provides the basic hardware adaptation layer, memory map, build scripts, third-party licensing compliance, and a validation application demonstrating ThreadX thread creation and mutex synchronization on RISC-V32.
Key Changes & Implementations
1. Build System & Toolchain
CMakeLists.txt&cmake/esp32c6-toolchain.cmake: Cross-compilation support usingriscv32-esp-elf-gcc(-march=rv32imac_zicsr_zifencei -mabi=ilp32). Includes post-buildesptool.py elf2imagegeneration (esp32c6_demo.bin).2. Assembly Boot & Trap Infrastructure
entry.S: Initial CPU setup clearing Machine Interrupts (csrc mstatus, 8), setting up Global Pointer (gp), zeroing.bss, enforcing Direct Modemtvec(Mode 0), and jumping toc6_startup.vectors.S: Trap vector table pre-allocating 128-byte stack frames required by ThreadX RISC-V context save (_tx_thread_context_save), dispatching interrupts to C, and restoring thread context (_tx_thread_context_restore).tx_initialize_low_level.S: Assembly hook allocating stack space to preserveraacross platform C driver initialization (esp32c6_platform_init).3. Memory Map & Bootloader Validation
link.ld: Configured for ESP32-C6 512 KB SRAM (0x40800000). PlacedKEEP(*(.rodata_desc .rodata_desc.*))at byte offset 0x20 of segment 0 so Espressif's 2nd-stage bootloader validatesesp_app_desc_t(0xABCD5432magic word). Defines_tx_initialize_unused_memoryat heap boundary.4. Platform Hardware Drivers (
platform/)console.c: UART driver using Espressif ROM API (esp_rom_output_tx_one_char) with\n\r\nline normalization.interrupt.c: Configures PCR INTMTX bus clock (0x60096090), PLIC priority levels, CPU interrupt thresholds, andmie.MEIE/mie.MTIECSR bits. Implements RISC-V PLIC Claim/Complete transaction dispatching viaPLIC_MXINT_CLAIM_REG(0x20001094).systimer.c: Links pinned ESP-IDFsystimer_hal.c, connects Alarm 0 to 16 MHz Counter 0, takes hardware snapshots, and reloads periodic 10ms target values.startup.c: Definesesp_app_desc_t, unlocks/disables hardware LP Watchdog Timer (LP_WDT), and hands off execution totx_kernel_enter().5. Application Demo & Compliance
demo_threadx.c: ThreadX kernel validation demo creatingdemo_mutex,thread_0, andthread_1with 16-byte aligned static RISC-V stack buffers.NOTICE.md: Formal third-party IP attribution file following Eclipse Foundation and Apache 2.0 standards for Espressif Systems, 10xEngineers, and Zephyr RTOS.README.md: Build, flash, serial monitor, and OpenOCD/GDB debugging instructions.Known Technical Issues & Status (For Future Development)
Warning
This bring-up example is an initial foundation and has active hardware tick issues documented in
README.md:thread_0_entry. However, after callingtx_thread_sleep(), the ThreadX scheduler remains in_tx_thread_schedule_loopbecause PLIC external interrupts are not advancing_tx_timer_system_clock.Recommended Next Steps
As outlined in [
threadx_ESP32C6_native_WIFI_plan.md]:platform/systimer.cimplementation with a pinned ESP-IDFesp_timerframework component import (esp_timer_systimer.c/systimer_hal.c) or use the native CPU RISC-V Machine Timer (mtimecmp/MTIE).Verification Performed
riscv32-esp-elf-gcc15.2.0.esptool.py elf2image.esp32c6_demo.elf.