This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
hw:zynq:linux:petalinux:rootfs [2019/03/29 12:26] jakub.moron |
hw:zynq:linux:petalinux:rootfs [2022/03/09 10:30] (current) jakub.moron |
||
---|---|---|---|
Line 4: | Line 4: | ||
qemu-user-static debootstrap binfmt-support </code> | qemu-user-static debootstrap binfmt-support </code> | ||
- Setup enviroment: <code> | - Setup enviroment: <code> | ||
- | export targetdir=rootfs | + | export targetdir=rootfs</code>For Debian 9:<code> |
- | export distro=stretch | + | export distro=stretch </code>Or for Debian 10:<code> |
- | mkdir $targetdir | + | export distro=buster </code>Or for Debian 11:<code> |
- | </code> | + | export distro=bullseye</code><code> |
+ | sudo mkdir $targetdir | ||
+ | </code> Ensure that $targetdir is owned by root:root. | ||
- Build the root file system: download the needed .deb packages and unpack it into ''$targetdir'': <code> | - Build the root file system: download the needed .deb packages and unpack it into ''$targetdir'': <code> | ||
sudo debootstrap --arch=armhf --foreign $distro $targetdir | sudo debootstrap --arch=armhf --foreign $distro $targetdir | ||
Line 14: | Line 16: | ||
sudo chroot $targetdir | sudo chroot $targetdir | ||
</code> | </code> | ||
- | - Configure and install the root filesystem by running the .deb configuration scripts inside the emulated ''armhf'' architecture (this is why ''qemu-arm-static'' is needed) <code> | + | - Configure and install the root filesystem by running the .deb configuration scripts inside the emulated ''armhf'' architecture (this is why ''qemu-arm-static'' is needed). For Debian 9:<code> |
- | export distro=stretch | + | export distro=stretch </code>Or for Debian 10:<code> |
+ | export distro=buster </code>Or for Debian 11:<code> | ||
+ | export distro=bullseye</code><code> | ||
export LANG=C | export LANG=C | ||
/debootstrap/debootstrap --second-stage | /debootstrap/debootstrap --second-stage | ||
</code> | </code> | ||
- | - Setup APT: <code> | + | - Setup APT: For Debian 11: <code> |
+ | cat << EOT > /etc/apt/sources.list | ||
+ | deb http://ftp.ch.debian.org/debian/ $distro main contrib non-free | ||
+ | deb-src http://ftp.ch.debian.org/debian/ $distro main contrib non-free | ||
+ | deb http://security.debian.org/debian-security $distro-security main contrib non-free | ||
+ | deb-src http://security.debian.org/debian-security $distro-security main contrib non-free | ||
+ | deb http://ftp.ch.debian.org/debian/ $distro-updates main contrib non-free | ||
+ | deb-src http://ftp.ch.debian.org/debian/ $distro-updates main contrib non-free | ||
+ | EOT | ||
+ | </code> For older Debian: <code> | ||
cat << EOT > /etc/apt/sources.list | cat << EOT > /etc/apt/sources.list | ||
deb http://ftp.ch.debian.org/debian/ $distro main contrib non-free | deb http://ftp.ch.debian.org/debian/ $distro main contrib non-free | ||
Line 38: | Line 51: | ||
apt install locales dialog | apt install locales dialog | ||
dpkg-reconfigure locales | dpkg-reconfigure locales | ||
- | apt install openssh-server ntpdate resolvconf sudo less hwinfo ntp tcsh zsh vim | + | apt install openssh-server ntpdate resolvconf sudo less hwinfo ntp tcsh zsh vim |
</code> | </code> | ||
- Set root password: <code> | - Set root password: <code> | ||
passwd | passwd | ||
</code> | </code> | ||
+ | - Install really required packages (if you want to use non-static address): <code> | ||
+ | apt install net-tools isc-dhcp-client | ||
+ | </code> | ||
+ | - Install anything you need and customize your system. Some useful set: <code> | ||
+ | apt install build-essential bash-completion time python python-pip python3 python3-pip i2c-tools gcc g++ | ||
+ | </code> | ||
+ | - In order to auto-close ssh session on powerdown, install: <code> | ||
+ | apt install libpam-systemd dbus | ||
+ | </code> and check if ''UsePAM yes'' is set in ''/etc/ssh/sshd_config'' | ||
- Configure interfaces: \\ -- assign fixed address: <code> | - Configure interfaces: \\ -- assign fixed address: <code> | ||
cat << EOT > /etc/network/interfaces.d/interface | cat << EOT > /etc/network/interfaces.d/interface | ||
Line 62: | Line 84: | ||
EOT | EOT | ||
</code> <code> | </code> <code> | ||
- | cat << EOT >> /etc/resolv.conf | + | cat << EOT > /etc/resolv.conf |
EOT | EOT | ||
</code> | </code> | ||
Line 84: | Line 106: | ||
- Set debug UART console: <code> | - Set debug UART console: <code> | ||
echo T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt1000 >> /etc/inittab | echo T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt1000 >> /etc/inittab | ||
- | </code> | ||
- | - Install really required packages (if you want to use non-static address): <code> | ||
- | apt install net-tools isc-dhcp-client | ||
- | </code> | ||
- | - Install anything you need and customize your system. Some useful set: <code> | ||
- | apt install build-essential bash-completion time python python-pip | ||
</code> | </code> | ||
- Install kernel modules build by PetaLinux: \\ **From different console:** <code> | - Install kernel modules build by PetaLinux: \\ **From different console:** <code> | ||
cd <boot_project_path>/<boot_project_name> | cd <boot_project_path>/<boot_project_name> | ||
sudo tar xvfp build/tmp/deploy/images/plnx-zynq7/modules-plnx-zynq7.tgz -C <rootfs_project_path> | sudo tar xvfp build/tmp/deploy/images/plnx-zynq7/modules-plnx-zynq7.tgz -C <rootfs_project_path> | ||
- | </code> The ''<rootfs_project_path>'' __should point at the root of the rootfs__, i.e. at ''$targetdir''. \\ Please __notice__ that the modules file may have different name depending on the architecture.\\ \\ **In the ''chroot'' enviroment:** <code> | + | </code> or <code> |
+ | sudo tar xvfp build/tmp/deploy/images/zynq-generic/modules-zynq-generic.tgz -C <rootfs_project_path> | ||
+ | </code> The ''<rootfs_project_path>'' __should point at the root of the rootfs__, i.e. at ''$targetdir''. \\ Please __notice__ that the modules file may have different name depending on the architecture.\\ \\ **In the ''chroot'' enviroment -- petalinux 2018.3:** <code> | ||
chown -R root:root /lib | chown -R root:root /lib | ||
mv /lib/modules/4.14.0-xilinx-v2018.3/ /lib/modules/`uname -r`/ | mv /lib/modules/4.14.0-xilinx-v2018.3/ /lib/modules/`uname -r`/ | ||
depmod | depmod | ||
+ | mv /lib/modules/`uname -r`/ /lib/modules/4.14.0-xilinx-v2018.3/ | ||
+ | </code>\\ **In the ''chroot'' enviroment -- petalinux 2020.2:** <code> | ||
+ | chown -R root:root /lib | ||
+ | mv /lib/modules/5.4.0-xilinx-v2020.2/ /lib/modules/`uname -r`/ | ||
+ | depmod | ||
+ | mv /lib/modules/`uname -r`/ /lib/modules/5.4.0-xilinx-v2020.2/ | ||
+ | </code> | ||
+ | - Load module for generic UIO with altered ''compatible'' property: <code> | ||
+ | cat << EOT > /etc/modules-load.d/uio_pdrv_genirq.conf | ||
+ | uio_pdrv_genirq | ||
+ | EOT | ||
+ | </code><code> | ||
+ | cat << EOT > /etc/modprobe.d/uio_pdrv_genirq.conf | ||
+ | options uio_pdrv_genirq of_id=generic-uio | ||
+ | EOT | ||
+ | </code> | ||
+ | - Create group ''uio_user'' (or any other name you want) and add user to it: <code> | ||
+ | groupadd uio_user | ||
+ | usermod -a -G uio_user <username> | ||
+ | </code> | ||
+ | - Make ''/dev/uio*'' devices accessible for group ''uio_user'': <code> | ||
+ | cat << EOT > /etc/udev/rules.d/90-uio.rules | ||
+ | SUBSYSTEM=="uio", KERNEL=="uio[0-9]*", GROUP="uio_user", MODE="0660" | ||
+ | EOT | ||
</code> | </code> | ||
+ | - Make ''i2c-tools'' command available for the user <code> | ||
+ | usermod -a -G i2c <username> | ||
+ | </code> and add path to ''/usr/sbin'' to user ''.bashrc'' | ||
- Exit and cleanup: <code> | - Exit and cleanup: <code> | ||
exit | exit | ||
Line 107: | Line 152: | ||
sudo cp /usr/bin/qemu-arm-static $targetdir/usr/bin | sudo cp /usr/bin/qemu-arm-static $targetdir/usr/bin | ||
sudo chroot $targetdir | sudo chroot $targetdir | ||
+ | </code> Debian 10 - ''qemu-arm-static'' comes from ''qemu-user-static'' package. \\ In case of network problems: <code> | ||
+ | echo "nameserver 8.8.8.8" > /etc/resolv.conf | ||
</code> Do what you need and <code> | </code> Do what you need and <code> | ||
exit | exit |