ARM HPS Linux
The programming model I wish to use in ece5760 is LINUX running on the ARM processors, talking to hardware on the FPGA through Qsys.
Standalone programming of HPS using native GCC in UP linux.
I would prefer not to use design automation tools, like OpenCL, but stay at the level of the Qsys module interconnect, with custom FPGA hardware.
Setting up the UP Linux environment:
- To start, you will use the UP LINUX 2016 image. The rest of this page assumes this version of Linux.
- If you are working with a windows machine, The sections 2.1 and 2.2 Using Linux on the DE1-SoC
shows how to install Linux on an SDcard.
- If you are working from a Mac, then you probably want to use ApplePiBaker
- Once Linux is running on the HPS:
- Log in using the board serial connection as explained in section 2.3 of Using Linux on the DE1-SoC
but use PSFTP to tranfer files, not the USB drive explained in section 2.4
- To configure the FPGA, we will not use the scheme described in Section 3, but rather download
configuration using the USB blaster interface from Quartus Prime.
- Compile C code as explained in section 4, 4.1, 4.3 and 4.4 of Using Linux on the DE1-SoC
- If you have never used Linux, you may want to look at:
- Before doing anything else:
- Remember: People write malware for Linux! Practice safe computing!
- Login as root using the serial terminal connection and PuTTY (on Mac use Terminal)
- Put a strong password on the root account using
- Disable the linaro account using
passwd linaro -l
- You should not shut down the system by just turning off the power.
To avoid corrupting the file system use:
shutdown -h now
- To reboot use:
- Editing on the HPS
- Usually you will edit source code on a PC, then transfer the code by SFTP to the HPS
- But sometimes small edits (e.g. config files) are done on the HPS. Editors:
- vi -- it is on every linux system. commands.
You just have to remember the state (command/insert) of the editor.
- vim -- very much like vi commands, but the state of the editor is indicated.
To download: apt-get install vim
- GNU nano -- slightly less cryptic than vi, more commands, and users guide
When mouse support has been configured and enabled, a single mouse click places the cursor at the indicated position. Clicking a second time in the same position toggles the mark to start a selection range. Clicking in the shortcut list executes the selected shortcut. The mouse will work on the console when gpm is running (which seems to be the default). Invoke mouse with nano -m
- GNU emacs -- bewildering. This is not an editor, it is a way of life.
- In the lab you will connect to the internet using a wired system, and we will require you to use a static address for security
- The Cornell 10space system will be used for any FPGA on the internet in the lab.
- The MAC address and IP address are locked down and must match.
You will use a static address assigned to your group. You may not use another group's addresses.
- You will need to specify an MAC address, IP address, and
a router address in
iface eth0 inet static
hwaddress ether 12:34:56:78:90:yy
dns-nameservers 126.96.36.199 188.8.131.52 184.108.40.206
- With a static address, you may need to add DNS servers.
/etc/resolv.conf to add the lines:
- Secure Shell login
- When networking is up, then at the Linux prompt do
sudo apt-get install openssh-server
- You may need to do
sudo apt-get update before installing any packages
passwd to add a password to
root if you have not already done this!
- Make sure that PuTTY and PSFTP are installed on the Windows machine (on Mac use Terminal)
- Use PuTTY to SSH to the ARM.
Open the IP address assigned by DHCP (Find address using
-- OR use the static address assigned to you
- Use PSFTP to move files to/from the ARM (use
- The ARM cpus are completely capable of running GCC to communicate with either native HPS peripherials or with the FPGA.
You compile from the command line with the usual Linux syntax. Some projects require compile flags which are noted below.
- man page
- Minumum compile command is gcc source.c -o executable_file_name
- To use math library include
-lm option on the command line and
<math.h> in the code
- To use pThreads include the
-pthread option on the command line
<pthread.h> in the code
taskset allows you to place a process on either ARM processor.
However, Linux attempts to migrate processes to load balance if you do nothing.
htop (sudo apt-get install htop) shows you what is running and on which processor.
clamav is an antivirus program you might install using
apt-get install clamav
Then you can update the virus database
and scan the file system using
- But if the update fails with a locked database then
sudo /etc/init.d/clamav-freshclam stop
sudo freshclam -v
sudo /etc/init.d/clamav-freshclam start
ntp sets network time. get it with
apt-get install ntp
You need to edit
/etc/ntp.conf to include the line
Service starts up after a minute or so.
Occasionally I need to restart
sudo service ntp restart
apt-get sometimes fails with the error "
Problem with MergeList ..."
Apparently this is due to a correpted database so
sudo rm -vf /var/lib/apt/lists/*
sudo apt-get update
Then try again
- Mount a USB flash drive
- Plug it in, then look for something like sda1 in /dev
- cd to /mnt
- mkdir sda1
- mount /dev/sda1 /mnt/sda1
- To eject the drive: umount /dev/sda1
- SD cards fail. Backup your good image, or you will do all the work again.
- On windows, Win32 disk imager can be used to READ an image from the SD card.
- On Mac, use ApplePiBaker
- Do not use this networking method in the lab.
If you connect to internet using Cornell DHCP, then Cornell requires a fixed, registered MAC address in order to use DHCP.
Since the board boots with a different MAC address every time you, have to fix the MAC address.
Note that if you get hit with malware, Cornell will throw you off the net!
Do not use this in the lab. Use this only if you buy your own board and use in your own facility.
To set this up:
- At the Linux prompt do
ifconfig and copy the MAC address to
- Every time you start the board you must execute
ifconfig eth0 down
ifconfig eth0 hw ether <mac addr>
ifconfig eth0 up
<mac addr> the the address you registered
put these commands in
/etc/rc.local so that they are executed on startup
- The DHCP server should then assign you an IP address
- If networking does not start then execute
DE1-SOC literature list
Using the DE1-SOC FPGA by Ahmed Kamel
Stereoscopic Depth on an FPGA via OpenCL by Ahmed Kamel and Aashish Agarwal
Running Linux on DE1-SOC by MANISH PATEL and SYED TAHMID MAHBUB
OpenCL on DE1-SOC Sahil P Potnis (email@example.com) Aashish Agarwal (firstname.lastname@example.org) Ahmed Kamel (email@example.com)
Audio Core (Qsys University Program 15.1) local copy
Video Core (Qsys University Program 15.1) local copy
External to Avalon Bus Master (external here means in the FPGA, but not in the Qsys bus structure)
Avalon to External Bus Slave (external here means in the FPGA, but not in the Qsys bus structure)
(old LINUX image)
Copyright Cornell University
February 2, 2017