Introduction

In this lab exercise  we'll make a quick image for the STM32MP157D-DK1 using Buildroot. Later on we will switch to the Yocto Project and focus on customizing our build.

Getting Buildroot

Create a new directory and clone the buildroot repository

mkdir lab2
cd lab2
git clone git://git.buildroot.net/buildroot
cd buildroot

Build Embedded Linux Image

You can view the boards that are supported by default in Buildroot:

ls configs


If you can’t find your particular board, you will likely need to find a Buildroot defconfig file on the Internet or write your own (which we won’t get into). We don’t have an stm32mp157d-dk1 defconfig file available, but we can use the ‘a’ version (it just runs at a slower clock speed). Set up the configuration for your board with:

make stm32mp157a_dk1_defconfig


You can adjust kernel and default package options with the following:

make menuconfig

We won’t make any changes, so just exit out of the config menu.

To build the image, enter: 

make


Wait a while - this will take time. When it’s done, you can check the output:

ls -la output/images

Copying the Image to SD Card

Block Device Export

The generate image needs to be copied to the SD card prior to booting. Given the nature of your lab setup you have no immedate access neither to the discovery boards nor the SD cards inserted into the boards. But there is a way to mount the SD cards using the discovert boards in USB OTG mode turning the setup into an USB SD card reader. This mode is called the UMS mass storage mode which can be turn on using the boot loader U-Boot. In U-Boot you do the following:

help ums
ums - Use the UMS [USB Mass Storage]
 
Usage:
ums <USB_controller> [<devtype>] <dev[:part]>  e.g. ums 0 mmc 0
    devtype defaults to mmc

The ums command will loop forever. Discontinue UMS mode pressing CTRL-C. 

On STMicroelectronics boards the OTG USB controller device index is 0, SD card = mmc 0 and, if available, e-MMC = mmc 1. 
You can check the connected device on an SDMMC with the mmc list and mmc info U-Boot command.


Do get into U-Boot login as root enter the following

/sbin/reboot now

or take a look at the follwoing minicom session:

Once the Kernel has stopped and the bootloader takes control hit a key to stop automatic boot process.


Put the board in mass storage mode as described above:


You should now see a new storage block device:

gosper@ce-eda1:~$ ls -l /dev/sd*
brw-rw----  1 root disk 8,  0 Oct 10 13:37 /dev/sda
brw-rw----  1 root disk 8,  1 Oct 10 13:37 /dev/sda1
brw-rw----  1 root disk 8,  2 Oct 10 13:37 /dev/sda2
brw-rw----  1 root disk 8,  5 Oct 10 13:37 /dev/sda5
brw-rw-rw-+ 1 root disk 8, 16 Oct 16 17:11 /dev/sdb
brw-rw-rw-+ 1 root disk 8, 17 Oct 16 17:11 /dev/sdb1
brw-rw-rw-+ 1 root disk 8, 18 Oct 16 17:11 /dev/sdb2
brw-rw-rw-+ 1 root disk 8, 19 Oct 16 17:11 /dev/sdb3
brw-rw-rw-+ 1 root disk 8, 20 Oct 16 17:11 /dev/sdb4

In the above example you can identify the corresponding disk associated with the UMS / USB OTG process via the read / write permissions - /dev/sdb is your device.
Then, copy the .img file to the raw SD card:

Copy Image to Disk

sudo dd if=/output/images/sdcard.img of=/dev/sdb bs=1M


Stop the UMS process in U-Boot and boot your buildroot image.

  • Keine Stichwörter