CHDK Wiki
Register
(→‎Overview: dropped the newline requirement after 'DC_scriptdisk' part. CHDK lua script didn't create it and windows line endings will kill ya... /sylikc)
m (→‎*nix: mismatched "if")
(8 intermediate revisions by 5 users not shown)
Line 5: Line 5:
 
The following are required to run a canon script. The tools below can be used to set this up
 
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 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:
 
* The SD card must contain the following items:
 
# The string "SCRIPT" must be at offset 0x1F0 of the first sector (Boot sector).
 
# The string "SCRIPT" must be at offset 0x1F0 of the first sector (Boot sector).
 
# 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)
 
# 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)
 
# The file "extend.m" must exist on the root directory. This file must contain the Canon BASIC script to execute.
 
# The file "extend.m" must exist on the root directory. This file must contain the Canon BASIC script to execute.
  +
# Start the camera in Play Mode then click the FUNC button to run the script. Some touchscreen cameras run the script when the focus lever is turned to the left.
   
 
==CHDK==
 
==CHDK==
The following lua script prepares a script disk on camera. You must have [[LUA/LUA_Reference/Native_Function_Calls|Native function call]] support compiled in.
+
The following lua script prepares a script disk on camera. You must have [[Lua/Lua_Reference/Native_Function_Calls|Native function call]] support compiled in.
 
<source lang="lua">
 
<source lang="lua">
 
--[[
 
--[[
Line 33: Line 35:
   
 
==*nix==
 
==*nix==
The following shell script is from Alfredo and Orens original documentation. This should be applicable to most unixish systems, but may need some adjustment for your specific system.
+
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
 
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
Line 51: Line 53:
 
exit 112
 
exit 112
 
fi
 
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
 
#TAG on boot sector
echo -n SCRIPT | dd bs=1 count=6 seek=496 of=$1
+
if ! echo -n SCRIPT | dd bs=1 count=6 seek=496 of=$1 ; then {
  +
echo failed writing to boot sector
#mount card
 
  +
exit 113
umount /mnt
 
  +
} fi
mount $1 /mnt
 
  +
if mount | grep /mnt ; then {
 
umount /mnt
  +
} fi
 
if ! mount $1 /mnt ; then {
  +
echo failed to mount
  +
exit 114
  +
} fi
 
#create script request file
 
#create script request file
echo "for DC_scriptdisk" > /mnt/script.req
+
echo -n "for DC_scriptdisk" > /mnt/script.req
 
#Example script
 
#Example script
 
echo 'private sub sayHello()
 
echo 'private sub sayHello()
Line 74: Line 85:
   
 
==Windows==
 
==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 <tt> [x] SCRIPT </tt>in the <tt> Strings </tt> 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.
 
On Windows a Disk Editor can be used to write the string "SCRIPT" onto the SD-Card.
   
  +
{{tagb|→}}'''Double check the drive / drive letter to avoid killing your hard disk drive(s) !'''
===HxD===
 
  +
 
====HxD====
 
* Download [http://mh-nexus.de/en/hxd/ HxD - Freeware Hex Editor and Disk Editor]
 
* Download [http://mh-nexus.de/en/hxd/ HxD - Freeware Hex Editor and Disk Editor]
* Start HxD with Administrator Rights
+
* Start HxD with administrator rights
* Choose first Partition on SD-Card and uncheck Writeprotected
+
* Choose the first partition on your SD card and uncheck "Writeprotected"
* Edit you SD-Card following [[Canon_Basic#Format_of_the_SD_card]]
+
* Edit you SD card following [[Canon_Basic#Format_of_the_SD_card]], then create the "script.req" file and save your script like described in [[Canon_Basic/Card_Setup#Overview]]
  +
 
[[File:Canon_scriptdisk_hxd.png|thumb|left|HxD - Canon Script Disk]]
 
[[File:Canon_scriptdisk_hxd.png|thumb|left|HxD - Canon Script Disk]]
 
[[Category:Development]]
 
[[Category:Development]]

Revision as of 03:11, 24 April 2014

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.

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).
  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 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 compiled in.

--[[
@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