Introduction
The Altera Cyclone V SoC Development Kit Reference Platform Porting Guide describes the hardware and software design of the Altera® Cyclone® V SoC Development Kit Reference Platform (c5soc) for use with the Altera Software Development Kit (SDK) for OpenCL™ (AOCL).
Before proceeding, it is recommended to familiarize yourself with the following documents:
- Altera SDK for OpenCL Cyclone V SoC Getting Started Guide
- Altera SDK for OpenCL Custom Platform Toolkit User Guide
- Cyclone V Device Handbook, Volume 3: Hard Processor System Technical Reference Manual
Additional information is available on the Cyclone V SoC Development Kit and SoC Embedded Design Suite page of the Altera website.
? Attention: This guide assumes an in-depth understanding of the Altera SDK for OpenCL Custom Platform Toolkit User Guide. It focuses on the differences between AOCL support on the Cyclone V SoC Development Kit and a generic AOCL Custom Platform, rather than detailing the implementation of a Custom Platform.
Related Information
- Altera SDK for OpenCL Cyclone V SoC Getting Started Guide
- Altera SDK for OpenCL Custom Platform Toolkit User Guide
- Cyclone V Device Handbook, Volume 3: Hard Processor System Technical Reference Manual
- Cyclone V SoC Development Kit and SoC Embedded Design Suite page on the Altera website
Overview of the Cyclone V SoC Development Kit Reference Platform
The Cyclone V SoC Development Kit Reference Platform is available with the Altera SDK for OpenCL.
(1) OpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission of the Khronos Group™.
(2) The Altera SDK for OpenCL is based on a published Khronos Specification and has passed the Khronos Conformance Testing Process. Current conformance status can be found at www.khronos.org/conformance.
© 2015 Altera Corporation. All rights reserved. Altera, Arria, Cyclone, Enpirion, MAX, MegaCore, NIOS, Quartus, and Stratix are trademarks of Altera Corporation. All other trademarks are the property of their respective holders. Altera warrants product performance to current specifications but reserves the right to make changes without notice. Altera assumes no liability for the application or use of information, products, or services described herein, except as expressly agreed in writing. Customers are advised to obtain the latest device specifications before relying on published information.
Cyclone V SoC Development Kit Reference Platform Board Variants
AOCL support for the Cyclone V SoC Development Kit leverages the following board features to maximize performance:
- FPGA device with the FPGA core logic.
- Hard processor system (HPS) with dual-core ARM® Cortex®-A9 CPU.
- Shared physical memory between the CPU and the FPGA core fabric.
The Altera SDK for OpenCL Cyclone V SoC Development Kit Reference Platform includes two board variants:
- c5soc board: This default board provides access to two DDR memory banks. The HPS DDR is accessible by both the FPGA and the CPU. The FPGA DDR is accessible only by the FPGA.
- c5soc_sharedonly board: This variant offers only HPS DDR connectivity, with the FPGA DDR inaccessible. It is more area-efficient and suitable for prototyping boards with a single DDR memory bank.
To target the c5soc_sharedonly board variant when compiling an OpenCL kernel, use the --board c5soc_sharedonly option in your aoc command.
Refer to the Altera SDK for OpenCL Programming Guide for more information on the --board <board_name> option.
Related Information
- Compiling a Kernel for a Specific FPGA Board (--board <board_name>)
Content of the Cyclone V SoC Development Kit Reference Platform
The Cyclone V SoC Development Kit Reference Platform consists of the following files and directories:
| File or Directory | Description |
|---|---|
board_env.xml |
eXtensible Markup Language (XML) file that describes c5soc to the Altera SDK for OpenCL. |
linux_sd_card_image.tgz |
Compressed SD flash card image file containing all necessary components for AOCL users of the Cyclone V SoC Development Kit. |
arm32 |
Directory containing: 1. A bin subdirectory with AOCL utilities (program and diagnose) specific to the Cyclone V SoC Development Kit. 2. A lib subdirectory with the memory-mapped device (MMD) library precompiled for a 32-bit Linux on ARM Cortex-A9 environment. |
c5soc |
Directory containing the hardware template for the board variant with two DDR SDRAM. |
c5soc_sharedonly |
Directory containing the hardware template for the board variant with one DDR SDRAM. |
driver |
Directory containing the source codes for the Linux kernel driver and the program and diagnose utilities. |
Relevant Features of the Cyclone V SoC Development Kit
The following features of the Cyclone V SoC Development Kit are relevant to the Altera SDK for OpenCL:
- Dual-core ARM Cortex-A9 CPU running 32-bit Linux.
- Advanced eXtensible Interface (AXI) bus between the HPS and the FPGA core fabric.
- Two hardened DDR memory controllers, each connecting to a 1 gigabyte (GB) DDR3 SDRAM.
- One DDR controller is accessible to the FPGA core only (FPGA DDR).
- The other DDR controller is accessible to both the HPS and the FPGA (HPS DDR), enabling shared memory between the CPU and FPGA core.
- The CPU can reconfigure the FPGA core fabric.
Cyclone V SoC Development Kit Reference Platform Design Goals and Decisions
Altera bases the reference platform implementation on several design goals and decisions. Consider these when porting the platform to your SoC board.
c5soc Design Goals:
- Provide the highest possible bandwidth between kernels on the FPGA and the DDR memory system(s).
- Ensure FPGA computations (OpenCL kernels) do not interfere with other CPU tasks, such as servicing peripherals.
- Maximize FPGA resources for kernel computations, minimizing interface components.
High-Level Design Decisions:
- The Reference Platform uses hard DDR memory controllers with the widest possible configuration (256 bits).
- The FPGA communicates directly with the HPS DDR memory controller, bypassing the AXI bus and L3 switch within the HPS. This direct communication optimizes bandwidth to DDR and prevents FPGA computations from interfering with CPU communications.
- Scatter-gather direct memory access (SG-DMA) is not part of the FPGA interface logic. Data is stored in the shared HPS DDR for efficiency. Direct access to CPU memory by the FPGA is more efficient than DMA, saving FPGA area and simplifying the Linux kernel driver.
Porting the Reference Platform to Your SoC Board
⚠️ Warning: Memory transfer between the shared HPS DDR system and the FPGA-only DDR system is very slow. Use this method only for very small amounts of data.
The host and device perform non-DMA data transfer via the HPS-to-FPGA (H2F) bridge using a single 32-bit port. This is sufficient as the Linux kernel can only issue single 32-bit read/write requests without DMA.
Control signals from the host to the device use a lightweight H2F (LH2F) bridge, ideal for low-bandwidth signals.
Tasks for Porting:
- Select either the single DDR memory or dual DDR memory version of the c5soc Reference Platform as the starting point.
- Update pin locations in the
ALTERAOCLSDKROOT/board/c5soc/<board_variant>/top.qsffile. ReplaceALTERAOCLSDKROOTwith the Altera SDK for OpenCL installation path and<board_variant>withc5soc_sharedonly(one DDR) orc5soc(two DDR). - Update DDR settings for HPS and/or FPGA SDRAM blocks in the
ALTERAOCLSDKROOT/board/c5soc/<board_variant>/system.qsysfile. - Ensure the design placement is timing clean for guaranteed timing closure. To port the
c5socboard partition (acl_iface_partition.qxp):- Remove
acl_iface_partition.qxpfrom theALTERAOCLSDKROOT/board/c5soc/c5socdirectory. - Enable the
acl_iface_regionLogicLock™ region by changing the Tcl command:
toset_global_assignment -name LL_ENABLED OFF -section_id acl_iface_regionset_global_assignment -name LL_ENABLED ON -section_id acl_iface_region - Compile an OpenCL kernel for your board.
- Adjust the LogicLock region size and location if necessary.
- Export the partition as the
acl_iface_partition.qxpQuartus Prime Exported Partition File once timing is clean.
Importing this file into the top-level design fulfills the requirement for a board design with a guaranteed timing closure flow, as described in the Altera SDK for OpenCL Custom Platform Toolkit User Guide.
- Remove
For detailed instructions on modifying and preserving board partitions, refer to the Quartus® Prime Incremental Compilation for Hierarchical and Team-Based Design chapter of the Quartus Prime Standard Edition Handbook.
Updating a Ported Reference Platform
In the current Cyclone V SoC Development Kit Reference Platform, the HPS block is part of the nonkernel logic partition and cannot be exported within the .qxp file. To update an existing Custom Platform modified from a previous c5soc version:
- Implement the QXP preservation flow.
- Update the SD flash card image for the latest runtime environment.
- Update the
board_spec.xmlfile to enable automigration.
Altera SDK for OpenCL versions 14.1 and later use board_spec.xml for board information and automatic updates. Updating this file helps AOCL distinguish between unpreserved and QXP-based Custom Platforms.
Refer to Custom Platform Automigration for Forward Compatibility in the Altera SDK for OpenCL Custom Platform Toolkit User Guide for more information.
Steps to implement QXP preservation flow:
- Create a partition around the HPS in the
.qsfQuartus Prime Settings File before partitioning the nonkernel logic. Example commands for manual partitioning and setting HPS_PARTITION type are provided. - When exporting the partition for
acl_iface_partition, use the--incremental_compilation_export_flatten=offoption to leave the HPS partition as a blackbox. Example Quartus CDB commands are shown.
After excluding the HPS, import the .qxp file and compile your design.
Update the SD flash card image:
- Mount the FAT32 and ext3 partitions of the existing image as loop-back devices. Refer to Step 2 in Building an SD Flash Card Image for instructions.
- In the
/home/root/opencl_arm32_rtedirectory, remove previous RTE files. - Download and unpack the current RTE version into the
/home/root/opencl_arm32_rtedirectory. - Update the
ACL_DRIVER_VERSIONin<path_Custom_Platform>/driver/version.hto the current AOCL and driver versions (e.g., 15.1.x). - Rebuild the driver.
- Delete hardware folders of your Custom Platform and copy the platform and updated driver to
/home/root/opencl_arm_rte/board. - Copy the
Altera.icdfile from/home/root/opencl_arm32_rteto/etc/OpenCL/vendors. - Unmount and test the new image. Refer to Steps 8-11 in Building an SD Flash Card Image for details.
Related Information
- Building an SD Flash Card Image on page 1-10
- Custom Platform Automigration for Forward Compatibility
Software Support for Shared Memory
Shared physical memory between the FPGA and CPU is preferred for OpenCL kernels on SoCs. Since the FPGA accesses shared physical memory directly, it does not have access to the CPU's page tables that map user virtual addresses to physical page addresses.
Hardware-wise, OpenCL kernels connect directly to the HPS DDR memory controller. Software support for shared physical memory involves:
- Standard CPU memory allocation functions (like
malloc()) cannot allocate regions usable by the FPGA. These functions allocate memory contiguous in virtual address space, but not necessarily physically contiguous. User-space applications on Linux lack the ability to allocate physically-contiguous memory, so the Linux kernel driver must handle this. - The OpenCL SoC Linux kernel driver uses the
mmap()function to allocate and map shared physical memory into user space. It utilizes the standard Linux kernel calldma_alloc_coherent()for requesting physically-contiguous memory regions. - By default,
dma_alloc_coherent()allocates no more than 0.5 MB of physically-contiguous memory. To enable larger allocations, the contiguous memory allocator (CMA) feature of the Linux kernel must be enabled and the kernel recompiled.
For the Cyclone V SoC Development Kit Reference Platform, CMA manages 512 MB of the 1 GB physical memory. This value can be adjusted based on application needs. While dma_alloc_coherent() may not always allocate the full 512 MB, it typically provides approximately 450 MB.
- CPU caching can affect visibility of writes to OpenCL kernels. The
mmap()function in the OpenCL SoC Linux kernel driver usespgprot_noncached()orremap_pf_range()to disable caching for this memory region. - After
dma_alloc_coherent()allocates physically-contiguous memory,mmap()returns the virtual address. The host application uses this virtual address, while OpenCL kernels require physical addresses. The Linux kernel driver maps virtual to physical addresses.
The aocl_mmd_shared_mem_alloc() MMD API call handles these queries:
mmap()allocates memory and returns the virtual address.- An additional query maps the returned virtual address to a physical address.
The aocl_mmd_shared_mem_alloc() call returns two addresses: the virtual address and the physical address (via device_ptr_out).
⚠️ Warning: The driver can only map virtual addresses returned by mmap() to physical addresses. Requesting the physical address for any other virtual pointer returns NULL.
⚠️ Warning: The Altera SDK for OpenCL runtime libraries assume shared memory is the first memory listed in board_spec.xml. The physical address obtained by the Linux kernel driver becomes the Avalon® address for the OpenCL kernel to the HPS SDRAM.
Use the clCreateBuffer() call to allocate shared memory as a device buffer:
- For the two-DDR board variant (shared and nonshared memory),
clCreateBuffer()allocates shared memory ifCL_MEM_USE_HOST_PTRis specified. Other flags allocate to nonshared memory. - For the one-DDR board variant (only shared memory),
clCreateBuffer()always allocates shared memory.
Currently, 32-bit Linux on ARM CPU supports shared memory in AOCL runtime libraries. Other environments (e.g., x86_64 Linux, 64-bit Windows) do not.
C5soc does not distinguish between shared and nonshared memory due to:
- History: Heterogeneous memory support was unavailable when shared memory support was created.
- Uniform interface: To maintain consistency across heterogeneous computing vendors, Altera uses the same interface as other board vendors for memory allocation and usage.
FPGA Reconfiguration
For Altera SoCs, the CPU can reconfigure the FPGA core fabric without interrupting CPU operation. The FPGA Manager hardware block handles this. A Linux kernel driver provides easy access to the FPGA Manager.
- To view FPGA core status, use the command:
cat /sys/class/fpga/fpga0/status
The Altera SDK for OpenCL program utility uses this interface to program the FPGA. When reprogramming an FPGA core with a running CPU, the utility performs these tasks:
- Disable all communication bridges (H2F and LH2F) between the FPGA and HPS before reprogramming. Reenable them after completion.
- Ensure the link between the FPGA and HPS DDR controller is disabled during reprogramming.
- Disable FPGA interrupts during reprogramming and notify the driver to reject any interrupts.
Consult the program utility's source code for implementation details.
⚠️ Warning: Do not change the HPS DDR controller configuration while the CPU is running, as this may cause fatal errors by altering the configuration during active memory transactions. Reprogramming the FPGA core with an image using a different HPS DDR configuration while the CPU is running is not permitted.
The OpenCL system and the Golden Hardware reference design (SoC Embedded Design Suite - EDS) configure the HPS DDR to a single 256-bit mode. CPU components like the branch predictor or page table prefetcher may issue DDR commands even when the CPU appears idle. Therefore, boot time is the only safe time to set the HPS DDR controller configuration. U-boot must load a raw binary file (.rbf) image. Enabling HPS DDR with unused FPGA ports and changing configurations afterward can lead to issues. The OpenCL Linux kernel driver no longer includes logic for setting the HPS DDR controller configuration.
The SW3 DIP switches on the Cyclone V SoC Development Kit control the expected format of the .rbf image (compressed/encrypted). C5soc and the Golden Hardware Reference Design use compressed but unencrypted .rbf images. SW3 DIP switch settings in the Altera SDK for OpenCL Cyclone V SoC Getting Started Guide match this configuration.
Related Information
- HPS-FPGA Interfaces
- Configuring the SW3 Switches
FPGA System Architecture Details
Support for the Cyclone V SoC Development Kit Reference Platform is based on the Stratix® V Reference Platform (s5_ref), available with the Altera SDK for OpenCL. The c5soc Qsys system and kernel driver organization are similar to s5_ref.
The following FPGA core components are common to both c5soc and s5_ref:
- VERSION_ID block
- Rest mechanism
- Memory bank divider
- Cache snoop interface
- Kernel clock
- Control register access (CRA) blocks
? Attention: The OpenCL system does not use the FPGA-to-HPS (F2H) bridge. Refer to the HPS-FPGA Interfaces section in the Cyclone V Device Handbook, Volume 3: Hard Processor System Technical Reference Manual for details.
Building an SD Flash Card Image
The Altera Cyclone V SoC is a full system-on-a-chip. Altera recommends delivering the system definition as an SD flash card image, which users can write to a micro SD card to prepare the SoC board for use.
You can build an SD flash card image by following instructions on the GSRD - SD Card page on the RocketBoards.org website. Alternatively, modify the image provided with the Cyclone V SoC Development Kit Reference Platform.
The c5soc linux_sd_card_image.tgz file is located in ALTERAOCLSDKROOT/board/c5soc, where ALTERAOCLSDKROOT is the AOCL installation path.
? Attention: Root or sudo privileges are required to modify the SD flash card image.
The following steps describe creating the linux_sd_card_image.tgz image from the Golden System Reference Design (GSRD) SD flash card image:
Note: To create the image from the c5soc image, perform all applicable tasks in this procedure.
- Begin with the GSRD SD flash card image version 14.0.
- Mount the FAT32 and ext3 partitions of the image as loop-back devices. To mount a partition:
- Determine the partition's byte start using
/sbin/fdisk -lu image_file. (Example: Partition 1, W95 FAT, block offset 2121728; byte offset = 512 * 2121728 = 1086324736 bytes). - Identify a free loop device (e.g.,
/dev/loop0) withlosetup -f. - Assign the flash card image to the loop device:
losetup /dev/loop0 image_file -0 1086324736. - Mount the loop device:
mount /dev/loop0 /media/disk1./media/disk1will now be a mounted FAT32 partition. - Repeat steps a-d for the ext3 partition.
- Determine the partition's byte start using
- Place the unpacked
aclrte_arm32package into/home/root/opencl_arm32_rteon the ext3 partition. - Delete your Custom Platform's hardware folder(s) and place the Custom Platform into the
boardsubdirectory ofopencl_arm32_rte. - Create
init_opencl.shin/home/rootwith the following content:export ALTERAOCLSDKROOT=/home/root/opencl_arm32_rte export AOCL_BOARD_PACKAGE_ROOT=$ALTERAOCLSDKROOT/board/<board_name> export PATH=$ALTERAOCLSDKROOT/bin:$PATH export LD_LIBRARY_PATH=$ALTERAOCLSDKROOT/host/arm32/lib:$LD_LIBRARY_PATH insmod $AOCL_BOARD_PACKAGE_ROOT/driver/aclsoc_drv.koThe AOCL user runs
source ./init_opencl.shto load environment variables and the OpenCL Linux kernel driver. - If updating the preloader, DTS files, or Linux kernel, follow instructions in the Altera SoC Embedded Design Suite User Guide to recompile and update files on the mounted FAT32 partition.
Recompiling the Linux Kernel and the OpenCL Linux Kernel Driver
To run OpenCL applications on the Cyclone V SoC board, you must first compile the OpenCL Linux kernel driver and the Linux kernel. Kernel recompilation is necessary to enable CMA.
? Attention: You will likely need to update the preloader if your Custom Platform has different pin usages than those in c5soc.
Remember: If you recompile the Linux kernel, use the same source files to recompile the Linux kernel driver. A mismatch will prevent the driver from loading. Ensure CMA is enabled.
Refer to Recompiling the Linux Kernel and the OpenCL Linux Kernel Driver for more information.
- Click the GSRD v14.0 - Compiling Linux link on the RocketBoards.org website Resources page for instructions on downloading and rebuilding the Linux kernel source code.
- The build process creates
arch/arm/configs/socfpga_defconfig. Add the following lines to this file:CONFIG_MEMORY_ISOLATION=y CONFIG_CMA=y CONFIG_DMA_CMA=y CONFIG_CMA_DEBUG=y CONFIG_CMA_SIZE_MBYTES=512 CONFIG_CMA_SIZE_SEL_MBYTES=y CONFIG_CMA_ALIGNMENT=8 CONFIG_CMA_AREAS=7CONFIG_CMA_SIZE_MBYTESsets the upper limit for physically contiguous memory. Increase this value if more memory is needed.? Attention: The total physical memory available to the ARM processor on the SoC board is 1 GB. Altera does not recommend setting the CMA manager close to 1 GB.
- Run
make ARCH=arm socfpga_deconfig. - Run
make ARCH=arm zImage. The resulting image is inarch/arm/boot/zImage. - Run
export CROSS_COMPILE=arm-linux-gnueabihf-. - Place the
zImagefile into the FAT32 partition of the flash card image. - To recompile the OpenCL Linux kernel driver, set the
KDIRvalue in the driver's Makefile to the directory containing the Linux kernel source files. - Type
make. - To verify CMA is enabled, power up the SoC board and run
grep init_cma /proc/kallsyms. CMA is enabled if the output is non-empty.
Steps for testing the SD flash card image:
- Write the uncompressed image to a micro SD flash card.
- Insert the card into the SoC board.
- Power up the board.
- Invoke the
aocl diagnoseutility command.
Related Information
- GSRD - SD Card page on the RocketBoards.org website
- Altera SoC Embedded Design Suite User Guide
- OpenCL Design Examples page on the Altera website
- Recompiling the Linux Kernel and the OpenCL Linux Kernel Driver on page 1-11
- Querying the Device Name of Your FPGA Board (diagnose)
Known Issues
There are limitations when using the Altera SDK for OpenCL with the Cyclone V SoC Development Kit Reference Platform:
- Vendor and board names reported by
CL_DEVICE_VENDORandCL_DEVICE_NAMEstrings of theclGetDeviceInfo()call cannot be overridden. - If the host allocates constant memory in shared DDR (HPS DDR) and modifies it after kernel execution, the data may become outdated. This is because the FPGA core cannot snoop on CPU-to-HPS DDR transactions. To prevent this, implement one of the following workarounds:
- Do not modify constant memory after initialization.
- If multiple
__constantdata sets are required, create multiple constant memory buffers. - If available, allocate constant memory in the FPGA DDR on your accelerator board.
- The AOCL utility on ARM only supports the
programanddiagnoseutility commands.
Document Revision History
The flash, install, and uninstall utility commands are not applicable to the Cyclone V SoC Development Kit for the following reasons:
- Install/Uninstall: The install utility requires compiling the
aclsoc_drvLinux kernel driver and enabling it on the SoC. The development machine already has SoC Linux kernel sources, which may differ from the SoC's sources, making the location unknown to the AOCL user. The uninstall utility is also unavailable. Deliveringaclsoc_drvis challenging as the default distribution lacks Linux kernel include files or the GNU Compiler Collection (GCC). - Flash Utility: Requires placing a
.rbffile on the FAT32 partition of the micro SD card. This partition is not mounted on board power-up. Updating requires a flash card reader and the development machine.
When switching between Altera Offline Compiler Executable files (.aocx) for different board variants (c5soc and c5soc_sharedonly), use the AOCL program utility to load the .aocx file for the new variant the first time. Running the host application with a new variant while the FPGA contains an image from another variant may cause a fatal error.
The .qxp file does not include interface partition assignments, as Quartus Prime software consistently meets timing requirements for this partition.
When powering up the board, its media access control (MAC) address is random. To set a static MAC address:
- During U-Boot power-up, press any key to enter the U-Boot prompt.
- Type
setenv ethaddr 00:07:ed:00:00:03(or any desired MAC address) at the prompt. - Type
saveenv. - Reboot the board.
Revision History
| Date | Version | Changes |
|---|---|---|
| November 2015 | 2015.11.02 | Maintenance release; changed instances of Quartus II to Quartus Prime. |
| May 2015 | 15.0.0 | In FPGA Reconfiguration, removed instruction to reprogram FPGA core with a .rbf image using cat <image_filename>.rbf > /dev/fpga0 as it is not recommended. |
| December 2014 | 14.1.0 | Renamed document to Altera Cyclone V SoC Development Kit Reference Platform Porting Guide. Updated reprogram utility to aocl program <device_name> <your_kernel_filename>.aocx. Updated diagnostic utility to aocl diagnose and aocl diagnose <device_name>. Updated porting procedure to include instructions on porting and modifying the c5soc board partition for timing-clean partitions. Inserted topic Updating a Ported Reference Platform (excluding HPS, updating SD card image). Updated Building an SD Flash Card Image section, recommending GSRD version 14.0. Updated Recompiling Linux Kernel section (set CROSS_COMPILE, verify CMA). |
| July 2014 | 14.0.0 | Initial Release. |







