How does CHDK start running

  • 20 Replies
  • 29474 Views
  • Publish
    How does CHDK start running
    « on: 23 / May / 2008, 01:57:26 »
    Advertisements
    I find CHDK extremely interesting. However there is much of it I don't understand.

    the fundamental question is:
    - how does CHDK get loaded and started? can anyone please explain this?

    I put DISKBOOT.BIN and PS.FIR in the root directory of my SD card.
    Then this causes a new menu function appear ("update firmware" or similar)
    - can anyone explain what is happening here?

    I invoke the menu function, and the camera restarts with CHDK running -
    how does this happen?


    What is the meaning and function of the 2 files DISKBOOT.BIN and PS.FIR?
    Why are 2 required?


    If I make the SD card bootable, CHDK can run automatically on power-on -
    how does this work?

    The instructions say to lock the SD card, with the little switch - why is
    this necessary?

    What is the first thing that gets run on startup?
    (I am using a PS A540).

    In src/core/entry.S: is some assmbler code, marked '.section .entry'
    which jumps to startup. This looks like it gets run pretty early.

    and in src/loader/a540/entry.S is similar code, it jumps to my_restart

    my_restart basically does a copy and restart operation.


    Any info much appreciated!

    *

    Offline whim

    • ******
    • 2013
    • A495/590/620/630 ixus70/115/220/230/300/870 S95
  • Publish
    Re: How does CHDK start running
    « Reply #1 on: 23 / May / 2008, 02:36:14 »
    This post DryOS - some success has lots of info on CHDK startup

    wim

    *

    Offline intrnst

    • **
    • 99
    • A710IS + Morebest
  • Publish
    Re: How does CHDK start running
    « Reply #2 on: 23 / May / 2008, 06:16:56 »
    -- funny english, be aware -- CHDK for Dummies - The Very First Steps

  • Publish
    Re: How does CHDK start running
    « Reply #3 on: 25 / May / 2008, 17:45:36 »
    Please, join us at Newbie issues, still - [CHDK for Dummies - The Very First Steps]
    Hi and welcome!

    Hi, I think you misunderstood my question. I don't need help in getting CHDK to run. I downloaded it, built it and ran it without problems. I also made a few experimental modifications to it, again without problem.

    What I am after is technical programming information in the mechanism by which CHDK is booted in a Canon camera. Firstly because it is very interesting to learn about this, secondly, because possible changes I have in mind require knowledge of this.

    Cheers
    W


  • Publish
    Re: How does CHDK start running
    « Reply #4 on: 25 / May / 2008, 17:46:29 »
    This post DryOS - some success has lots of info on CHDK startup

    wim

    Thankyou whim - I will have a look at this.

    *

    Offline intrnst

    • **
    • 99
    • A710IS + Morebest
  • Publish
    Re: How does CHDK start running
    « Reply #5 on: 26 / May / 2008, 14:54:15 »
    wombat
    Sorry if a didn't make myself clear. I'm not exactly an English spoken.
    I was wondering if you could help us in the matter of CHDK for Newbies - Very First Steps, that is: how to identify and help the new guy first needs.
    Once again, if you please, stop by and write some lines about it or you can help directly here.


    Cheers.
    -- funny english, be aware -- CHDK for Dummies - The Very First Steps

    *

    Offline jeff666

    • ****
    • 181
    • A720IS
  • Publish
    Re: How does CHDK start running
    « Reply #6 on: 29 / May / 2008, 06:57:55 »
    I put DISKBOOT.BIN and PS.FIR in the root directory of my SD card.
    Then this causes a new menu function appear ("update firmware" or similar)
    - can anyone explain what is happening here?

    if file exists *.FIR then show menuentry "firm update"

    Quote
    I invoke the menu function, and the camera restarts with CHDK running -
    how does this happen?

    1. load and decode .FIR-file
    2. move decoded contents to 0x1900
    3. continue execution at 0x1900 => our code is executed, now.

    Quote
    What is the meaning and function of the 2 files DISKBOOT.BIN and PS.FIR?
    Why are 2 required?

    *.FIR is run using "Firm Update" menu.
    DISKBOOT.BIN (two other names are also possible) is run using the Diskboot-loader.

    .FIR-files are encoded using the model-ID to prevent accidential firmware-update on the wrong camera.
    .BIN-files are not encoded.

    For VxWorks-cams the encoding mechanism is known and the .bin are converted to .fir

    Quote
    If I make the SD card bootable, CHDK can run automatically on power-on -
    how does this work?
    The instructions say to lock the SD card, with the little switch - why is
    this necessary?

    Canon-firmwares have a diskboot-loader. It works like this:
    1. Check: fileexists DISKBOOT.BIN, ROMWRITE.BIN or UPGRADER.BIN?
    2. Check: Writeprotect set?
    3. Check: string "BOOTDISK" at pos 0x40 in MBR.
    4. if 1-3 are true then load file to 0x1900, continue execution there => our code is executed.


    CHDK restarts the cam and uses modified functions copied from the original firmware to hook itself into normal operation. Details on this are in the article already linked.

    Cheers.

  • Publish
    Re: How does CHDK start running
    « Reply #7 on: 04 / June / 2008, 02:31:20 »




    Quote
    If I make the SD card bootable, CHDK can run automatically on power-on -
    how does this work?
    The instructions say to lock the SD card, with the little switch - why is
    this necessary?

    Canon-firmwares have a diskboot-loader. It works like this:
    1. Check: fileexists DISKBOOT.BIN, ROMWRITE.BIN or UPGRADER.BIN?
    2. Check: Writeprotect set?
    3. Check: string "BOOTDISK" at pos 0x40 in MBR.
    4. if 1-3 are true then load file to 0x1900, continue execution there => our code is executed.

    ...

    Cheers.

    Thanks for this info.


    So do PS.FIR and DISKBOOT.BIN contain essentially the same file? Just a different format?




    I presume the 'make bootable' menu command writes the string 'BOOTDISK' into the MBR?

    By the way, how did you (or others) work all this out? e.g. how did you find that file is loaded to
    the specific address 0x1900? etc


    Cheers
    W




    *

    Offline jeff666

    • ****
    • 181
    • A720IS
  • Publish
    Re: How does CHDK start running
    « Reply #8 on: 04 / June / 2008, 07:03:05 »
    So do PS.FIR and DISKBOOT.BIN contain essentially the same file? Just a different format?

    Correct.

    Quote
    I presume the 'make bootable' menu command writes the string 'BOOTDISK' into the MBR?

    Also correct. There's even a function in the firmware that's called MakeBootdisk and does exactly that.

    Quote
    By the way, how did you (or others) work all this out? e.g. how did you find that file is loaded to
    the specific address 0x1900? etc

    The person who discovered that was Vitaliyb, who reverse enigneered an official firmware update for the A620 (or A630) and made the original Raw-Hack. Pretty much the same work that the folks in the CHDK-on-DSLR-forum are doing right now.

    Cheers.

  • Publish
    Re: How does CHDK start running
    « Reply #9 on: 04 / June / 2008, 11:56:42 »
    @jeff666:

    Thanks for the clear overview!
    ~~~~~~~~~~~~~~~~~~~~~

    <")%%%><<

     

    Related Topics