NXP i.MX 6 ホスト環境構築とBSP提供イメージのSDカードへの書き込み

メモ

購入

  • MCIMX6ULL-EVK

ダウンロード

  • L4.19.35_1.1.0_images_MX6UL7D.zip
  • L4.19.35_1.1.0_LINUX_DOCS.zip

Host環境

試したこと

  • 付属の SD Card でboot(Quick Reference Guide を見ながら) → OK

  • i.MX_Linux_User's_Guide.pdf を参照して、

$ sudo dd if=<image name>.wic of=/dev/sdx bs=1M && sync

で imx-image-multimedia-imx6ul7d.wic を SD Card にコピーしブート → NG、デバッグ用USBに何も出力されず

  • i.MX_Linux_User's_Guide.pdf と i.MX_Yocto_Project_User's_Guide.pdf を参照して、以下を実施。
$ sudo fdisk /dev/sdx
/dev/sdx1 は vfat でフォーマット
/dev/sdx2 は ext4 でフォーマット
*dtb ファイル を /dev/sdx1 に展開(/dev/sdx1 は mount させてファイルコピー)
zImageを配置
imx-image-multimedia-imx6ul7d.tar.bz2 を /dev/sdx2 に展開(/dev/sdx2 は mount させてファイルコピー)
最後に
$ sudo dd if=<U-Boot image> of=/dev/sdx bs=1k seek=<offset> conv=fsync

→ OK、デバッグ用USBに以下が出力され、SD Card から正常に起動が確認できた。

U-Boot 2019.04-4.19.35-1.1.0+g4d377539a1 (Oct 29 2019 - 19:32:57 +0000)

CPU:   Freescale i.MX6ULL rev1.1 900 MHz (running at 396 MHz)
CPU:   Commercial temperature grade (0C to 95C) at 36C

(略)

Starting kernel ...

(略)

NXP i.MX Release Distro 4.19-warrior imx6ul7d ttymxc0

imx6ul7d login:

スクリプト

自分用のメモ

#! /bin/bash

if [ -z $1 ]; then
    echo "usage: sudo $0 /dev/sdx"
    exit 1
fi

echo -en "\e[33;1m${1} will be formatted, are you sure?\e[m (y/n): "
read input
if [ "$input" = 'Y' -o "$input" = 'y' ]; then
    echo "continue"
else
    exit 1
fi

# 
# https://qastack.jp/superuser/332252/how-to-create-and-format-a-partition-using-a-bash-script
# 

# --------------------------------------------------
umount "${1}"*
sync

# to create the partitions programatically (rather than manually)
# we're going to simulate the manual input to fdisk
# The sed script strips off all the comments so that we can 
# document what we're doing in-line with the actual commands
# Note that a blank line (commented as "defualt" will send a empty
# line terminated with a newline to take the fdisk default.
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${1}
  p  # [lists the current partitions]
  d  # [to delete existing partitions. Repeat this until no unnecessary partitions are reported by the 'p' command to start fresh.]
     # default
  d
     # default
  d
     # default
  n  # [create a new partition]
  p  # [create a primary partition - use for both partitions]
  1  # [the first partition]
  20480  # [starting at offset sector]
  1024000 # [size for the first partition to be used for the boot images]
  Y  # 署名を削除しますか? [Y]es/[N]o:
  p  # [to check the partitions]
  n
  p
  2
  1228800 # [starting at offset sector, which leaves enough space for the kernel, the bootloader and its configuration data]
    # [using the default value will create a partition that extends to the last sector of the media]
  Y  # 署名を削除しますか? [Y]es/[N]o:
  p
  w  # [this writes the partition table to the media and fdisk exits]
  q # and we're done
EOF
sync

# --------------------------------------------------
mkfs.vfat -n boot -S 512 ${1}1
mkfs.ext4 -F -L rootfs ${1}2
sync

# --------------------------------------------------
workdir="/home/xxxx/work"
mkdir -p $workdir/boot && mount -t vfat ${1}1 $workdir/boot || exit
mkdir -p $workdir/image && mount -t ext4 ${1}2 $workdir/image || exit
sync

# --------------------------------------------------
cp -r ./L4.19.35_1.1.0_images_MX6UL7D/zImage-imx6ull14x14evk.bin $workdir/boot/zImage && sync || exit

# --------------------------------------------------
cp -r ./L4.19.35_1.1.0_images_MX6UL7D/*.dtb $workdir/boot/
sync

cp ./L4.19.35_1.1.0_images_MX6UL7D/imx-image-full-imx6ul7d.tar.bz2 $workdir/image/
pushd $workdir/image/
tar -jxvf imx-image-full-imx6ul7d.tar.bz2
popd
sync

dd if=./L4.19.35_1.1.0_images_MX6UL7D/u-boot-imx6ull14x14evk_sd.imx of=${1} bs=1k seek=1 conv=fsync
sync

# --------------------------------------------------
umount $workdir/boot
umount $workdir/image
sync

TODO

  • SD Card の作成手順をもう少し詳細を記述する
  • Yocto環境構築

https://blog.web.nifty.com/engineer/1040 https://www.yoctoproject.org/docs/2.3.2/ref-manual/ref-manual.html#ref-features-image http://mickey-happygolucky.hatenablog.com/entry/2018/11/27/102308 https://yoctobbq.lineo.co.jp/?q=node/161 https://pc.watch.impress.co.jp/docs/column/1month-kouza/672565.html