robocowboy: (Default)
[personal profile] robocowboy
My new Canon SX1 arrived today, though I didn't really get much time to play with it. Amazing photo and video quality from the first round of test shots. Loving it. I'll spend the next two weekends taking as many photos and videos as I can to get comfortable with it before the big trip.

I also got CHDK (Canon Hackers Development Kit) installed on it with no issues. Well, except for the fact that I couldn't leave well enough alone and wrote a new installation script. If anybody with a supported Canon camera wants to try preparing a camera card for CHDK installation under OS X, give it a try.




#!/bin/bash
#
################################################################################
# CHDK installer script for OSX
################################################################################


################################################################################
# identify OS version for correct diskutil syntax
################################################################################

OS_VERSION=`sw_vers | grep Build | awk '{print $2}' | sed s/[A-Z]/\ /g | awk '{print $1}'`


################################################################################
# identify disk for CHDK installation
################################################################################

while [[ $REPLY1 != "yes" ]]
do
    clear
    printf "\nThis script will step you through preparing a memory card for use with CHDK."
    printf "\n\nI have tested the script on Leopard and Snow Leopard (Mac OS X 10.5 and 10.6)"
    printf "\nand it worked for me. However, use this at your own risk!"
    printf "\n\nThe tools in utilized by this script can format (i.e. ERASE) any,"
    printf "\nyes ANY disk on your computer that you specify."
    printf "\n\nI've tried to make it easy to do it right, but please pay attention!"
    printf "\n\n\n\n\nAre you willing to take responsibility for your own actions"
    printf "\nand proceed with caution?\n\n"
    echo "type 'yes' or 'no'"

    read REPLY1; [ "$REPLY1" == yes ] || exit
done

clear
diskutil list

printf "\nThis is a list of all disks in your system."
printf "\nIdentify the one you want to install CHDK on."
printf "\n\nenter the disk number: disk"

read NUMBER; DEVICE=disk${NUMBER}

if [[ $OS_VERSION == 10 ]]
then
    READONLY=`diskutil info $DEVICE | grep "Read-Only Media" | awk '{print $3}'`
elif [[ $OS_VERSION == 9 ]]
then
    READONLY=`diskutil info $DEVICE | grep "Read Only" | awk '{print $3}'`
else
    echo "Your OS is older than Leopard and I haven't tested the script on it."
    echo "Hack away at your own peril and have a nice day!"
    exit
fi

if ! [ -e /dev/$DEVICE ]
then
    echo "/dev/$DEVICE does not exist!"
    exit
elif [[ $DEVICE == `df | grep -e "/$" | sed s/[s/]/\ /g | awk '{print $2" "$3 }' | sed s/\ /s/g` ]]
then
    echo "That's your boot volume! Don't erase that!"
    exit
elif [[ $READONLY == "Yes" ]]
then
    echo "File system is read-only. Unlock your card!"
    exit
fi    

printf "Enter a name for the CHDK partition (or press return for CHDK) : "
read CHDK_VOL; [ "$CHDK_VOL" != "" ] || CHDK_VOL="CHDK"
    
printf "Enter a name for the other partition (or press return for CAMCARD) : "
read CAMCARD_VOL; [ "$CAMCARD_VOL" != "" ] || CAMCARD_VOL="CAMCARD"

WARN="We are about to *COMPLETELY* erase ${DEVICE}. Is this correct?"
echo
echo $WARN | sed s/./!/g
echo $WARN
echo $WARN | sed s/./!/g
echo "type 'yes' or 'no'"
read REPLY2; [ "$REPLY2" == yes ] || exit


################################################################################
# format and partition the disk
################################################################################

if [[ $OS_VERSION == 10 ]]
then
    diskutil partitionDisk $DEVICE 2 MBR "MS-DOS FAT16" $CHDK_VOL 16M "MS-DOS FAT32" $CAMCARD_VOL R
elif [[ $OS_VERSION == 9 ]]
then
    diskutil partitionDisk $DEVICE 2 MBRFormat "MS-DOS FAT16" $CHDK_VOL 16M "MS-DOS FAT32" $CAMCARD_VOL 16M
else
    echo "Your OS is older than Leopard and I haven't tested the script on it."
    echo "Hack away at your own peril and have a nice day!"
    exit
fi

printf "\n\nI sure hope this is what you wanted!"
printf "\n\nPress RETURN to continue" ; read


################################################################################
# make CHDK partition bootable
################################################################################

#dd if=/dev/${DEVICE}s1 of=BootSector.bin bs=512 count=1
#printf "BOOTDISK" | dd bs=1 count=8 seek=0x40 conv=notrunc of=BootSector.bin
#dd if=BootSector.bin of=/dev/${DEVICE}s1 bs=512 count=1
#rm BootSector.bin

clear
printf "Type 'yes' to make the volume named $CHDK_VOL on $DEVICE bootable"
printf "\nor just press RETURN to skip and continue.\n"; read REPLY3

if [ $REPLY3 == "yes" ]
then
    diskutil unmountDisk $DEVICE
    clear
    
    echo "---- BEFORE ----"
    hexdump -C -n 80 /dev/${DEVICE}s1
    echo "---- BEFORE ----"

    echo
    printf "BOOTDISK" | dd bs=1 count=8 seek=0x40 conv=notrunc of=/dev/${DEVICE}s1
    echo

    echo "---- AFTER ----"
    hexdump -C -n 80 /dev/${DEVICE}s1
    echo "---- AFTER ----"

    printf "\n\nPress RETURN to continue" ; read
    
    diskutil mountDisk $DEVICE
fi


################################################################################
# maybe put veer.req and/or vers.req files onto card
################################################################################

while [[ $REPLY4 != "4" ]]
do
    clear
    echo "Would you like a 'ver.req' and/or 'vers.req' file placed on your card"
    echo "to help you identify your camera firmware version?"
    echo
    echo "1. only 'ver.req' file"
    echo "2. only 'vers.req' file"
    echo "3. both files"
    echo "4. do nothing"
    printf "\nEnter a number: "

    read REPLY4; [ "$REPLY4" != "" ] || exit

    case "$REPLY4" in
        1)
            touch /Volumes/${CHDK_VOL}/ver.req;
            REPLY4=4
            ;;
        2)
            touch /Volumes/${CHDK_VOL}/vers.req;
            REPLY4=4
            ;;
        3)
            touch /Volumes/${CHDK_VOL}/ver.req;
            touch /Volumes/${CHDK_VOL}/vers.req;
            REPLY4=4
            ;;
    esac
done


################################################################################
# the end!
################################################################################

echo
ls -1 /Volumes/$CHDK_VOL
echo
echo "If you need to, don't forget to lock your card after copying CHDK files to it"
printf "\n\nHappy shooting!\n\n"



(yes, it's an ugly hack, but that's how I roll)

The features in CHDK I really want to use are the scriptable and highly configurable time-lapse photography tricks. People are working on ones that adjust aperture and shutter speed, etc, across the day and night so you can take really long time-lapse shots and have the exposure be correct for the time of day. Yet another hacking hobby. Neat stuff!

I should get some sleep now so I can enjoy some daylight with the new camera later.
From:
Anonymous( )Anonymous This account has disabled anonymous posting.
OpenID( )OpenID You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address. Sign in using OpenID.
User
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.

Profile

robocowboy: (Default)
robocowboy

December 2014

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
28 293031   

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 27th, 2017 02:23 pm
Powered by Dreamwidth Studios