Create a dual partition bootable 4GB SDHC card with CHDK under Linux (Slackware) - Hello, I'm a NEWBIE - HELP!! (Newbies assistance, User Guides and thank you notes) - CHDK Forum supplierdeeply

Create a dual partition bootable 4GB SDHC card with CHDK under Linux (Slackware)

  • 2 Replies
  • 8343 Views
Advertisements
Hi there,
This topic is covered somewhat patchily, I found, so I'll document the process of creating a bootable CHDK SDHC card with two partitions for those using Linux.  

The process I followed is from memory of what I read in various posts here.  

Summary: Start with an assumed trashed SDHC card, zero it, format in camera, repartition the card, format the partitions under Linux, load chdk files into both partitions, boot the card and take a photo to confirm image files saved in the second partition as advertised.  Phew!

Note: The 40 cylinder size I used below suits the SanDisk 4GB SDHC card I have, you may prefer to use +1M below in place of the +39 that I used, in order to get a 1MB partition.  The 40 cylinder size I chose created an approx 3/4MB partition.

Do look at the 'fdisk -l' listing from your system and change '/dev/sdc' below to match your SDHC card.

Following is the terminal view, and yes, you need root access:

login as: root
Authenticating with public key "grant@peetoo" from agent
Last login: Mon Jul  6 19:35:02 2009 from sillywin.mire.mine.nu
Linux 2.6.30.1a.

Before marriage the three little words are "I love you," after marriage
they are "Let's eat out."

root@pooh64:~# fdisk -l
...
Disk /dev/sdc: 4075 MB, 4075290624 bytes
126 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 7812 * 512 = 3999744 bytes
Disk identifier: 0x00000000

Disk /dev/sdc doesn't contain a valid partition table

# zero the memory card, taking very special care to set the 'of=...' to SD card,
#  and not your hard drive!

root@pooh64:~# dd if=/dev/zero bs=4k of=/dev/sdc
dd: writing `/dev/sdc': No space left on device
994945+0 records in
994944+0 records out
4075290624 bytes (4.1 GB) copied, 250.36 s, 16.3 MB/s
root@pooh64:~# eject /dev/sdc

# format card in camera and return to the SDHC card reader

# repartition the card (note the information about your card may differ, adjust to suit)

root@pooh64:~# fdisk /dev/sdc

The number of cylinders for this disk is set to 189513.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-189513, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-189513, default 189513): +39  ## see note above ##

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 4
Changed system type of partition 1 to 4 (FAT16 <32M)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (41-189513, default 41):
Using default value 41
Last cylinder, +cylinders or +size{K,M,G} (41-189513, default 189513):
Using default value 189513

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): b
Changed system type of partition 2 to b (W95 FAT32)

Command (m for help): p

Disk /dev/sdc: 4075 MB, 4075290624 bytes
7 heads, 6 sectors/track, 189513 cylinders
Units = cylinders of 42 * 512 = 21504 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1          40         837    4  FAT16 <32M
/dev/sdc2              41      189513     3978933    b  W95 FAT32

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.

# Note: above warning is satisfied because we wrote zeroes to entire memory card
#  if you didn't write zeroes to card, do 'dd if=/dev/zero bs=512 count=1 of=/dev/sdXY
#  where X is drive value Y is 1 then 2, this clears the partitions' first sector as reqd.

# Format the card (create the filesystems), first the FAT16 partition

root@pooh64:~# mkdosfs -n CANON_DC /dev/sdc1
mkdosfs 2.11 (12 Mar 2005)

# Then create the FAT32 second partition

root@pooh64:~# mkdosfs -F 32 -n CANON_DC /dev/sdc2
mkdosfs 2.11 (12 Mar 2005)

# Mount first partition and write the required boot files

root@pooh64:~# mount /dev/sdc1 /mnt/tmp/
root@pooh64:~# cp /home/common/a590-101b-0.9.8-783/DISKBOOT.BIN /mnt/tmp/
root@pooh64:~# cp /home/common/a590-101b-0.9.8-783/PS.FI2 /mnt/tmp/
root@pooh64:~# cp /home/common/a590-101b-0.9.8-783/vers.req /mnt/tmp/
root@pooh64:~# umount /mnt/tmp/

# Mount the second partitions and copy all the CHDK files
root@pooh64:~# mount /dev/sdc2 /mnt/tmp/
root@pooh64:~# cp -r /home/common/a590-101b-0.9.8-783/* /mnt/tmp
root@pooh64:~# umount /mnt/tmp/

# Make the first partition bootable

root@pooh64:~# printf "BOOTDISK\000" > bootdisk
root@pooh64:~# dd if=bootdisk bs=1 count=9 seek=64 of=/dev/sdc1
9+0 records in
9+0 records out
9 bytes (9 B) copied, 0.00124109 s, 7.3 kB/s

root@pooh64:~# eject /dev/sdc


You should now have a bootable SDHC card that auto-boots in camera when the SDHC card is set to 'Lock'.

And no windoze box required 8)
« Last Edit: 10 / July / 2009, 21:56:57 by bugsplatter »

*

Offline reyalp

  • ******
  • 14118
FWIW you don't need need dual partition at all for a 4 gig card. All you need is FAT16 with 64k clusters.
Don't forget what the H stands for.

FWIW you don't need need dual partition at all for a 4 gig card. All you need is FAT16 with 64k clusters.

Perhaps I should have used an 8GB example?  4GB was first SDHC card I picked up ;)

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal