Building Custom Yocto Image


#1

The instructions below show how to build custom yocto images for the WP76 and WP85. Note that if someone chooses to build their own yocto image then they should set the LEGATO_KERNELROOT environment variable before building MangOH, for example:

WP85:
export LEGATO_KERNELROOT="~/yocto-2.2/build_src/tmp/work/swi_mdm9x15-poky-linux-gnueabi/linux-yocto/3.14.29-r0.1/linux-swi_mdm9x15-standard-build"

WP76:
export LEGATO_KERNELROOT="~/yocto-2.2/build_src/tmp/work/swi_mdm9x28-poky-linux-gnueabi/linux-quic/3.18.44-r1/build"

1. Initialize repo

Create yocto folder:
mkdir ~/yocto-2.2
cd ~/yocto-2.2

WP85:
repo init -u git://gerrit-legato/manifest -m lxswi/branches/master/systems/wp85xx.xml -g “default,amss”

WP76:
repo init -u git://gerrit-legato/manifest -m lxswi/branches/master/systems/wp76xx.xml

2. Synchronize repo and build yocto

repo sync
make image_src

To set/unset kernel configuration options use the following commands:
cd $LEGATO_KERNELROOT
VERBOSE=1 make ARCH=arm menuconfig

Note if you just want to rebuild the kernel then the following can be used in a script (e.g. here we create a script called build_kernel.sh and place in the build_src folder).

WP85:
bitbake -c compile -f linux-yocto
bitbake -c build -f linux-yocto
bitbake -c build -f mdm9x15-image-minimal

WP76:
bitbake -c compile -f linux-quic
bitbake -c build -f linux-quic
bitbake -c build -f mdm9x28-image-minimal

3. Build and install the toolchain (optional)

Note this step is only required for users that desire to build their own toolchain instead of downloading it from the sierrawireless web sites:

WP85:
https://source.sierrawireless.com/resources/airprime/software/wpx5xx/wpx5xx-firmware-latest-release-components/

WP76:
https://source.sierrawireless.com/resources/airprime/software/wp76xx/wp76xx-firmware-latest-release-components/

make toolchain_src

WP85:
cd ~/yocto-2.2/
sudo ./build_src/tmp/deploy/sdk/poky-swi-ext-glibc-x86_64-meta-toolchain-swi-ext-armv7a-neon-toolchain-swi-ext-2.2.3.sh

WP76:
cd ~/yocto-2.2/
sudo ./build_src/tmp/deploy/sdk/poky-swi-ext-glibc-x86_64-meta-toolchain-swi-ext-armv7a-neon-toolchain-swi-ext-2.2.3.sh

4. Download new yocto build to the target device

Note before downloading switch pin 7 up for the MangOH Red and then once the downloading has started switch pin 7 back down.

WP85:
cd ~/yocto-2.2/
swiflash -m “WP85XX” -i ./build_src/tmp/deploy/images/swi-mdm9x15/yocto-legato_wp85.cwe
OR
copy yocto-legato_wp85.cwe to a folder on Windows PC with fdt2 installed
fdt2 yocto-legato_wp85.cwe

WP76:
cd ~/yocto-2.2/
swiflash -m “WP76XX” -i …/yocto-wp76/build_src/tmp/deploy/images/swi-mdm9x28/yocto_wp76xx.4k.cwe
OR
copy yocto-legato_wp85.cwe to a folder on Windows PC with fdt2 installed
fdt2 yocto_wp76xx.4k.cwe


#2

currently not working, I can not get the xml:

repo init -u git://gerrit-legato/manifest -m lxswi/branches/master/systems/wp76xx.xml

fatal: unable to connect to gerrit-legato:
gerrit-legato: Name or service not known

please advice


#3

I suspect those are internal git servers.


#4

thank you, if so how can I get the sources in order to build a Yocto image?


#5

Hey @deadpoolcode,

I just got some build hardware so I’m just starting to unravel this as well. I think everything you need can be found in here: http://downloads.sierrawireless.com/AirPrime/WPx5xx/Release15/Legato-Dist-Source-mdm9x15-SWI9X15Y_07.12.14.00.tar.bz2


#6

The repo steps are wrong. @nick is correct that gerrit-legato is a server only accessible inside Sierra Wireless. For now, download the tarball for your module. @nick linked to the one for wp75/85.


#7

Hey @dclark75,

