Arm processor and linux

Создание образа Ubuntu для ARM «from scratch»

Когда разработка только начинается часто еще непонятно какие именно пакеты пойдут в целевую rootfs.

Иными словами хвататься за LFS, buildroot или yocto (или еще что-то) еще рано, а начинать уже нужно. Для богатых (у меня на пилотных образцах 4GB eMMC) есть выход раздать разработчикам дистрибутив, который позволит оперативно доставить что-то чего не хватает в данный момент, а затем мы всегда можем собрать списки пакетов и сформировать список для целевой rootfs.

Данная статья не несет в себе новизны и представляет из себя простую copy-paste инструкцию.

Цель статьи сборка Ubuntu rootfs для ARM борды (в моем случае на базе Colibri imx7d).

Сборка образа

Собираем целевой rootfs для тиражирования.

Распаковываем Ubuntu Base

Релиз выбираем сами исходя из необходимости и собственных предпочтений. Здесь я привел 20.

$ mkdir ubuntu20 $ cd ubuntu20 $ mkdir rootfs $ wget http://cdimage.ubuntu.com/ubuntu-base/releases/20.04/release/ubuntu-base-20.04-base-armhf.tar.gz $ tar xf ubuntu-base-20.04-base-armhf.tar.gz -C rootfs

Проверка поддержки BINFMT в ядре

Если у вас распространенный дистрибутив, то поддержка BINFMT_MISC есть и все настроено, если нет — то я уверен, что вы знаете как включить поддержку BINFMT в ядре.

Убедитесь, что BINFMT_MISC включено в ядре:

$ zcat /proc/config.gz | grep BINFMT CONFIG_BINFMT_ELF=y CONFIG_COMPAT_BINFMT_ELF=y CONFIG_BINFMT_SCRIPT=y CONFIG_BINFMT_MISC=y

Теперь надо проверить настройки:

$ ls /proc/sys/fs/binfmt_misc qemu-arm register status $ cat /proc/sys/fs/binfmt_misc/qemu-arm enabled interpreter /usr/bin/qemu-arm flags: OC offset 0 magic 7f454c4601010100000000000000000002002800 mask ffffffffffffff00fffffffffffffffffeffffff

Зарегистрировать вручную можно с помощью, например, вот этой инструкции.

Настройка qemu static arm

Теперь нам понадобится экземпляр qemu собранный статически.

$ wget http://ftp.debian.org/debian/pool/main/q/qemu/qemu-user-static_5.0-13_amd64.deb $ alient -t qemu-user-static_5.0-13_amd64.deb # путь в rootfs и имя исполняемого файла должно совпадать с /proc/sys/fs/binfmt_misc/qemu-arm $ mkdir qemu $ tar xf qemu-user-static-5.0.tgz -C qemu $ file qemu/usr/bin/qemu-arm-static qemu/usr/bin/qemu-arm-static: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=be45f9a321cccc5c139cc1991a4042907f9673b6, for GNU/Linux 3.2.0, stripped $ cp qemu/usr/bin/qemu-arm-static rootfs/usr/bin/qemu-arm $ file rootfs/usr/bin/qemu-arm rootfs/usr/bin/qemu-arm: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=be45f9a321cccc5c139cc1991a4042907f9673b6, for GNU/Linux 3.2.0, stripped

Chroot

#!/bin/bash function mnt() < echo "MOUNTING" sudo mount -t proc /proc $proc sudo mount --rbind /sys $sys sudo mount --make-rslave $sys sudo mount --rbind /dev $dev sudo mount --make-rslave $dev sudo mount -o bind /dev/pts $dev/pts sudo chroot $ > function umnt() < echo "UNMOUNTING" sudo umount $proc sudo umount $sys sudo umount $dev/pts sudo umount $dev > if [ "$1" == "-m" ] && [ -n "$2" ] ; then mnt $1 $2 elif [ "$1" == "-u" ] && [ -n "$2" ]; then umnt $1 $2 else echo "" echo "Either 1'st, 2'nd or both parameters were missing" echo "" echo "1'st parameter can be one of these: -m(mount) OR -u(umount)" echo "2'nd parameter is the full path of rootfs directory(with trailing '/')" echo "" echo "For example: ch-mount -m /media/sdcard/" echo "" echo 1st parameter : $ echo 2nd parameter : $ fi

Любуемся на полученный результат:

$ ./ch-mount.sh -m rootfs/ # cat /etc/os-release NAME="Ubuntu" VERSION="20.04 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04 LTS" VERSION_ID="20.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=focal UBUNTU_CODENAME=focal # uname -a Linux NShubin 5.5.9-gentoo-x86_64 #1 SMP PREEMPT Mon Mar 16 14:34:52 MSK 2020 armv7l armv7l armv7l GNU/Linux

Ради интереса замерим размер до и после установки минимального (для меня) набора пакетов:

# apt update # apt upgrade --yes

Установим интересующие нас пакеты:

# SYSTEMD_IGNORE_CHROOT=yes apt install --yes autoconf kmod socat ifupdown ethtool iputils-ping net-tools ssh g++ iproute2 dhcpcd5 incron ser2net udev systemd gcc minicom vim cmake make mtd-utils util-linux git strace gdb libiio-dev iiod

Заголовочные файлы ядра, модули, это отдельный разговор. Загрузчик, ядро, модули, device tree через Ubuntu мы конечно же не поставим. Они придут к нам извне или сами соберем или нам их выдаст производитель борды, в любом случае это за гранью данной инструкции.

Читайте также:  Создать системного пользователя linux

До какой-то степени расхождение версий допустимо, но лучше взять их со сборки ядра.

