DE-25 FPGA Dev Kit Part 7 (HPS Demo 1)

The purpose of this article is to cross-compile a demo for the ARM in the HPS of the DE-25 FPGA Dev Kit

Please refer to the previous article Part 6 where the ARM Cross Compiler was installed in a Linux host before proceeding with this article. Make sure all the files from the SoC directory are present from the examples in the SoC of the resources CD from Part 1. In this case we will be covering the hps_led_key,

with the following relevant files,

gpio_lib.c  gpio_lib.h  led_lib.c  led_lib.h  main.c  Makefile

For illustration purposes of this demo, only modify the main.c program as follows,

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include "gpio_lib.h"
#include "led_lib.h"

/****************************************************************
 * Main
 ****************************************************************/
 
 int main(int argc, char **argv)
{	
	GPIO_HANDLE *line_key;
	unsigned int io_led=0;
	int loop;
	int fd_led;
	unsigned int key_value;
	bool bLedLight = true;

	line_key = gpio_open_line("/dev/gpiochip0", 16/*line 16 for KEY*/, 0 /*input*/);
	
	fd_led = led_fd_open(io_led);

	loop = 20;
	while (loop >= 0) {
		//gpio_get_value(io_key, &value);
		gpio_get_line_value(line_key, &key_value); // key_value is low active
		if (!key_value || bLedLight)
			led_fd_write(fd_led, "1", 2); // light led
		else
			led_fd_write(fd_led, "0", 2); // unlight led
		printf("DigiKey Coffee Cup Input Key: %x\n", key_value);
		bLedLight = bLedLight?false:true;
		usleep(800*1000); // 0.8 second
		loop--;
	}
	
	led_fd_close(fd_led);
	gpio_close_line(line_key);
	
	return 0;
}

In order to cross-compile this demo please proceed with the following command,

digikey_coffee_cup: ~$  export CROSS_COMPILE=aarch64-none-linux-gnu-

Now proceed with make as shown next,

digikey_coffee_cup: ~$ make
aarch64-none-linux-gnu-gcc -g -O0 -Werror -Wall -c main.c -o main.o
aarch64-none-linux-gnu-gcc -g -O0 -Werror -Wall -c led_lib.c -o led_lib.o
aarch64-none-linux-gnu-gcc -g -O0 -Werror -Wall -c gpio_lib.c -o gpio_lib.o
aarch64-none-linux-gnu-gcc -g -O0 -Werror -Wall main.o led_lib.o gpio_lib.o -o hps_led_key 
aarch64-none-linux-gnu-nm hps_led_key > hps_led_key.map

In order to run this ARM executable in the HPS in the DE-25 FPGA Dev Kit. Proceed to copy the hps_led_key ARM binary to the DE-25 FPGA Dev Kit from the Linux host via SSH the WiFi Router as outlined in a previous article Part 5. The following scp command copies the file from the Linux host to the DE-25 HPS via SSH (Please change the IP address and path as needed),

digikey_coffee_cup: ~$ scp hps_led_key terasic@192.168.1.131:/home/terasic/SoC

Execute the ARM binary for the HPS in the SSH or PuTTY terminal connection as desired,

The HPS button in the DE-25 FPGA Dev Kit was pressed and properly recognized by the ARM binary running in the HPS for the Agilex 5, also an HPS connected LED blinked on/off in the board as expected. This completes the first HPS demo in this series for the DE-25 FPGA Dev Kit.

The DE-25 FPGA Dev Kit is a powerful platform featuring an HPS/FPGA Agilex 5 (available as D-Series and E-Series depending on the case) capable of implementing Tensor AI slices,

that go beyond what traditional/classical old school DSP slices implemented in the past,

and it is available at DigiKey.

Have a wonderful day!

This article is available in spanish here.

Este artículo está disponible en español aquí.

1 Like