rebooting/loading CHDK binaries from lua or canon basic - page 3 - General Discussion and Assistance - CHDK Forum

rebooting/loading CHDK binaries from lua or canon basic

  • 60 Replies
  • 13756 Views
*

Offline reyalp

  • ******
  • 11903
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #20 on: 17 / September / 2010, 02:41:18 »
Advertisements
Thinking about adding reboot support to the trunk. I've added the reset function to the sigs, trying a full batch build now.

I have both reboot and booting a different binary working on d10 and a540.

propose something like:
reboot(["filename"])
If filename isn't given, it does a regular reboot, otherwise load and boot file. The plain reboot version (at least) should be in ubasic too.

Also requires the DispCon_TurnOffDisplay, but can just use event procs from C code rather than verifying 100+ stubs.

Thoughts ?
Don't forget what the H stands for.

Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #21 on: 17 / September / 2010, 05:07:40 »
I've added the reset function to the sigs

How much disk space do all the DISKBOOT.BIN's require ?

Quote
I have both reboot and booting a different binary working on d10 and a540.
Thoughts ?


Does that mean you can boot CHDK from SDM and vice versa ?


*

Offline reyalp

  • ******
  • 11903
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #22 on: 17 / September / 2010, 13:25:59 »
How much disk space do all the DISKBOOT.BIN's require ?
You mean for all CHDK cameras ? I don't know off hand. Current CHDK diskboots are about 250k each, so * ~160 camera+firmware variants is ~40mb, or half that if you zip them.
Quote
Quote
I have both reboot and booting a different binary working on d10 and a540.
Thoughts ?
Does that mean you can boot CHDK from SDM and vice versa ?
Only if SDM implemented the equivalent functionality ;)

Actually, it should work if you have CHDK autoboot, you could load SDM manually, and then do a plain reboot from SDM to get back to CHDK.

One unfortunate thing is that the file boot method will not be able to use encoded files, so on newer cameras you'd need two copies if you wanted to be able to autoboot or manually boot the same version. To get around this you'd have to either find the diskboot decoding function (bunch of cameras to check, but you can skip vx and old dryos) or implement it in CHDK (adds a bit of bloat.)
Don't forget what the H stands for.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #23 on: 18 / September / 2010, 10:50:40 »
Thoughts ?

Aside from "go for it", not really :)



*

Offline fe50

  • ******
  • 3099
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50

*

Offline reyalp

  • ******
  • 11903
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #25 on: 19 / September / 2010, 18:47:49 »
Checked this in, changeset 944

Both lua and ubasic accept reboot by itself or with a file name. On lua, it will return false on failure (file not found, out of memory etc). It doesn't return a value on ubasic, but the fact the script is still running indicates failure.

This feature should be considered experimental. It appears to work on d10 and a540, so it will probably work on a range of vxworks and dryos cams.

example lua script:
Code: [Select]
--[[
@title reboot
@param a use file
@default a 0
--]]
if a == 0 then
reboot()
end
reboot("A/MAIN.BIN")
and ubasic
Code: [Select]
@title reboot
@param a use file
@default a 0

if a=0 then reboot else reboot "A/MAIN.BIN"
Description
 shut down the display and reboot the camera.
 bootfile is the name of the file to boot.
  Must be an unencoded ARM binary, will be loaded at 0x1900
  For cameras which use encoded diskboot, loader/<camera>/main.bin may be used
  For cameras which do not use encoded diskboot, DISKBOOT.BIN may be used
  No sanity checking is performed on the binary, except that the size is >= 4 bytes
 If bootfile is NULL, camera firmware is rebooted. DISKBOOT.BIN will be loaded or not according to normal rules
 returns 0 on failure, does not return on success
 does NOT save camera settings to flash
 does NOT retract lens before rebooting
 calling from playback mode is recommended

Regarding retracting the lens, the event proc StoreLensForShutDown may be of interest. I haven't tried it. If not retracted when you call reboot, the freshly booted OS will (probably) retract the lens, and then re-extend it if in rec mode.

I haven't checked whether Restart syncs files to disk, but it is a good idea to close any files you had open before rebooting.

If diskboot is present, rebooting with a file is slightly faster, since it boots CHDK directly instead of booting the canon OS and then rebooting again for CHDK.

The Restart function is not identified really well by sigs. I've tried to verify, but with so many cameras, errors are likely

The following cameras were matched 100%. I have not not checked most of them against dumps
a430 a480 a610 a620 a650 a700 a720 g9 ixus100 ixus55 ixus60 ixus65 ixus750 ixus800 ixus80 ixus85 ixus860 ixus90 ixus95 ixus960 ixus970 s90 ixusizoom s3is sx100 sx200

The following were manually verified (some were also 100%). If one sub was correct, I haven't checked the others
a450 a460 a470 a530 a540 a550 a560 a570 a590 a630 a640 a710 d10 ixus70 ixus75 ixus850 ixus950 tx1

The following were corrected in stubs_entry_2.s
a2000 g11 g7 ixus40 ixus50 ixus700 ixus870 ixus980 s2is s5is sx10 sx110 sx1 sx20

The function is pretty easy to find. On older cameras (vxworks and early dryos) just look for "Restart Called". On newer cameras look for the constant 0x12345678 and then look around for cp15 code. It is also usually very close to the function detected by finsig.
« Last Edit: 19 / September / 2010, 18:53:32 by reyalp »
Don't forget what the H stands for.

*

Offline whim

  • ******
  • 2013
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #26 on: 19 / September / 2010, 22:15:18 »
@reyalp

thanks for all the efforts !

not sure if you need this feedback, but FWIW:

- compiled vanilla trunk 945 on GCC 4.5.1 and updated cams
- added your script code (as both bas & lua)

reboot() works OK from shooting mode - only a=0 tested
this goes for both IXUS70_SD1000-101B and A590-101B
I would have tested the A590 with a=1 as well, but ran out of batteries ...
will test more extensively and on more cams tomorrow.

cheers,

wim

*

Offline reyalp

  • ******
  • 11903
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #27 on: 19 / September / 2010, 22:50:51 »
Whim, thanks for testing. Definitely good to know which cameras it works on. Probably no need to test both ubasic and lua.

for a=1 to work, you must copy something to A/MAIN.BIN. For cameras that don't need encoded diskboot, this can just be DISKBOOT.BIN renamed. For others, you can use loader/<camera>/main.bin from your source tree.

I'm guessing most people will only use reboot() without a file, but being able to load SDM or another build might be useful sometimes.

I would also be curious if this works on the cameras (SX1 etc) where "firm update" does not work. If so, we can probably make a canon basic loader to allow manual loading on these models.
Don't forget what the H stands for.


*

Offline whim

  • ******
  • 2013
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #28 on: 19 / September / 2010, 23:53:04 »
Quote
...no need to test both ubasic and lua
yeah, sloppy reporting there: used the lua one on 1 and the bas version on the other cam
signing off now, it's 5:30 AM here ...

wim

*

Offline reyalp

  • ******
  • 11903
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #29 on: 20 / September / 2010, 03:07:29 »
I've added an updated cbasic loader: http://chdk.wikia.com/wiki/Canon_Basic/Scripts/Loader
This version does not require an external binary file for the loader code, and works on both vxworks and dryos.
Don't forget what the H stands for.

 

Related Topics