USB and Ethernet connectivity on the Zynq-7000 using the Micrium uC/OS BSP

In two previous articles, I have looked at using Micrium’s uC/OS RTOS on the Xilinx Zynq-7000. I only covered kernel and storage. This time, I will be exploring some connectivity options in combination with the Digilent Zybo. Namely, using Micrium’s USB device solution and HTTP server through the Zybo’s Ethernet port. This is also a perfect opportunity to try the new and improved release of Vivado 2017.1.

The plan is to use the Zybo on-board SD Card to hold the html files for the HTTP server. To make it more interesting, instead of just copying the files using a PC, I’ll turn the Zybo into a USB mass storage device to access the SD Card.

Digilent ZYBO
Digilent ZYBO

Vivado 2017.1

Xilinx wasn’t kidding about the leaner and more streamlined interface. The updated visual design is quite appreciated on larger high resolution monitors. I can also imagine that the less cluttered interface will make it easier for newcomers. Also, an interesting side effect, is that screenshots for blogs and tutorials are now much better looking at smaller resolution, thanks to the increased font size and leaner theme.

Back to the Zybo, since this is mostly an SDK project demonstration not much needs to be done other than exporting the hardware definition to the SDK. The board definition can be downloaded from the Digilent website and copied to the usual location i.e. Xilinx/Vivado/2017.1/data/boards/board_files.

Curiously, the default MIO configuration for the Zybo has the Ethernet MDIO interface routed to the EMIO. Since we want to control the external Ethernet phy it’s necessary to change it to the correct MIO pins.

Zybo MIO Configuration
Zybo MIO Configuration

Ethernet configuration

Configuring Micrium’s TCP/IP stack for the Zybo is slightly more complicated than it was for the ZC702 and other similar Xilinx reference boards. The Micrium initialization code expects the Marvell 88E1111 GigE phy, while the Zybo uses the Realtek RTL8211E. The RTL8211E is fairly straightforward however so writing a custom PHY was an easy thing.

After replacing the phy code with my own, I was able to setup the PS Ethernet interface using the BSP configuration screen.

Micrium uC/OS BSP ethernet configuration
Micrium uC/OS BSP ethernet configuration

I’m connected directly to a local test network so I hard-coded the IP address and disabled DHCP. Also, I apparently made a small mistake in my phy MDIO address autodetection routine as it’s autodetected as 0. Feeling a bit lazy, I hardcoded the phy address to 1, as it should be on the Zybo.

A quick ping test to show that it works. Pretty much the networking equivalent of hello world.

Ethernet ping test
Ethernet ping test

USB mass storage

To load the html file for the HTTP server I’ll configure the Zybo as a USB mass storage device. The Micrium BSP is shipped with an MSC demo that can be selected when creating a new SDK project using the ucos BSP. The only configuration required is to select the USB interface and set it to device.

Micrium uC/OS BSP USB configuration
Micrium uC/OS BSP USB configuration

There is a good set of example files for the Micrium HTTP server shipped with the source code. I simply copied the file to the SD Card and added the C code to my SDK project.

SD Card on the Zybo through a USB mass storage device
SD Card on the Zybo through a USB mass storage device

Note that a file system volume cannot be access while it’s being used as an MSC device. As such we need to either change the project to disable the USB device, or have a way, to disable the MSC device at runtime.

Accessing the IP address hard coded earlier in a browser will now display the demonstration webpage.

Micrium demonstration webpage
Micrium demonstration webpage

All that in less than an hour, including the custom PHY.

Questions or comments?

Do not hesitate to contact us at blog@jblopen.com. Your questions, comments and, suggestions are appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *