ELE409 SPRING2018 LAB0 Getting familiar with the LXDE system Objectives: Pre-Lab: 1. Burn the linux system onto a micro-sd card 2. Get familiar with basic linux commands 3. Be able to communicate with and send files from the linux systems that will be used Obtain a micro-sd card that is at least 8 GB. You will also need an appropriate reader so that you can interface with the lab computers. Obtain the DE1_SoC_MTL2_LXDE.img from the Terasic website. Burn Micro-SD card 1. Open up a terminal window. 2. First we need to delete all the partitions on the sd card that came from the factory. We are going to use the fdisk command to do this. First plug in your SD card and type: >> fdisk -l 3. Find your SD card. It should be something like sdb or sdc. Check the sizes to find which drive is yours. Remember how many partitions the drive has. This will be indicated by the number after the sd. So you might see DEVICE BOOT START END SECTORS TYPE /dev/sdb1 /dev/sdb2 /dev/sdb3 FAT16 FAT32 NTFS This means that the b device has 3 partitions 4. Now open up the program called disks. 5. Select the partitions and hit the - minus button to delete all the partitions until there is only 1 with free space on it. 6. Navigate to the folder containing the LXDE.img file using the cd command: >> cd path/of/de1_soc_mtl2_lxde.img
7. Use the dd command to burn the image file onto the sd card. 8. Now type: >> dd if=de1_soc_mtl2_lxde.img of=/dev/sdb bs=1m 9. Where sdb is sdb or sdc depending on your drive. 10. dd stands for data dump, if stands for input file, of stands for output file, bs stands for block size. 11. Wait. This might take a while. Load FPGA with sd card image 1. Put SD card into FPGA. 2. Make sure Mode Select is set to all zeros MSEL = 00000. 3. Press the power button. 4. If everything was done correctly the seven seg displays will all show 8 s after about 15 seconds. Two penguins will appear on the screen after about 30 seconds. Serial Monitoring of LXDE system 1. Open up a terminal window. 2. Type: >> screen /dev/ttyusb0 115200 3. You should then be inside shell window for the LXDE system. 4. To exit the shell press CTRL-a then \ then type yes and enter. 5. If there is ever an error about a detached screen. Find the screen session you want to end: >> screen -ls 6. Then end it. >> screen -X -S session# kill Using the LXDE system 1. Using this LXDE system should be very similar to the Ubuntu that you have in the lab. 2. The biggest difference is that you are the root user on the LXDE system. 3. Username: root 4. We need to add a password in order to use certain commands. Type: >> passwd 5. Then enter in your password twice. I suggest something short and easy to remember like rhody
Changing the MAC address 1. Because the hardware on the boards are uploaded from identical designs, the boards all have the same ip addresses. When the boards attempt to lease ip addresses they end up receiving the same one. 2. To fix this we are going to permanently change the mac address on the board. 3. Use the screen command to connect to the board. 4. type: vi /etc/network/interfaces 5. This will open up the interfaces configuration file. 6. In order to insert text press i then to save hit escape to get to the command line and type :wq and press enter. w is for write and q is for quit. 7. add the following lines underneath the existing 2 lines where XX corresponds to the mac address assigned to you: auto eth0 iface eth0 inet dhcp hwaddress ether 02:00:00:00:00:XX 8. save and quit the text editor. 9. reboot the device. 10. Use the ifconfig command to check that the mac address matches your assigned address: >> ifconfig grep HWaddr Checking for internet 1. Make sure the DE1SOC ethernet port is connected. 2. From terminal window on your desktop use the screen command to get a command line interface for the LXDE. 3. Use the ifconfig command to see if the LXDE system has an ip address. 4. Open up a terminal window and type: >> ifconfig grep inet addr: 5. The board s ip address should be the first result that comes up. Remember that address. Adding packages 1. In order to get certain functionality it is necessary to add packages to the LXDE system.
2. To do this we use the apt-get command which will look at your sources list for the package specified. Unfortunately the sources list is outdated and incorrect so we have to go in and amend the sources list. 3. First we will want to make a backup of the current sources list just in case something happens and we need it. It is good practice to do this when editing system files. Type: >> cd /etc/apt >> cp sources.list sources.list.bak 4. Now we want to edit the file. Type: >> vi sources.list 5. Change the deb and deb-src sources to look like this: deb http://old-releases.ubuntu.com/ubuntu quantal main universe deb-src http://old-releases.ubuntu.com/ubuntu quantal main universe 6. Now save and return to the command line using the same controls as in step 6 of Changing the MAC Address. 7. We must now update all the packages. Type: >> sudo apt-get update 8. Now we need to install a new package. For the next section we will need an openssh server so type: >> sudo apt-get install openssh-server --fix-missing 9. This will take a little while to finish. Connecting via ssh 1. Open a terminal window on your desktop and type: >> ssh root@ipaddress 2. You will be prompted for a password. Type it in and press enter 3. You should now see the same shell that you had using the screen command. 4. This will be very important for sending files to and from the board. 5. To exit the connection type: >> exit 6. If you get a warning that says that the remote host identification has changed remove the offending host key. This usually happens because you changed the OS or the ssh installation on the board (which is very possible given that we are messing around with that frequently). >> ssh-keygen -R desired.ip.address i. Where desired.ip.address is the address that you wish to connect to.
Install lighttpd and run demos 1. Install lighttpd on the board. >> sudo apt-get install lighttpd 2. We will be using CGI (common gateway interface). 3. Copy the cgi-bin folder from the lab0 folder to this path: /var/www/ this folder should contain some demo files >> scp -r path/of/cgi-bin root@ip.address:/var/www/ 4. Run the following commands. They have to do with permissions of the files: >> chmod u+s LEDMonitoringDemo.cgi >> chmod u+s bubbleleveldemo.cgi >> chmod u+s hardwarecontroldemo.cgi 5. Make a copy of the lighttpd.conf file on the board >> cd /etc/lighttpd >> cp lighttpd.conf lighttpd.conf.old 6. Copy lighttpd.conf from the lab0 folder to /etc/lighttpd/ 7. Restart the lighttpd server >> /etc/init.d/lighttpd restart 8. Using a web browser on a machine that is running on the same network, navigate to the address: http://board.ip/cgi-bin where board.ip is the ip address you found with ifconfig command. 9. Try using some of the demos.