Giter Site home page Giter Site logo

robertofem / cyclonevsoc-examples Goto Github PK

View Code? Open in Web Editor NEW
99.0 16.0 41.0 33.06 MB

Examples using the Cyclone V SoC chip

License: GNU General Public License v3.0

C 92.92% Makefile 0.47% Shell 0.03% Objective-C 0.25% Assembly 2.68% Verilog 2.86% Tcl 0.80%

cyclonevsoc-examples's Introduction

Cyclone V SoC examples

Examples using the FPSoC chip Cyclone V SoC. All these examples were tested on DE1-SoC board. However most of them are easily ported to other boards including Cyclone V SoC chips because they do not interact with the hardware in the board.

Cyclone V SoC simplified block diagram

This repository contains:

  • Starting-guides: guides on how to start with Cyclone V SoC boards. Currently only a guide for DE1-SoC board is available. However the process to start with any Cyclone V SoC board is similar and this guide can be used regardless the Cyclone V SoC board used.

  • Baremetal-applications: Stand-alone applications without Operating System.

    • DMA_transfer_FPGA_DMAC: This example shows how to use a DMA controller in the FPGA to read and write the HPS memories. Transfers can be done with cache switched ON through ACP and with cache switched OFF through the L3-to-SDRAMC port.
    • DMA_transfer_PL330_ACP: This is a complete example on moving data using the HPS Direct Memory Access Controller (DMAC) PL330. Data can be moved from a buffer in processor to another buffer in processor or to the FPGA. This example also shows how to switch on the cache memories L1 and L2 and how to configure the ACP port to access cache memories from L3 when caches are on.
    • Second_counter_PMU: This example uses a counter in the Performance Monitoring Unit (PMU) timer to measure seconds and build a second counter. It stands as an example on how to use PMU to measure time in baremetal.
  • FPGA-hardware: Quartus projects describing the FPGA hardware needed in some of the examples.

    • DE1-SoC: Hardware for Terasic´s DE1-SoC board.
      • FPGA_DMA: it implements a DMA controller in the FPGA and a 1kB on-chip memory. Using this DMA it is possible to move data between HPS and FPGA using the FPGA as master.
      • FPGA_OCR_256K: this hardware project includes a 256kB On-Chip memory in the FPGA, implemented using 10Mb memory blocks. This memory is hanging at the beginning of the address space of the HPS-to-FPGA bridge.
  • Linux-applications:

    • Test_DMA_PL330_LKM: it shows how to use the DMA_PL330_LKM module.
    • DMA_transfer_FPGA_DMAC: It transfers data from an On-Chip RAM in FPGA to On-Chip RAM in HPS and viceversa using a DMA Controller in FPGA.
    • DMA_transfer_FPGA_DMAC_driver: It transfers data from an On-Chip RAM in FPGA to a Buffer in the application using a DMA Controller in the FPGA and the Alloc_DMAble_buff_LKM module.
  • Linux-modules: Linux Loadable Kernel Modules (LKM).

    • Alloc_DMAble_buff_LKM: This driver allocates up to 5 physically contiguous buffers in kernel space and provides its physical addresses through sysfs and access to the buffer through character device interface. These buffers are intended to work as intermediate buffers in DMA transfers. Linux_applications/DMA_transfer_FPGA_DMAC_driver shows how to use it.
    • DMA_PL330_LKM_Basic: stand-alone module that makes a data transfer using the PL330 DMAC (available in HPS) when inserted into the operating system. It can be configured to move data between: FPGA memory, HPS On-chip RAM, uncached buffer in processor´s RAM and cached buffer in processor´s RAM (through APC). It is a complete example that can be used as starting point for developing a DMA module for a specific application.
    • DMA_PL330_LKM: module to make transfers between an application and the FPGA using PL330 DMAC. It uses char device driver interface to copy the data from application to a uncached or cached (through ACP) buffer in driver´s memory space. Later it uses PL330 DMAC to copy that buffer to FPGA. A /dev/dma_pl330 entry is created so writing in the FPGA is so easy as writing to a file. Linux_applications/Test_DMA_PL330_LKM shows how to use it.
    • Enable_PMU_user_space: this module permits access to the Performance Monitoring Unit (PMU) from user space. By default the access from user space is forbidden and a bit must be setting from kernel space to later have access from user space. This module accomplishes that task.
  • Useful-scripts: Linux shell scripts to ease configuration of the board.

    • fixed_mac_dhcp.sh: fixes MAC and asks IP using DHCP protocol.
  • SD-baremetal: This brief tutorial explains how to build a SD card to run the baremetal examples provided in this repository.

  • SD-operating-system: It explains how to build an SD card with Operating System from scratch. All the files needed are also provided to save time. Currently the OS that have been tested are:

    • Angstrom-v2013.12.
    • Angstrom-v2016.12. This tutorial also explains MAC spoofing (to set-up MAC on start-up), custom driver installation and running applications on start-up.

