supplierdeeply

rebooting/loading CHDK binaries from lua or canon basic

  • 60 Replies
  • 8302 Views
*

Offline hwntw

  • ***
  • 132
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #50 on: 16 / May / 2011, 08:15:53 »
Advertisements
Hello,
How do I boot SDM from within CHDK, using a script?
I have read this thread and the WIki on the subject, but so far I can only do a reboot of CHDK.
What should the file name be and what arguments does the script need?
SDM doesn't appear to include PS.FI2 files, which makes this more difficult for dryos cameras.

If you build an FI2 file, you can just put it on your SD card, named something like SDM.FI2, and then call reboot("A/SDM.FI2")

Without an FI2 file, you must have an *unencoded* diskboot. This means you can't use the DISKBOOT.BIN from dryos cameras. Instead, you must build sdm, and save loader/<camera>/main.bin*  onto your SD card. Then use
reboot("A/MAIN.BIN")
You can rename it to anything you like, as long as the extension doesn't start with .FI

For cameras that don't use an encoded diskboot (vxworks) you can just use diskboot.bin instead of main.bin.

* I'm assuming the SDM build process creates this like CHDK, haven't checked.

edit:
It occurs to me that the Canon "firm update" menu may get confused if there are multiple .FI2 files in the root directory. If this is a problem, you can probably avoid it by calling the file *.FIX or putting it in a sub directory.
Hello,
I have this working using the MAIN.BIN method.
With CHDK 1187 running, execute Reyalp's sample reboot.bas and my Ixus 95 reboots into SDM. Power cycle to get back into CHDK.
I got the MAIN.BIN from compiling SDM 1.85 in CHDK-Shell, with the gmake clean compile option disabled, file is in ... loader/[Platform]

Best,

Colin
Ixus 300HS S100 G9


Windows XP SP3

*

Offline funnel

  • ****
  • 349
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #51 on: 15 / April / 2012, 03:43:52 »
On sx220 doesn't work with the unencoded main.bin.

From lua:
reboot() -> works
reboot("A/PS.FI2") -> encoded works
reboot("A/MAIN.BIN") -> not working
reboot("A/DISKBOOT.BIN") -> encoded not working

With the unencoded bin also crashes with the lua script from the first post and the canonbasic script.

Fails on the function that is pointed from 0x80000000 (0XFFFF0880 in my case). It just hangs with a black screen. Removing the turnoff_display doesn't do anything special, the same crash just without the black screen. The romlog is empty.

*

Offline asm1989

  • *****
  • 527
  • SX720, SX260, SX210 & SX200
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #52 on: 15 / April / 2012, 06:07:04 »
funnel
I understand MAIN.BIN & DISKBOOT.BIN are the same file, and the encode is done  including in CHDK GCC the OPT_FI2 option?

What combinations have you tryed with the CanonBasic Script?

*

Offline philmoz

  • *****
  • 2936
    • Photos
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #53 on: 15 / April / 2012, 06:35:25 »
I understand MAIN.BIN & DISKBOOT.BIN are the same file, and the encode is done  including in CHDK GCC the OPT_FI2 option?

main.bin - is the executable code as compiled and linked by GCC
diskboot.bin - is main.bin obfuscated using 'dancing bits'
ps.fi2 - is main.bin compressed and encoded with the firmware encryption key

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)


*

Offline asm1989

  • *****
  • 527
  • SX720, SX260, SX210 & SX200
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #54 on: 15 / April / 2012, 09:21:54 »
THANKS!!  philmoz    :xmas :xmas

I was using diskboot.bin with the dancingbits as main.bin , Now I can load sx260 using the canonbasic script!!


*

Offline funnel

  • ****
  • 349
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #55 on: 15 / April / 2012, 10:20:38 »
I accidentally used the main.bin from core/main.bin instead the one in the loader/camera/main.bin. Both loaders work fine.
« Last Edit: 15 / April / 2012, 10:32:16 by funnel »

*

Offline alvm

  • ***
  • 116
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #56 on: 02 / June / 2012, 13:07:28 »
Hi,

I'm trying run binary file using Canon basic binary loader http://chdk.wikia.com/wiki/Canon_Basic/Scripts/Loader

I've added code from cpuinfo path to /loader/a810/main.c file and compiled it. Then I've copied main.bin to SD card and run the binary loader script. In UART I get string "Start Program on RAM" and cam hungs. What can be wrong?

The my_restart() function:

Code: [Select]
void __attribute__((noreturn)) my_restart()
{
    #if 0
    void __attribute__((noreturn)) (*copy_and_restart)(char *dst, char *src, long length);
    int i;

//*(int*)0xC0220120 = 0x46;

    for (i=0; i<(blob_copy_and_reset_size/sizeof(long)); i++)
{
    ((long*)(RESTARTSTART))[i] = blob_copy_and_reset[i];
    }

    copy_and_restart = (void*)RESTARTSTART;
    copy_and_restart((void*)MEMISOSTART, (char*)blob_chdk_core, blob_chdk_core_size);
    #else
    cpuinfo_write_file();
    #endif
}

Thanks,
Alex.

*

Offline srsa_4c

  • ******
  • 3171
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #57 on: 02 / June / 2012, 13:40:21 »
Hi,

I'm trying run binary file using Canon basic binary loader
I think you're mixing up different things. That loader is for loading a binary that is able to boot the camera. You replaced the CHDK loader with a function call. This will never work, as you see, the camera tries to execute it, but the process ends up in nowhere.
To use that routine (cpuinfo http://chdk.setepontos.com/index.php?topic=2139.0 , I guess that's what you would like to run), you need a functioning OS. Try to re-integrate that patch into the CHDK core, as it was originally intended.
« Last Edit: 02 / June / 2012, 13:42:17 by srsa_4c »


*

Offline alvm

  • ***
  • 116
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #58 on: 02 / June / 2012, 14:13:50 »
As I understood from chdk wiki the script can run any bin files not for boot only.

Sorry, _vsprintf() was be ported wrong... Patch works fine:

Code: [Select]
Start Program on RAM

Call debug_read_cpuinfo()

debug_read_cpuinfo() is OK

ID         0x41059461

Cache type 0x0F112112

TCM type   0x000C00C0

Control    0x00050079

Protection Region 0 0x0000003D

Protection Region 1 0xC000002F

Protection Region 2 0x00000033

Protection Region 3 0x40000033

Protection Region 4 0x80000017

Protection Region 5 0xFF80002D

Protection Region 6 0x00000000

Protection Region 7 0x00000000

Region data perms 0x03333330

Region inst perms 0x03333330

DCache cfg 0x00000034

ICache cfg 0x00000034

Write buffer 0x00000034

DTCM cfg   0x80000006

ITCM cfg   0x00000006

Exit from cpuinfo_write_file() <---- after this cam hangs but it doesn't matter yet :)

« Last Edit: 02 / June / 2012, 14:28:34 by alvm »

*

Offline srsa_4c

  • ******
  • 3171
Re: rebooting/loading CHDK binaries from lua or canon basic
« Reply #59 on: 02 / June / 2012, 14:29:38 »
As I understood from chdk wiki the script can run any bin files not for boot only.
Yes, but this http://chdk.wikia.com/wiki/Canon_Basic/Scripts/Loader script was meant to reboot the camera with a loaded binary, it was not meant to return normally. Of course you can create a proper event procedure that can also return, but then you don't need reboot.
« Last Edit: 02 / June / 2012, 14:32:00 by srsa_4c »

 

Related Topics