Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run nuttx(kernel build) on real hardware instead of qemu semihosting? #9501

Open
GooTal opened this issue Jun 9, 2023 · 6 comments
Open

Comments

@GooTal
Copy link

GooTal commented Jun 9, 2023

Hi, i`ve already ported Nuttx(kernel build) to LoongArch referring to qemu-rv:virt.

I notice that qemu-rv:virt used semihosting to load nsh_main`s code into memory from host file system.

But on real hardware, it`s necessary to load nsh_main`s code from disk. I`m trying to figure out how to load the related code.

I`ve successfully run nuttx(flat build) on real hardware. Here`s how i run it: I put the elf file under the /boot/ directory of Linux. And loaded the elf by grub or pmon, then boot the kernel.

I hope to put the nuttx(kernel build) and apps/bin/sh under the /boot/ directory of Linux. And use grub to boot my kernel, too. Is this a feasible way?

Could anyone provide some suggestions? Thanks a lot.

@xiaoxiang781216
Copy link
Contributor

Hi, i`ve already ported Nuttx(kernel build) to LoongArch referring to qemu-rv:virt.

I notice that qemu-rv:virt used semihosting to load nsh_main`s code into memory from host file system.

But on real hardware, its necessary to load nsh_mains code from disk. I`m trying to figure out how to load the related code.

Ive successfully run nuttx(flat build) on real hardware. Heres how i run it: I put the elf file under the /boot/ directory of Linux. And loaded the elf by grub or pmon, then boot the kernel.

I hope to put the nuttx(kernel build) and apps/bin/sh under the /boot/ directory of Linux. And use grub to boot my kernel, too. Is this a feasible way?

Yes, but you need mount /boot inside nuttx before nuttx can launch sh

Could anyone provide some suggestions? Thanks a lot.

If the debugger can connect to your device through JTAG, you can continue use semihosting.

@patacongo
Copy link
Contributor

patacongo commented Jun 9, 2023

There are some general instructions for a few ARM platforms. I used the SAMA5D4-EK in the past with the root file system on an SD card. I put instructions in the board README.txt file:

https://github.com/apache/nuttx/blob/master/boards/arm/sama5/sama5d4-ek/README.txt#L4091

That README.txt file also includes instructions for testing with a built-in ROMFS root file system.

I also noticed these using qemu-system-arm:

https://github.com/apache/nuttx/blob/master/boards/arm/imx6/sabre-6quad/README.txt#L892
https://github.com/apache/nuttx/blob/master/boards/arm/imx6/sabre-6quad/README.txt#L929

You could also check the RISC-V board README files to see if instructions were provided:

boards/risc-v/litex/arty_a7/configs/knsh/defconfig:CONFIG_BUILD_KERNEL=y
boards/risc-v/mpfs/icicle/configs/knsh/defconfig:CONFIG_BUILD_KERNEL=y
boards/risc-v/qemu-rv/rv-virt/configs/knetnsh64/defconfig:CONFIG_BUILD_KERNEL=y

@GooTal
Copy link
Author

GooTal commented Jun 12, 2023

Yes, but you need mount /boot inside nuttx before nuttx can launch sh

But the /boot is on my SSD hard disk and i didn`t find the code for SATA driver in nuttx. Is this still a feasible way?

I can only find out nand flash support. But i`m running on a Desktop CPU so it`s quite troublesome to port SATA driver all over again.😀

If the debugger can connect to your device through JTAG, you can continue use semihosting.

Thanks, but the JTAG doesn`t support it for now.

@patacongo
Copy link
Contributor

But the /boot is on my SSD hard disk and i didn`t find the code for SATA driver in nuttx. Is this still a feasible way?

Probably not. There is no SATA support in NuttX. NAND would not work either because there is no supported NAND-compatible file system.

If you want to use a NuttX native file system, the easiest thing to do would be to use and internal ROMFS file system. I referred to this above:

https://github.com/apache/nuttx/blob/master/boards/arm/sama5/sama5d4-ek/README.txt#L4127

This requires some special initialization logic:

https://github.com/apache/nuttx/blob/master/boards/arm/sama5/sama5d4-ek/src/sam_bringup.c#L233

@GooTal
Copy link
Author

GooTal commented Jun 12, 2023

If you want to use a NuttX native file system, the easiest thing to do would be to use and internal ROMFS file system. I referred to this above:

https://github.com/apache/nuttx/blob/master/boards/arm/sama5/sama5d4-ek/README.txt#L4127

This requires some special initialization logic:

https://github.com/apache/nuttx/blob/master/boards/arm/sama5/sama5d4-ek/src/sam_bringup.c#L233

Thank you so much.

Could you update the section 6b in this document? I`m not quite familiar with the build method of romfs.

Ha, i built it successfully. Maybe i`ll consider enabling USB as persistent storage device after i enabled the romfs

@lupyuen
Copy link
Member

lupyuen commented Jul 16, 2023

Hi: I have the same question while porting NuttX to Star64 JH7110 SBC.

Fortunately the SBC runs on U-Boot Bootloader, so I'll try to use the Initial RAM Disk (initrd) to load the Apps Filesystem with ROMFS.

Thanks for the suggestions! :-)

Update: NuttX on Star64 JH7110 SBC now boots with Initial RAM Disk (initrd)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants