Page 1 of 2

Re: What about the Nios2?

Posted: Sun May 31, 2015 11:48 pm
by erik
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

Re: What about the Nios2?

Posted: Thu Jun 04, 2015 12:29 pm
by jynik
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

Re: What about the Nios2?

Posted: Thu Jun 04, 2015 7:50 pm
by erik
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.

Re: What about the Nios2?

Posted: Fri Jun 05, 2015 8:21 am
by jynik
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

Re: What about the Nios2?

Posted: Mon Jun 08, 2015 7:35 am
by erik
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

Re: What about the Nios2?

Posted: Tue Jun 09, 2015 7:49 am
by jynik
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.

Re: What about the Nios2?

Posted: Thu Jun 11, 2015 1:21 am
by erik
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

Re: What about the Nios2?

Posted: Thu Jun 11, 2015 6:06 am
by bpadalino
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

Re: What about the Nios2?

Posted: Fri Jun 12, 2015 12:28 am
by erik
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.

Re: What about the Nios2?

Posted: Fri Jun 12, 2015 6:06 am
by bpadalino
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

Re: What about the Nios2?

Posted: Mon Jul 27, 2015 4:15 am
by erik
Hello again,

at first I have to tell that all hardware and software is running now.
Quartus is still not running on the workstation I used before but now I have a new notebook and it runs.
Further the USB cable was broken. Thats the reason fore the failures.

The last weeks I have developed a VHDL block and at next I will try to get it up and running on the bladeRF.
I'm able to set the gains and the bandwidth by setting up registers of the lms.
I further need to set up the XB200, the samplerate and the frequency.
I have seen on an other thread here that I can use the lms_set_precalculated_frequency() function to set the frequency I want.
But thats my old problem in understanding what about "struct bladerf *dev".
I am not a software developer so maybe someone can explain what I have to do.
As far as I can understand it is the device handler but isn't it only in use if I want to access the bladeRF from the host?
It seams that there are all functions I need but all of them uses the device handler so it will be a great help to know how I have to use it inside the nios.

Thanks,

Erik

Re: What about the Nios2?

Posted: Thu Aug 06, 2015 1:14 am
by erik
Hello,

I have figured out that I have just to type 0 for the device handler.
Now i can set up all things from inside the NIOS but can't attatch the xb200 and can't enable tx and rx.
Maybe there is such an easy way like using lms_set_precalculated_frequency() for setting up the frequency.
If so than please let me know.

My goal is to set up the bladeRF completely from the NIOS.
I have only one configuration to set.

Currently I'm using the cli to attach the xb200 and start tx an rx by configuring a file for both one to read from and one to write to. Inside the fpga I throw away the samples from host and use my own sine-generator on tx side and on the rx side I get my signal directly from the lms and ignore the rest is following. (using the hosted rev)
Further I have to use the cli still to set the frequency even if I'm able to set it up by NIOS but it appears an error.
I think this error is because the bladeRF trys to retune in this case.

Thanks for your answer,

Erik

Re: What about the Nios2?

Posted: Wed Apr 20, 2016 6:24 am
by Jordaw
Hello,

I try to work on the Nios 2, so i follow the instruction on the readme, and find this topic who explain in details the steps to have a debug session on eclipse.
For me that work until the step (12). Now it's impossible for me launching the debug session i think because of "path" problems, but i can't solves it. In the make file i've already verify than this line is present: QUARTUS_PROJECT_DIR := ../../../../../../quartus/work/output_files, i try to change this line but no way

In debug configuration, this warning appear:

WARNING: Unable to locate SOF or JDI file in Quartus project directory "/home/jordi/bladeRF/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios". Processor name might not be shown correctly in selection dialog but the functionality is not affected. Please make sure "QUARTUS_PROJECT_DIR" is set correctly in Makefile.

So i can't launch a debug session because of that so>>>> "Lauching new configuration has encountered a problem"

the error message is:
Error reported by System Console
java.util.concurrent.ExecutionException: java.lang.Exception: design_load: /home/jordi/bladeRF/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios does not contain any Quartus project files
invoked from within
"design_load {/home/jordi/bladeRF/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios}"
invoked from within
"interp eval $slave {
design_load {/home/jordi/bladeRF/hdl/fpga/ip/altera/nios_system/software/bladeRF_nios}

}"



If someone have an idea :)

Jordaw!

Re: What about the Nios2?

Posted: Wed Apr 20, 2016 6:56 am
by jynik
Could you confirm that you're launching nios2-eclipse from the nio2-command-shell? This shell launcher script ensures you have all of the necessary environment variables set when working with the tools.

For example?

Code: Select all

user@host $ ~/software/altera/15.1/nios2eds/nios2_command_shell.sh
------------------------------------------------
Altera Nios2 Command Shell [GCC 4]

Version 15.1, Build 193
------------------------------------------------
user@host:~$ eclipse-nios2 
Also, can you ensure that you can clean and build the project from the command line? This can help determine whether you have a general environment setup problem vs an Eclipse problem.

Re: What about the Nios2?

Posted: Wed Apr 20, 2016 7:12 am
by Jordaw
I'm not very sure understand you :s, i launch Eclipse by this way. is it ok?

Code: Select all

jordi@jordi-Aspire-5742Z:~/altera/15.0/nios2eds$ eclipse-nios2
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
jordi@jordi-Aspire-5742Z:~/altera/15.0/nios2eds$ ./nios2_command_shell.sh
------------------------------------------------
Altera Nios2 Command Shell [GCC 4]

Version 15.0, Build 145
------------------------------------------------
jordi@jordi-Aspire-5742Z:~/altera/15.0/nios2eds$ cd
jordi@jordi-Aspire-5742Z:~$ eclipse-nios2
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

I don't understand what you mean by clean and build the project from the command line? if you can explain me ...

So, after lauching eclipse by this way, i follow all the step you describe on the topic, but impossible launching debug session cause of "bladeRF_nios does not contain any Quartus project files"

Jordaw.