Далее приводится руководство по установке ArchLinux ARM на плату Orange Pi One. Большая часть материала взята отсюда: https://www.amedeobaragiola.me/blog/2016/06/04/archlinux-arm-on-orange-pi-one/.
Note: As of 27/11/2016 the mainline kernel included in the ArchLinux ARM Image supports ethernet and USB. Please use the following image: ArchLinuxARM-armv7-latest.tar.gz
I recently found out about this new SoC board called Orange Pi that you can easily buy on Aliexpress for just 9 Euros. While the hardware is great for the price, featuring a Quad-Core Allwinner H3 CPU capable of showing 4K videos seamlessly, the software support is terrible as expected.
Let’s start by saying that there’s no official support within the Linux Mainline kernel; our Orange Pi can boot, but there’s no Ethernet & USB drivers making this little board quite useless.
The kernel provided by Allwinner is extremely outdated (3.4) and doesn’t support systemd. (Hence it can’t boot Archlinux ARM)
Currently the only stable OS is armbian, http://www.armbian.com/, by third-party community users.
My goal here is to boot ArchLinux ARM on the board with proper working Ethernet & USB. To do so I’ve chosen this kernel: https://github.com/jwrdegoede/linux-sunxi.git
Скачиваем linaro toolchain с этого адреса
https://releases.linaro.org/components/toolchain/binaries/latest-5/arm-linux-gnueabihf/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz и распаковываем, например, в каталог /opt/
.
Далее можно поставить символьную ссылку, чтобы корневой путь toolchain был удобным:
ln -s gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf /opt/gcc-linaro
Примечание: данная сборка имеет множество повторяющихся файлов. Данный скрипт освободит 137 Мбайт. Запускать из каталога gcc-linaro.
cd bin rm arm-linux-gnueabihf-c++ ln -s arm-linux-gnueabihf-g++ arm-linux-gnueabihf-c++ rm arm-linux-gnueabihf-gcc ln -s arm-linux-gnueabihf-gcc-6.3.1 arm-linux-gnueabihf-gcc rm arm-linux-gnueabihf-ld ln -s arm-linux-gnueabihf-ld.bfd arm-linux-gnueabihf-ld cd .. cd arm-linux-gnueabihf rm -r lib ln -s libc/lib lib rm bin/* for t in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib readelf strip do ln -s ../../bin/arm-linux-gnueabihf-$t bin/$t done rm libc/usr/libexec/getconf/* for t in POSIX_V6_ILP32_OFF32 POSIX_V6_ILP32_OFFBIG POSIX_V7_ILP32_OFF32 POSIX_V7_ILP32_OFFBIG XBS5_ILP32_OFF32 XBS5_ILP32_OFFBIG do ln -s ../../bin/getconf libc/usr/libexec/getconf/$t done cd .. cd share/man/man1 rm arm-linux-gnueabihf-g++.1 ln -s arm-linux-gnueabihf-gcc.1 arm-linux-gnueabihf-g++.1
Затем настраиваем окружение, в котором далее будет выполняться сборка загрузчика U-Boot и ядра:
export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabihf- export PATH=/opt/gcc-linaro/bin:$PATH
После этого в командах make
уже не нужно указывать архитектуру и тип кросс-компиляции.
First of all clear everything out:
dd if=/dev/zero of=/dev/sdX bs=1M count=8
Then run fdisk and create a new partition starting from 2048 & format it:
fdisk /dev/sdX mkfs.ext4 /dev/sdX1
wget http://archlinuxarm.org/os/ArchLinuxARM-armv7-latest.tar.gz
Now mount the SD Card ext4 partition and extract the official image inside: (The following commands may require root privileges!)
mkdir ArchARM mount /dev/sdX1 ArchARM bsdtar -zxvf ArchLinuxARM-armv7-latest.tar.gz -C ArchARM sync
You should now have a folder called linux with the kernel in it and another one called ArchARM mounted on the SD card partition 1. (Rename the kernel folder accordingly)
Загружаем исходный код:
git clone -b v4.12-footrail --depth 1 https://github.com/jwrdegoede/linux-sunxi.git # old: git clone –single-branch -b sunxi-wip https://github.com/jwrdegoede/linux-sunxi.git
В данном варианте не заработал сетевой адаптер (2017-08-03).
git clone git://github.com/linux-sunxi/linux-sunxi.git -b sunxi-next --depth=1
В данном варианте сеть работает сразу.
Далее все действия выполняются в корневом каталоге исходного кода linux-sunxi
.
It’s necessary to edit the kernel config file to enable emac ethernet support.
Для поддержки Ethernet emac в файле arch/arm/configs/sunxi_defconfig
добавить в конец строку:
CONFIG_SUN8I_EMAC=y
или же поставить нижеуказанный патч, в котором это учтено. Однако полезность данной опции сомнительна.
Накладываем на ядро патч, который добавляет framebuffer в device tree для H3 (http://orangepi.pp.ua/index.php/topic,406.15.html?PHPSESSID=32008a926e97c20dd94bbaa03a46789d). Патч, адаптированный для linux-sunxi-next 4.13.0-rc3 можно сразу взять здесь: sun8i-h3_reug.patch.gz. Далее:
patch -p1 < sun8i-h3_reug.patch
Имеется еще один патч https://patchwork.kernel.org/patch/9390817/, который может будет полезен для других плат на базе Allwinner H3.
Включаем встроенные в SoC UART1 и UART2 при необходимости (аналогично с UART3). Для этого в файле
arch/arm/boot/dts/sun8i-h3-orangepi-one.dts
в секциях настройки &uart1
и &uart2
исправляем status
с disabled
на okay
:
&uart1 { pinctrl-names = "default"; pinctrl-0 = <&uart1_pins>; status = "okay"; }; &uart2 { pinctrl-names = "default"; pinctrl-0 = <&uart2_pins>; status = "okay"; };
После загрузки системы данные порты будут видны как /dev/ttyS1
и /dev/ttyS2
соответственно.
Порт UART0 /dev/ttyS0
- консоль управления, выводы которой (GND,TX,RX) выведены на плате отдельно около разъема RJ-45. Расположение выводов UART1 и UART2 см. на схеме ниже.
Описание конкретных выводов для портов указано в файле arch/arm/boot/dts/sunxi-h3-h5.dtsi
, который должен помочь на случай необходимости использования RTS/CTS.
Выбираем базовый конфигурационный файл для сборки ядра:
make sunxi_defconfig
Для более тонкой настройки запускаем конфигурацию через меню:
make menuconfig
Отключаем поддержку initramfs:
General setup
—> Initial RAM filesystem and RAM disk (initramfs/initrd) support
убираем.Выбираем поддержку framebuffer:
Device Drivers
—> Graphics support
—> Frame buffer Devices
, отмечаем Support for frame buffer devices
,Simple framebuffer support
.Device Drivers
—> Graphics support
—> Console display driver support
, отмечаем Framebuffer Console support
.Отключаем поддержку других SoC:
System type
—> Allwinner SoCs
—> оставить только Allwinner sun8i Family SoCs support
.Device Drivers
—> Graphics support
—> убрать DRM Support for Allwinner A10 Display Engine
.
Включаем поддержку USB-периферии в меню Device Drivers
—> USB support
:
[*] OTG support <M> USB Modem (CDC ACM) support <*> USB Mass Storage support <*> USB Serial Converter support ---> [*] USB Serial Console device support [*] USB Generic Serial Driver <M> USB Serial Simple Driver <M> USB Belkin and Peracom Single Port Serial Driver <M> USB Winchiphead CH341 Single Port Serial Driver <M> USB CP210x family of UART Bridge Controllers <M> USB FTDI Single Port Serial Driver <M> USB Prolific 2303 Single Port Serial Driver <M> USB driver for GSM and CDMA modems
Далее для включения драйвера framebuffer в аргументах ядра (см. файл boot.cmd
) нужно будет указать console=tty1
.
Собственно компиляция:
make -j4 zImage dtbs modules make INSTALL_MOD_PATH=output modules_install make INSTALL_MOD_PATH=output firmware_install make INSTALL_MOD_PATH=output headers_install INSTALL_HDR_PATH=output/usr
Замечание: Опцию make -j4 установить в зависимости от числа ядер ЦПУ хост-машины.
Предполагаем, что точка монтирования SD-карты ArchARM
.
#Cleaning up rm -r ArchARM/boot/zImage rm ArchARM/boot/dtbs/* #Copying cp -R linux/arch/arm/boot/zImage ArchARM/boot/ cp -R linux/arch/arm/boot/dts/sun8i-h3*.dtb ArchARM/boot/dtbs/ cp -R linux/output/lib/ ArchARM/usr/ cp -R linux/output/usr/ ArchARM/
Скачать исходный код загрузчика с ftp://ftp.denx.de/pub/u-boot/. В данном примере использована версия 2017-09-rc1. Для сборки образа загрузчика также может понадобится установить пакет python-devel.
Для поддержки видео выхода HDMI через framebuffer в Linux необходимо применить патч. (http://orangepi.pp.ua/index.php/topic,406.15.html) Скачиваем патч отсюда: https://github.com/Icenowy/u-boot/commit/315edb971fa05d80fd0f17190406125f7455dc96.patch Далее применяем патч из корневого каталога исходников U-Boot:
git apply 315edb971fa05d80fd0f17190406125f7455dc96.patch
или так, если не было git-репозитория:
patch -p1 < 315edb971fa05d80fd0f17190406125f7455dc96.patch
Сборка с настройкой PATH и указанием архитектуры:
Сборка загрузчика U-Boot:
make -j4 orangepi_one_defconfig make -j4 all
После успешной сборки в корневом каталоге исходников будет сам загрузчик u-boot-sunxi-with-spl.bin
.
Внимание: перед установкой нового загрузчика обязательно выполнить очистку первых 2048 секторов SD-карты!
После очистки заново запустить fdisk
и создать таблицу разделов. Создавать сам раздел уже не надо!
Download U-boot boot.txt and run:
Создать сценарий для загрузчика boot.cmd
с содержимым:
part uuid ${devtype} ${devnum}:${bootpart} uuid setenv bootargs console=${console} console=tty1 hdmi.audio=EDID:0 disp.screen0_output_mode=1280x1024p60 root=PARTUUID=${uuid} consoleblank=0 rw rootwait setenv stdout serial,video setenv stderr serial,video if load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /boot/zImage; then if load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /boot/dtbs/${fdtfile}; then if load ${devtype} ${devnum}:${bootpart} ${ramdisk_addr_r} /boot/initramfs-linux.img; then bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}; else bootz ${kernel_addr_r} - ${fdt_addr_r}; fi; fi; fi
Скомпилировать сценарий в файл boot.scr
:
mkimage -A arm -O linux -T script -C none -n "Orange Pi One boot script" -d boot.cmd boot.scr
Copy the output file boot.scr
to the SD Card /boot
directory.
Now unmount your SD Card partition with:
umount /dev/sdX1
And dd u-boot after the partition table:
dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8
Enjoy your new Orange Pi board!
Some stuff taken from: http://www.orangepi.org/orangepibbsen/forum.php?mod=viewthread&tid=845
Чтобы исключить сообщения при загрузке типа
*** Warning - bad CRC, using default environment
нужно один раз остановить загрузку U-Boot и дать команду
saveenv
U-Boot SPL 2017.09-rc1 (Aug 07 2017 - 18:58:33) DRAM: 512 MiB Trying to boot from MMC1 U-Boot 2017.09-rc1 (Aug 07 2017 - 18:58:33 +0300) Allwinner Technology CPU: Allwinner H3 (SUN8I 1680) Model: Xunlong Orange Pi One DRAM: 512 MiB MMC: SUNXI SD/MMC: 0 In: serial Out: vidconsole Err: vidconsole Net: phy interface0 eth0: ethernet@1c30000 starting USB... USB0: USB EHCI 1.00 USB1: USB OHCI 1.0 scanning bus 0 for devices... 1 USB Device(s) found scanning bus 1 for devices... 2 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Hit any key to stop autoboot: 0
CPU Core frequency adjusting in U-Boot
Run make menuconfig:
Boot Images —> CPU Clock frequency
Default should be 1080 (Mhz); I lowered it to 816 Mhz
Voltage Regulator SY8113B patch
The following enables the On-Board Voltage regulator which can switch the Core voltage between 1.1V and 1.3V (Should NEVER exceed 1.5V)
Patch here: https://patchwork.kernel.org/patch/9198383/ download and save as patch.diff in linux/arch/arm/boot/dts. Then run:
patch < patch.diff
Check that our SY8113B is working by checking the 1V2C voltage point on the PCB (near the main processor). It should read 1.1V for frequencies ⇐ 816 Mhz
Be aware that as of right now no CPU scaling is implemented in the mainline kernel, so the U-boot clock speed is used instead.
GPIO C Library
This works: https://github.com/zhaolei/WiringOP | gpio readall to list GPIO Layout. | No PWM support
My Kernel Config (archlinuxarm-linux-v7 based): Download
Thanks to tekdoc.
Удаление ядра ArchLinux и прошивок. После удаления нужно заново скопировать на SD-карту ядро zImage и файлы /boot/dtbs/*.
pacman -R linux-armv7 linux-firmware mkinitcpio mkinitcpio-busybox
Удаление оставшихся файлов:
rm -R /usr/lib/firmware/
Удаление ненужных локалей:
pacman -S localepurge
Закомментировать в /etc/locale.nopurge NEEDSCONFIGFIRST, затем:
localepurge
Установить пакет sunxi-tools
.
Включение и выключение светодиода «Status» (от рута):
sunxi-pio -m PA15=1 sunxi-pio -m PA15=0