Nn embedded linux notes

From Wiki at Neela Nurseries
Revision as of 21:33, 13 December 2017 by Ted (talk | contribs) (^ linux/arch/arm/configs and bcm2709_defconfig versus versatile_defconfig)
Jump to: navigation, search

Wiki Main Page | User Page of Ted | Google search engine


Embedded Linux Notes
this wiki article created 2017-12-11 Monday



Overview

This wiki document is a collection of Ted's notes on embedded Linux studies, with a starting point of building a recipe for a Linux system to run on a RaspberryPi 2 target hardware platform. Near term goal is to build a customized Linux 4.x kernel and test that it runs on a RaspberryPi dev board. Long term goal has two parts:  (1) build a more useful Linux system with working C and C++ toolchain, networking stack, web server, e-mail and database server support, an X server or comparable graphics and desktop support, and  (2) target other hardware platforms beyond RaspberryPi 2 board.

As of 2017-12-11 these notes are a mess, so Ted reviewing work so far and here starting summary of what's important, what has worked, what best steps known today to take going forward. First the major pieces we are finding and using:

  • cross-compiling toolchain, e.g. Linaro gcc
  • QEMU system hardware emulator

The cross-compiler and related tools we use to build our kernel and 'target' a.k.a. 'guest' system softwares. The guest system in our case is a Linux kernel and additional programs compiled to run together as a complete system on an ARM based processor, in the target hardware which is the RaspberryPi 2 board. We cross compile in order to get the much faster compilation times available on a typical cerca 2010 Intel desktop computer. The QEMU software allows us to experiment, jumping through some hoops, with our ARM-targeted kernels and softwares, without a physical RaspberryPi board present. We also get to skip the step of creating a system image and flashing that to SD card. Knowing how to create an SD-card-ready image, however, is important. We'll return to this we hope sooner than later, once we have seen our cross-compiled system pieces run in normal expected ways in QEMU's target hardware emulating environment.

Our target system software pieces for a basic Linux operating system include:

  • Linux kernel 4.x
  • device tree binary (dtb file)
  • kernel modules
  • root file system

Kernel, device trees and kernel modules are all part of the official operating system space. These three pieces get compiled when configuring Linux kernel for a RaspberryPi target board, using the kernel's arch/arm/configs/bcm2709_defconfig default configuration file. Our needed root file system is a separate matter, which we must built separately. We also have a number of options for how to configure and specify what we want to build in this file system.

As of this Monday, Ted finds good notes at a page of Azeria Labs and also a post by graduate student MedicineYeh. Ted finds a little more success from Azeria Labs article, getting QEMU invocations to bring up an already-compiled QEMU Linux kernel for ARM. But Ted's custom compiled 4.x kernels haven't booted yet, and no diagnostics messages visible save four lines relating to some kind of sound card module. MedicineYeh's blog post goes into more details about root file systems and a couple of ways to build them quickly for basic testing and practice, but so far none of his example calls to QEMU have worked. These all hang and time-out without any diagnostics feedback. MedicineYeh's blog post seems to imply in its QEMU output captures that QEMU can put guest system message to the shell which invoked QEMU. But it's not clear to Ted how this would happen, and it doesn't appear to happen by default. QEMU will present the ARM-targeted kernel with a device tree that's expressed in the device tree binary file that the Linux kernel arch' ARM default configuration describes somewhere under the hood . . . that device tree is different and separate from the host's device tree, including the host system's.

Regarding QEMU passing guest kernel message to standard out, there's mention in Azeria Labs article about QEMU option and argument -serial stdio. Ted to try this once he has kernel, dtb file, kernel modules and rootfs all cross-compiled for ARM on Ubuntu host . . .




^ New section - Trouble points

Two trouble points as of 2017-12-11 Monday. One, we're not seeing guest system messages in any of invoking shell, QEMU window, nor Remmina VNC client window. Ted wants to see guest system diagnostics at QEMU-invoking shell prompt. Two, Ted unsure whether we're mounting a rootfs properly in our call to QEMU.


Figure x - problems building and running Linux for ARM under QEMU

  • guest kernel diagnostics not visible
  • questions about passing rootfs to QEMU properly



^ RaspberryPi Kernel Compilation


