<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>10646</bug_id>
          
          <creation_ts>2016-11-11 16:19:27 +0000</creation_ts>
          <short_desc>Add support for Altera/Nios2 in qemu</short_desc>
          <delta_ts>2018-10-18 15:07:31 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>core</component>
          <version>2.3</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Undecided</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>4.99</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Juro Bystricky">juro.bystricky</reporter>
          <assigned_to name="Juro Bystricky">juro.bystricky</assigned_to>
          <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>robin.l.jordan</cc>
    
    <cc>sgw</cc>
    
    <cc>yau.wai.gan</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Yes (doc changes required)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>68255</commentid>
    <comment_count>0</comment_count>
    <who name="Juro Bystricky">juro.bystricky</who>
    <bug_when>2016-11-11 16:19:27 +0000</bug_when>
    <thetext>As a future enhancement, it would make sense to improve support Altera/Nios2.
Nios2 is a one of the Linux supported architectures. 
There are patches for QEMU to support Nios2 CPU, including MMU. (There is an effort to upstream the support to QEMU mainline).
This would tie in nicely with some other enhancements, as is for example a currently under review planned support for Zephyr (which supports Nios2).
It would make also sense as a multiconfig use case, where there is a potential 
need to build two distinct (but associated) images: one for Intel architecture and one for Altera/Nios2.
There are several hw Altera platforms, I believe Zephyr uses this one:
https://www.altera.com/products/boards_and_kits/dev-kits/altera/kit-max-10m50-evaluation.html

The support can be provided via a separate meta-layer, or directly in oe-core (poky).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70145</commentid>
    <comment_count>1</comment_count>
    <who name="Juro Bystricky">juro.bystricky</who>
    <bug_when>2017-01-25 18:40:22 +0000</bug_when>
    <thetext>Things just got a bit easier as Altera/Nios2 are now natively (as of today!) supported by upstream QEMU.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71026</commentid>
    <comment_count>2</comment_count>
    <who name="Juro Bystricky">juro.bystricky</who>
    <bug_when>2017-03-01 23:57:00 +0000</bug_when>
    <thetext>I pushed the related changes here:

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=jurob/qemunios2

It is now possible to run

$ MACHINE=qemunios2 bitbake core-image-minimal
$ runqemu qemunios2

QEMU emulates the Altera/Nios2 hw: CPU + MMU, intc, jtag-uart, serial uart, timers, Ethernet network controller. It is possible to boot a Linux image (initramfs)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>71027</commentid>
    <comment_count>3</comment_count>
    <who name="Juro Bystricky">juro.bystricky</who>
    <bug_when>2017-03-02 00:16:42 +0000</bug_when>
    <thetext>After booting Linux, we can query interrupts and CPU:

root@qemunios2:~# cat /proc/interrupts
           CPU0       
  1:       6966  NIOS2-INTC   0  timer
  2:      59737  NIOS2-INTC   1  serial
  3:          7  NIOS2-INTC   2  eth0
  4:          0  NIOS2-INTC   3  eth0

root@qemunios2:~# cat /proc/cpuinfo
CPU:            Nios II/fast
MMU:            present
FPU:            none
Clocking:       75.00 MHz
BogoMips:       150.00
Calibration:    75000000 loops
HW:
 MUL:           yes
 MULX:          no
 DIV:           yes
Icache:         32kB, line length: 32
Dcache:         32kB, line length: 32
TLB:            16 ways, 256 entries, 8 PID bits</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72863</commentid>
    <comment_count>4</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2017-04-26 16:00:17 +0000</bug_when>
    <thetext>For 2.4 can we support a basic qemu machine within OE-Core? Is that a reasonable thing to target?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72864</commentid>
    <comment_count>5</comment_count>
    <who name="Juro Bystricky">juro.bystricky</who>
    <bug_when>2017-04-26 16:16:35 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; For 2.4 can we support a basic qemu machine within OE-Core? Is that a
&gt; reasonable thing to target?

Yes, it should be reasonable. The QEMU master already has support for Nios2,
so the next QEMU release should make it official. However, QEMU is just one part,
obviously we also need to support Nios2 toolchain. This is not difficult either,
but it would be nice not to have to use meta-altera layer where various tunes are defined. We should probably also define a corresponding HW reference platform to make sure HW and QEMU behave identically.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73681</commentid>
    <comment_count>6</comment_count>
    <who name="Juro Bystricky">juro.bystricky</who>
    <bug_when>2017-06-05 16:23:07 +0000</bug_when>
    <thetext>These are the steps that allow reproducing the build.

$ git clone https://git.yoctoproject.org/git/poky-contrib
$ cd poky-contrib/
$ git checkout 52f5276976d9fe2a695ae7ca558d3234335d6adf
$ source oe-init-build-env build-qemunios2
$ MACHINE=qemunios2 bitbake core-image-minimal

...wait for build to finish ...

$ runqemu qemunios2

There will be some warnings during the build, but they can be ignored.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76368</commentid>
    <comment_count>7</comment_count>
    <who name="Juro Bystricky">juro.bystricky</who>
    <bug_when>2017-08-30 23:21:00 +0000</bug_when>
    <thetext>Master now supports/builds Nios2 qemu
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=7f45ea5083b845490bc3db2a449b6e8b71

With the layer meta-altera it is fairly simple to build core-image-minimal (with initramfs) and run this image on 10m50 Altera board (with GHRD FPGA flashed).
It is also possible to boot the image via u-boot over Ethernet.

However, moving to 2.5 as some documentation and additional testing is required.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79602</commentid>
    <comment_count>8</comment_count>
    <who name="Robin Jordan">robin.l.jordan</who>
    <bug_when>2018-02-26 20:30:36 +0000</bug_when>
    <thetext>Please provide an update on the status of this and let me know if it will be ready for YP 2.5 M3.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81907</commentid>
    <comment_count>9</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2018-10-18 15:07:31 +0000</bug_when>
    <thetext>As per Juro&apos;s comment the work is done and this was just pending documentation which someone could add if they so wish but nobody seems willing, resolving as fixed.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>