CHDK inner workings? - General Discussion and Assistance - CHDK Forum  

CHDK inner workings?

  • 8 Replies
  • 3461 Views
*

Offline ixus

  • *
  • 25
  • SD1000/IXUS70
CHDK inner workings?
« on: 01 / March / 2008, 19:26:23 »
Advertisements
Where can I find information on how CHDK works? For example here are some CHDK technical details I am unclear about.

* CHDK is loaded into camera as a firmware upgrade, yet firmware is not upgraded, and CHDK runs on top of current firmware. How is this possible?

* How is CHDK auto load on startup possible?

* What is the interaction between CHDK and the camera firmware? Does CHDK access camera information from the camera firmware or is it accessing them directly from hardware? If the latter, why not just do away with camera firmware altogether?

* I've only seen Allbest source code so I don't know if this applies to other CHDK source codes, but why is there almost zero documentation on source code? No function documentation or file documentation. Is source code documentation located somewhere else or there is no source code documentation at all?




*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: CHDK inner workings?
« Reply #1 on: 02 / March / 2008, 03:34:23 »
* CHDK is loaded into camera as a firmware upgrade, yet firmware is not upgraded, and CHDK runs on top of current firmware. How is this possible?
It's some kind of magic! Really! That stuff was discovered and implemented by Vitaly, so I have only basic understanding here:
- Camera loads CHDK into memory and executes the code. It does not matter the way which the camera uses to do that (FirmwareUpdate or Diskboot).
- Upon execution CHDK installs its own startup code and reboots the camera.
- Camera boots from new startup procedure. CHDK creates its own task (to save RAW and redraw GUI), installs hooks on some tasks, such as keyboard, shooting, etc., and passes the control back to the original firmware.
- CHDK acts on events hooked.


* How is CHDK auto load on startup possible?
This is a feature of original firmware. It always looks for some particular files and conditions and does some particular actions. In case of DISKBOOT.BIN, it loads and executes the file only from FAT16 file system and if card is locked.


* What is the interaction between CHDK and the camera firmware? Does CHDK access camera information from the camera firmware or is it accessing them directly from hardware? If the latter, why not just do away with camera firmware altogether?
It uses both methods: the using of firmware functions and the accessing hardware directly.
The main reasons why CHDK is not just mixed with the firmware are 1) there is no sources of original firmware and patching of it could be difficult task and 2) much more risks to get a brick in case of permanent writing patched firmware back.


* I've only seen Allbest source code so I don't know if this applies to other CHDK source codes, but why is there almost zero documentation on source code? No function documentation or file documentation. Is source code documentation located somewhere else or there is no source code documentation at all?
Programmers (only russian?) are too lazy in case of documenting of source code... So, only sources, wiki and this forum. There are no places with documentation except mentioned.


PS. Maybe some answers you can in find Where do I get the BIG picture of CHDK ? topic.
CHDK Developer.

Re: CHDK inner workings?
« Reply #2 on: 02 / March / 2008, 05:24:44 »
Quote
but why is there almost zero documentation on source code? No function documentation or file documentation.
This is my biggest peeve with CHDK. I've been attempting to understand several parts of the code and it's much quicker for me to just slog away rather than ask questions here. I'm attempting to compile a version that uses pawn rather than uBasic since I want a bit more scripting power, plus speed. But although I think this would be simple for one of the popular developers, it's been keeping me awake many nights. I've been relying a lot on the cross-references that someone posted a couple of weeks back to work out what changes are needed. Some documentation on the source hierarchy would be a great help.

*

Offline whim

  • ******
  • 2041
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: CHDK inner workings?
« Reply #3 on: 02 / March / 2008, 06:19:19 »
@johnnythe

Quote
I've been relying a lot on the cross-references that someone posted a couple of weeks back to work out what changes are needed.

Nice to know it's usefull ! Just in case you prefer to tweak the XREFs yourself, anyone can.
You can get a free 14 day eval version of 'Understand for C++' here:
Scitools - Maintenance, Metrics and Documentation Tools for Ada, C, C++, Java, and FORTRAN
I easily managed to 'rearm' it for another 14 days after it expired.

@GrAnd
On a related note, I recently discovered that 'gcc/arm-elf/bin/ld.exe' - linker/loader i suppose -  in the dev kit supports a '--cref' flag:
Quote
--cref                      Output cross reference table
I tried adding it to the makefile.inc, but couldn't find any output ? Does it need params / a path ? Any hints would be helpful,
it would be MUCH 'cleaner' to have the dev kit generate it's own XREF.

wim


*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: CHDK inner workings?
« Reply #4 on: 02 / March / 2008, 07:36:54 »
@whim
The '--cref' option outputs the following: (see the file attached).
CHDK Developer.

*

Offline whim

  • ******
  • 2041
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: CHDK inner workings?
« Reply #5 on: 02 / March / 2008, 08:03:23 »
@GrAnd

So how do I get this cref.txt ? Do I just add 'LDFLAGS+=--cref' in the root makefile.inc ?
Is the cref.txt created by default in the $(topdir)loader/$(PLATFORM) ?

thanks,
wim

*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: CHDK inner workings?
« Reply #6 on: 02 / March / 2008, 08:15:14 »
I added '--cref' option to the end of 'LDOPTS' in the 'core/Makefile'.

LDOPTS+=-Wl,-N,-Ttext,$(MEMISOSTART),--cref
CHDK Developer.

*

Offline whim

  • ******
  • 2041
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: CHDK inner workings?
« Reply #7 on: 02 / March / 2008, 08:42:48 »
@GrAnd.
Thanks, got it now. Turns out if you redirect errors ( like 2>errors.txt ) that's were it dumps it's cref (under Win dev kit)

wim


*

Offline ixus

  • *
  • 25
  • SD1000/IXUS70
Re: CHDK inner workings?
« Reply #8 on: 02 / March / 2008, 13:03:07 »
Thanks Grand,

Can we start a project documenting the source code?
First, we should make a rule that any new functions added to the source code should have at least basic documentation of what it does.
Second, we should slowly start documenting the entire source code starting with the most important functions.
Third, we should make a documentation header for the souce code file.

 

Related Topics