This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new c71a15708d6 boards/xtensa/esp32: switch esp32-m5-stickc-plus to nxinit 
entrypoint
c71a15708d6 is described below

commit c71a15708d69039c5a483836124c98989b3625be
Author: Junbo Zheng <[email protected]>
AuthorDate: Thu Nov 12 10:44:06 2026 +0800

    boards/xtensa/esp32: switch esp32-m5-stickc-plus to nxinit entrypoint
    
    Use init_main as the init entrypoint, with the console shell started
    as an nxinit service from the /etc/init.d/init.rc baked into the
    ROMFS, matching what the esp32s3 boards already do.
    
    The ROMFS packing in the esp32 common board code now appends
    etc/init.d/init.rc to the image when CONFIG_SYSTEM_NXINIT is enabled,
    mirroring boards/xtensa/esp32s3/common.
    
    NSH runs as the "console" service with 8K of stack: the default
    DEFAULT_TASK_STACKSIZE overflows when NSH is spawned as a service and
    runs commands like ps.
    
    Testing:
    - cmake -B build -DBOARD_CONFIG=esp32-m5-stickc-plus:nsh, flashed on
      an M5StickC Plus: ps shows init_main (pid 2) with the sh service as
      its child, and reboot comes back to the same state.
    
    Signed-off-by: Junbo Zheng <[email protected]>
---
 boards/xtensa/esp32/common/src/CMakeLists.txt      |  9 ++++--
 boards/xtensa/esp32/common/src/Make.defs           |  3 ++
 boards/xtensa/esp32/common/src/etc/init.d/init.rc  | 34 ++++++++++++++++++++++
 .../esp32-m5-stickc-plus/configs/nsh/defconfig     | 10 ++++++-
 4 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/boards/xtensa/esp32/common/src/CMakeLists.txt 
b/boards/xtensa/esp32/common/src/CMakeLists.txt
index 4168d3646c7..dfcaa84a688 100644
--- a/boards/xtensa/esp32/common/src/CMakeLists.txt
+++ b/boards/xtensa/esp32/common/src/CMakeLists.txt
@@ -121,14 +121,19 @@ if(CONFIG_ARCH_BOARD_COMMON)
   endif()
 
   if(CONFIG_ETC_ROMFS)
+    set(RCSRCS etc/init.d/rc.sysinit etc/init.d/rcS)
+
+    if(CONFIG_SYSTEM_NXINIT)
+      list(APPEND RCSRCS etc/init.d/init.rc)
+    endif()
+
     nuttx_add_romfs(
       NAME
       etc
       MOUNTPOINT
       etc
       RCSRCS
-      etc/init.d/rc.sysinit
-      etc/init.d/rcS
+      ${RCSRCS}
       PATH
       ${CMAKE_CURRENT_BINARY_DIR}/etc)
     target_link_libraries(board PRIVATE romfs_etc)
diff --git a/boards/xtensa/esp32/common/src/Make.defs 
b/boards/xtensa/esp32/common/src/Make.defs
index af42351072e..26a0bbb9460 100644
--- a/boards/xtensa/esp32/common/src/Make.defs
+++ b/boards/xtensa/esp32/common/src/Make.defs
@@ -176,6 +176,9 @@ endif
 
 ifeq ($(CONFIG_ETC_ROMFS),y)
   RCSRCS  = etc/init.d/rc.sysinit etc/init.d/rcS
+ifeq ($(CONFIG_SYSTEM_NXINIT),y)
+  RCSRCS += etc/init.d/init.rc
+endif
 endif
 
 DEPPATH += --dep-path src
diff --git a/boards/xtensa/esp32/common/src/etc/init.d/init.rc 
b/boards/xtensa/esp32/common/src/etc/init.d/init.rc
new file mode 100644
index 00000000000..c21d14e537e
--- /dev/null
+++ b/boards/xtensa/esp32/common/src/etc/init.d/init.rc
@@ -0,0 +1,34 @@
+/****************************************************************************
+ * boards/xtensa/esp32/common/src/etc/init.d/init.rc
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#ifdef CONFIG_SYSTEM_NSH
+
+service console sh
+   console
+   restart_period 1000
+
+on init
+   start console
+
+#endif
diff --git a/boards/xtensa/esp32/esp32-m5-stickc-plus/configs/nsh/defconfig 
b/boards/xtensa/esp32/esp32-m5-stickc-plus/configs/nsh/defconfig
index 19807288e99..ea104b0173d 100644
--- a/boards/xtensa/esp32/esp32-m5-stickc-plus/configs/nsh/defconfig
+++ b/boards/xtensa/esp32/esp32-m5-stickc-plus/configs/nsh/defconfig
@@ -41,6 +41,7 @@ CONFIG_ESP32_SPIFLASH=y
 CONFIG_ESP32_SPIFLASH_LITTLEFS=y
 CONFIG_ESP32_STORAGE_MTD_SIZE=0x280000
 CONFIG_ESP32_UART0=y
+CONFIG_ETC_ROMFS=y
 CONFIG_EXAMPLES_BUTTONS=y
 CONFIG_EXAMPLES_FB=y
 CONFIG_EXAMPLES_HELLO=y
@@ -48,10 +49,11 @@ CONFIG_EXAMPLES_LEDS=y
 CONFIG_EXAMPLES_PWM=y
 CONFIG_FS_LARGEFILE=y
 CONFIG_FS_PROCFS=y
+CONFIG_FS_ROMFS=y
 CONFIG_HAVE_CXX=y
 CONFIG_HAVE_CXXINITIALIZE=y
 CONFIG_IDLETHREAD_STACKSIZE=3072
-CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INIT_ENTRYPOINT="init_main"
 CONFIG_INIT_STACKSIZE=3072
 CONFIG_INPUT=y
 CONFIG_INPUT_BUTTONS=y
@@ -66,6 +68,7 @@ CONFIG_LCD_ST7789_XOFFSET=53
 CONFIG_LCD_ST7789_XRES=135
 CONFIG_LCD_ST7789_YOFFSET=40
 CONFIG_LCD_ST7789_YRES=240
+CONFIG_LIBC_EXECFUNCS=y
 CONFIG_LINE_MAX=64
 CONFIG_MM_REGIONS=3
 CONFIG_NSH_BUILTIN_APPS=y
@@ -79,6 +82,8 @@ CONFIG_RR_INTERVAL=200
 CONFIG_RTC=y
 CONFIG_RTC_EXTERNAL=y
 CONFIG_RTC_PCF8563=y
+CONFIG_SCHED_CHILD_STATUS=y
+CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_WAITPID=y
 CONFIG_SENSORS=y
 CONFIG_SENSORS_MPU6050=y
@@ -88,6 +93,9 @@ CONFIG_START_MONTH=12
 CONFIG_START_YEAR=2011
 CONFIG_SYSLOG_BUFFER=y
 CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_NSH_STACKSIZE=8192
+CONFIG_SYSTEM_NXINIT=y
+CONFIG_SYSTEM_NXINIT_STACKSIZE=4096
 CONFIG_SYSTEM_SENSORTEST=y
 CONFIG_UART0_SERIAL_CONSOLE=y
 CONFIG_USERLED=y

Reply via email to