- 2017-11-25 SAT - These notes are of first efforts to cross-compile Linux kernel and device tree blob, on Intel i386/i686 host system, for target ARM system specifically RaspberryPi 2 dev board. As of 2017-DEC-09 Saturday, four or five custom kernel configurations with rpi target chosen / in mind have failed, for reasons such as "enermation or pound define value not an integer" and "alignment type of variable x not available [on target processor]". Ted noting that the Linux kernel stable release with all its options and supported target hardware platforms and peripherals is heavyweight, not by default configured to be small or simple as possible. Now also looking into Tiny Kernel wiki page and home page of Tiny Core Linux.

Here are instructions for compiling and for cross-compiling a Linux kernel for RaspberryPi target system:



Here are limited instructions on how to configure the Linux kernel for RaspberryPi target systems:



Back in 2017 February this year, February 24th just after Embedded Linux Conference, looks like Ted stepped through some of the instructions at this Raspberry Pi dot org documentation page. Ted noting there are two directories on compiling host in /mnt with this timestamp:


ted@localhost:/mnt$ ls -l make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
total 44
drwxr-xr-x 2 root root 4096 Oct 24  2016 dvd-rom
drwxr-xr-x 2 root root 4096 Feb 24  2017 ext4
drwxr-xr-x 2 root root 4096 Feb 24  2017 fat32
   .
   .
   .

When issuing the cross-compile command that task seemed to complete quickly, giving the following messages which total less than two hundred lines:


ted@rangari:~/projects/raspberrypi/linux$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
#
# configuration written to .config
#
ted@rangari:~/projects/raspberrypi/linux$ make -j 2 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs
scripts/kconfig/conf  --silentoldconfig Kconfig
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  HOSTCC  scripts/dtc/dtc.o
  HOSTCC  scripts/dtc/flattree.o
  HOSTCC  scripts/dtc/fstree.o
  HOSTCC  scripts/dtc/data.o
  HOSTCC  scripts/dtc/livetree.o
  HOSTCC  scripts/dtc/treesource.o
  HOSTCC  scripts/dtc/srcpos.o
make[1]: 'include/generated/mach-types.h' is up to date.
  CHK     include/generated/timeconst.h
  CHK     include/generated/bounds.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  HOSTCC  scripts/dtc/checks.o make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
  HOSTCC  scripts/dtc/util.o
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  HOSTCC  scripts/dtc/dtc-parser.tab.o
  HOSTLD  scripts/dtc/dtc
  HOSTCC  scripts/genksyms/genksyms.o
  HOSTCC  scripts/genksyms/parse.tab.o
  HOSTCC  scripts/mod/mk_elfconfig
  HOSTCC  scripts/genksyms/lex.lex.o
  MKELF   scripts/mod/elfconfig.hhttps://www.raspberrypi.org/forums/viewtopic.php?f=66&t=178806
  HOSTCC  scripts/mod/modpost.o
  HOSTLD  scripts/genksyms/genksyms
  HOSTCC  scripts/kallsyms
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/pnmtologo
  HOSTCC  scripts/conmakehash make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
  HOSTCC  scripts/mod/sumversion.o
  HOSTCC  scripts/recordmcount
  HOSTLD  scripts/mod/modpost
  HOSTCC  scripts/sortextable
  HOSTCC  usr/gen_init_cpio
  CHK     include/generated/compile.h
  GEN     usr/initramfs_data.cpio.gz
  HOSTCC  arch/arm/vdso/vdsomunge
  AS      usr/initramfs_data.o
  LD      usr/built-in.o
  MUNGE   arch/arm/vdso/vdso.so.dbg
  OBJCOPY arch/arm/vdso/vdso.so
  AS      arch/arm/vdso/vdso.o
  LD      arch/arm/vdso/built-in.o
  GZIP    kernel/config_data.gz make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
  CHK     kernel/config_data.h
  HOSTCC  lib/gen_crc32table
  HOSTCC  lib/raid6/mktables
  TABLE   lib/raid6/tables.c
  CC [M]  lib/raid6/tables.o
  LD [M]  lib/raid6/raid6_pq.o
  GEN     lib/crc32table.h
  CC      lib/crc32.o
  LD      lib/built-in.o
  LOGO    drivers/video/logo/logo_linux_clut224.c
  LOGO    drivers/video/logo/logo_linux_mono.c
  LOGO    drivers/video/logo/logo_superh_mono.c make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
  LOGO    drivers/video/logo/logo_superh_vga16.c make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
  LOGO    drivers/video/logo/logo_linux_vga16.c
  LOGO    drivers/video/logo/logo_blackfin_vga16.c
  LOGO    drivers/video/logo/clut_vga16.c
  LOGO    drivers/video/logo/logo_spe_clut224.c
  LOGO    drivers/video/logo/logo_mac_clut224.c
  LOGO    drivers/video/logo/logo_superh_clut224.c
  LOGO    drivers/video/logo/logo_sun_clut224.c
  LOGO    drivers/video/logo/logo_parisc_clut224.c
  LOGO    drivers/video/logo/logo_blackfin_clut224.c
  LOGO    drivers/video/logo/logo_dec_clut224.c
  LOGO    drivers/video/logo/logo_m32r_clut224.c
  LOGO    drivers/video/logo/logo_sgi_clut224.c
  CC      drivers/video/logo/logo_linux_clut224.o
  LD      drivers/video/logo/built-in.o
  LD      drivers/video/built-in.o make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
  LD      drivers/built-in.o
  LINK    vmlinux
  LD      vmlinux.o
  MODPOST vmlinux.o
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  LD      init/built-in.o
  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map
  OBJCOPY arch/arm/boot/Image
  Building modules, stage 2.
  Kernel: arch/arm/boot/Image is ready
  Kernel: arch/arm/boot/Image is ready
  GZIP    arch/arm/boot/compressed/piggy.gzip
  AS      arch/arm/boot/compressed/piggy.gzip.o
  LD      arch/arm/boot/compressed/vmlinux
  OBJCOPY arch/arm/boot/zImage
  Kernel: arch/arm/boot/zImage is ready
  MODPOST 1540 modules
  LD [M]  lib/raid6/raid6_pq.ko