# apt install --yes linux-headers-generic

Смотрим, что получилось и получилось немало:

# apt clean # du -d 0 -h / 2>/dev/null 770M /

Не забудьте задать пароль.

Пакуем образ

$ sudo tar -C rootfs --transform "s|^./||" --numeric-owner --owner=0 --group=0 -c ./ | tar --delete ./ | gzip > rootfs.tar.gz

Дополнительно можем поставить etckeeper с настройкой autopush

Ну допустим раздали мы нашу сборку, работа пошла, как лучше собрать потом различные версии нашей системы.

На помощь нам может прийти etckeeper.

  • можете защитить определённые ветки
  • генерировать уникальный ключ для каждого устройства
  • запретить force push
  • и т.д. .
# ssh-keygen # apt install etckeeper # etckeeper init # cd /etc # git remote add origin . 

Настроим autopush

Можем конечно заранее же создать ветки на устройстве (допустим сделать скрипт или службу, которая отработает при первом запуске).

# cat /etc/etckeeper/etckeeper.conf PUSH_REMOTE="origin"

Ленивый путь

Пусть у нас будет какой-то уникальный идентификатор, допустим серийный номер процессора (ну или MAC — серьезные компании покупают диапазон):

# cat /proc/cpuinfo processor : 0 model name : ARMv7 Processor rev 5 (v7l) BogoMIPS : 60.36 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xc07 CPU revision : 5 processor : 1 model name : ARMv7 Processor rev 5 (v7l) BogoMIPS : 60.36 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xc07 CPU revision : 5 Hardware : Freescale i.MX7 Dual (Device Tree) Revision : 0000 Serial : 06372509

Тогда мы можем использовать его для имени ветки в которую будем пушить:

# cat /proc/cpuinfo | grep Serial | cut -d':' -f 2 | tr -d [:blank:] 06372509
# cat /etc/etckeeper/commit.d/40myown-push #!/bin/sh set -e if [ "$VCS" = git ] && [ -d .git ]; then branch=$(cat /proc/cpuinfo | grep Serial | cut -d':' -f 2 | tr -d [:blank:]) cd /etc/ git push origin master:$ fi

И всё — через некоторое время можем посмотреть изменения и сформировать список пакетов для целевой прошивки.

Читайте также:  Линукс минт два монитора

Источник

4 of the Best Linux Distributions You Can Run on ARM Devices

Day by day, ARM devices get more and more popular, especially in the world of Linux. Years ago ARM just meant the Raspberry Pi. Now it means a host of devices: hobby boards like the Pi, servers, compact desktop computers and even laptops!

That is why we have decided to make a list and discuss what the best Linux operating systems for ARM devices are. Each operating system has its negatives and positives. Which one should you use? Let’s find out!

1. Arch Linux ARM

linux-arm-arch-linux-arm

Perhaps the most dedicated ARM Linux distribution project out there, Arch Linux ARM, aims to bring Linux to all sorts of ARM-based devices. Arch for ARM supports multiple different ARM releases, from ARM v5 to v8 with dozens of device-specific images.

The real benefit of using Arch Linux for ARM circles back to the reason Arch Linux proper is such a good choice: the Arch Linux User Repository. This is because a lot of programs in the AUR are set up to compile from scratch, meaning that for a lot of situations users will not need to rely on packages being ported, as most AUR programs can be ported to ARM by themselves easily.

2. Debian on ARM

linux-arm-debian-on-arm

Out of all the different types of Linux out there, you’ll find few reliable. This is why Debian has a home on many Linux servers, desktops, laptops and now even your favorite ARM computer, and comes with three separate releases: ARM EABI for old 32-bit devices, ARM hard-float for newer 32-bit devices, and a 64-bit ARM port for modern devices.

Читайте также:  Печать штрих кодов linux

For those looking for a stable and reliable basis for a Raspberry Pi 3-powered home theater or Beaglebone Black ARM desktop, the Debian project may be a good place to start!

3. Manjaro ARM

linux-arm-manjaro-arm

Those who are unfamiliar with Manjaro, listen up: it’s a Linux distribution that takes the technological strength of Arch Linux and combines it with steady and stable updates, effectively turning Manjaro into a Ubuntu or Debian distro based on Arch Linux.

On ARM Manjaro’s mission is the same. Bring great Arch Linux features, but add in stability. The Manjaro ARM project does a good job at this, though at this time only supports the Raspberry Pi3 and 2. More devices like the Pi Zero and Odroid C1 (and 2) are under development.

4. Chromium OS

linux-arm-chromium-os

The best Linux distribution for ARM-based Laptops and ARM-based microcomputers doesn’t come from the Linux community. Instead, it comes (in part) from Google. Chromium OS is the open-source implementation of Google’s Chrome OS for Laptops, dongles and desktops.

Chromium OS isn’t full Linux, and when users log into it they’ll find out that the experience is essentially what users can expect on a Chromebook: a web browser, support for Chrome-based apps, and other basic tools like MP3 and video playback.

In a world where most of the technology on the Web is moving away from flash, this open-source operating makes sense, even on ARM devices. Chromium OS doesn’t have any specific builds for specific devices, but images exist for use on ARM devices here.

Conclusion

ARM is a growing competitor to the standard PC architecture and is here to stay. As more and more people go mobile or decide to indulge in small, hobbyist boards, ARM will continue to flourish. As this trend continues, we can only hope that development for high-class Linux distributions will continue as well. For now, the choices on this list are a great start.

Derrik Diener is a freelance technology blogger.

Источник

Оцените статью
Adblock
detector