CHDK用、自動ブートSDの準備
Canon S95を愛用しており、ブラケティングを多用することなどから、ロシアンファームCHDKを使用している。普段のワークフローだと問題ないんだが、たまさかカメラからSDを引っこ抜いてコンビニなどの店頭プリントを使用するときに問題が生じる。カメラ側では見えているファイルが店頭プリント機では見えないのだ。
まあ、何か原因があるんだろうが、特に困りもしないので放っておいた。暇なので検証してみた。背景と原因はこういうことらしい。
- S95の発売は2010年8月、つまりCHDKのブートはFAT16パーティションから行う必要がある。んでもって、4GB以上のSDを使うとなると、ブート用のFAT16パーティションとは別に、二番目のVFATパーティションを用意することになる。
- CHDKを使用する上で、またLinux上でカードリーダで使用する際は、上のパーティション構成でまったく問題ない。ただ、WindowsやWindowsベースの店頭プリント機ではパーティションが見えない。
- Windowsでパーティションが見えるようにトリックが必要。
これを踏まえた上で、SDをCHDK用に準備するには以下のようになる。
- 先ずフォーマットする。道具は何でもよいが結果はこんな感じ。ブート用とデータ用の二つのパーティション、ブートフラグ。
$ sudo fdisk -l /dev/sdg Disk /dev/sdg: 16.1 GB, 16055795712 bytes 64 heads, 32 sectors/track, 15312 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x9357b7f9 Device Boot Start End Blocks Id System /dev/sdg1 * 1 11 11248 6 FAT16 /dev/sdg2 12 15312 15668224 b W95 FAT32
$ sudo mkdosfs /dev/sdg1 mkdosfs 3.0.7 (24 Dec 2009) $ sudo mkdosfs -F32 /dev/sdg2 mkdosfs 3.0.7 (24 Dec 2009)
- SDをブート用にする。ここでいうブート用とは、Canon製カメラでのSDの取扱いでのハナシ。
$ echo -n BOOTDISK | sudo dd bs=1 count=8 seek=64 of=/dev/sdg1
- SDにCHDKを仕込む。DISKBOOT.BIN、vers.req、PS.FI2などブート関連はFAT16パーティションのルートに。CCHDK.CFG、SCRIPTSフォルダ、LANGフォルダなどCHDKユーティリティを含むCHDKフォルダをFAT32パーティションへ。
$ sudo sfdisk -uS -N3 -f /dev/sdg Checking that no-one is using this disk right now ... BLKRRPART: Device or resource busy This disk is currently in use - repartitioning is probably a bad idea. Umount all file systems, and swapoff all swap partitions on this disk. Use the --no-reread flag to suppress this check. Disk /dev/sdg: 15312 cylinders, 64 heads, 32 sectors/track Old situation: Units = sectors of 512 bytes, counting from 0 Device Boot Start End #sectors Id System /dev/sdg1 * 32 6143 6112 6 FAT16 <- この行を /dev/sdg2 6144 31358975 31352832 b W95 FAT32 /dev/sdg3 0 - 0 0 Empty /dev/sdg4 0 - 0 0 Empty Input in the following format; absent fields get a default value. <start> <size> <type [E,S,L,X,hex]> <bootable [-,*]> <c,h,s> <c,h,s> Usually you only need to specify <start> and <size> (and perhaps <type>). /dev/sdg3 :32 6112 6 <- ここでそのまま指定 Warning: given size (6112) exceeds max allowable size (0) /dev/sdg3 32 6143 6112 6 FAT16 New situation: Units = sectors of 512 bytes, counting from 0 Device Boot Start End #sectors Id System /dev/sdg1 * 32 6143 6112 6 FAT16 /dev/sdg2 6144 31358975 31352832 b W95 FAT32 /dev/sdg3 32 6143 6112 6 FAT16 /dev/sdg4 0 - 0 0 Empty Warning: partitions 1 and 3 overlap Do you want to write this to disk? [ynq] y Successfully wrote the new partition table Re-reading the partition table ... BLKRRPART: Device or resource busy The command to re-read the partition table failed. Run partprobe(8), kpartx(8) or reboot your system now, before using mkfs If you created or changed a DOS partition, /dev/foo7, say, then use dd(1) to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1 (See fdisk(8).)
$ sudo sfdisk --id /dev/sdg 1 5 Done
おしまい。カードリーダからSDを抜き、書き込みロックしてからカメラへ。
参考サイト