Unreliable startup - General Discussion and Assistance - CHDK Forum supplierdeeply

Unreliable startup

  • 3 Replies
  • 2260 Views
*

Offline waldo

  • ***
  • 238
Unreliable startup
« on: 09 / November / 2009, 13:56:58 »
Advertisements
I am getting my feet wet in doing a CHDK port and to get more familiar with how things work inside a build, I am taking an existing working port for the SD400 and I am stripping it down to some simple code that just loads CHDK and flashes an LED.

All is going well, but I have found that as the code size gets smaller (less than 15KB), CHDK will not start up reliably.  The camera sometimes starts OK or sometimes just extends the lens a tiny amount and shuts down or sometimes will not start at all.

Thinking that this may be related to the code starting up too fast, I lengthened the time in the loader startup delay loop by a factor of 10 and 100 with no help.

Are there any other things I should look at to make the camera start up more reliably?

*

Offline reyalp

  • ******
  • 13965
Re: Unreliable startup
« Reply #1 on: 09 / November / 2009, 17:27:04 »
Can you describe more clearly exactly what you are doing ?

Are you loading with diskboot or firm update or both ?

How are you reducing the size (if you don't need the canon OS running, the simple way is to eliminate all but the loader stuff from blobs.s. If you want the canon OS to boot, then you have to get to platform/<camera>/sub/<version>/boot.c)

What are you trying to do in your code ? If you are trying to access canon functions before the OS is loaded, bad things will usually happen, but this will depend on how much of the original canon OS is clobbered by your firmware image.

Don't forget what the H stands for.

*

Offline waldo

  • ***
  • 238
Re: Unreliable startup
« Reply #2 on: 09 / November / 2009, 18:28:39 »
I'm starting with a working release and stripping it down to better understand what code is involved in the boot process. 

I just discovered that if I create a large const array and access a member of the array to keep it from getting optimized out, all my problems go away.  I now have 5K of executable code and 40K of data that is not executed and it now boots reliably 100% of the time.  So apparently my code was OK, but something in CHDK does not like loading and running small code.

*

Offline reyalp

  • ******
  • 13965
Re: Unreliable startup
« Reply #3 on: 09 / November / 2009, 18:39:05 »
I'm starting with a working release and stripping it down to better understand what code is involved in the boot process.  
This is a lousy way to do it. Start in loader/<camera>/entry.S and follow the code. You can always check loader/<camera>/main.dump to see what the final image looked like.
Quote
I just discovered that if I create a large const array and access a member of the array to keep it from getting optimized out, all my problems go away.  I now have 5K of executable code and 40K of data that is not executed and it now boots reliably 100% of the time.  So apparently my code was OK, but something in CHDK does not like loading and running small code.
Again, if you described what you were doing and how you were doing it, someone might be able to explain why this is happening. Generally speaking, the size of CHDK code doesn't matter. udumper works with an image of a few hundred bytes.

edit:
if you haven't already, you should have a look through http://chdk.wikia.com/wiki/Adding_support_for_a_new_camera which describes some of the boot process. The threads linked in http://chdk.wikia.com/wiki/Udumper and http://chdk.setepontos.com/index.php/topic,1454.0.html may also be useful.
« Last Edit: 09 / November / 2009, 18:43:42 by reyalp »
Don't forget what the H stands for.


 

Related Topics