-
Notifications
You must be signed in to change notification settings - Fork 2
Root file system
This section describes how to build a root file system with Debian for an armhf platform.
- Debian: To create a debian root file system, you need a Debian. A fresh installed virtual machine is enough.
- su(do): We will do fancy things, so you will need super user rights on our Debian. The following steps will use sudo.
- Packages: debootstrap qemu-system-arm binfmt-support qemu-user-static
The following command will create a root file system based on Debian 9 (stretch). To use newer versions of Debian, change stretch to the corresponding name.
sudo debootstrap --arch=armhf --verbose --include=net-tools --foreign stretch rootfs
Here are already many packages installed after creating the root file system. If something is missing, it can be included using --include=A,B,C. It is also possible to exclude packages using --exclude=A,B,C. For more details use --help.
After this first step, we need chroot to mount our fresh rootfs:
sudo cp /usr/bin/qemu-arm-static rootfs/usr/bin
sudo chroot rootfs/ /bin/bash
Now we use debootstrap again to finish our root file system:
su
/debootstrap/debootstrap --second-stage
Before we can use the new created file system, we need to make some configurations. All these configurations need to be done inside the chroot environment which we used before.
To add a password to the root account of this file system, use the following command.
passwd
If you want to access this linux system via LAN, it is helpful to give it a customized hostname. To do this you need to change its name inside the file /etc/hostname.
Additionally you can add this short name to localhost in /etc/hosts:
127.0.0.1 localhost #add hostname here#
...
To be able to use your network connection at startup, you need to add the following lines to /etc/network/interfaces:
# enable virtual loopback adapter
auto lo
iface lo inet loopback
# enable eth0 with dhcp
auto eth0
iface eth0 inet dhcp
If you change the MAC address of your ethernet phy, Linux will probably add a new controller configuration named eth1. In this scenario eth0 with the old MAC address is will be gone forever. So it would be helpful to rename eth1 to eth0 and simply forget the old eth0. To do this open /etc/udev/rules.d/70-persistent-net.rules. Delete the old eth0 configuration and rename eth1 to eth0.
ZYNQBERRY SPECIAL: The LAN port of the zynqberry is not connected to the zynq peripherals but to an external USB-IC LAN9514. Thus, the network connection is named enx00800f117000.
If no dhcp server is available a specified ip address should be used to make sure that a connection can be garanteed. Therefore please append the following lines to /etc/dhcp/dhclient.conf:
lease {
interface "enx00800f117000";
fixed-address 192.168.0.200;
medium "link0 link1";
option host-name "zynqberry";
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.0.255;
renew 2 2200/1/12 00:00:01;
rebind 2 2200/1/12 00:00:01;
expire 2 2200/1/12 00:00:01;
}
If you want to use PS_UART0 or PS_UART1 as tty console, you need to make some modifications.
Add the following lines to /etc/securetty:
# Zynq's UARTs
ttyPS0
ttyPS1
Create files /etc/init/ttyPS0 and /etc/init/ttyPS1 and add the following content for ttyPS0:
# ttyPS0 - getty
#
# This service maintains a getty on ttyPS0 from the point the system is
# started until it is shut down again.
start on stopped rc RUNLEVEL=[2345] and (
not-container or
container CONTAINER=lxc or
container CONTAINER=lxc-libvirt)
stop on runlevel [!2345]
respawn
exec /sbin/getty -L -8 115200 ttyPS0
You need to change ttyPS0 to ttyPS1 to get the other file. Of course you can change the RS232 configuration.
To leave this chroot environment, use the exit command.
Use the following command to build a compressed file container:
sudo tar -zcvf filesystem.tar.gz -C rootfs ./
The following things can be executed directly on the target platform
Use the following command to update the package manager:
apt-get update
Install the git packages that you are able to clone necessary repositories:
apt-get install git
Install the ssh package:
apt-get install ssh
To be able to use to ssh connection with the root user go to /etc/ssh/sshd_config and uncomment the following line:
PermitRootLogin yes
Restart the ssh service:
/etc/init.d/ssh restart
The webserver configuration can be done directly on the Zynqberry. Use the following command to install all needed packages:
apt-get install lighttpd php-cgi perl
After installation configure the webserver to use php:
lighty-enable-mod fastcgi
lighty-enable-mod fastcgi-php
The www-data user needs sudo rights to be able to change our hardware. So we need to install sudo:
apt-get install sudo
Add the user www-data to sudoers-list:
adduser www-data sudo
Change the sudo rules to allow www-data to use sudo without password authentication. Use visudo and change the the line to:
%sudo ALL=(ALL:ALL) NOPASSWD: ALL
Restart your system here
We need to create a folder in which all bitstreams are loaded:
mkdir /lib/firmware
chmod a+w /lib/firmware
We need to create a folder to mount the configfs:
mkdir /config