au Qua Station - Part 4 - Kernel Build and install
Although the Qua station is based on Linux, the factory firmware uses Android for some reason. This is the first headless Android system I have seen in the wild. Android is also not really designed for CLI use, and the directory structure is... odd - so for most people it is much easier to set up a "normal" Linux distribution for daily use.
This Post (https://old.haruroid.com/haruroid.0t0.jp/blog/archives/1309.html) described an approach to use the existing kernel and run Debian on top of that using chroot. (Note; The link above does not work for me in Chrome, but it works in Safari). That technically works, but it is a bit dodgy.
The good thing about using the stock kernel from au is that it supports all of the LEDs and buttons, the bad thing is... everything else. For heavy use, it's probably better to install a native Linux system.
As for trying to use the stock au kernel binary/device tree with a normal distribution: It is easy enough to set up, and the kernel/device tree files can be extracted from the eMMC relatively easily in case you want to USB boot - but there is a watchdog function that keeps resetting the machine every 30 seconds.
Au/KDDI has released the source code to the kernel, but it is a 4.1.17 kernel. My attitude is that if it works, it works, so 4.1.17 is fine. On the other hand, if I have to compile anyway, I would rather use a newer kernel. Since the QuaStation has no built-in ethernet port (unusual for a NAS, no?), it is required to use a USB ethernet dongle. I can tell you from my testing the following dongles worked:
1. Apple MacBook Air USB ethernet dongle. (The original one that says on the package "Compatible only with Apple MacBook Air computers")
2. Nintendo WII ethernet dongle.
3. Some other generic ethernet dongle I found laying around.
But... none of these are USB 3 Gigabit Ethernet dongles, and since I intend to use these machines for major network traffic, that wouldn't do.
I found some dongles which were supposed to work well in Linux and tried them:
The Qua Station uses the same SoC as the Banana Pi W2. Sources are available for that machine for kernel 4.9, so that is a good place to start. (http://forum.banana-pi.org/t/bpi-w2-new-image-ubuntu-20-04-linux/12288)
I tried to use the kernel from the latest Banana Pi W2 Debian 20 server release as-is, but it did not work, so I had to recompile it with some configuration changes. (including some found here).
For that, I referred to the lovely guide available here: 【Qua station】 Linuxカーネルをビルドする – お部屋でモバイル
I saved copied of all of these files in case they suddenly become unavailable, so feel free to contact me if you can't find them.
Recompiling did not work on the Qua Station itself, with strange errors appearing. Instead, I compiled on my MacBook under Debian 20.
I was amazed when it compiled in less than a minute, since the poster mentioned that it took around an hour on his computer. This is probably more because I have 64GB of RAM and am using a fast SSD than it is because the i9 is that much faster than an i3.
Once the kernel is built, it can be booted from USB relatively easily.
You need to :
1. Create a FAT32 formatted USB drive.
2. Copy the device tree (dtb), linux kernel, and initrd files from wherever the build process dumps them into a folder on the USB drive. (I took a screen shot here so I would remember the names and path to enter in u-boot in order to load them).
I had to change some things, as my system recognized the internal eMMC as /dev/blkmmc0 in kernel 4.1.17 but /dev/blkmmc1 under 4.9.x. That can be quite annoying if you are trying to experiment with different kernel versions and want to set up the root filesystem on an SD Card for testing.
Please note that SATA devices show up like /dev/sda under v4.1.x and /dev/sataa under 4.9.x.
Booting Notes:
After copying the files to the USB drive, I used the following commands in u-boot:
usb start
fatload usb 0 0x01f00000 /bpi/bpi-w2.dtb
fatload usb 0 0x03000000 /bpi/uImage
fatload usb 0 0x02200000 /bpi/uinitrd
If you are using the debian image for the Banana Pi, then the root password is "bananapi". If you used a stock Debian image... well then you can't log in, because you would have to set the password via chroot and enable root login from the console or such before even making the filesystem.
root@QuaStation:~# uname -aLinux QuaStation.local 4.9.119-BPI-W2-Kernel #2 SMP PREEMPT Sat Jul 3 01:26:49 PDT 2021 aarch64 aarch64 aarch64 GNU/Linux
systemctl disable systemd-udev-settle.servicesystemctl disable multipathd.servicesystemctl disable systemd-networkd-wait-online.servicesystemctl disable systemd-networkd-wait-online.servicesystemctl disable ifupdown-pre.servicesystemctl disable cloud-init.servicesystemctl disable networking.servicenano /etc/fstab (fix the LABEL=BPI-BOOT stuff).
root@ubuntu:~# dmesg | grep enx[ 1351.849047] cdc_ether 7-1:2.0 enx28ee5215e0eb: renamed from eth1[ 1465.477836] cdc_ether 7-1:2.0 enx28ee5215e0eb: unregister 'cdc_ether' usb-xhci-hcd.8.auto-1, CDC Ethernet Device[ 1481.378386] ax88179_178a 7-1:1.0 enx50c4dd6dc7a0: renamed from eth1[ 2650.881035] ax88179_178a 7-1:1.0 enx18ece79533e9: renamed from eth1[ 2668.738468] ax88179_178a 7-1:1.0 enx58278cbe48c4: renamed from eth1
#Copy from SD card to SATA SSD (dirty way since we are mounted).dd status=progress bs=512 if=/dev/mmcblk0 of=/dev/satab# Fix damage caused by copying mounted FSchkfs.ext4 /dev/satab# Add new partition for /homecfdisk /dev/satabmkfs.btrfs /dev/satab3
# remove the thing that causes lots of error messages
apt-get remove cloud-init
# install useful tools and create /etc/network/interfaces
apt-get install avahi-daemon mc uptimed mosh ifupdown net-tools
#set up to boot from USBenv set bootcmd "usb start;fatload usb 0 0x01f00000 /bpi/bpi-w2.dtb;fatload usb 0 0x03000000 /bpi/uimage;fatload usb 0 0x02200000 /bpi/uinitrd; env set bootargs earlycon=uart8250,mmio32,0x98007800 console=ttyS0,115200n8 initrd=0x02200000,0x7F0000 root=/dev/satab2 rw rootwait rootfstype=ext4 init=/sbin/init selinux=0 nmi_watchdog=1 devtmpfs.mount=1;env set bootcmd 'booti 0x03000000 - 0x01f00000';b2ndbc"
env save
bootcmd=mmc read 0x03000000 1512A 8772;mmc read 0x01f00000 13581 6d;mmc read 0x02200000 230A0 2D7A;mmc read 0x01b00000 135FA 1A8F;env set bootargs earlycon=uart8250,mmio32,0x98007800 console=ttyS0,115200n8 initrd=0x02200000,0x7F0000 root=/dev/satab2 rw rootwait rootfstype=ext4 init=/sbin/init selinux=0 nmi_watchdog=0 devtmpfs.mount=1;env set bootcmd booti 0x03000000 - 0x01f00000;b2ndbcRealtek> env saveSaving Environment to FACTORY...[ENV] Writing to Factory...[FAC] factory_save: MMC[FAC] Save to eMMC (blk#:0x1100, buf:0x07000000, len:0x22000)[FAC] Save to eMMC (seq#:0x38, pp:0)done
Realtek> reset
Please choose a mode(1-7): 1Now building...make -C u-boot-rt rtd1296_sd_bananapi_defconfig CROSS_COMPILE=/home/console/qua/BPI-W2-bsp-w2-4.9-v1.0/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-make[1]: Entering directory '/home/console/qua/BPI-W2-bsp-w2-4.9-v1.0/u-boot-rt'HOSTCC scripts/basic/fixdepHOSTCC scripts/kconfig/conf.oSHIPPED scripts/kconfig/zconf.tab.cSHIPPED scripts/kconfig/zconf.lex.cSHIPPED scripts/kconfig/zconf.hash.cHOSTCC scripts/kconfig/zconf.tab.oIn file included from scripts/kconfig/zconf.tab.c:2534:scripts/kconfig/confdata.c: In function ‘conf_write’:scripts/kconfig/confdata.c:765:19: warning: ‘%s’ directive writing likely 7 or more bytes into a region of size between 1 and 4097 [-Wformat-overflow=]765 | sprintf(newname, "%s%s", dirname, basename);| ^~~~~~scripts/kconfig/confdata.c:765:19: note: assuming directive output of 7 bytesIn file included from /usr/include/stdio.h:867,from scripts/kconfig/zconf.tab.c:84:/usr/include/aarch64-linux-gnu/bits/stdio2.h:36:10: note: ‘__builtin___sprintf_chk’ output 1 or more bytes (assuming 4104) into a destination of size 409736 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~37 | __bos (__s), __fmt, __va_arg_pack ());| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~In file included from scripts/kconfig/zconf.tab.c:2534:scripts/kconfig/confdata.c:768:20: warning: ‘.tmpconfig.’ directive writing 11 bytes into a region of size between 1 and 4097 [-Wformat-overflow=]768 | sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());| ^~~~~~~~~~~~~~~~~In file included from /usr/include/stdio.h:867,from scripts/kconfig/zconf.tab.c:84:/usr/include/aarch64-linux-gnu/bits/stdio2.h:36:10: note: ‘__builtin___sprintf_chk’ output between 13 and 4119 bytes into a destination of size 409736 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~37 | __bos (__s), __fmt, __va_arg_pack ());| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~HOSTLD scripts/kconfig/conf## configuration written to .config#make[1]: Leaving directory '/home/console/qua/BPI-W2-bsp-w2-4.9-v1.0/u-boot-rt'make -C u-boot-rt all CROSS_COMPILE=/home/console/qua/BPI-W2-bsp-w2-4.9-v1.0/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- BUILD_BOOTCODE_ONLY=truemake[1]: Entering directory '/home/console/qua/BPI-W2-bsp-w2-4.9-v1.0/u-boot-rt'/home/console/qua/BPI-W2-bsp-w2-4.9-v1.0/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc: 1: cannot open @@: No such file/home/console/qua/BPI-W2-bsp-w2-4.9-v1.0/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc: 1: ELF: not found/home/console/qua/BPI-W2-bsp-w2-4.9-v1.0/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc: 3: Syntax error: "(" unexpected/bin/sh: 1: /home/console/qua/BPI-W2-bsp-w2-4.9-v1.0/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc: Exec format errordirname: missing operandTry 'dirname --help' for more information.scripts/kconfig/conf --silentoldconfig KconfigCHK include/config.hUPD include/config.hGEN include/autoconf.mk/bin/sh: 1: /home/console/qua/BPI-W2-bsp-w2-4.9-v1.0/toolchains/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc: Exec format errormake[2]: *** [scripts/Makefile.autoconf:72: include/autoconf.mk] Error 1make[1]: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/uboot.release'. Stop.make[1]: Leaving directory '/home/console/qua/BPI-W2-bsp-w2-4.9-v1.0/u-boot-rt'make: *** [Makefile:36: u-boot] Error 2Build failed!
Comments
Post a Comment