ted@rangari:~/projects/raspberrypi/linux$


At this point it looks like we may have enough to attempt the qemu invocation which was partially working off site west side, since couple days ago we were missing what appeared to be only the kernel when invoking qemu on build box rangari . . .

So we can launch Raspbian for the RaspberryPi 2 board, using a kernel we've built on an i386 architecture host server, using the default bcmp_2907 (mis-spelled) kernel config file. But we can't fully compile a kernel for an ARM / Rpi target architecture when we make any kernel configuration changes via `make menuconfig`. The script which successfully starts our qemu-system-arm version 2.10.0 is:


#!/bin/bash

qemu-system-arm -kernel ./kernel-qemu-4.4.34-jessie -cpu arm1176 -m 256 -M versatilepb -serial stdio -append "root=/dev/sda2 rootfstype=ext4 rw" -hda ./2017-09-07-raspbian-stretch-lite.img -redir tcp:5022::22 -no-reboot

exit 0


Right now this script is located along side several already compiled, ARM-targeted kernels which Ted believes are from the git available cross-compile Rpi project by one 'dhruvvyas90' . . . Dhruvvyas90 qemu-rpi-kernel.

ted@localhost:/var/local/ted/projects/raspberrypi/qemu_vms$ ls
2017-09-07-raspbian-stretch-lite.img  kernel-qemu-4.1.7-jessie   kernel-qemu-4.4.21-jessie  README.md
kernel-qemu-3.10.25-wheezy            kernel-qemu-4.4.12-jessie  kernel-qemu-4.4.26-jessie  start-qemu.sh
kernel-qemu-4.1.13-jessie             kernel-qemu-4.4.13-jessie  kernel-qemu-4.4.34-jessie  tools
ted@localhost:/var/local/ted/projects/raspberrypi/qemu_vms$


- Summary rpi kernel compilations -

As of 2017 Dec 2 we can using QEMU 2.10.0 boot and use Raspbian image and kernel from Raspberry Pi on-line store. We can also substitute alternate kernel in call to QEMU system emulator, a kernel from . . .



^ edit point - custom Rpi-targeted kernel config issues

- 2017-11-30 -

In file included from ./include/uapi/linux/stddef.h:1:0,
                 from ./include/linux/stddef.h:4,
                 from ./include/uapi/linux/posix_types.h:4,
                 from ./include/uapi/linux/types.h:13,
                 from ./include/linux/types.h:5,
                 from fs/xfs/xfs_linux.h:21,
                 from fs/xfs/xfs.h:32,
                 from fs/xfs/xfs_super.c:19:
In function ‘xfs_check_ondisk_structs’,
    inlined from ‘init_xfs_fs’ at fs/xfs/xfs_super.c:1974:2:
