This page needs tagging. Please add keywords describing what this page is about.

Overview

The GSRD includes a numbed of sample Linux applications that help demonstrate some of the features of the platform:
  • Control LEDs
  • Detect interrupts from push buttons and DIP switches
  • Display Hello World message
The sample applications can be used as a starting point for users to write their own applications that interact with software IP through Linux drivers.

WARNING: Linux drivers for Soft IP cores should be loaded only after the FPGA is programmed and the bridges are correctly enabled. Otherwise the driver will try to access memory locations that are not available, and the device or kernel may crash. The GSRD already implements this guideline.

Sample Application Source Code

The source code for the sample applications is delivered as part of the Yocto recipes. When using the default installation paths, the Yocto recipes can be found at ~/poky-socfpga/meta-altera/recipes-gsrd.

Reference information:

Prerequisites

1. Boot Linux on the target board as described in Booting Linux Using Prebuilt SD Card Image. You will not need to use the serial terminal if you plan on using ssh connection.2. Connect to the board using one of the following options: 3. In serial console, or ssh client console, change current folder to be /home/root/altera- this is where the application binaries are stored.
 # cd /home/root/altera

Display Hello World Message

1. Run the following command to display the Hello World message on the console:
# ./hello 

Exercise Soft PIO Driver for LED Control

1. In order to blink an LED in a loop, with a specified delay in ms, run the following command:
# ./blink  <led_number> <delay_ms> 

  • The led_number specifies the desired LED, and is a value between 0 and 3.
  • The delay_ms is a number that specifies the desired delay in ms between turning the LED on and off.
2. In order to turn an individual LED on or off, run the following command:
# ./toggle  <led_number> <state> 

  • The led_number specifies the desired LED, and is a value between 0 and 3.
  • The state needs to be 1 to turn the LED off, and 0 to turn the LED on-- -- -- StevenKravatsky - 01 Mar 2015 - 17:39 - 01 Mar 2015 - 17:39 - 01 Mar 2015 - 17:39.
3. In order to scroll the FPGA LEDs with a specified delay, please run the following command:
# ./scroll_client <delay> 

The delay parameter is a numbed the specifies the desired scrolling behavior:
  • delay > 0 - specify new scrolling delay in ms, and start scrolling
  • delay < 0 - stop scrolling
  • delay = 0 - display current scroll delay

Register Interrupt and Call Interrupt Service Routine

In order to register an interrupt handler to a specific GPIO, you will first need to determine the GPIO numbers used.

1. Go to Lightweight HPS2FPGA Address Map and write down the address offsets for the DIP switches and the buttons, and add the offset of the LW_H2F bridge of 0x100000000 to determine the address of the peripheral
Peripheral Address Offset Address
dipsw_pio 0x00010080 0x100010080
button_pio 0x000100c0 0x1000100c0
Determine which of the GPIO entries from /sys/class/gpio/ matches the offsets by searching for the address in the label entry.

2. For DIP switches, run:
# grep -ri "0x100010080" /sys/class/gpio/gpiochip*/label 

The output will be something similar with:
/sys/class/gpio/gpiochip165/label:/sopc@0/bridge@0xc0000000/gpio@0x100010080

This means that the GPIOs 165 .. 168 are allocated to the DIP switches (there are four of them).

3. For push buttons run:
# grep -ri "0x1000100C0" /sys/class/gpio/gpiochip*/label

The output will be something similar with:
/sys/class/gpio/gpiochip169/label:/sopc@0/bridge@0xc0000000/gpio@0x1000100C0

This means that the GPIOs 169, 170 are allocated to the push buttons (there are two of them).

4. In order to register an interrupt handler to a GPIO interrupt, run the following command:
# modprobe gpio_interrupt gpio_number=<gpio_number>

Where gpio_number is one of the numbers determined at the previous steps.

For example run:
# modprobe gpio_interrupt gpio_number=169

5. Press FPGA push button 0 (s6).

If you are on the serial console, you will see the following message displayed on the console:
Interrupt happened at gpio:169

If you are on the ssh console, you will need to run the program dmesg after pressing the button in order to see the messages:
# dmesg 

© 1999-2024 RocketBoards.org by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

Privacy Policy - Terms Of Use

This website is using cookies. More info. That's Fine