cyclonevsoc-examples's People

Contributors

robertofem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cyclonevsoc-examples's Issues

Minor defect in ghrd_top.v

Hello,

In CycloneVSoC-examples/FPGA-hardware/DE1-SoC/FPGA_DMA/ghrd_top.v, line 335:

.axi_signals_aruser (pio_controlled_axi_signals[ARPROT_BASE+: ARPROT_SIZE]),
.axi_signals_arprot (pio_controlled_axi_signals[ARUSER_BASE+: ARUSER_SIZE])

The name of inputs and the parameter macros seems to be reversed.

This might not be a problem now, when you use them, it may be hard to understand.

Best Regards,
affe00

Two questions on your DMA FPGA hardware

Hello,
I have two questions on your DMA FPGA hardware design.

  1. Why did you chose 100MHz for the PLL output? It that the maximum for any of the used IPs?
  2. How do you write to the ACP ID Mapper? Do you simply send data in its address space (which seems to start at 0x8000 0000 and end at 0xbfff ffff).

Edit (a third question):

Is the DMA mandatory to read and write to the ACP from the FPGA side (I dont need the HPS to see what's inside the OCR)?

Thanks!

Compile error while making DMA_PL330_LKM

I get following error while trying to compile DMA_PL330_LKM for DE10-Nano kernel 4.5 using gcc cross compiler included in SoC EDS 18.1.
before that i had to modify Makefile and add KBUILD_CFLAGS += -Wno-strict-prototypes -Wno-implicit-function-declaration to it to resolve some errors, also i got errors in DMA_PL330_LKM.c before '__ATTR()' call so i resolved it by adding following code at line 420 before the call:

#undef VERIFY_OCTAL_PERMISSIONS
#define VERIFY_OCTAL_PERMISSIONS(perms) (perms)

yet i still can't Make the DMA_PL330_LKM.

full output of make command:

make
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C /home/alireza/Desktop/linux-socfpga M=/home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM modules
make[1]: Entering directory '/home/alireza/Desktop/linux-socfpga'
  CC [M]  /home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/DMA_PL330_LKM.o
In file included from /home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/DMA_PL330_LKM.c:24:0:
/home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.h:86:5: warning: "ALT_DMA_PERIPH_PROVISION_I2C_SUPPORT" is not defined [-Wundef]
 #if ALT_DMA_PERIPH_PROVISION_I2C_SUPPORT
     ^
/home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.h:738:5: warning: "ALT_DMA_PERIPH_PROVISION_I2C_SUPPORT" is not defined [-Wundef]
 #if ALT_DMA_PERIPH_PROVISION_I2C_SUPPORT
     ^
/home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/DMA_PL330_LKM.c: In function ‘dev_write’:
/home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/DMA_PL330_LKM.c:622:7: warning: unused variable ‘i’ [-Wunused-variable]
   int i;
       ^
  CC [M]  /home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.o
In file included from /home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.c:45:0:
/home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.h:86:5: warning: "ALT_DMA_PERIPH_PROVISION_I2C_SUPPORT" is not defined [-Wundef]
 #if ALT_DMA_PERIPH_PROVISION_I2C_SUPPORT
     ^
/home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.h:738:5: warning: "ALT_DMA_PERIPH_PROVISION_I2C_SUPPORT" is not defined [-Wundef]
 #if ALT_DMA_PERIPH_PROVISION_I2C_SUPPORT
     ^
In file included from arch/arm/include/generated/asm/current.h:1:0,
                 from include/linux/wait.h:9,
                 from include/linux/completion.h:11,
                 from include/linux/rcupdate.h:43,
                 from include/linux/rbtree.h:34,
                 from include/linux/vmalloc.h:8,
                 from include/asm-generic/io.h:704,
                 from ./arch/arm/include/asm/io.h:439,
                 from /home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.c:49:
/home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.c: In function ‘alt_dma_channel_kill’:
include/asm-generic/current.h:6:45: error: expected ‘)’ before ‘->’ token
 #define get_current() (current_thread_info()->task)
                                             ^