./include/linux/compiler.h:518:38: error: call to ‘__compiletime_assert_119’ declared with attribute error: XFS: sizeof(xfs_dir2_sf_entry_t) is wrong, expected 3
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                      ^
./include/linux/compiler.h:501:4: note: in definition of macro ‘__compiletime_assert’
    prefix ## suffix();    \
    ^
./include/linux/compiler.h:518:2: note: in expansion of macro ‘_compiletime_assert’
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^
./include/linux/bug.h:54:37: note: in expansion of macro ‘compiletime_assert’
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                     ^
fs/xfs/xfs_ondisk.h:22:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’
  BUILD_BUG_ON_MSG(sizeof(structname) != (size), "XFS: sizeof(" \
  ^
fs/xfs/xfs_ondisk.h:119:2: note: in expansion of macro ‘XFS_CHECK_STRUCT_SIZE’
  XFS_CHECK_STRUCT_SIZE(xfs_dir2_sf_entry_t,  3);
  ^
scripts/Makefile.build:293: recipe for target 'fs/xfs/xfs_super.o' failed
make[2]: *** [fs/xfs/xfs_super.o] Error 1
scripts/Makefile.build:544: recipe for target 'fs/xfs' failed
make[1]: *** [fs/xfs] Error 2
Makefile:991: recipe for target 'fs' failed
make: *** [fs] Error 2

real	17m33.542s
user	16m10.988s
sys	0m53.000s


Ok as of 2017-12-08 and a few days ago Ted realizing that the `make menuconfig` type call to configure a Linux kernel for a RaspberryPi/Arm target architecture must be of the form as follows below . . . and before starting a fresh kernel configuration it is a good idea to clean up all old object files, intermediate files, old config information using:

   $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mrproper
 
   $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Now again calling the version of this command with options to compile kernel, device tree binary, and modules:

   $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

^ edit point - further references for kernel configuration wrt RaspberryPi target

Ted found these references in the README.md file of QEMU Rpi Tools project. Local directory is qemu-rpi-kernel/. Invoking `git status .` shows this to be a git repository. Invoking `git remote -v` shows this repository to be a clone of:

ted@localhost:~/projects/qemu/qemu-rpi-kernel$ git remote -v
origin  https://github.com/dhruvvyas90/qemu-rpi-kernel.git (fetch)
origin  https://github.com/dhruvvyas90/qemu-rpi-kernel.git (push)
ted@localhost:~/projects/qemu/qemu-rpi-kernel$ #


In the READ.md file the Rpi kernel project author who doesn't identify him or herself lists the following four references together, and there are a couple more refs beyond these mentioned near the end of READ.md:

https://web.archive.org/web/20131210001638/http://xecdesign.com/compiling-a-kernel/
https://web.archive.org/web/20131209235952/http://xecdesign.com/compiling-qemu/
https://web.archive.org/web/20131210001407/http://xecdesign.com/working-with-qemu/
https://web.archive.org/web/20131210001526/http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/



^ Rpi kernel configuration further references



^ general kernel configuration and compile reference

- 2017-12-05 - Ted adding section on general articles, some non-Rpi articles and reference materials which explain how to configure a kernel and then how to invoke the build process and point `make` to the new custom configuration file. This so far not clear from the instructions at Raspberry Pi's articles https://www.raspberrypi.org/documentation/linux/kernel/building.md and https://www.raspberrypi.org/documentation/linux/kernel/configuring.md. These references found at Google via search phrase "invoking make after custom kernel configuration":




^ kernel configuration files and extraction

A booted Linux kernel which exports its configuration settings to /proc/config.gz can be studied in detail from its configuration standpoint. Tools to use in this case include fdisk on the unmounted root file system which got booted up to a working system with the given kernel. During that run session the kernel will populate /proc/config.gz. On the unmounted root file system image use fdisk to determine partition count, file system type and block size, and starting block of the rootfs. Then mount that partition within the rootfs image file with an offset equal to (block size * starting block). Example of this at Azeria Labs RaspberryPi under Qemu tutorial.

Alternately depending on a kernel configuration flag a script named extract-ikconfig can be used on the compressed kernel image, sometimes named zImage to extract the given kernel's configuration . . .



^ linux/arch/arm/configs and bcm2709_defconfig versus versatile_defconfig

Today is 2017-12-13 Wednesday, and yesterday we determined that the one difference between bootable QEMU + kernel + rootfs and non-booting QEMU + kernel + rootfs is the compiled kernel file. So somethings are wrong with our kernel configuration. We retrieved the kernel configuration from the drhuvvyas90 pre-compiled Rpi kernel named kernel-qemu-4.4.34-jessie by mounting the "jessie stretch lite" rootfs image from RaspberryPi downloads page, and copying /proc/config.gz from that rootfs. We could not extract any config information from our compiled kernel, but we likely left disabled a kernel config option mentioned in https://stackoverflow.com/questions/14958192/getting-config-from-linux-kernel-image which would permit running script extract-ikconfig on a compressed kernel image.

While studying drhuvvyas90's build-qemu-kernel shell script in file qemu-rpi-kernel/tools/build-kernel-qemu we notice reference to a default configuration file which is different from the bcm2709_defconfig default configuration named in some of our recently found tutorials on building Linux kernel for RaspberryPi 2 development boards . . .



^ kernel - specific configuration build results

Errors run into when building kernel following configuration 'versatile_defconfig' . . .

  CC      lib/win_minmax.o
  AR      lib/lib.a
  EXPORTS lib/lib-ksyms.o
  LD      lib/built-in.o
  LD      virt/lib/built-in.o
  LD      virt/built-in.o
  LD      vmlinux.o
  MODPOST vmlinux.o
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  LD      init/built-in.o
arch/arm/mm/built-in.o:(___ksymtab+arm926_dma_clean_range+0x0): undefined reference to `arm926_dma_clean_range'
arch/arm/mm/built-in.o:(___ksymtab+arm926_dma_inv_range+0x0): undefined reference to `arm926_dma_inv_range'
Makefile:972: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1

real	23m22.245s
user	21m5.491s
sys	1m21.729s
veris@alta-spare-6:/var/local/raspberrypi/linux$



^ Buildroot

Per Medicine Yeh's tutorial setting out to compile and use buildroot project, to create Linux based root file system to run under QEMU. Mid-way messages from `make` call on buildroot project downloaded from git repository:

/usr/bin/install -m 0644 support/misc/target-dir-warning.txt /var/local/ted/projects-on-slash-var/buildroot/buildroot/output/target/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
>>> skeleton-init-sysv  Extracting
>>> skeleton-init-sysv  Patching
>>> skeleton-init-sysv  Configuring
>>> skeleton-init-sysv  Building
>>> skeleton-init-sysv  Installing to target
rsync -a --ignore-times --exclude .svn --exclude .git --exclude .hg --exclude .bzr --exclude CVS --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' package/skeleton-init-sysv//skeleton/ /var/local/ted/projects-on-slash-var/buildroot/buildroot/output/target/
>>> skeleton  Extracting
>>> skeleton  Patching
>>> skeleton  Configuring
>>> skeleton  Building
>>> skeleton  Installing to target
>>> linux-headers 4.14.4 Downloading
--2017-12-09 23:11:28--  https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.4.tar.xz
Resolving cdn.kernel.org (cdn.kernel.org)... 151.101.53.176, 2a04:4e42:d::432
Connecting to cdn.kernel.org (cdn.kernel.org)|151.101.53.176|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 100784788 (96M) [application/x-xz]
Saving to: ‘/var/local/ted/projects-on-slash-var/buildroot/buildroot/output/build/.linux-4.14.4.tar.xz.VsSH6c/output’


Tail message from `make` on buildroot project:

chmod a+x /var/local/ted/projects-on-slash-var/buildroot/buildroot/output/build/buildroot-fs/fakeroot.fs
rm -f /var/local/ted/projects-on-slash-var/buildroot/buildroot/output/target/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
PATH="/var/local/ted/projects-on-slash-var/buildroot/buildroot/output/host/bin:/var/local/ted/projects-on-slash-var/buildroot/buildroot/output/host/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/sbin:/usr/sbin:/opt/cross/bin:/opt/cross/x-tools/arm-unknown-linux-gnueabi/bin:/home/ted/bin:/usr/local/mysql/bin:/usr/lib/xscreensaver:/etc/init.d:/var/opt/sam-ba_cdc_cdc_linux" /var/local/ted/projects-on-slash-var/buildroot/buildroot/output/host/bin/fakeroot -- /var/local/ted/projects-on-slash-var/buildroot/buildroot/output/build/buildroot-fs/fakeroot.fs
rootdir=/var/local/ted/projects-on-slash-var/buildroot/buildroot/output/target
table='/var/local/ted/projects-on-slash-var/buildroot/buildroot/output/build/buildroot-fs/device_table.txt'
/usr/bin/install -m 0644 support/misc/target-dir-warning.txt /var/local/ted/projects-on-slash-var/buildroot/buildroot/output/target/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM

real    48m56.055s
user    53m27.352s
sys     4m47.896s
ted@rangari:/var/local/ted/projects/buildroot/buildroot$



^ Putting The Pieces Together - QEMU, kernel, rootfs


On our day host system we need and have a cross-compiler, a guest system emulator, a cross-compiled Linux 4.x kernel, a corresponding device tree binary and a root file system . . .


   cross-compiler       ~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
   qemu                 /usr/local/bin/qemu-system-arm
   kernel               /var/local/raspberrypi/linux/arch/arm/boot/zImage
   device tree binary   /var/local/raspberrypi/linux/arch/arm/boot/dts/[ bcm2709-rpi-2-b.dtb | bcm2836-rpi-2-b.dtb | ... ] not sure which dtb to use! - TMH
   root file system     ...

One root file system we have which is part of a successful QEMU boot of a guest Raspbian system is the ~1.85GB raspbian stretch lite image, md5 check sum noted here:

   projects-on-slash-var/raspberrypi/qemu_vms$ md5sum /var/local/ted/downloads/raspberrypi/2017-09-07-raspbian-stretch-lite.img
   2d5f26a5c75ea7e5677542a3411851e3  /var/local/ted/downloads/raspberrypi/2017-09-07-raspbian-stretch-lite.img

And after copying and uncompressing, in the rpi image /proc/config.gz to /home/pi the image file is yet the same size byte-wise but its md5 checksum has changed:


   /var/local/ted/projects-on-slash-var/raspberrypi/qemu_vms$ md5sum /var/local/ted/downloads/raspberrypi/2017-09-07-raspbian-stretch-lite.img
   779a317911ccee73c8a63ff62f670977  /var/local/ted/downloads/raspberrypi/2017-09-07-raspbian-stretch-lite.img


Per Azeria Labs tutorial on emulating RaspberryPi operating system and hardware, a prerequisite step which modifies a system "reach run level" time must be modified. To modify a file in a disk image file we mount the image file in a manner like,


   $ sudo mount -v -o offset=47185920 -t ext4 /var/local/raspberrypi/file-system-images/2017-04-10-raspbian-jessie.img /mnt/raspbian
   [sudo] password for user: 
   mount: /dev/loop0 mounted on /mnt/raspbian.
   $



^ QEMU references



# qemu-system-arm -kernel arch/arm/boot/zImage -dtb rtsm_ve-cortex_a15x4.dtb -m 512 -M vexpress-a15 -serial stdio -append "console=ttyAMA0"



Extra Notes on QEMU


Gosh frustrating, we were just practicing with calling QEMU in the following way (figure x) which follows the form of invocations we have seen in multiple tutorials and forum posts. Nearly all calls fail with a two lines "audio: Could not init `oss' audio driver . . . Could not read keymap file: 'en-us'". Ted suspected these might be errors coming from the kernel starting up in QEMU, and thought to change the kernel to an earlier release in the pre-compiled kernels of Dhruvvyas. This thought led to choosing a non-existent kernel filename and trying that out in call to QEMU. This made no difference! Same error messages, looks like QEMU doesn't get to the point of sanity checking or needing a valid kernel file name. So how can we debug this failure to boot a kernel plus root filesystem for RaspberryPi "guest" platform? What program or executing code are we actually wanting to debug?

Figure x - QEMU invocation which fails with or without kernel . . .

$ qemu-system-arm -M versatilepb -cpu arm1176 -m 256 -serial stdio -kernel /var/local/raspberrypi/qemu-rpi-kernel/kernel-qemu-4.4.34-jessiez -dtb /var/local/raspberrypi/linux/arch/arm/boot/dts/bcm2709-rpi-2-b.dtb -append "root=/dev/sda2 rootfstype=ext4 rw init=/bin/bash console=ttyAMA0" -drive format=raw,file=/home/veris/Downloads/raspberrypi/2017-08-16-raspbian-stretch-lite.img

audio: Could not init `oss' audio driver
Could not read keymap file: 'en-us'

$



References



- - - top of page - - -