简体   繁体   中英

Running NIOS2 on QEMU

I found in QEMU NIOS IP https://wiki.qemu.org/Documentation/Platforms/Nios2 I have downloaded intel tool chain from their website: https://www.intel.com/content/www/us/en/programmable/products/boards_and_kits/dev-kits/altera/kit-niosii-2s60.html I have few questions:

  1. Is the NIOS2 in QEMU IP matching intel's NIOS IP?
  2. What is the toolchain you use to compile and run it in QEMU? Is it same tool-chain as provided by intel's website?
  3. How to general Firmware code and run it on NIOS over QEMU. In the Wiki it says: qemu-system-nios2 -M 10m50-ghrd -kernel -dtb -nographic
  4. How to generate dtb file for it?
  5. Do we need to take products created by the quartos/EDS for the running of the QEMU, other from the compiled binary? (DTB - board specification?)
  6. Do we need to run it with specific QEMU parameters/arguments?
  7. Do you have code examples for NIOS using its peripherals?

Basically, I didn't find any documentations/examples about how to use the NIOS2 in QEMU. Can you help with some additional info? Even some basic “hello would” (compile and run in QEMU) would be great…

UPDATE: the most up-to-date answer to this question may be to analyse the linux console nios test at https://gitlab.com/qemu-project/qemu/-/blob/master/tests/acceptance/boot_linux_console.py#L1029 (or of course contact a maintainer). The kernel image from advent calendar 2018 day 14 runs great. It looks like it can all be done with buildroot.

My comments started bearing fruit, so I'll try to put a partial answer together. I haven't gotten this to work yet, but maybe this can be helpful to others who might work farther.

NOTE: If you just want to run a single nios2 binary, you can pass it straight to qemu-nios2 . qemu-system-nios2 is for running linux.

  1. I believe the qemu behavior is functionality rather than intellectual property. It would be a bug if it mismatched. I do not know whether it does. Mentioning IP here, please remember that open source projects are generally run by a handful of vulnerable caring devs who usually have no legal team if ownership of intellectual property is challenged. If there's an issue, it would be polite to refer the concerning party to https://eff.org/ who often legally represents such things.
  2. I expect that any nios2 toolchain works. Here's a toolchain from a quick internet search that led me to bootlin.com . Appears to include instructions on how to duplicate it from source.
  3. See 4
  4. Here is what I have so far for firmware generation:
# set up a toolchain (note: this old step is redundant with buildroot, lower down, which also installs a toolchain and even builds a kernel if asked)
wget https://toolchains.bootlin.com/downloads/releases/toolchains/nios2/tarballs/nios2--glibc--stable-2020.08-1.tar.bz2
tar -jxvf nios2--glibc--stable-2020.08-1.tar.bz2

# get kernel sources (pass --depth 1 to speed up)
git clone https://github.com/altera-opensource/linux-socfpga.git

# build kernel and device tree
cd linux-socfpga
make ARCH=nios2 CROSS_COMPILE=$(pwd)/../nios2--glibc--stable-2020.08-1/bin/nios2-linux- 10m50_defconfig 10m50_devboard.dtb vmlinux -j5
cd ..

# kernel is now at linux-socfpga/vmlinux
# device tree is now at linux-socfpga/arch/nios2/boot/dts/10m50_devboard.dtb

# set up buildroot to build a root image
git clone https://github.com/buildroot/buildroot.git
cd buildroot

# configure for qemu nios2
make qemu_nios2_10m50_defconfig 

# build root image
PERL_MM_OPT= LDFLAGS= CPPFLAGS= LD_LIBRARY_PATH= make
cd ..

# rootfs images are now in buildroot/output/images/
  1. I'm afraid I'm just a visitor and I don't know who quartos/eds are or what compiled binary you are referring to.
  2. The qemu command line appears to be qemu-system-nios2 -M <machine> -kernel <kernel file> -dtb <dtb file> <rootfs image file> . The example machine is 10m50-ghrd which we built the kernel for above, and this may be the only one.
  3. not yet. i'll try to update this answer if i get farther. feel free to edit it if you get farther.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM