Home

ITA - ArchLinux vs Yocto : Day 1

archlinux linux yocto

Inroduzione

Nei giorni passati mi sono ritrovato a dover familiarizzare con yocto, sono partito dalla guida riportata sulla wiki di archlinux e dalla overview del progetto stesso.

Vi preannuncio che sono riuscito a far funzioanre questo tool direttamente su arch, al tentatico numero 3, la storia degli altri tentativi li lascio come punto di partenza per eventuali future investigazioni.

Per riassumere sembra che il risultato dipenda dalla versione di yocto che si sta andando a preparare.

Procedura

Installazione

Pacchetti

Dal wiki (versione aggiornata al 15 ottobre 2020) i pacchetti da installare possone essere installati con il seguente comando :

pacman -S git diffstat unzip texinfo python wget xterm sdl rpcsvc-proto socat cpio inetutils multilib-devel

Python2

Per usare python2 invece non ho seguito quanto riportato dalla guida ma ho preferito puntare sui moduli d’ambiente come spiegato in questo articolo

Esecuzioni d’esempio

Tantativo 1

$ module load python2
$ git clone --branch morty https://git.yoctoproject.org/git/poky ~/poky
$ cd ~/poky
$ source oe-init-build-env build-qemux86
You had no conf/local.conf file. This configuration file has therefore been
created for you with some default values. You may wish to edit it to, for
example, select a different MACHINE (target hardware). See conf/local.conf
for more information as common configuration options are commented.

You had no conf/bblayers.conf file. This configuration file has therefore been
created for you with some default values. To add additional metadata layers
into your configuration please add entries to conf/bblayers.conf.

The Yocto Project has extensive documentation about OE including a reference
manual which can be found at:
    http://yoctoproject.org/documentation

For more information about OpenEmbedded see their website:
    http://www.openembedded.org/


### Shell environment set up for builds. ###

You can now run 'bitbake <target>'

Common targets are:
    core-image-minimal
    core-image-sato
    meta-toolchain
    meta-ide-support

You can also run generated qemu images with a command like 'runqemu qemux86'

$ bitbake core-image-minimal
/home/stethewwolf/poky/bitbake/lib/bb/fetch2/clearcase.py:160: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if command is 'mkview':
/home/stethewwolf/poky/bitbake/lib/bb/fetch2/clearcase.py:167: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif command is 'rmview':
/home/stethewwolf/poky/bitbake/lib/bb/fetch2/clearcase.py:171: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif command is 'setcs':
WARNING: /home/stethewwolf/poky/meta/lib/oe/maketype.py:99: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
  if not isinstance(obj, collections.Callable):

WARNING: Host distribution "ArchLinux" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
ERROR: /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato.bb: Can't get compiler version from gcc --version output | ETA: 0:00:25
WARNING: /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato.bb: Exception during build_dependencies for create_shar
WARNING: /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato.bb: Error during finalise of /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato.bb
ERROR: ExpansionError during parsing /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato.bb
Traceback (most recent call last):
bb.data_smart.ExpansionError: Failure expanding variable create_shar, expression was # copy in the template shar extractor script
	cp /home/stethewwolf/poky/meta/files/toolchain-shar-extract.sh /home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/x86_64-deploy-core-image-sato-populate-sdk/poky-glibc-x86_64-core-image-sato-i586-toolchain-2.2.4.sh

	rm -f /home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/temp/pre_install_command /home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/temp/post_install_command

	if [1 -eq 1] ; then
		cp /home/stethewwolf/poky/meta/files/toolchain-shar-relocate.sh /home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/temp/post_install_command
	fi
	cat << "EOF" >> /home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/temp/pre_install_command

EOF

	cat << "EOF" >> /home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/temp/post_install_command

EOF
	sed -i -e '/@SDK_PRE_INSTALL_COMMAND@/r /home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/temp/pre_install_command' \
		-e '/@SDK_POST_INSTALL_COMMAND@/r /home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/temp/post_install_command' \
		/home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/x86_64-deploy-core-image-sato-populate-sdk/poky-glibc-x86_64-core-image-sato-i586-toolchain-2.2.4.sh

	# substitute variables
	sed -i -e 's#@SDK_ARCH@#x86_64#g' \
		-e 's#@SDKPATH@#/opt/poky/2.2.4#g' \
		-e 's#@SDKEXTPATH@#~/poky_sdk#g' \
		-e 's#@OLDEST_KERNEL@#2.6.32#g' \
		-e 's#@REAL_MULTIMACH_TARGET_SYS@#i586-poky-linux#g' \
		-e 's#@SDK_TITLE@#${@d.getVar("SDK_TITLE", True).replace('&', '\&')}#g' \
		-e 's#@SDK_VERSION@#2.2.4#g' \
		-e '/@SDK_PRE_INSTALL_COMMAND@/d' \
		-e '/@SDK_POST_INSTALL_COMMAND@/d' \
		-e 's#@SDK_GCC_VER@#${@oe.utils.host_gcc_version(d)}#g' \
		/home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/x86_64-deploy-core-image-sato-populate-sdk/poky-glibc-x86_64-core-image-sato-i586-toolchain-2.2.4.sh

	# add execution permission
	chmod +x /home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/x86_64-deploy-core-image-sato-populate-sdk/poky-glibc-x86_64-core-image-sato-i586-toolchain-2.2.4.sh

	# append the SDK tarball
	cat /home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/x86_64-deploy-core-image-sato-populate-sdk/poky-glibc-x86_64-core-image-sato-i586-toolchain-2.2.4.tar.xz >> /home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/x86_64-deploy-core-image-sato-populate-sdk/poky-glibc-x86_64-core-image-sato-i586-toolchain-2.2.4.sh

	# delete the old tarball, we don't need it anymore
	rm /home/stethewwolf/poky/build-qemux86/tmp/work/qemux86-poky-linux/core-image-sato/1.0-r0/x86_64-deploy-core-image-sato-populate-sdk/poky-glibc-x86_64-core-image-sato-i586-toolchain-2.2.4.tar.xz
 which triggered exception BBHandledException: 

ERROR: /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato-sdk.bb: Can't get compiler version from gcc --version output
WARNING: /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato-sdk.bb: Exception during build_dependencies for create_shar
WARNING: /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato-sdk.bb: Error during finalise of /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato-sdk.bb
ERROR: /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato-sdk-ptest.bb: Can't get compiler version from gcc --version output
WARNING: /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato-sdk-ptest.bb: Exception during build_dependencies for create_shar
WARNING: /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato-sdk-ptest.bb: Error during finalise of /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato-sdk-ptest.bb
ERROR: /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato-dev.bb: Can't get compiler version from gcc --version output
WARNING: /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato-dev.bb: Exception during build_dependencies for create_shar
WARNING: /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato-dev.bb: Error during finalise of /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato-dev.bb

Summary: There were 10 WARNING messages shown.
Summary: There were 5 ERROR messages shown, returning a non-zero exit code.

Tentativo 2

E’ presto per scoraggiarsi inoltre l’errore da considerare è :

ERROR: /home/stethewwolf/poky/meta/recipes-sato/images/core-image-sato.bb: Can't get compiler version from gcc --version output

facile da cercare su internet.

Infatti cercando ho trovato questa patch:

quindi con vim ho editato il file ..//meta/lib/oe/utils.py alla linea 245:

$ grep "#match" ..//meta/lib/oe/utils.py -A 5 -B 5 -n
240- env["PATH"] = d.getVar("PATH", True)
241- output = subprocess.check_output("%s --version" % compiler, shell=True, env=env).decode("utf-8")
242- except subprocess.CalledProcessError as e:
243- bb.fatal("Error running %s --version: %s" % (compiler, e.output.decode("utf-8")))
244-
245: #match = re.match(".* (\d\.\d)\.\d.*", output.split('\n')[0])
246- match = re.match(r".* (\d+\.\d+)\.\d+.*", output.split('\n')[0])
247-
248- if not match:
249- bb.fatal("Can't get compiler version from %s --version output" % compiler)
250-

a questo punto posso ripetere i comandi di build :

$ source oe-init-build-env build-qemux86
You had no conf/local.conf file. This configuration file has therefore been
created for you with some default values. You may wish to edit it to, for
example, select a different MACHINE (target hardware). See conf/local.conf
for more information as common configuration options are commented.

You had no conf/bblayers.conf file. This configuration file has therefore been
created for you with some default values. To add additional metadata layers
into your configuration please add entries to conf/bblayers.conf.

The Yocto Project has extensive documentation about OE including a reference
manual which can be found at:
    http://yoctoproject.org/documentation

For more information about OpenEmbedded see their website:
    http://www.openembedded.org/


### Shell environment set up for builds. ###

You can now run 'bitbake <target>'

Common targets are:
    core-image-minimal
    core-image-sato
    meta-toolchain
    meta-ide-support

You can also run generated qemu images with a command like 'runqemu qemux86'
$ bitbake core-image-minimal
/home/stethewwolf/tmp/poky/bitbake/lib/bb/fetch2/clearcase.py:160: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if command is 'mkview':
/home/stethewwolf/tmp/poky/bitbake/lib/bb/fetch2/clearcase.py:167: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif command is 'rmview':
/home/stethewwolf/tmp/poky/bitbake/lib/bb/fetch2/clearcase.py:171: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif command is 'setcs':
WARNING: /home/stethewwolf/tmp/poky/meta/lib/oe/maketype.py:99: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
  if not isinstance(obj, collections.Callable):

WARNING: Host distribution "ArchLinux" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Parsing recipes: 100% |########################################################################################################################################################################################################| Time: 0:00:24
Parsing of 864 .bb files complete (0 cached, 864 parsed). 1320 targets, 50 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION = "1.32.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "ArchLinux"
TARGET_SYS = "i586-poky-linux"
MACHINE = "qemux86"
DISTRO = "poky"
DISTRO_VERSION = "2.2.4"
TUNE_FEATURES = "m32 i586"
TARGET_FPU = ""
meta              
meta-poky         
meta-yocto-bsp = "morty:e56be3cee517c5262486136dbd6d649b68c3a8b7"

NOTE: Fetching uninative binary shim from http://downloads.yoctoproject.org/releases/uninative/1.8/x86_64-nativesdk-libc.tar.bz2;sha256sum=de4947e98e09e1432d069311cc2093974ecb9138a714fd5466f73524de66a693
--2020-10-16 14:20:54-- http://downloads.yoctoproject.org/releases/uninative/1.8/x86_64-nativesdk-libc.tar.bz2
Connecting to 127.0.0.1:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 14304759 (14M) [application/octet-stream]
Saving to: ‘/home/stethewwolf/tmp/poky/build-qemux86/downloads/uninative/de4947e98e09e1432d069311cc2093974ecb9138a714fd5466f73524de66a693/x86_64-nativesdk-libc.tar.bz2’


2020-10-16 14:20:59 (3.69 MB/s) - ‘/home/stethewwolf/tmp/poky/build-qemux86/downloads/uninative/de4947e98e09e1432d069311cc2093974ecb9138a714fd5466f73524de66a693/x86_64-nativesdk-libc.tar.bz2’ saved [14304759/14304759]

WARNING: Your host glibc verson (2.32) is newer than that in uninative (2.27). Disabling uninative so that sstate is not corrupted.
/home/stethewwolf/tmp/poky/meta/classes/buildstats.bbclass:103: SyntaxWarning: "is" with a literal. Did you mean "=="?###################### | ETA: 0:00:01
  if status is "passed":
Initialising tasks: 100% |#####################################################################################################################################################################################################| Time: 0:00:03
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: m4-native-1.4.17-r0 do_compile: oe_runmake failed
ERROR: m4-native-1.4.17-r0 do_compile: Function failed: do_compile (log file is located at /home/stethewwolf/tmp/poky/build-qemux86/tmp/work/x86_64-linux/m4-native/1.4.17-r0/temp/log.do_compile.49945)
ERROR: Logfile of failure stored in: /home/stethewwolf/tmp/poky/build-qemux86/tmp/work/x86_64-linux/m4-native/1.4.17-r0/temp/log.do_compile.49945
Log data follows:
.
.
.
Summary: 1 task failed:
  /home/stethewwolf/tmp/poky/meta/recipes-devtools/m4/m4-native_1.4.17.bb:do_compile
Summary: There were 6 WARNING messages shown.
Summary: There were 5 ERROR messages shown, returning a non-zero exit code.

L’output precedente è stato tagliato, qui è possibile trovare il file con il log completo.

L’errore principale è :

| gcc -I. -I../../m4-1.4.17/lib -isystem/home/stethewwolf/tmp/poky/build-qemux86/tmp/sysroots/x86_64-linux/usr/include -isystem/home/stethewwolf/tmp/poky/build-qemux86/tmp/sysroots/x86_64-linux/usr/include -O2 -pipe -c -o printf-args.o ../../m4-1.4.17/lib/printf-args.c
| ../../m4-1.4.17/lib/freadahead.c: In function ‘freadahead’:
| ../../m4-1.4.17/lib/freadahead.c:91:3: error: #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
| 91 | #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
| | ^ ~~~~
| make[3]: *** [Makefile:1842: freadahead.o] Error 1
| make[3]: *** Waiting for unfinished jobs....
| ../../m4-1.4.17/lib/fseeko.c: In function ‘rpl_fseeko’:
| ../../m4-1.4.17/lib/fseeko.c:109:4: error: #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
| 109 | #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
| | ^ ~~~~
| make[3]: *** [Makefile:1842: fseeko.o] Error 1

A questo punto mi sono bloccato, la gestione di quella libreria è completamente out of scope, l’bbiettivo è buildare yocto e creare le mie customizzazioni.

Tentativo 3

Come ultima spiaggia provo a seguire la guida ufficiale yocto in breve

cd tmp/
git clone https://git.yoctoproject.org/git/poky poky
cd poky/
git fetch --tags
git checkout tags/yocto-3.1.3 -b my-yocto-3.1.3
[stethewwolf@hel poky]$ source oe-init-build-env
You had no conf/local.conf file. This configuration file has therefore been
created for you with some default values. You may wish to edit it to, for
example, select a different MACHINE (target hardware). See conf/local.conf
for more information as common configuration options are commented.

