What about the Nios2?

Discussions related to embedded firmware, driver, and user mode application software development

Moderator: robert.ghilduta

erik
Posts: 17
Joined: Mon May 18, 2015 12:35 am

Re: What about the Nios2?

Post by erik » Sun May 31, 2015 11:48 pm

Hello,

I have an additional question.
Is there a list of the commands the nios is receiving?

I try to implement somewhat like the cli but in the nios.
So I think i only have to know the uart commands to the corresponding commands of the cli.
I could get the commands by debugging and try every cli command but maybe there is allready a list.

Greetings,

Erik

jynik
Posts: 455
Joined: Thu Jun 06, 2013 8:15 pm

Re: What about the Nios2?

Post by jynik » Thu Jun 04, 2015 12:29 pm

Hi Erik,

The current NIOS implementation receives and responds with a 16-byte word:

Code: Select all

0: Magic byte 'N'
1: Mode
     bit [7] Read operation
     bit [6]: Write operation
     bit [5:4] Device specifier
          00 = Config I/O between the NIOS II and the programmable fabric
          01 = LMS6002D register access
          10 = VCTCXO trim DAC register access
          11 = SI5338 register access
    bits[3:0]  Payload count
bytes[2-15]: Address/Data pairs.
As I mentioned earlier, I'm right in the middle of re-writing the NIOS code to improve readability and add new functionality. As such, I think it makes more sense to point you to the upcoming code, rather than familiarize with the older code.

So far, it's going really great, and we are adding functionality to improve the speed of commands, as well as provide the ability to schedule fast re-tune operations (synchronized with the timestamp counters). I'm personally very happy with the speedup results, and looking forward to improving them even further.

In doing this, I'm trying to ensure the source files are much better documented, especially the UART command formats. We will continue to support the current format, which we will call the NIOS Legacy Packet format.

This code is being worked on in this dev-nios_refactor branch, on my GitHub account. Once it's cleaned up, it will be brought into the Nuand repo.

Because this development branch is transient, I'm also attaching a .tar.bz2 of the dev repo, as to ensure this forum post contains the info in the future, when the branch is gone.

In this new code, you will find the following differences in paths:
  • The NIOS code has been moved from the "lms_spi_controller" project to a more appropriately named "bladeRF_nios" project.
  • There is a top-level fpga_common directory now
    • Command formats are specified here, as both the host code and NIOS need to know this information
    • LMS6002 code has been move here, allowing us to run a subset of the retune operation on the NIOS II. Note that we only build certain functions in the NIOS code, but you should be able to enable/disable what you want.
  • The architecture has been redesigned such that you can now have different "Packet handlers" and custom packet formats for your programmable logic. The legacy packet format works as it has in the past. You can see an example of a new format in the retune packet format, which utilizes the notion of a packet handler having deferred work
Attachments
bladeRF-dev-nios_refector-2015-06-04-ffbdf2caa.tar.bz2
"Pre-Alpha" Development of NIOS code refactoring and improvements
(1.03 MiB) Downloaded 1206 times

erik
Posts: 17
Joined: Mon May 18, 2015 12:35 am

Re: What about the Nios2?

Post by erik » Thu Jun 04, 2015 7:50 pm

Thank you for your request.

I had a look to your branch some days ago but I wasnt sure if I can use the code I this state. Yesterday my byteblaster is arrived. I will install it now and than take a further peek to your branch and test the new development.

jynik
Posts: 455
Joined: Thu Jun 06, 2013 8:15 pm

Re: What about the Nios2?

Post by jynik » Fri Jun 05, 2015 8:21 am

Hi Erik,

What I posted is now functional. Currently, it requires some cleanup and some additional error checking.

If nothing else, I think that code is a little bit cleaner, which will allow you more quickly understand how to write code for and debug the NIOS II.

Please note that the libbladeRF, NIOS code and FPGA HDL are all updated. You will need to build the FPGA (v0.2.0) to use that branch. The updated FPGA includes an interrupt-based command UART, and the time tamer have been separated into an RX and TX time tamer, each with programmable interrupts.

Best regards,
Jon

erik
Posts: 17
Joined: Mon May 18, 2015 12:35 am

Re: What about the Nios2?

Post by erik » Mon Jun 08, 2015 7:35 am

Hello,

I have a problem with the new code. I cant run the build_bladerf.sh skript. Becaus of that:

2015.06.08.16:31:00 Info: No custom instruction connections, skipping transform
Exception in thread "main" java.lang.NullPointerException
at com.altera.sopcmodel.transforms.avalon.Domain.getSymmetryCheckerForPoint(Domain.java:308)
at com.altera.sopcmodel.transforms.avalon.Domain.isSymmetric(Domain.java:284)
at com.altera.sopcmodel.transforms.avalon.InitialInterconnectTransform.checkValidDomain(InitialInterconnectTransform.java:108)
at com.altera.sopcmodel.transforms.avalon.InitialInterconnectTransform.doExecute(InitialInterconnectTransform.java:83)
at com.altera.sopcmodel.transforms.SopcTransformStep.execute(SopcTransformStep.java:66)
at com.altera.sopcmodel.transforms.SopcTransformList.doExecute(SopcTransformList.java:112)
at com.altera.sopcmodel.transforms.SopcTransformStep.execute(SopcTransformStep.java:66)
at com.altera.sopcmodel.transforms.mm.MMTransform.doExecute(MMTransform.java:112)
at com.altera.sopcmodel.transforms.SopcTransformStep.execute(SopcTransformStep.java:66)
at com.altera.sopcmodel.transforms.SopcTransformList.doExecute(SopcTransformList.java:112)
at com.altera.sopcmodel.transforms.SopcTransformStep.execute(SopcTransformStep.java:66)
at com.altera.sopcmodel.transforms.avalon.AvalonTransform.doExecute(AvalonTransform.java:48)
at com.altera.sopcmodel.transforms.SopcTransformStep.execute(SopcTransformStep.java:66)
at com.altera.sopcmodel.ensemble.EnsembleUtils.doTransform(EnsembleUtils.java:1332)
at com.altera.sopc.generator.EnsembleGenerationFileSet2.attemptTransform(EnsembleGenerationFileSet2.java:90)
at com.altera.sopc.generator.EnsembleGenerationFileSet2.generate(EnsembleGenerationFileSet2.java:51)
at com.altera.sopc.generator.FileSet2.generate(FileSet2.java:134)
at com.altera.sopc.generator.Sellafield.generate(Sellafield.java:381)
at com.altera.sopcmodel.sbtools.sbgenerate.SbGenerate.act(SbGenerate.java:622)
at com.altera.utilities.AltCmdLineToolBase.runTheTool(AltCmdLineToolBase.java:640)
at com.altera.sopcmodel.sbtools.sbgenerate.SbGenerate.main(SbGenerate.java:1106)

In an older version of your branch maybe from within the last 3 weeks I can run the skript but not run the cli after loading the image because of that:

adminhtw@adminrechner:~$ bladeRF-cli -i -v verbose
[VERBOSE @ libusb.c:515] Using libusb version: 1.0.17.10830
[VERBOSE @ libusb.c:406] Found a bladeRF (idx=0)
[VERBOSE @ libusb.c:458] USB port reset succeeded for bladeRF adcb3b86c8749988eefcf733b81c1912
[VERBOSE @ usb.c:284] Changing to USB alt setting 0
[VERBOSE @ usb.c:284] Changing to USB alt setting 1
[DEBUG @ usb.c:201] Failed to read FPGA version[0]: Operation timed out
Failed to open device (first available): Operation timed out

Is there a way to solve one of these problems.

Thank you

Erik


edit:

The second failure i mentioned is not because of the new code.
It also is present with old versions. When you had attached the usb blaster and had a debug session you are not able to launch the cli after that.

So it seams that it is not possible to load the code to the nios using the usb blaster and than use the cli to check the configs which are done by the nios code.
I have to run the build_bladerf.sh skript every time.

Further there is an error because of the new fpga version.:

[INFO @ version_compat.c:110] FPGA version (v0.2.0) is newer than entries in libbladeRF's compatibility table. Please update libbladeRF if problems arise.
Failed to open device (first available): Operation timed out

How i can update the libbladeRF by myself?

THX Erik

jynik
Posts: 455
Joined: Thu Jun 06, 2013 8:15 pm

Re: What about the Nios2?

Post by jynik » Tue Jun 09, 2015 7:49 am

Hi Erik,

First, I just wanted to let you know that the updated code has been pushed to a dev-fpga_v0.2.0 branch on the Nuand repo. It will undergo some further review and testing there, before being merged to master.

Regarding the 2015.06.08.16:31:00 Info: No custom instruction connections, skipping transform message. Are you using Quartus 15.0? This is required for the new FPGA code. I honestly have no idea what this error message is actually trying to convey, and can only guess that your environment differs from ours in some significant way.

