ふぁみこんくらしっくみにのなかみをまとめ

いろいろわかってきたのでまとめとく

尚、こんなん組み込みLinuxやってたら普通だろ、っていうことも
今回いろいろやって初めて知ったことが多いので見下しといてほしい。

 

構成

  • ブートローダ u-boot (allwinner-zhにボードコンフィグ追加、ファイル修正)
  • Linux version 3.4.112 (cis@vm-cis-deb9-05) (gcc version 4.8.5 (Buildroot 2015.11.1) ) #1 SMP PREEMPT Tue Aug 30 12:04:24 CEST 2016

起動パラメータ

cmdline = root=/dev/nandb decrypt ro console=ttyS0,115200 loglevel=4 ion_cma_512m=148m ion_cma_1g=176m ion_carveout_512m=8m ion_carveout_1g=150m coherent_pool=4m consoleblank=0

 

init

#!/bin/sh
# devtmpfs does not get automounted for initramfs
/bin/mount -t devtmpfs devtmpfs /dev
exec 0</dev/console
exec 1>/dev/console
exec 2>/dev/console
exec /sbin/init $*

/sbin/init

#!/bin/sh

/bin/mount -t proc proc /proc
/bin/mount -t sysfs sys /sys

for i in $(cat /proc/cmdline); do
if [ "$i" = "ro" ] ; then
READONLY="y"
elif [ "${i#root=}" != "$i" ] ; then
ROOTFS="${i#root=}"
elif [ "$i" = "decrypt" ] ; then
DECRYPT="y"
fi
done

MOUNT_OPTS="noatime"
if [ "${DECRYPT}" = "y" ]; then
if [ "${READONLY}" == "y" ]; then
READONLY="--readonly"
else
READONLY=""
fi

/sbin/cryptsetup open ${ROOTFS} root-crypt ${READONLY} --type plain --cipher aes-xts-plain --key-file /key-file
/bin/mount -o "${MOUNT_OPTS}" /dev/mapper/root-crypt /newroot
else
if [ "${READONLY}" == "y" ]; then
MOUNT_OPTS="ro,${MOUNT_OPTS}"
fi

/bin/mount -o "${MOUNT_OPTS}" ${ROOTFS} /newroot
fi

/bin/mount --move /dev /newroot/dev
/bin/umount /proc
/bin/umount /sys
exec /sbin/switch_root /newroot /sbin/init

 

NAND構成 (のbootlog出力)

[ 5.297022] [ND]partition->size :914432
[ 5.301291] [ND]partition->cross_talk :0
[ 5.305654] [ND]partition->attribute :0
[ 5.309953] [ND]partition->start.Chip_NO :0
[ 5.314607] [ND]partition->start.Block_NO :64
[ 5.319450] [ND]partition->end.Chip_NO :0
[ 5.323938] [ND]partition->end.Block_NO :2047
[ 5.328782] [ND]partition->nand_disk[0].size :32768
[ 5.334240] [ND]partition->nand_disk[0].type :0
[ 5.339275] [ND]partition->nand_disk[1].size :6144
[ 5.344597] [ND]partition->nand_disk[1].type :0
[ 5.349630] [ND]partition->nand_disk[2].size :38912
[ 5.355059] [ND]partition->nand_disk[2].type :0
[ 5.360100] [ND]partition->nand_disk[3].size :806912
[ 5.365649] [ND]partition->nand_disk[3].type :0
[ 5.370687] [ND]partition->nand_disk[4].size :2048
[ 5.376048] [ND]partition->nand_disk[4].type :0
[ 5.381088] [ND]partition->nand_disk[5].size :27648
[ 5.386514] [ND]partition->nand_disk[5].type :0

NANDパーティション

[0] : mbr + boot
[1] : rootfs (encrypted, lzmasquashfs)
[2] : private (データ保存?)
[3] : UDISK (?)