since I want to get into the secrets of CHDK and do own developments I need a kind of overview how CHDK is organized.
The assertion CHDK is organized assumes facts not in evidence
Is there any flowchart available which shows the overall workflow of CHDK after the cam ist switched on?
Or do I heave to read and understand the code line by line?
Not all of it, but if you want to understand the code reading it is a good place to start. My usual approach is to look at some area I'm interested in and grep to figure out what references it. Or if I don't know where the thing I'm interested in, grep for likely terms.
This old thread has some hint about how chdk starts http://chdk.setepontos.com/index.php/topic,1454.0.html
though beware it's very old so some of the information is out of date.
The wiki porting page (also sadly out of date) http://chdk.wikia.com/wiki/Adding_support_for_a_new_camera
also gives some good information about the overall structure (or lack thereof)
how a newbee like me should know what is done here?
- what is spytask_can_start=0; for?
Spytask needs to wait for some filesystem stuff to be ready (see your platform/<some camera>sub/<some sub>/boot.c )
- what is aram_malloc_init(); for?
- what is exmem_malloc_init(); for?
Suggest you look at those functions if the name isn't sufficiently self-explanatory.
- what does this do: while((i++<400) && !spytask_can_start) msleep(10);
Wait for either spytask_can_start to be set or 4 seconds to pass.
- why msleep(50); is called?
started() and finished() turn the debug LED on and off, this keeps it on long enough to see.
As you can see if there is nothing documented inside the code it is very very difficult to understand the rules and functionality behind, but I need it to get a basic understanding what is under the hood of CHDK.
What please is the best way to get familar with that?
The same way the rest of us do... by reading the code and trying to make it do what we want. Cursing and drinking are also recommended but not strictly required.
I don't want to complain but I really want to know why the developers do not put some small comments into the code that some other developer can get a better understanding. I think code documentation is mandatory especially in OpenSource projects where several developers work together.
I agree that the source is poorly documented.
That said, documentation trivial things (like the *_malloc_init above) is not really helpful IMO. To really *understand* the code you need to read the *code* not the comments.
- What is the entry function (is there something like a main() function) which is called after switching on the camera?
Everything starts in loader/<camera>/entry.s
From there after some copying it goes to platform/<camera>/main.c startup() which then goes to sub/<sub>/boot.c boot()
The boot code starts the various tasks (like OS threads or processes). Most CHDK code runs in either spytask or kbd_task.
- How any writing to the screen is done. What is the basic function to put any drawing or text on the screen.
This is done in the core/gui* files, if you should easily be able to find some functions that draw things by name and see how they are used.