Timeouts
If you connect to the NIOS II core and the byte blaster is holding it in reset, then the host (libbladeRF) will not receive responses to its requests. This is why it times out. When stepping through code on the NIOS II, I use the -DLIBBLADERF_DISABLE_USB_TIMEOUTS CMake option to compile out the timeouts. (Note that since bladeRF-cli catches Ctrl-C, you'll want to kill it some other way, such as with SIGUSR1 if you find that you need to.)

If your FPGA image is bad or contains problems, timeouts will occur just because the device is not running.

To debug the NIOS code, I would load the FPGA as you normally do, and exit the CLI. Then I would attach the debugger, and have it load and reset the NIOS core. This should run fine.


libbladeRF version
If you checked out that code in the new branch or pulled it from my archive, you can build it the same way you normally would. See the wiki for this. If you're unfamiliar with using git to check out a branch, some of these resources should be of great help.

erik
Posts: 17
Joined: Mon May 18, 2015 12:35 am

Re: What about the Nios2?

Post by erik » Thu Jun 11, 2015 1:21 am

Good morning,

the first problem was that I not used Quartus II 15 I think.
But now Ihave changed to 15 nothing works any more.

When quartus is analysing the files from the hosted rev the following failure appears.: Error (12074): File /home/adminhtw/bladeRF-dev-nios_refactor/hdl/quartus/work/db/hosted.cmp.rdb is not a recognized design file type
When I start the compilation quartus hangs in analysis and synthesis. And it says "Sorry! The Quartus II software quit unexpectedly." With the following failure.
(The build_bladerf.sh throws the same failure!)

Info (286031): Timing-Driven Synthesis is running on partition "Top"

*** Fatal Error: Illegal Instruction
Module: quartus_map
Stack Trace:
0xbe5e9: MLS_NETLIST::factor_node_recursively(std::vector<std::vector<SGATE_OTERM_INV_PAIR, MEM_STL_ALLOCATOR<SGATE_OTERM_INV_PAIR> >, MEM_STL_ALLOCATOR<std::vector<SGATE_OTERM_INV_PAIR, MEM_STL_ALLOCATOR<SGATE_OTERM_INV_PAIR> > > > const&, CDB_SGATE_COMB*, bool) + 0xc99 (synth_mls)
0xea819: MLS_NETLIST::resynthesize_node(CDB_SGATE_COMB*, int*, int*, MLS_RESYNTHESIZE_CONFIG&, MLS_COLLAPSE_CACHE&, MLS_FFC&, std::vector<CDB_SGATE_OTERM*, MEM_STL_ALLOCATOR<CDB_SGATE_OTERM*> >&, std::vector<CDB_SGATE_NODE*, MEM_STL_ALLOCATOR<CDB_SGATE_NODE*> >&) + 0xc79 (synth_mls)
0xed37b: MLS_NETLIST::resynthesize_nodes(bool, bool, bool) + 0x61b (synth_mls)
0xf50bd: MLS_NETLIST::call_named_function(std::basic_string<char, std::char_traits<char>, MEM_STL_ALLOCATOR<char> > const&, std::basic_string<char, std::char_traits<char>, MEM_STL_ALLOCATOR<char> > const&, std::basic_string<char, std::char_traits<char>, MEM_STL_ALLOCATOR<char> > const&) + 0x10ad (synth_mls)
0x105eff: MLS_INTERFACE::call_named_function(char const*, char const*, char const*) + 0x6f (synth_mls)
0x16e5e3: RTL_SCRIPT::call_named_function(char const*, char const*, char const*, int, int, int) + 0x723 (synth_opt)
0x1711d2: RTL_SCRIPT::process_script(CDB_SGATE_NETLIST*, CDB_SGATE_HIERARCHY*, BASEX_ELABORATE_INFO*, CMP_FACADE*, RTL_SCRIPT_ENUM, char const* (*) [3], int, RTL_SCRIPT_STEP*, RTL_SCRIPT_STEP*) + 0x7b2 (synth_opt)
0x1889e6: opt_process_netlist_scripted(CMP_FACADE*, CDB_SGATE_HIERARCHY*, BASEX_ELABORATE_INFO*, RTL_SCRIPT_ENUM, bool) + 0x376 (synth_opt)
0x51620: RTL_ROOT::process_sgate_netlist(CMP_FACADE*, CDB_SGATE_HIERARCHY*, BASEX_ELABORATE_INFO*, RTL_PASS_ENUM) + 0x558 (synth_opt)
0x18147f: SGN_SYNTHESIS::high_level_synthesis() + 0x16f (synth_sgn)
0x182188: SGN_SYNTHESIS::process_current_stage() + 0x148 (synth_sgn)
0x19153a: SGN_EXTRACTOR::synthesize_partition(unsigned long) + 0x41a (synth_sgn)
0x191fb4: SGN_EXTRACTOR::synthesis() + 0x1d4 (synth_sgn)
0x1a49b8: SGN_EXTRACTOR::synthesis_and_post_processing() + 0x1a8 (synth_sgn)
0x1a52c2: sgn_qic_full(CMP_FACADE*, std::vector<std::basic_string<char, std::char_traits<char>, MEM_STL_ALLOCATOR<char> >, MEM_STL_ALLOCATOR<std::basic_string<char, std::char_traits<char>, MEM_STL_ALLOCATOR<char> > > >&, std::vector<double, MEM_STL_ALLOCATOR<double> >&) + 0x262 (synth_sgn)
0x248c8: qsyn_execute_sgn(CMP_FACADE*, std::vector<std::basic_string<char, std::char_traits<char>, MEM_STL_ALLOCATOR<char> >, MEM_STL_ALLOCATOR<std::basic_string<char, std::char_traits<char>, MEM_STL_ALLOCATOR<char> > > >&, std::basic_string<char, std::char_traits<char>, MEM_STL_ALLOCATOR<char> > const&, THR_NAMED_PIPE*, THR_NAMED_PIPE*) + 0x158 (quartus_map)
0x43cb9: QSYN_FRAMEWORK::execute_core(THR_NAMED_PIPE*, THR_NAMED_PIPE*) + 0x1e9 (quartus_map)
0x476ba: QSYN_FRAMEWORK::execute() + 0xbca (quartus_map)
0x2008c: qexe_standard_main(QEXE_FRAMEWORK*, QEXE_OPTION_DEFINITION const**, int, char const**) + 0x872 (comp_qexe)
0x3c458: qsyn_main(int, char const**) + 0x1e8 (quartus_map)
0x49ef0: msg_main_thread(void*) + 0x10 (ccl_msg)
0x5d4c: thr_final_wrapper + 0xc (ccl_thr)
0x49fa5: msg_thread_wrapper(void* (*)(void*), void*) + 0x5b (ccl_msg)
0x6ab3b: mem_thread_wrapper(void* (*)(void*), void*) + 0x9b (quartus_map)
0x8def: err_thread_wrapper(void* (*)(void*), void*) + 0x27 (ccl_err)
0x6112: thr_thread_wrapper + 0x15 (ccl_thr)
0x4bee2: msg_exe_main(int, char const**, int (*)(int, char const**)) + 0xa3 (ccl_msg)
0x21ec5: __libc_start_main + 0xf5 (c.so.6)


End-trace

Result: ERROR: Error(s) found while running an executable. See report file(s) for error message(s). Message log indicates which executable was run last.

ERROR: Analysis & Synthesis Failed
Info (23030): Evaluation of Tcl script ../build.tcl was successful
Info: Quartus II 64-Bit Shell was successful. 0 errors, 52 warnings
Info: Peak virtual memory: 745 megabytes
Info: Processing ended: Thu Jun 11 10:20:55 2015
Info: Elapsed time: 00:04:24
Info: Total CPU time (on all processors): 00:04:27


And the usb_blaster is not longer accessible from eclips to debug. In "Debug Configurations" I can not see the debugger when browse for it. (thats also in quartus 13.1 the problem after installing 15) I will check the devrules again.
But I can see it in quartus.


Im sorry for asking here again but I hope the reason is at least one problem and not a lot. Maybe you had to figure out some of these problems by yourself.

Have a nice day, ;)

