08 10月 2015

Intel Edison; boot from SD card.

There is very detailed post in Intel's forum. Basically I just follow the instruction in that post.
https://communities.intel.com/thread/61048

Prepare SD card

In my case, out-of-box Edison (edison-weekly_build_56_2014-08-20_15-54-05) did not have mkfs.ext4 command. But in the latest firmware (weekly-159), the command exists. And so you do not need a Linux PC to format SD card with ext4.

Copy edison-image-edison.ext4 in a zipped firmware file to Edison using scp command.
$ scp edison-image-edison.ext4 root@192.168.2.15:edison-image-edison.ext4
Or copy the file to a SD card.

Insert SD card to Edison. If you copied the file to SD card, then copy the ext4 image file to somewhere else as SD card will be formatted.
# cp /media/sdcard/edison-image-edison.ext4 /home/root/

Find SD card's device name
# mount | grep sdcard
In my case, it is /dev/mmcblk1.

Format it with ext4.
# umount /media/sdcard
# mkfs.ext4 /dev/mmcblk1p1

Mount ext4 image file and SD card.
# mount -o loop /home/root/edison-image-edison.ext4 /mnt
# mount /dev/mmcblk1p1 /media/sdcard

Copy files.
# cp -a /mnt/* /media/sdcard/

Configure U-Boot variables

I wrote a shell script based on the forum post.

#!/bin/sh
fw_setenv mmc-bootargs 'setenv bootargs root=${myrootfs} rootdelay=3 rootfstype=ext4 ${bootargs_console} ${bootargs_debug} systemd.unit=${bootargs_target}.target hardware_id=${hardware_id} g_multi.iSerialNumber=${serial#} g_multi.dev_addr=${usb0addr}'

# SD card
sdcard=`mount | grep sdcard | awk '{print $1;}'`
if [ "$sdcard" == "" ] ; then
  echo Insert SD card and try again.
  exit
fi
fw_setenv myrootfs_sdcard $sdcard

# eMMC
emmc=`/usr/sbin/fw_printenv uuid_rootfs | sed 's/uuid_rootfs=\(.*\)/\1/'`
fw_setenv myrootfs_emmc PARTUUID=$emmc

# Can use those at boot> prompt too.
fw_setenv do_boot_emmc 'setenv myrootfs ${myrootfs_emmc}; run do_boot'
fw_setenv do_boot_sdcard 'setenv myrootfs ${myrootfs_sdcard}; run do_boot'

# reboot from_sdcard or from_emmc
fw_setenv do_handle_bootargs_mode 'run do_preprocess_bootargs_mode; if itest.s $bootargs_mode == "ota" ; then run do_ota; fi; if itest.s $bootargs_mode == "boot" ; then run do_boot; fi; if itest.s $bootargs_mode == "flash"; then run do_flash; fi; if itest.s $bootargs_mode == "from_sdcard"; then run do_boot_sdcard; fi; if itest.s $bootargs_mode == "from_emmc"; then run do_boot_emmc; fi; run do_fallback; exit;'

The script modifies do_handle_bootargs_mode variable too. With this modification, you can boot from SD card by "reboot from_sdcard", or from eMMC by "reboot from_emmc".


0 件のコメント:

コメントを投稿