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

   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
   
   MARS-112: Switch `qemu-i486` (`nsh`, `vga_fb`) from `nsh_main` to `nxinit`'s
   `init_main`, aligning it with the migration already done for `sim`,
   `rv-virt` and `qemu-armv8a`.
   
   Two commits, in dependency order:
   
   1. **`arch/x86: Add -P to CPP to suppress linemarkers.`**
      x86's `Toolchain.defs` was the only 32/16-bit arch (besides sparc)
      whose `CPP` definition omitted `-P`. Without it, `gcc -E -x c`
      emits GNU linemarker lines (`# 0 "file"`) into preprocessed output.
      `boards/Board.mk`'s `PREPROCESS` macro runs any `RCSRCS` init.rc
      through `$(CPP)` before nxinit's parser
      (`apps/system/nxinit/parser.c`) reads it; the parser matches each
      line against known keywords (`on`, `service`, ...) with `strncmp()`
      and returns `-EINVAL` on the first linemarker line it hits, so any
      x86 board that preprocesses an nxinit `init.rc` fails to parse it
      at boot. Reproduced independently on the host toolchain outside
      NuttX: `gcc -E -x c` on a minimal init.rc emits linemarker lines;
      `gcc -E -P -x c` on the same input does not.
   
   2. **`boards/x86/qemu/qemu-i486: Switch nsh/vga_fb from nsh to nxinit.`**
      Depends on commit 1 to build/boot correctly, otherwise independent
      of the rest of the tree. `CONFIG_INIT_ENTRYPOINT`/`ENTRYNAME`
      `"nsh_main"` -> `"init_main"`, `CONFIG_SYSTEM_NXINIT=y` plus its
      Kconfig deps (`EXPERIMENTAL`, `LIBC_EXECFUNCS`, `SCHED_HAVE_PARENT`,
      `SCHED_CHILD_STATUS`), `CONFIG_ETC_ROMFS=y`, and a new
      `boards/x86/qemu/qemu-i486/src/etc/init.d/init.rc` byte-identical
      in content to `boards/arm64/qemu/qemu-armv8a/src/etc/init.d/init.rc`.
      `src/Makefile` wires the new `init.rc` into `RCSRCS` the same way
      `qemu-armv8a`'s `src/Makefile` does.
   
   ## Impact
   
   - Affects only `boards/x86/qemu/qemu-i486` (`nsh`, `vga_fb` configs)
     and the shared `arch/x86/src/common/Toolchain.defs`.
   - The `-P` fix is an x86-arch-level bugfix, not tied to this board; it
     can be reverted independently without affecting the board-switch
     commit's correctness on other x86 boards (verified it touches a
     different file than the analogous x86_64 `Toolchain.defs`, so there
     is no overlap with `qemu-intel64`/MARS-118, which needs its own,
     separate `-P` fix in `arch/x86_64/src/common/Toolchain.defs`).
   - `qemu-i486`'s third config (`ostest`, `INIT_ENTRYPOINT="ostest_main"`)
     is untouched — out of scope for this change.
   - No documentation changes required; this mirrors an existing,
     already-documented migration pattern (sim/rv-virt/armv8a).
   
   ## Testing
   
   Host: Linux, `gcc-13` with `gcc-13-multilib` (`gcc -m32`, no
   `i686-elf-gcc` cross toolchain required — x86's `Toolchain.defs` only
   sets `CROSSDEV` under Cygwin/macOS; Linux uses the host gcc directly
   with `-m32` via `CONFIG_ARCH_X86_M32=y`).
   
   QEMU: `qemu-system-i386`, both configs boot and were driven
   interactively via a serial console script (`ps`, `mount`, `free`,
   `fb`), not just compiled.
   
   **nsh** (`qemu-system-i386 -cpu 486 -m 2 -kernel nuttx.elf -nographic`):
   ```
   nsh> ps
     TID   PID  PPID PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK        
    STACK COMMAND
       0     0     0   0 FIFO     Kthread   - Ready              
0000000000000000 0002024 Idle_Task
       2     2     0 100 FIFO     Task      - Waiting  Semaphore 
0000000000000000 0002004 init_main
       3     3     2 100 FIFO     Task      - Running            
0000000000000000 0002012 sh
   nsh> mount
     /etc type romfs
     /proc type procfs
   nsh> free
         total       used       free    maxused    maxfree  nused  nfree name
        572784       9680     563104      10048     563104     52      1 Umem
   ```
   `init_main` (PID 2) is the parent, `sh` (PID 3, PPID 2) is its child;
   `/etc` ROMFS is mounted.
   
   **vga_fb** (`qemu-system-i386 -cpu 486 -m 1024 -vga std -serial stdio
   -display none -kernel nuttx.elf -nographic`): same `init_main`/`sh`
   parent-child relationship and `/etc` mount; `fb` command runs the
   framebuffer self-test to completion ("Test finished"); `free` shows
   551696/86832/464864 total/used/free — comfortably clear of
   `CONFIG_RAM_SIZE=1048576` (1MB) despite the heavier LCD framebuffer
   allocation versus `nsh`.
   
   `./tools/checkpatch.sh -g HEAD~2..HEAD` (patch/style check) passes
   clean; `-m` (commit-message check) flags "Missing Signed-off-by" on
   both commits, which is expected and intentional — per this repo's own
   `CONTRIBUTING.md` §1.5, "AI agents **MUST NOT** add `Signed-off-by`
   tags. Only humans can legally certify the commit." This PR is opened
   as **draft** pending a human `Signed-off-by` on both commits before
   it can leave draft.
   
   ---
   Prepared with assistance from an AI coding agent (Assisted-by:
   Claude:claude-sonnet-5 on both commits).
   


-- 
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