I’ve recently had some success building yocto from scratch for the WP85 using the tar ball I linked above. I modified meta-swi-extras/meta-swi-bin/files/fw-version in attempt to release my own build (mostly for the purpose of confirming that it flashed successfully). I was also sure to commit the changes since I’ve heard the build process will re-clone repos sometimes. After flashing this custom build, I did not see the updated firmware version. I believe these this could be two things:

  1. The firmware version is defined in 2 places somewhere else
  2. The custom build is not flashing successfully (despite a success message from swiflash)

Do you guys have any debugging advice? Unfortunately we do not have access to a serial console on these units.


#8

Update: I flashed release 14 (pre-built .spk file) and the version changed to match(SWI9X15Y_07.12.09.00 r34123 CARMD-EV-FRMWR1 2017/04/26 23:34:19). After that, I tried re-flashing our custom build (based onSWI9X15Y_07.12.14.00) and did not see the version change. This more or less confirms that our custom builds are not flashing.


#9

The SWI9X15Y_07.12.09.00 and SWI9X15Y_07.12.14.00 concerns the legato version not the linux image, in order to have an .spk image with the correct legato version you should build yocto image then run the swicwe command and you should point on both the linux image and the legato image that you want to install. It is better to use AT command to check the version using microcom interface. I hope that helps you.


#10

Hey @Souhail sorry for the delayed reply.

I’ve been working with custom images and I think I have a better understanding of how this all comes together. To my knowledge, SWI9X15Y_07.12.14.00 refers to the modem firmware and not the Legato version (though certain Legato releases come bundled with certain modem firmware versions), which is not part of the Yocto image. I found this diagram very helpful in that regard:

I’ve been successfully flashing custom .spk files produced using swicwe (thanks again for the suggestion @Souhail).

On an unrelated note, @dclark75, would you be able to clarify a little bit on customizing the kernel? I’m a little confused as to why we run VERBOSE=1 make ARCH=arm menuconfig in $LEGATO_KERNELROOT instead of in the main kernel directory (e.g /build-folder/yocto/kernel) before running make image_bin. Additionally, I had some trouble finding the BitBake executable. I’m sure it’s in here somewhere, but I don’t have the executable in my path, so simply invoking bitbake doesn’t work.

Cheers!


#11

Possible to get a git repository of the meta- modules? If we want to roll our own yocto repo using the latest yocto version? Because the tarball contains a very old version of yocto, according to here https://wiki.yoctoproject.org/wiki/Releases (1.7.3) was released in 2014…


#12

I think that to be able to access bitbake, you need to run source oe-init-build-env in the /poky directory.


#13

Thanks @fjanicki, I’ll give this a try.


#14

Where are you grabbing the Yocto version from? I recall seeing a newer revision somewhere in the code/build but I can’t seem to find it again.

Cheers!


#15

Not sure, I just use the version bundled in the tarball provided from sierra wireless’s download section. I would much prefer to use a git repo but none is available. Problem is that the bundled version is very old and it would be nice to be able to use a newer version.


#16

Yeah the tarball approach is definitely a little painful. I double checked the versions and it’s definitely Yocto 1.7.3 as you stated (not sure why I had a newer version in my head). I suspect Sierra Wireless will supply a nicer approach to managing custom images as it becomes more popular.

Cheers!


#17

I found this repo but it seems outdated. Maybe we can create an unofficial git repo?


#18

I’m currently trying to build yocto from source using the WP76XX SWI9X07Y_02.16.02.00 code and the steps posted above.

I’ve installed all the host build dependencies called out in Yocto Project Quick Start.

My process is the following:

  1. untar the source
  2. repo sync
  3. make image_bin

The build is failing and I am getting the following errors which relates to qemu-native 2.7.0-r1:

ERROR: qemu-native-2.7.0-r1 do_compile: oe_runmake failed
ERROR: qemu-native-2.7.0-r1 do_compile: Function failed: do_compile (log file is located at /home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/temp/log.do_compile.27008)
ERROR: Logfile of failure stored in: /home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/temp/log.do_compile.27008
Log data follows:
| DEBUG: Executing shell function do_compile
| NOTE: make -j 4 LD=ld AR=ar OBJCOPY=objcopy LDFLAGS=-L/home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/sysroots/x86_64-linux/usr/lib -L/home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/sysroots/x86_64-linux/lib -Wl,-rpath-link,/home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/sysroots/x86_64-linux/usr/lib -Wl,-rpath-link,/home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/sysroots/x86_64-linux/lib -Wl,-rpath,/home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/sysroots/x86_64-linux/usr/lib -Wl,-rpath,/home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/sysroots/x86_64-linux/lib -Wl,-O1 -fuse-ld=bfd
| ERROR: oe_runmake failed
| GEN arm-softmmu/config-devices.mak.tmp
| GEN aarch64-softmmu/config-devices.mak.tmp
| GEN aarch64-linux-user/config-devices.mak.tmp
| GEN arm-linux-user/config-devices.mak.tmp
| GEN arm-linux-user/config-devices.mak
| GEN aarch64-linux-user/config-devices.mak
| GEN i386-linux-user/config-devices.mak.tmp
| GEN i386-softmmu/config-devices.mak.tmp
| GEN arm-softmmu/config-devices.mak
| GEN mips-linux-user/config-devices.mak.tmp
| GEN aarch64-softmmu/config-devices.mak
| GEN mips-softmmu/config-devices.mak.tmp
| GEN i386-linux-user/config-devices.mak
| GEN mips-linux-user/config-devices.mak
| GEN mipsel-softmmu/config-devices.mak.tmp
| GEN i386-softmmu/config-devices.mak
| GEN mipsel-linux-user/config-devices.mak.tmp
| GEN mips64-linux-user/config-devices.mak.tmp
| GEN mipsel-linux-user/config-devices.mak
| GEN mips64-linux-user/config-devices.mak
| GEN mips64-softmmu/config-devices.mak.tmp
| GEN ppc-linux-user/config-devices.mak.tmp
| GEN mipsel-softmmu/config-devices.mak
| GEN mips-softmmu/config-devices.mak
| GEN ppc-softmmu/config-devices.mak.tmp
| GEN x86_64-linux-user/config-devices.mak.tmp
| GEN ppc-linux-user/config-devices.mak
| GEN x86_64-softmmu/config-devices.mak.tmp
| GEN x86_64-linux-user/config-devices.mak
| GEN mips64-softmmu/config-devices.mak
| GEN ppc-softmmu/config-devices.mak
| GEN x86_64-softmmu/config-devices.mak
| GEN qemu-options.def
| GEN config-host.h
| GEN qmp-commands.h
| GEN qapi-types.h
| GEN qapi-visit.h
| GEN qapi-event.h
| GEN qmp-introspect.h
| GEN tests/test-qapi-types.h
| GEN tests/test-qapi-visit.h
| GEN tests/test-qmp-commands.h
| GEN tests/test-qapi-event.h
| GEN tests/test-qmp-introspect.h
| GEN config-all-devices.mak
| GEN trace/generated-events.h
| GEN trace/generated-tracers.h
| GEN trace/generated-tcg-tracers.h
| GEN trace/generated-helpers-wrappers.h
| GEN trace/generated-helpers.h
| CC tests/qemu-iotests/socket_scm_helper.o
| GEN qemu-monitor.texi
| GEN qemu-img-cmds.texi
| GEN qemu-options.texi
| GEN qemu-monitor-info.texi
| GEN qemu-tech.html
| GEN qemu-img.1
| GEN qemu-nbd.8
| GEN qemu-ga.8
| GEN qmp-commands.txt
| GEN qga/qapi-generated/qga-qapi-types.h
| GEN qga/qapi-generated/qga-qapi-visit.h
| GEN qga/qapi-generated/qga-qmp-commands.h
| GEN qga/qapi-generated/qga-qapi-types.c
| GEN qga/qapi-generated/qga-qapi-visit.c
| GEN qga/qapi-generated/qga-qmp-marshal.c
| GEN qmp-introspect.c
| GEN qapi-types.c
| GEN qapi-visit.c
| GEN qapi-event.c
| CC qapi/qapi-visit-core.o
| CC qapi/qapi-dealloc-visitor.o
| CC qapi/qmp-input-visitor.o
| CC qapi/qmp-output-visitor.o
| CC qapi/qmp-dispatch.o
| CC qapi/qmp-registry.o
| CC qapi/string-input-visitor.o
| CC qapi/string-output-visitor.o
| CC qapi/opts-visitor.o
| CC qapi/qapi-clone-visitor.o
| CC qapi/qmp-event.o
| CC qapi/qapi-util.o
| CC qobject/qnull.o
| CC qobject/qint.o
| CC qobject/qstring.o
| CC qobject/qdict.o
| CC qobject/qlist.o
| CC qobject/qfloat.o
| CC qobject/qbool.o
| CC qobject/qjson.o
| CC qobject/qobject.o
| CC qobject/json-lexer.o
| CC qobject/json-streamer.o
| CC qobject/json-parser.o
| GEN trace/generated-events.c
| CC trace/control.o
| CC trace/qmp.o
| CC util/osdep.o
| CC util/cutils.o
| CC util/unicode.o
| CC util/qemu-timer-common.o
| CC util/compatfd.o
| CC util/event_notifier-posix.o
| CC util/mmap-alloc.o
| CC util/oslib-posix.o
| CC util/qemu-openpty.o
| CC util/qemu-thread-posix.o
| CC util/memfd.o
| /home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/qemu-2.7.0/util/memfd.c:40:12: error: static declaration of ‘memfd_create’ follows non-static declaration
| static int memfd_create(const char *name, unsigned int flags)
| ^~~~~~~~~~~~
| In file included from /usr/include/x86_64-linux-gnu/bits/mman-linux.h:115:0,
| from /usr/include/x86_64-linux-gnu/bits/mman.h:45,
| from /usr/include/x86_64-linux-gnu/sys/mman.h:41,
| from /home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/qemu-2.7.0/include/sysemu/os-posix.h:29,
| from /home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/qemu-2.7.0/include/qemu/osdep.h:104,
| from /home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/qemu-2.7.0/util/memfd.c:28:
| /usr/include/x86_64-linux-gnu/bits/mman-shared.h:46:5: note: previous declaration of ‘memfd_create’ was here
| int memfd_create (const char *__name, unsigned int __flags) __THROW;
| ^~~~~~~~~~~~
| /home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/qemu-2.7.0/rules.mak:59: recipe for target ‘util/memfd.o’ failed
| make: *** [util/memfd.o] Error 1
| make: *** Waiting for unfinished jobs…
| WARNING: /home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/temp/run.do_compile.27008:1 exit 1 from ‘exit 1’
| ERROR: Function failed: do_compile (log file is located at /home/drewwestrick/SW/workspace/legato_framework/yocto/build_bin/tmp/work/x86_64-linux/qemu-native/2.7.0-r1/temp/log.do_compile.27008)
ERROR: Task (virtual:native:/home/drewwestrick/SW/workspace/legato_framework/yocto/poky/meta/recipes-devtools/qemu/qemu_2.7.0.bb:do_compile) failed with exit code ‘1’
NOTE: Tasks Summary: Attempted 857 tasks of which 0 didn’t need to be rerun and 1 failed.
Summary: 1 task failed:
virtual:native:/home/drewwestrick/SW/workspace/legato_framework/yocto/poky/meta/recipes-devtools/qemu/qemu_2.7.0.bb:do_compile
Summary: There were 9 WARNING messages shown.
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.
Makefile:217: recipe for target ‘image_bin’ failed

