Build an image for booting in USB Mass-Storage mode

Материал из Wiren Board
Это утверждённая версия страницы. Она же — наиболее свежая версия.
Другие языки:

This manual describes how to build bootstream to boot Linux from USB Mass Storage Gadget. In this case, the contents of the SD-card becomes available via USB as a normal USB flash drive.

The structure of the bootstream:

  • U-Boot SPL - primary boot loader performs initial initialization
  • U-Boot - the boot loader itself, runs Linux
  • The Linux kernel image consists of several parts
    • zImage - kernel
    • initramfs - file system with modules to support USB gadget, is included in zImage
    • DTB - nformation about the periphery required for the kernel to work. Is appended to the end of the zImage, CONFIG_ARM_APPENDED_DTB option should be enabled in the config

Download bootstream


Building Linux

  • To get the kernel sources from git,
$ git clone https://github.com/contactless/linux.git
$ cd linux
$ git checkout dev/v4.1.15 
$ unzip initramfs_usbgadget.zip
$ sudo tar xvf initramfs_usbgadget.tar
  • Initialize the environment to build the kernel. If necessary, change the DT and CROSS_COMPILE variables in this file
$ . ./scripts/kbuild-env.sh
$ set +e
  • Set the config of the kernel
$ make mxs_usbgadget_defconfig
  • Build the kernel and modules by installing them in unpacked initramfs
$ INSTALL_MOD_PATH=./initramfs_usbgadget/ ./scripts/kbuild.sh
  • Build kernel with appended DTB and initramfs
$ ./scripts/kbuild-dtb.sh


Building U-Boot

  • Get u-Boot sources from git. You need a wb_v2015.07 branch
$ cd ..
$ git clone https://github.com/contactless/u-boot.git
$ cd u-boot
$ git checkout wb_v2015.07
  • Set u-Boot config
$ make mx28_wirenboard5_usbgadget_defconfig
  • Copy a previously collected image of [[kernel+initramfs]+DTB] to the U-Boot folder
$ cp ../linux/zImage-imx28-evk ./zImage
  • Build a combined image [U-Boot+[[kernel+initramfs]+DTB|kernel+initramfs]+DTB] into U-Boot folder
$ cp ../linux/zImage-imx28-evk ./zImage
  • Build a combined [U-Boot+[[kernel+initramfs]+DTB]] image suitable for booting to USB (bootstream)
$ CROSS_COMPILE='arm-linux-gnueabi-' make -j4 u-boot.sb


Assembling mxsldr

This utility is needed to download the resulting image via USB. Requires libusb-1.0 library installed (apt-get install libusb-1.0-0-dev)

$ cd ..
$ git clone http://git.denx.de/mxsldr.git
$ cd mxsldr
$ make


Loading a built image using mxsldr

$ ./mxsldr ../u-boot/u-boot.sb