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

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

commit 4ac8b5b8127c25529fbb5ddb8ff400aa3cb80ed3
Author: wangjianyu3 <[email protected]>
AuthorDate: Thu Oct 1 18:36:15 2026 +0800

    boards/x86_64/qemu-intel64: add nxinit /etc ROMFS support
    
    Add etc/init.d/init.rc and build it into the /etc ROMFS for Make and
    CMake.  The kernel-build romfs image uses the same ROM disk minor, so
    skip it with CONFIG_ETC_ROMFS and register it only with BUILD_KERNEL.
    
    Assisted-by: OpenCode:claude-sonnet-5 Kiro:claude-opus-5
    Signed-off-by: wangjianyu3 <[email protected]>
---
 boards/x86_64/qemu/qemu-intel64/src/.gitignore     |  1 +
 boards/x86_64/qemu/qemu-intel64/src/CMakeLists.txt | 16 ++++++++++-
 boards/x86_64/qemu/qemu-intel64/src/Makefile       | 11 +++++++-
 .../qemu/qemu-intel64/src/etc/init.d/init.rc       | 33 ++++++++++++++++++++++
 .../x86_64/qemu/qemu-intel64/src/qemu_boardinit.c  |  2 ++
 5 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/boards/x86_64/qemu/qemu-intel64/src/.gitignore 
b/boards/x86_64/qemu/qemu-intel64/src/.gitignore
new file mode 100644
index 00000000000..1baf09ba3ae
--- /dev/null
+++ b/boards/x86_64/qemu/qemu-intel64/src/.gitignore
@@ -0,0 +1 @@
+/etctmp*
diff --git a/boards/x86_64/qemu/qemu-intel64/src/CMakeLists.txt 
b/boards/x86_64/qemu/qemu-intel64/src/CMakeLists.txt
index 3852dd86afe..3c4dbdd438d 100644
--- a/boards/x86_64/qemu/qemu-intel64/src/CMakeLists.txt
+++ b/boards/x86_64/qemu/qemu-intel64/src/CMakeLists.txt
@@ -45,11 +45,25 @@ if(CONFIG_BUILD_KERNEL)
                     DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/romfs_boot.c)
   add_dependencies(board board_romfs)
   list(APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/romfs_boot.c)
-elseif(CONFIG_BOARD_LATE_INITIALIZE)
+elseif(CONFIG_BOARD_LATE_INITIALIZE AND NOT CONFIG_ETC_ROMFS)
   # empty ROMFS placeholder, see Makefile
   list(APPEND SRCS romfs_stub.c)
 endif()
 
 target_sources(board PRIVATE ${SRCS})
 
+if(CONFIG_ETC_ROMFS AND CONFIG_SYSTEM_NXINIT)
+  nuttx_add_romfs(
+    NAME
+    etc
+    MOUNTPOINT
+    etc
+    RCSRCS
+    etc/init.d/init.rc
+    PATH
+    ${CMAKE_CURRENT_BINARY_DIR}/etc)
+
+  target_link_libraries(board PRIVATE romfs_etc)
+endif()
+
 set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/qemu.ld")
diff --git a/boards/x86_64/qemu/qemu-intel64/src/Makefile 
b/boards/x86_64/qemu/qemu-intel64/src/Makefile
index 41518289d38..9d8fc57f968 100644
--- a/boards/x86_64/qemu/qemu-intel64/src/Makefile
+++ b/boards/x86_64/qemu/qemu-intel64/src/Makefile
@@ -23,10 +23,19 @@
 include $(TOPDIR)/Make.defs
 
 CSRCS = qemu_boot.c qemu_bringup.c qemu_net.c qemu_boardinit.c
-CSRCS += $(if $(wildcard romfs_boot.c), romfs_boot.c, romfs_stub.c)
+
+ifneq ($(CONFIG_ETC_ROMFS),y)
+  CSRCS += $(if $(wildcard romfs_boot.c), romfs_boot.c, romfs_stub.c)
+endif
 
 ifeq ($(CONFIG_BOARDCTL_RESET),y)
   CSRCS += qemu_reset.c
 endif
 
+ifeq ($(CONFIG_ETC_ROMFS),y)
+ifeq ($(CONFIG_SYSTEM_NXINIT),y)
+  RCSRCS += etc/init.d/init.rc
+endif
+endif
+
 include $(TOPDIR)/boards/Board.mk
diff --git a/boards/x86_64/qemu/qemu-intel64/src/etc/init.d/init.rc 
b/boards/x86_64/qemu/qemu-intel64/src/etc/init.d/init.rc
new file mode 100644
index 00000000000..84ec52b1a7d
--- /dev/null
+++ b/boards/x86_64/qemu/qemu-intel64/src/etc/init.d/init.rc
@@ -0,0 +1,33 @@
+/****************************************************************************
+ * boards/x86_64/qemu/qemu-intel64/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
+   restart_period 1000
+#endif
+
+on init
+#ifdef CONFIG_SYSTEM_NSH
+   start console
+#endif
diff --git a/boards/x86_64/qemu/qemu-intel64/src/qemu_boardinit.c 
b/boards/x86_64/qemu/qemu-intel64/src/qemu_boardinit.c
index 550b80de568..490f66e16fc 100644
--- a/boards/x86_64/qemu/qemu-intel64/src/qemu_boardinit.c
+++ b/boards/x86_64/qemu/qemu-intel64/src/qemu_boardinit.c
@@ -90,6 +90,7 @@ void board_late_initialize(void)
 
   /* Create ROM disk for mount in nx_start_application */
 
+#ifdef CONFIG_BUILD_KERNEL
   if (NSECTORS(romfs_img_len) > 1)
     {
       ret = romdisk_register(0, romfs_img, NSECTORS(romfs_img_len),
@@ -99,5 +100,6 @@ void board_late_initialize(void)
           ferr("ERROR: Failed to register romfs: %d\n", -ret);
         }
     }
+#endif
 }
 #endif

Reply via email to