DE1-SoC:
ARM HPS Linux
Cornell ece5760

The programming model I wish to use in ece5760 is LINUX running on the ARM processors, talking to hardware on the FPGA through Qsys.
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.

Standalone programming of HPS using native GCC in UP linux.

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

On the bottom of the DE1-SoC, set MSEL to 010101 (left to right), see DE1-Soc Users Manual page 12-13
This allows Linux to program the FPGA, but also allows direct hardware download using Quartus.

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.

Login as root using the serial terminal connection and PuTTY (on Mac use Terminal)

Put a strong password on the root account using passwd

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: reboot

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

With a static address, you may need to add DNS servers.
Edit /etc/resolv.conf to add the lines:nameserver 132.236.56.250
nameserver 128.253.180.2
nameserver 192.35.82.50
Then execute
/etc/init.d/networking restart If you get a eth0 error, then reboot

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

Use 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 ifconfig)
-- OR use the static address assigned to you

Use PSFTP to move files to/from the ARM (use help command)

The Cornell 10space system is not reachable from wireless devices!

GCC

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.

ntp sets network time. get it with apt-get install ntp
You need to edit /etc/ntp.conf to include the lineserver ntp0.cornell.edu
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 sosudo 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

Backup

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.

Python2.7 is installed in this distribution.
Python supports mmap, so you should be able to get to the FPGA, but is probably slow.

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
https://dnsdb.cit.cornell.edu/dnsdb-cgi/mycomputers.cgi

Every time you start the board you must executeifconfig eth0 down
ifconfig eth0 hw ether <mac addr>
ifconfig eth0 up
/etc/init.d/networking restart
Where <mac addr> the the address you registered
put these commands in /etc/rc.local so that they are executed on startup