Before I attempt to answer some of the questions, one advice: You need to disassemble your camera's firmware and at least one more (the ixus160, for example). Use this script first (after editing it, so it finds the utilities):
http://chdk.wikia.com/wiki/GPL:disassemble.plAfter that, use the resulting PRIMARY.BIN.dis plus the file named funcs_by_address.csv (finsig_dryos outputs this for you) with the following script:
http://chdk.wikia.com/wiki/User:Srsa_4c/GPL:stubs2disv7.pl . You'll get disassembly files that have a lot of functions identified and string references will become visible.
The missing stubs and variables can mostly be located using one or more known camera's disassembly as reference.
I don't understand the CHDK boot-up flow
Here's what happens when the camera loads diskboot.bin:
- The content of diskboot.bin is unscrambled and is copied to MEMBASEADDR (that's 0x1900 on DIGIC II...5).
- Cam is restarted, the bootloader jumps to the loaded code at 0x1900.
- The diskboot file starts with code found in loader/
- The CHDK loader copies the CHDK core to its final location. That is usually the original starting address of the camera's malloc heap. The Canon heap is then adjusted in the boot process so Canon code doesn't overwrite the CHDK core.
- A compatibility check is new in CHDK 1.5 (that's the check_compat call you quoted).
- When the CHDK core is relocated, the CHDK loader starts executing it (platform/camera/main.c).
- After this, a modified copy of Canon boot code is executed (platform/camera/sub/.../boot.c), to start the camera normally, with CHDK running alongside the firmware.
diskboot.bin files are scrambled, the scrambling method is known as "dancing bits".
- "task creation"
the firmware's CreateTask function (or one of its variants) is used to start tasks.
(what is "task")
Something like this:
https://en.wikipedia.org/wiki/Thread_(computing)
, what are these files with "*.S" extensions, how do they work in terms of C language usage
They contain ARM assembly and/or preprocessor macros. They are there to interface CHDK with the Canon firmware.
What it "kbd.c" - my camera doesn't have any keyboard.
Cameras have buttons, that's what we call keyboard.
But how would I get the value for NULL_SUB?
Find a BX LR instruction in your cam's disassembly and use its address.