include/asm-generic/current.h:7:17: note: in expansion of macro ‘get_current’
 #define current get_current()
                 ^
/home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.c:873:29: note: in expansion of macro ‘current’
     ALT_DMA_CHANNEL_STATE_t current;
                             ^
/home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.c:927:9: warning: passing argument 2 of ‘alt_dma_channel_state_get’ from incompatible pointer type [enabled by default]
         status = alt_dma_channel_state_get(channel, &current);
         ^
In file included from /home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.c:45:0:
/home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.h:591:17: note: expected ‘enum ALT_DMA_CHANNEL_STATE_t *’ but argument is of type ‘struct task_struct **’
 ALT_STATUS_CODE alt_dma_channel_state_get(ALT_DMA_CHANNEL_t channel,
                 ^
/home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.c:932:25: warning: comparison between pointer and integer [enabled by default]
         if (   (current == ALT_DMA_CHANNEL_STATE_KILLING)
                         ^
make[2]: *** [scripts/Makefile.build:259: /home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM/alt_dma.o] Error 1
make[1]: *** [Makefile:1391: _module_/home/alireza/Desktop/CycloneVSoC-examples/Linux-modules/DMA_PL330_LKM] Error 2
make[1]: Leaving directory '/home/alireza/Desktop/linux-socfpga'
make: *** [Makefile:19: modules] Error 2

De1 SoC GHRD

Hi @robertofem,
I try to follow gsrd manuals on https://rocketboards.org to get preloader and uboot and I get it successfully but nothing happened when I use it to boot Linux into de1. So could you give me de1_soc_GHRD folder or documentation about De1 GHRD, please?
Thank you!

Making *.ko in Linux-modules/DMA_PL330_LKM/

Hi, robertofem

I have tried to run supplied examples in Linux environment for HAN pilot platform from Terasic that uses Arria 10 SoC FPGA.

However, I met several problems..

First, supplied DMA_PL330.ko was compiled for Kernel version of 3.1, so i cannot use it directly.

After then, I tried to make DMA_PL330.ko using the makefile provided, but I cannot understand what "ROOTDIR" means.. does it means zImage?..

I am new for making SD card, so i just want to import LKM (*.ko) into the provided SD card image by Terasic. (https://www.terasic.com.tw/cgi-bin/page/archive.pl?Language=English&CategoryNo=216&No=1133&PartNo=4) Can you give me some guidance for it?..

I also wonder whether I have to recompile GHRD quartus project to use DMA_PL330, as GHRD project doe not enable the DMA peripheral request in Qsys, and have to rebuild SD card including modifed device tree infomation in Uboot Image..

Thank you..

Simple Makefile to Build a minimal Baremetal Application

Hi @robertofem,

Firstly, thank you for share these examples, I've learned so much trying to understand your codes.

I'm a beginner user of a DE1-SoC board, and now I'm trying to run my first bare-metal application. I've read some of your Makefiles in this repo, but, in my mind, there are some gaps in the build process of a bare-metal application.

Suppose that I have the code below:

#include <stdio.h>

int main() {

    printf("Hello!");

    return 0;
}

Could you, please, explain the steps that I need to build the file baremetal.bin from this code? All process to build and install the preloader and u-boot is not needed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.