• 0
akhilahmed

Include files of SDSoC for Zybo-Z7

Question

Hi, 

I've started using the platform for SDSoC on Zybo-Z7 from https://github.com/Digilent/SDSoC-Zybo-Z7-20/releases. I tried creating a linux based  "Hello World" application and was able to successfully run it on the board. I would like to start using GPIO and other peripherals for simple image processing application. 

When I add #include "xgpio.h" in my main.c file and build (found an online YouTube video demonstration), SDSoC is not able to locate the xgpio.h file.

Is there a solution to this? I don't get any error when I choose freeRTOS instead of linux.

Thank you!

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @akhilahmed,

Unfortunately I haven't had the bandwidth to work with SDSoC as of yet. I have reached out to more experienced engineers to see if they would have any input for you.

thank you for your patience,

Jon 

Share this post


Link to post
Share on other sites
  • 0

Hi @akhilahmed,

In the mentioned video tutorial, the leds are controlled using "xgpio.h" library but the application
is standalone. If you want to use a linux based application you have to use linux drivers for controlling.
In the current Petalinux build, which is used in SDSoC platform, UIO driver is the best approach.

Steps:
1. Vivado project generation:
    - Extract .dsa archive from /path_to_sdsoc_platform/zybo_z7_20/hw/zybo_z7_20.dsa
    - Launch Vivado
    - In Tcl Console: cd /path_to_extracted_dsa/prj
    - In Tcl Console: source rebuild.tcl
    - In this point you should have the vivado project which is the hardware component of SDSoC platform.
        Open Block Design. Change to Address Editor Tab.
        Here you will find the address for axi_gpio_led IP: 0x4122_0000

2. Petalinux UIO driver:
    - Launch SDx
    - Import zybo-z7-20 SDSoC platform
    - Create a new SDx linux based project using a sample application (e.g. array_zero_copy)
    - Build the project
    - Copy the files from /Dubug/sd_card to SD card
    - Plug the SD card in Zybo Z7. Make sure that the JP5 is set in SD position. Turn on the baord
    - Use your favorite serial terminal to interact with the board (115200, 8 data bits, 2 stop bits, none parity)
    - cd to /sys/class/uio
    - if you run ls you will get something like:
        uio0  uio1  uio2  uio3  uio4  uio5
    - Now you have to iterate through all these directories and to search for the above mentioned axi_gpio_led address:
        0x4122_0000
    - For example: cat uio0/maps/map0/addr will output: 0x41220000, which means that the axi_gpio_led can be
        accessed using linux uio driver through uio0 device.
    - Code:

	#include <stdio.h>
	#include <stdlib.h>
	#include <sys/ioctl.h>
	#include <sys/mman.h>
	#include <stdint.h>
	#include <unistd.h>
	#include <fcntl.h>

	#define UIO_MEM_SIZE 65536
	#define UIO_LED_PATH "/dev/uio0"

	void UioWrite32(uint8_t *uioMem, unsigned int offset, uint32_t data)
	{
	  *((uint32_t*) (uioMem+offset)) = data;
	}

	uint32_t UioRead32(uint8_t *uioMem, unsigned int offset)
	{
	  return *((uint32_t*) (uioMem+offset));
	}

	void led_count_down(uint8_t *ledMem) {
		uint8_t count = 0xF;
		uint8_t index = 0;

		for (index = 0; index < 5; index++) {
			UioWrite32(ledMem, 0, count);
			count = count >> 1;
			sleep(1);
		}
	}

	int main() {
		// Set Leds as output
		int led_fd = open(UIO_LED_PATH, O_RDWR);
		uint8_t *ledMem = (uint8_t *) mmap(	0, UIO_MEM_SIZE, PROT_READ | PROT_WRITE,
										MAP_SHARED, led_fd, (off_t)0);
		UioWrite32(ledMem, 4, 0x0); // Set all leds as output

		while(1) {
			// Start led count-down
			led_count_down(ledMem);
		}

		return 0;
	}

    - Build the project and copy the content of Debug/sd_card on SD sd_card
    - Power on the board and connect to it using a serial terminal
    - run the following commands:

mount mmcblk0p1 /mnt
cd /mnt
./project_name.elf

- Result: A countdown should be displayed on leds.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now