You had no conf/bblayers.conf file. This configuration file has therefore been
created for you with some default values. To add additional metadata layers
into your configuration please add entries to conf/bblayers.conf.

The Yocto Project has extensive documentation about OE including a reference
manual which can be found at:
    http://yoctoproject.org/documentation

For more information about OpenEmbedded see their website:
    http://www.openembedded.org/


### Shell environment set up for builds. ###

You can now run 'bitbake <target>'

Common targets are:
    core-image-minimal
    core-image-sato
    meta-toolchain
    meta-ide-support

You can also run generated qemu images with a command like 'runqemu qemux86'

Other commonly useful commands are:
 - 'devtool' and 'recipetool' handle common recipe tasks
 - 'bitbake-layers' handles common layer tasks
 - 'oe-pkgdata-util' handles common target package tasks
[stethewwolf@hel build]$ bitbake core-image-minimal
WARNING: Host distribution "manjaro" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Parsing recipes: 100% |############################################################################################################| Time: 0:00:37
Parsing of 771 .bb files complete (0 cached, 771 parsed). 1312 targets, 40 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION = "1.46.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "manjaro"
TARGET_SYS = "x86_64-poky-linux"
MACHINE = "qemux86-64"
DISTRO = "poky"
DISTRO_VERSION = "3.1.3"
TUNE_FEATURES = "m64 core2"
TARGET_FPU = ""
meta                 
meta-poky            
meta-yocto-bsp = "my-yocto-3.1.3:012ad10a89a889c21e67c27dc37d22520212548f"

NOTE: Fetching uninative binary shim http://downloads.yoctoproject.org/releases/uninative/2.9/x86_64-nativesdk-libc.tar.xz;sha256sum=d07916b95c419c81541a19c8ef0ed8cbd78ae18437ff28a4c8a60ef40518e423 (will check PREMIRRORS first)
Initialising tasks: 100% |#########################################################################################################| Time: 0:00:01
Sstate summary: Wanted 1159 Found 0 Missed 1159 Current 0 (0% match, 0% complete)
NOTE: Executing Tasks
WARNING: netbase-1_6.1-r0 do_fetch: Failed to fetch URL http://ftp.debian.org/debian/pool/main/n/netbase/netbase_6.1.tar.xz, attempting MIRRORS if available
NOTE: Tasks Summary: Attempted 3156 tasks of which 1 didn't need to be rerun and all succeeded.

Summary: There were 2 WARNING messages shown.

SIIII!!! dopo diverse ore di lavoro sul mio modesto pc, la build ha avuto successo ! Non rimache eseguire il test su una macchina virtuale, il seguente comando esegue la build in qemu.

[stethewwolf@hel build]$ runqemu qemux86-64
runqemu - INFO - Running MACHINE=qemux86-64 bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [/home/stethewwolf/Scrivania/poky/build/tmp/deploy/images/qemux86-64/bzImage--5.4.61+git0+7ed307f651_00809fdaf6-r0-qemux86-64-20201016165722.bin]
MACHINE: [qemux86-64]
FSTYPE: [ext4]
ROOTFS: [/home/stethewwolf/Scrivania/poky/build/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64-20201016165722.rootfs.ext4]
CONFFILE: [/home/stethewwolf/Scrivania/poky/build/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64-20201016165722.qemuboot.conf]

runqemu - INFO - Setting up tap interface under sudo
[sudo] password di stethewwolf: 
Riprovare.
[sudo] password di stethewwolf: 
runqemu - INFO - Network configuration: ip=192.168.7.2::192.168.7.1:255.255.255.0
runqemu - INFO - Running /home/stethewwolf/Scrivania/poky/build/tmp/work/x86_64-linux/qemu-helper-native/1.0-r1/recipe-sysroot-native/usr/bin/qemu-system-x86_64 -device virtio-net-pci,netdev=net0,mac=52:54:00:12:34:02 -netdev tap,id=net0,ifname=tap0,script=no,downscript=no -drive file=/home/stethewwolf/Scrivania/poky/build/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64-20201016165722.rootfs.ext4,if=virtio,format=raw -show-cursor -usb -device usb-tablet -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 -cpu core2duo -m 256 -serial mon:vc -serial null -kernel /home/stethewwolf/Scrivania/poky/build/tmp/deploy/images/qemux86-64/bzImage--5.4.61+git0+7ed307f651_00809fdaf6-r0-qemux86-64-20201016165722.bin -append 'root=/dev/vda rw mem=256M ip=192.168.7.2::192.168.7.1:255.255.255.0 oprofile.timer=1 '

runqemu - INFO - Cleaning up
Set 'tap0' nonpersistent

Riferimenti