Automatic and platform-independent CLI communication system via Ethernet with ComBlock support.
Project description
__/\\\________/\\\__/\\\\\\\\\\\\_____/\\\\____________/\\\\_____/\\\\\\\\\____
_\/\\\_______\/\\\_\/\\\////////\\\__\/\\\\\\________/\\\\\\___/\\\\\\\\\\\\\__
_\/\\\_______\/\\\_\/\\\______\//\\\_\/\\\//\\\____/\\\//\\\__/\\\/////////\\\_
_\/\\\_______\/\\\_\/\\\_______\/\\\_\/\\\\///\\\/\\\/_\/\\\_\/\\\_______\/\\\_
_\/\\\_______\/\\\_\/\\\_______\/\\\_\/\\\__\///\\\/___\/\\\_\/\\\\\\\\\\\\\\\_
_\/\\\_______\/\\\_\/\\\_______\/\\\_\/\\\____\///_____\/\\\_\/\\\/////////\\\_
_\//\\\______/\\\__\/\\\_______/\\\__\/\\\_____________\/\\\_\/\\\_______\/\\\_
__\///\\\\\\\\\/___\/\\\\\\\\\\\\/___\/\\\_____________\/\\\_\/\\\_______\/\\\_
____\/////////_____\////////////_____\///______________\///__\///________\///__
The UDMA is a remote control suite for interfacing a PC with custom logic in a SoC-FPGA. It was tested inside FreeRTOS on top of Lwip. But it should be able to run on any OS with little to no modifications (open an issue if you are interested on a specific port).
The communication with the FPGA is done through the ComBlock.
Server
The server is provided as a C header. For the moment this file is Xilinx specific more vendors will be considered in future updates. This file provides one external function called:
void process_command(u32 *recv_buf, int sd)
This function is interface agnostic. So in principle if the sd you provide supports the write function it should work. Currently it was only tested with Ethernet but Serial support will be considered for future updates.
Client
The client is a python CLI based on Cmd2 library. To install the Python app you just need to clone the repository and open a terminal inside the repository root folder. Then type:
For Linux
pip3 install .
or
pip install .
In Windows
pip3 install --editable .
or
pip install --editable .
Depending on the environment variable name you gave to your python3-pip path. It is recommended to run this in a python-env to avoid crossed requirements between different packages or apps that might break the install.
After the install you can execute the application by running udma_cli in any terminal. If the command cannot open terminal in the repo and run this command python3 src/cli/cli.py.
The UDMA specific functions are defined inside the src/udma/udma.py file within the UDMA class.
Inside the cli.py file the command line interface built on cmd2 is implemented.
If you want to integrate the functionality of UDMA into your projects all you need to do is include the udma.py in your Python project and instantiate the class.
UDMA class
The class is in practice a TCP socket wrapper that incorporates a minimal protocol to execute UDMA specific commands. When creating an instance of the class you need to provide the IP and port of the server. Once the socket is created you just need to provide the required parameters depending on the command.
A class that manages the communication with an UDMA server
Attributes
-------
ip: str
the ip of the server to connect to in 'XXX.XXX.XXX.XXX' format
port: int
the port of the server
s: socket
the tcp connection to the server
Methods
-------
set_ip(ip)
set the ip
set_port(port)
set the port
disconnect()
close the socket
get_ip()
return the ip
get_port()
return the port
connect()
connect to the server with the specified ip and port
close_server()
send 'quit' to stop the server
read_reg(reg)
send the read register command and return the value
write_reg(reg, data)
write data to the register
read_fifo(N)
return N values from the FIFO
write_fifo(N, data)
write N values to the FIFO
read_ram(addr, length, inc)
return length values from the RAM starting from addr with an increment of inc
write_ram( addr, length, inc, data)
write length values to the RAM starting from addr with an increment of inc
read_mem(addr, length, inc)
return length values from memory starting from addr with an increment of inc
write_mem(addr, length, inc, data)
write length values to memory starting from addr with an increment of inc
select_comblock()
change the selected comblock on the FPGA side
log()
disable or enable serial logging
Communication protocol
The communication between the PC and the board relies over Ethernet TCP/IP. Using sockets you can connect to the board from any program. To send comands you must follow the following structure:
The board will always answer with a response with the error flag of the command, data count and data if required.
Command List for CLI
Here is a list of the available commands specific to the application. The cmd2 package includes more commands that help the user such as the help command which can be used to get more information regarding the application and its commands.
Board communication
| connect | Create the connect command to allow communication with the board via Ethernet |
| log | Starts serial logging to debug the transmission and processing of the messages |
| udma | Create the x_udma command to pass the UDMA instruction to the specified LRA |
Note: UDMA function is not completely implemented and must not be used unless specified in the release notes
Comblock Read
| x_read_fifo | Create the x_read_fifo command to allow reading the FIFO of the Comblock |
| x_read_mem | Create the x_read_ram command to allow reading the RAM of the Comblock |
| x_read_ram | Create the x_read_ram command to allow reading the RAM of the Comblock |
| x_read_reg | Create the x_read_reg command to allow reading registers from the Comblock |
Comblock Write
| x_write_fifo | Create the x_write_fifo command to allow writing the FIFO of the Comblock |
| x_write_mem | Create the x_write_ram command to allow writing the RAM of the Comblock |
| x_write_ram | Create the x_write_ram command to allow writing the RAM of the Comblock |
| x_write_reg | Create the x_write_reg command to allow writing the registers of the Comblock |
Usage
Vitis software app
- Copy the folder '''/src/udma_sw_app''' into '''Vitis/2021.2/data/embeddedsw/lib/sw_apps'''.
- Open Vitis.
- Create a new application project.
- When prompted to select a template choose the UDMA Server.
- Done.
From Scratch
- Create a new Vivado project (make sure a processor that can run a TCP stack is present and also one Comblock).
- Add you custom logic and connect the control ports to the Comblock.
- Generate the bitstream and export it.
- Open your SDK or Vitis.
- Create a FreeRTOS project based on the LWIP Echo.
- Import 'udma.h' as a File System into the 'src' folder of the project.
- Build the project, at this point no errors should show up.
- Make a call to the process_message function inside 'echo.c' (or use the echo.c provided in the examples folder of this repo.).
- Build again.
- Load the bitstream onto the FPGA and program the ARM.
- Go to the PC, open python and connect via the CLI. The default socket in the SoC is 192.168.1.10:7 if no DHCP is present.
- Perform the read and write operations from the PC.
Example
There is an example and test files available on their respective folders.
Follow these guide to setup the example
- Create a new project in Vivado.
- Open the project settings and add the ComBlock repository.
- On the Tcl console navigate to the git repository. Use the
cdcommand to change directory,dirto display the content of the current directory, andpwdto show the current directory. - Once you reached the
udmadirectory, run the following script.source examples/udma_test_bd.tcl - This will create the block design needed to run the
udmatest. - Generate the bitsream.
- Export the Hardware including the bitstream.
Now that the hardware files were created we need the software.
- Open Vitis or SDK from Vivado.
- Create a project using the exported hardware.
- Select FreeRTOS as the operating system.
- Select the
FreeRTOS Lwip Echo serverproject example. - Modify BSP settings.
- On FreeRTOS go to
kernel_behaviortab and changetotal_heap_sizeto262144. - On lwip211 go to
lwip_memory_optionstab and changemem_sizeto262144. - On lwip211 go to
pbuf_optionstab and changepbuf_pool_sizeto2048. - On lwip211 go to
tcp_optionstab and changetcp_mssto2048andtcp_snd_bufto16384. - Build the BSP and you are ready to continue.
- On FreeRTOS go to
- Got to the project folder in the
Project Explorer, left click in the src folder and select Import. - In the
Generaltab selectFile System. - Browse your PC to the src folder of the repo.
- Select the
udma.hfile and theexamples/RVI_Lab/echo.cfile.
Project implementation
- Build the project.
- Connect the ZedBoard programming USB cable.
- Connect Ethernet cable and UART USB cable.
- Configure the FPGA and program the CPU.
- Run the Python CLI.
- Enjoy!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file udma-1.0b1.tar.gz.
File metadata
- Download URL: udma-1.0b1.tar.gz
- Upload date:
- Size: 28.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d49efd647da6659288d764735e7d737d71fd7db7f7fd2a390027ed5bbaa46d75
|
|
| MD5 |
d9625b813cd08080b739a0920be34b34
|
|
| BLAKE2b-256 |
0d2c0e292a940248f840df507b8cd021a73c395babfc77bacc6ee71ec016c1e3
|
File details
Details for the file udma-1.0b1-py3-none-any.whl.
File metadata
- Download URL: udma-1.0b1-py3-none-any.whl
- Upload date:
- Size: 26.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7c8a6fd7dd5af847aacf52b871f5cf772a8f2430c20fa01ffceaa2a36c5ae44
|
|
| MD5 |
1b46459b32300e269df05641c9691af2
|
|
| BLAKE2b-256 |
b0a3521c2f8b2833f9ec250054742d9ef7ba0df62e3a0cd63d3ee60a972eafc5
|