[bootlin/training-materials updates] master: Embedded Linux online: new challenges (7022f4ae)

Michael Opdenacker michael.opdenacker at bootlin.com
Sun May 31 17:50:55 CEST 2020


Repository : https://github.com/bootlin/training-materials
On branch  : master
Link       : https://github.com/bootlin/training-materials/commit/7022f4ae47cf837abc2c5b697d231a176753da6c

>---------------------------------------------------------------

commit 7022f4ae47cf837abc2c5b697d231a176753da6c
Author: Michael Opdenacker <michael.opdenacker at bootlin.com>
Date:   Sun May 31 17:50:55 2020 +0200

    Embedded Linux online: new challenges
    
    Signed-off-by: Michael Opdenacker <michael.opdenacker at bootlin.com>


>---------------------------------------------------------------

7022f4ae47cf837abc2c5b697d231a176753da6c
 .../online-challenges/004-prepare-sd.txt           | 41 +++++++++++++++++
 .../online-challenges/005-boot-linux-from-sd       | 51 ++++++++++++++++++++++
 .../online-challenges/known-issues.txt             | 12 +++++
 3 files changed, 104 insertions(+)

diff --git a/resources/embedded-linux/online-challenges/004-prepare-sd.txt b/resources/embedded-linux/online-challenges/004-prepare-sd.txt
new file mode 100644
index 00000000..95b3a56e
--- /dev/null
+++ b/resources/embedded-linux/online-challenges/004-prepare-sd.txt
@@ -0,0 +1,41 @@
+Prepare SD card
+---------------
+
+Goal: prepare an SD card image
+- to contain the zImage and DTB file for booting
+  (instead of booting the kernel directly
+  from the QEMU command line)
+- to contain the future root filesystem
+
+- Using the dd command, create a 1 GB file
+  filled with zeros, called "sd.img"
+  This will be used by QEMU as an SD card disk image
+
+- Run "cfdisk sd.img" and create the same partitions
+  as in the "Block filesystems lab":
+  - Partition 1: primary, 64M, bootable, "FAT16" type
+  - Partition 2: primary, 8M, "Linux" type (default)
+  - Partition 3: primary, all remaining space, "Linux" type (default)
+  Write the changes and quit
+
+- Now use the loop driver to emulate block devices
+  from this image and its partitions:
+
+  sudo losetup -f --show --partscan sd.img
+
+  -f: finds a free loop device
+  --show: shows the loop device that it used
+  --partscan: scans the loop device for partitions
+    and creates additional /dev/loop<x>p<y> block
+    devices.
+
+- Using such devices, you can now format the 3 partitions:
+  - Partition 1: FAT16, with "boot" label
+  - Partition 2: ext4, with "root" label
+  - Partition 3: ext4, with "data" label
+
+- Last but not least, mount the first partition and
+  copy the zImage and dtb file to it.
+
+- Unmount the first partition and release the loop device:
+  sudo losetup -d /dev/loop<x>
diff --git a/resources/embedded-linux/online-challenges/005-boot-linux-from-sd b/resources/embedded-linux/online-challenges/005-boot-linux-from-sd
new file mode 100644
index 00000000..d26a04d8
--- /dev/null
+++ b/resources/embedded-linux/online-challenges/005-boot-linux-from-sd
@@ -0,0 +1,51 @@
+Boot Linux from SD
+------------------
+
+We are going to load the kernel and DTB from the FAT
+filesystem in the first partition of the emulated SD card.
+
+To make this happen, we have to set U-Boot's "bootcmd"
+environment variable to do this.
+
+- The first thing we need is to recompile U-Boot with
+  the ability to store its environment in a file in a FAT
+  partition (our emulated machine doesn't have flash).
+
+  So, go back to U-Boot's configuration and:
+  - unset "Environment in flash memory" (CONFIG_ENV_IS_IN_FLASH)
+  - set "Environment is in a FAT filesystem" (CONFIG_ENV_IS_IN_FAT)
+  - set "Name of the block device for the environment" (CONFIG_ENV_FAT_INTERFACE) to "mmc"
+  - set "Device and partition for where to store the environemt in FAT" (CONFIG_ENV_FAT_DEVICE_AND_PART) to "0:1"
+    The above two settings correspond to the arguments of the "fatload" command
+    (see the block filesystems lab)
+  - Also add support for the "editenv" command (CONFIG_CMD_EDITENV)
+    that is not present in the default configuration for our board
+    Unfortunately, this command is currently broken.
+
+- Recompile U-Boot
+
+- Start QEMU again, but this time with the emulated SD card:
+  qemu-system-arm -M vexpress-a9 -m 128M -nographic -kernel u-boot -sd sd.img
+
+- Then make sure that you can set and store an environment variable:
+  setenv foo bar
+  saveenv
+
+- Type "reset" and check that "foo" is still set:
+  printenv foo
+
+- Now, run "bdinfo" and fine that RAM starts at 0x60000000.
+  We will load the kernel image from the SD's FAT partition to
+  address 0x61000000, and the DTB at address 0x62000000
+
+  Modify the "bootcmd" environment variable to do this,
+  and then boot the kernel from such addresses in RAM.
+
+  Also set the "bootargs" variable to use "ttyAMA0" as console.
+  We will configure the root device in the next lab.
+
+- Run "saveenv" then "reset" and then make sure that the
+  the board boots the Linux kernel as far as previously.
+
+It's now time to compile a root filesystem for Linux
+to use!
diff --git a/resources/embedded-linux/online-challenges/known-issues.txt b/resources/embedded-linux/online-challenges/known-issues.txt
new file mode 100644
index 00000000..2a07b35b
--- /dev/null
+++ b/resources/embedded-linux/online-challenges/known-issues.txt
@@ -0,0 +1,12 @@
+Current issues
+--------------
+
+- "editenv" broken in U-Boot in QEMU
+  (2020.07-rc2 status)
+  This may be related to the fact
+  that editing previous commands is broken too
+  (need to investigate).
+
+- The "boot" command doesn't work either
+  as an equivalent to "run bootcmd"
+  (2020.04 status)




More information about the training-materials-updates mailing list