Build Configuration:

Build Configuration:
BB_VERSION = “1.32.0”
BUILD_SYS = “x86_64-linux”
NATIVELSBSTRING = “Ubuntu-18.04”
TARGET_SYS = “arm-poky-linux-gnueabi”
MACHINE = “swi-mdm9x28”
DISTRO = “poky-swi-ext”
DISTRO_VERSION = “2.2.3”
TUNE_FEATURES = “arm armv7a vfp neon”
TARGET_FPU = “softfp”
meta
meta-poky
meta-yocto-bsp = “HEAD:e6aadcc2a04ae4e85b1cb00c5c9ce1c0f76ee871”
meta-python
meta-networking
meta-oe = “HEAD:b40116cf457b88a2db14b86fda9627fb34d56ae6”
common
meta-swi-mdm9xxx
meta-swi-mdm9x28 = “HEAD:f646dfd3f5c04ca9a38321020cc4f3f9bdc015f5”
meta-swi-mdm9xxx-bin
meta-swi-mdm9x28-bin
meta-swi-mdm9x28
meta-swi-mdm9xxx-bin
meta-swi-mdm9x28-bin
common = “HEAD:9aca15ff07789cda916d0cd7efc4dacb87714883”

Should I try and use a more up-to-date version of qemu-native?

@dfrey @dclark75 @asyal


#19

Have you tried make image_bin. I believe make image_src is only possible within Sierra Wireless because it depends on proprietary source.


#20

Yes sorry that was a typo. make image_src is not even an option in the Makefile. I’m running make image_bin.