LimeSDR-USB - Implement custom USB Commands

Hello everyone,
First of all, I just want to precise that I am kind of a newbie to FPGA and all. I’ve been struggling in understanding some part of the designs so I do believe you’ll find easy answers to my question.

I would like to implement a custom USB interface with commands that will change values of some FPGA signals. For this, I was planning on developing my own program in C using libusb. However, I have some doubts on how to do it properly.

First I thought using the FX3 SPI interface but I found out it was not possible to use it as there is a 32-bit wide FX3 data bus. Then I thought passing the data through USB directly but I have some issues understanding how I can achieve this as the NIOS IP directly manages that (I would have to override to implement my own block, is that it ?).

Mainly, I barely understand what is usable and what is already used as means of communication between the PC and the FPGA. What are the possibilites

Thanks in advance,

1 Like

Well, after some researches, here’s what I am planning on doing :

  • Modify FX3 firmware by adding two endpoints for bidirectional control (such as EP0F or EP8F), and update Slave FIFO Interface by adding sockets for my new endpoints ;

  • Update gateware and FX3_SlaveFifo component to match the firmware

  • Therefore I’ll have my new functionnalities without losing LMS7002M or waveform control.

If anyone tried that, I would be glad to hear about it. In theory, it seems possible but you never know what problems you’re gonna get so…


Hi @tomlib,

Could you elaborate this, please.
I do not think you need to make these changes, while everything is there already.
This document could be useful for you I think:

Hello @Zack,
Thanks for your answer.

I am planning on adding custom blocks to the design and I need USB communication to configure some of the registers of my new blocks.

Well as far as I have understood, there are two endpoints used for stream (EP01 and EP81), and two endpoints used for control data (EP0F and EP8F). I believe all these endpoints are driven to the NIOS CPU, which is something I want to avoid. So by adding two endpoints (and updating firmware accordingly) driven to my own components, I won’t lose any functionalities.

Please correct me if I’m wrong and if I can use already existing endpoints.


Hi @tomlib,

NIOS CPU is not involved in data stream communications (i.e.EP01 and EP81). But yes, NIOS CPU communicates via control endpoints EP0F and EP8F with the software running on PC.

Now I am confident that you do not need to change FX3 firmware, everything you need is there already. What you need to do is do create your blocks in FPGA, define control registers accessible via SPI interface and implement additional commands to read/write these registers in PC software and NIOS CPU firmware.

And yes, you should study document I’ve provided earlier. It will explain everything you need to implement your application.

1 Like


Indeed, I got confused.

I’ve never heard about NIOS CPU firmware ? Do you mean by editing the “LMS64C_protocol.h” file ?
To be fair, I thought about doing that and I went in another direction, because I guess I got confused by the fact that the package was named “spi”.

Well I have always used this gateware document but I still have trouble seeing what has to be done in my case. As I said in the initial post, I am kinda new to these technologies so yeah I am struggling.


Hey @tomlib,

you can easily use the internal SPI bus to add your own configuration registers. Maybe this helps you:

I use this to control my custom DDS/CIC decimator core inside the FPGA. By using the SPI configuration registers (see link) you do not need to modify any firmware/driver. The entire configuration can then be done in the user application using the “write register” functions, already existing in the Lime/Soapy API :slight_smile:


Hey @JTAG,

I eventually found out the way to go with the last chapters of the gateware document, and your message confirms that I am now heading for the right solution. So I thank you and @Zack for helping me out !


1 Like