Инструменты пользователя

Инструменты сайта


orange_pi_one

Это старая версия документа.


Orange Pi One

Ссылки

Установка и настройка ArchLinux

Введение

Далее приводится руководство по установке 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

Установка ARM Toolchain и настройка окружения

Скачиваем 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

Затем настраиваем окружение, в котором далее будет выполняться сборка загрузчика U-Boot и ядра:

export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
export PATH=/opt/gcc-linaro/bin:$PATH

После этого в командах make уже не нужно указывать архитектуру и тип кросс-компиляции.

Подготовка SD-карты

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

Official ArchLinuxARM Image download

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)

Сборка ядра

Получение исходного кода

Вариант 1. Репозиторий jwrdegoede/linux-sunxi

Загружаем исходный код:

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).

Вариант 2. Репозиторий linux-sunxi/linux-sunxi
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.

Выбираем базовый конфигурационный файл для сборки ядра:

make sunxi_defconfig

Для более тонкой настройки запускаем конфигурацию через меню:

make menuconfig

Выбираем поддержку framebuffer:

  1. Device Drivers —> Graphics support —> Frame buffer Devices, отмечаем Support for frame buffer devices,
  2. здесь же выбираем Simple framebuffer support.
  3. Device Drivers —> Graphics support —> Console display driver support, отмечаем Framebuffer Console support.

Отключаем поддержку других SoC:

  1. System type —> Allwinner SoCs —> оставить только Allwinner sun8i Family SoCs support.
  2. Device Drivers —> Graphics support —> убрать DRM Support for Allwinner A10 Display Engine.

Далее для включения драйвера 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-карту

Предполагаем, что точка монтирования 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/* ArchARM/boot/dtbs/
cp -R linux/output/lib/ ArchARM/usr/
cp -R linux/output/usr/ ArchARM/

Сборка загрузчика U-Boot

Скачать исходный код загрузчика с 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.

Установка загрузчика U-Boot

Внимание: перед установкой нового загрузчика обязательно выполнить очистку первых 2048 секторов SD-карты! После очистки заново запустить fdisk и создать таблицу разделов. Создавать сам раздел уже не надо!

Download U-boot boot.txt and run:

Создать сценарий для загрузчика boot.cmd с содержимым:

part uuid ${devtype} ${devnum}:${bootpart} uuid
setenv bootargs console=${console} console=tty1 disp.screen0_output_mode=vga root=PARTUUID=${uuid} rw rootwait

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

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.

orange_pi_one.1502203273.txt.gz · Последние изменения: 2017/08/08 17:41 — reug