Erik

bpadalino
Posts: 303
Joined: Mon Mar 04, 2013 4:53 pm

Re: What about the Nios2?

Post by bpadalino » Thu Jun 11, 2015 6:06 am

Unfortunately we didn't need to figure out those problems.

Can you successfully create any design at all, or is it just the bladeRF one that is killing you?

If you do the ATSC TX image instead of hosted, does it still crash?

How much memory are you using? What host OS? How much free space on your hard drive?

Brian

erik
Posts: 17
Joined: Mon May 18, 2015 12:35 am

Re: What about the Nios2?

Post by erik » Fri Jun 12, 2015 12:28 am

Hello,

I have tested and it seams like I cant create any design with Quartus II 15 but the 13.1 still works but not with the newest code. May this is because of incompatibility and the reason to switch to Quartus II 15.

I am using:

Ubuntu 14.04 64-Bit
3GB RAM
Intel® Pentium(R) D CPU 2.66GHz × 2
Gallium 0.4 on AMD CEDAR
1TB HDD almost free

Because of the last line before "End-trace" in my last post I think the problem hangs on a library. I try to install the right libc.
Maybe I have to uninstall the tons of i386 libs I had to install for the use of Quartus II 13.1. but I will try it first without that because I would go crazy :lol: .

In the worst case I will switch to Windows maybe this will figure out all problems and easily all is running. But it would also take some time so it would be better to get linux running again I think.
I will report when it works.

Greetings,

Erik

edit:

I can now use Quartus 13.1 again :). Will try to get 15 working next week.

bpadalino
Posts: 303
Joined: Mon Mar 04, 2013 4:53 pm

Re: What about the Nios2?

Post by bpadalino » Fri Jun 12, 2015 6:06 am

We've tested here successfully with Ubuntu 14.10 and 15.04.

It sounds like it may just be a library compatibility issue on Quartus' part?

Keep us posted with your status and good luck.

Brian

Post Reply