CHDK Wiki
Register
Advertisement

This section contains tools to prepare your card for use with the canon script system.

Warning

Backup the Data on your SD-Card before you continue.


Warning

Avoid executing Canon Basic scripts when CHDK is loaded, unless you know what you are doing. Explained [here].

Overview[]

The following are required to run a canon script. The tools below can be used to set this up

  • The SD card may be in FAT16 or FAT32 format.
  • The SD card may need to be low-level formatted in the camera first.
  • The SD card must contain the following items:
  1. The string "SCRIPT" must be at offset 0x1F0 of the first sector (Boot sector of the partition).
  2. The file "script.req" must exist on the card's root directory, and must only contain the string "for DC_scriptdisk" (works without any trailing newline character)
  3. The file "extend.m" must exist on the root directory. This file must contain the Canon BASIC script to execute.
  4. Start the camera in Play Mode then click the FUNC./SET button to run the script. Some touchscreen cameras run the script when the focus lever is turned to the left.

CHDK[]

The following lua script prepares a script disk on camera. You must have Native function call support enabled in the CHDK miscellaneous menu.

--[[
@title prepare script disk
]]

f=io.open("A/SCRIPT.REQ","w")
if not f then
	error("file open failed")
end
f:write("for DC_scriptdisk")
f:close()

if call_event_proc("SystemEventInit") == -1 then
	call_event_proc("System.Create")
end
call_event_proc("MakeScriptDisk",0)

--

*nix[]

The following shell script is adapted from Alfredo and Orens original documentation. This should be applicable to most unixish systems, but may need some adjustment for your specific system.

Note: Mac OSX users can prepare cards using my MacBoot app (which does pretty much what the unix script does but somewhat more safely). Download from http://www.zenoshrdlu.com/macboot/macboot.html

Warning

This script could damage your system if you tell it to use the wrong device. Make sure you know which device is your SD card, and that the usage of /mnt is compatible with your system.


#!/bin/bash
#Enable powershot basic scripting on a memory card
if [ $# -ne 1 ] ; then
  echo
  echo "Usage : ./makeScriptCard.sh [ device ]"
  echo
  echo " [ device ] is a fat32 / fat16 partition on the memory card"
  echo " example : ./makeScriptCard.sh /dev/sdb1"
  echo "NOTE: please run as root"
  exit 112
fi
echo Boot sector of $1 will be modified. If you are not sure this is what you want then cancel with Ctrl-C
sleep 8
#TAG on boot sector
if ! echo -n SCRIPT | dd bs=1 count=6 seek=496 of=$1 ; then {
   echo failed writing to boot sector
   exit 113
} fi
if mount | grep /mnt ; then {
    umount /mnt
} fi
if ! mount $1 /mnt ; then {
    echo failed to mount
    exit 114
} fi
#create script request file
echo -n "for DC_scriptdisk" > /mnt/script.req
#Example script
echo 'private sub sayHello()
  a=LCDMsg_Create()
  LCDMsg_SetStr(a,"Hello World!")
end sub
private sub Initialize()
  UI.CreatePublic()
  sayHello()
end sub
'>/mnt/extend.m
#Done !
echo "Please check /mnt for files extend.m and script.req"

Windows[]

EOScard[]

The EOScard utility can be used to prepare the cards boot sector with the "SCRIPT" string.

  • Start EOSCard, select your SD card drive
  • Check [x] SCRIPT in the Strings section, uncheck all other options there
  • Press "Save" to write the boot sector
  • You'll get a feedback information in the status bar
  • Close EOSCard
  • Create the "script.req" file and save your script like described in Canon_Basic/Card_Setup#Overview
  • Remove the SD card using the "safely remove hardware" icon from the taskbar


Disk editor[]

On Windows a Disk Editor can be used to write the string "SCRIPT" onto the SD-Card.

Double check the drive / drive letter to avoid killing your hard disk drive(s) !

HxD[]

Canon scriptdisk hxd

HxD - Canon Script Disk

Advertisement