* 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.