khadas / fenix

One-stop script set to build Ubuntu/Debian images
GNU General Public License v2.0
215 stars 135 forks source link

Build debian server kernel 4.9 for VIM2 using docker failed at almost last steps #20

Closed darren closed 6 years ago

darren commented 6 years ago

Try to build on NUC, it fails when running /home/khadas/fenix/scripts/rootfs_stage.sh part of the logs:


***********************PARAMETERS************************
Fenix Version:         0.3
Khadas Board:          VIM2
Uboot Version:         2015.01
Uboot Configuration:   kvim2_defconfig
Uboot Branch:          khadas-vim-v2015.01
Linux Version:         4.9
Linux Configuration:   kvim_defconfig
Linux DTB:             arch/arm64/boot/dts/amlogic/kvim2_linux.dtb
Linux Branch:          khadas-vim-4.9.y
Distribution:          Debian
Distribution Release:  stretch
Distribution Type:     server
Distribution Arch:     arm64
Install Type:          EMMC
Final Image:           VIM2_Debian-server-stretch_Linux-4.9_arm64_EMMC_2018-08-03.img
*********************************************************

make[1]: Leaving directory '/home/khadas/fenix/linux'                                                                                                                                
Info: Building debs...                                                                                                                                                               
Info: Build board deb...                                                                                                                                                             
Building package: linux-board-package-amlogic-s912                                                                                                                                   
dpkg-deb: building package 'linux-board-package-amlogic-s912' in '/home/khadas/fenix/build/images/.tmp/linux-board-package-amlogic-s912_0.3_arm64.deb'.                              
./scripts/create_image.sh:88 Warning: This script requires root privileges, trying to use sudo, please enter your passowrd!                                                          
Info: Preparing rootfs for VIM2-stretch                                                                                                                                              
Info: Creating new rootfs for stretch                                                                                                                                                
Info: Installing base system - Stage 1/2                                                                                                                                             
I: Retrieving InRelease                                                                                                                                                              
I: Retrieving Release                                                                                                                                                                
I: Retrieving Release.gpg                                                                                                                                                            
I: Checking Release signature                                                                                                                                                        
I: Valid Release signature (key id 067E3C456BAE240ACEE88F6FEF0F382A1A7B6500)                                                                                                         
I: Retrieving Packages                                                                                                                                                               
I: Validating Packages                                                                                                                                                               
I: Resolving dependencies of required packages...                                                                                                                                    
I: Resolving dependencies of base packages...                                                                                                                                        
I: Found additional required dependencies: libaudit1 libaudit-common libbz2-1.0 libcap-ng0 libdb5.3 libdebconfclient0 libgcrypt20 libgpg-error0 liblz4-1 libncursesw5 libsemanage1 li
bsemanage-common libsystemd0 libudev1 libustr-1.0-1                                                                                                                                  
I: Found additional base dependencies: dmsetup gnupg-agent libapparmor1 libassuan0 libbsd0 libcap2 libc-l10n libcryptsetup4 libdevmapper1.02.1 libdns-export162 libelf1 libfastjson4l
ibffi6 libgmp10 libgnutls30 libhogweed4 libidn11 libidn2-0 libip4tc0 libip6tc0 libiptc0 libisc-export160 libksba8 liblocale-gettext-perl liblognorm5 libmnl0 libncurses5 libnetfilter
-conntrack3 libnettle6 libnfnetlink0 libnpth0 libp11-kit0 libpsl5 libseccomp2 libsqlite3-0 libtasn1-6 libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libunistring0li
bxtables12 pinentry-curses xxd    

.....

I: Extracting libsystemd0...
I: Extracting libudev1...
I: Extracting sysvinit-utils...
I: Extracting tar...
I: Extracting tzdata...
I: Extracting libustr-1.0-1...
I: Extracting bsdutils...
I: Extracting libblkid1...
I: Extracting libfdisk1...
I: Extracting libmount1...
I: Extracting libsmartcols1...
I: Extracting libuuid1...
I: Extracting mount...
I: Extracting util-linux...
I: Extracting liblzma5...
I: Extracting zlib1g...
Info: Installing base system - Stage 2/2
chroot: failed to run command ‘/bin/bash’: Exec format error
Cleanup...
Makefile:7: recipe for target 'all' failed
make: *** [all] Error 126

Any clues?

darren commented 6 years ago

The actual command fails is:

root@f3031c7d94df:/home/khadas/fenix# chroot /home/khadas/fenix/build/images/.tmp/rootfs-VIM2-stretch-server /bin/bash -c '/debootstrap/debootstrap --second-stage'
chroot: failed to run command ‘/bin/bash’: Exec format error
numbqq commented 6 years ago

Hello Darren,

What's the system of your host PC?

Do you use the dockerfile we provided to create the docker environment?

Thanks.

darren commented 6 years ago

@numbqq

Many Thanks for your great work that makes building the image easy for us.

  1. My Host PC is Debian 9.5 on intel NUC
  2. Yes, I am using your dockerfile and created the docker environment.

I think I may have found the problem: something's wrong with qemu and binfmt support. And I made these changes(switch to debian, because I can not find libc:arm64 for ubuntu bionic)

diff --git a/Dockerfile b/Dockerfile
index f150c29..8694695 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,5 @@
-FROM ubuntu:18.04
-RUN dpkg --add-architecture i386
+FROM debian
+RUN dpkg --add-architecture arm64
 RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade && \
        DEBIAN_FRONTEND=noninteractive apt-get install -y sudo git dialog lsb-release binutils wget ca-certificates device-tree-compiler \
        pv bc lzop zip binfmt-support build-essential ccache debootstrap ntpdate gawk gcc-arm-linux-gnueabihf \
@@ -7,8 +7,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade &&
        debian-keyring debian-archive-keyring f2fs-tools libfile-fcntllock-perl rsync libssl-dev nfs-kernel-server btrfs-tools \
        ncurses-term p7zip-full kmod dosfstools libc6-dev-armhf-cross fakeroot \
        curl patchutils python liblz4-tool libpython2.7-dev linux-base swig libpython-dev aptly acl\
-       systemd-container udev g++-5-arm-linux-gnueabihf lib32stdc++6 \
-       libc6-i386 lib32ncurses5 lib32tinfo5 locales ncurses-base zlib1g:i386 pixz bison libbison-dev flex libfl-dev lib32z1 tzdata cpio
+       systemd-container udev g++-6-arm-linux-gnueabihf lib32stdc++6 \
+       libc6:arm64 lib32ncurses5 lib32tinfo5 locales ncurses-base zlib1g pixz bison libbison-dev flex libfl-dev lib32z1 tzdata cpio apt-utils
 RUN locale-gen en_US.UTF-8

and Now I met another problem:

Allocating group tables: done                                                                                                                                                        
Writing inode tables: done                                                                                                                                                           
Creating journal (8192 blocks): done                                                                                                                                                 
Writing superblocks and filesystem accounting information: done                                                                                                                      

mount: /home/khadas/fenix/build/images/rootfs.img: failed to setup loop device: No such file or directory                                                                            
Cleanup...                                                                                                                                                                           
Makefile:7: recipe for target 'all' failed                                                                                                                                           
make: *** [all] Error 32                                                                                                                                                             
root@f34268c07bc7:/home/khadas/fenix# mount -o loop /home/khadas/fenix/build/images/rootfs.img  /mnt                                                                                 
mount: /home/khadas/fenix/build/images/rootfs.img: failed to setup loop device: No such file or directory       

It seems that loop is not working in docker, I shall dig it further.

darren commented 6 years ago

the loop problem can be fixed by running:

mknod /dev/loop0 -m0660 b 7 0

finally got the image:

Pack image[/home/khadas/fenix/build/images/VIM2_Debian-server-stretch_Linux-4.9_arm64_EMMC_2018-08-04.img] OK

Info: IMAGE: /home/khadas/fenix/build/images/VIM2_Debian-server-stretch_Linux-4.9_arm64_EMMC_2018-08-04.img
Cleanup...

Done.
numbqq commented 6 years ago

My Host PC is Debian 9.5 on intel NUC

OK. Haven't tried on Debian build host yet.

Glad to see you fixup it. Can you boot the image well?

Thanks.

darren commented 6 years ago

@numbqq

hmmm, no luck, the image built in docker can not boot, do not know why...

Then I tried building in a Ubuntu Xenial 16.04 x64 host, burn the image, and it boots ok..

numbqq commented 6 years ago

hmmm, no luck, the image built in docker can not boot, do not know why...

OK. I will look into this issue...

numbqq commented 6 years ago

Hello @Darren ,

This issue has been fixed https://github.com/khadas/fenix/commit/5e3bd927671716c6e7c2f3696d3eee39944188ce

You don't need to modify the Dockerfile, just install qemu-user-static on your Debian host.

$ sudo apt-get install qemu-user-static

And try to build in Docker.

Thanks.

abliss commented 6 years ago

FYI I got the same issue even though qemu-user-static was installed on the host. I am not using docker.

===========================================
#VERSION: 0.4

#KHADAS_BOARD=VIM2
#VENDOR=Amlogic
#CHIP=S912
#LINUX=4.9
#UBOOT=2015.01
#DISTRIBUTION=Ubuntu
#DISTRIB_RELEASE=xenial
#DISTRIB_TYPE=server
#DISTRIB_ARCH=arm64
#INSTALL_TYPE=EMMC

===========================================

The problem seems to be that I don't have the binfmt_misc module installed (or available) on my host.

numbqq commented 6 years ago

The problem seems to be that I don't have the binfmt_misc module installed (or available) on my host.

What's your host OS?

When you install the binfmt_misc module does it works?

fixup https://github.com/khadas/fenix/commit/ffd5759c26f8a2af9c319b98917d82dba3d25012