change shortest shutter speed - page 2 - General Discussion and Assistance - CHDK Forum

change shortest shutter speed

  • 21 Replies
  • 4960 Views
Re: change shortest shutter speed
« Reply #10 on: 09 / March / 2011, 05:17:48 »
Advertisements
You would have to find the value.

As far as I know, no one has looked.

That could keep you occupied for a very long time (and still not find it).

It's not a problem, I have much experience with such things.
But this will be useless if I can't patch that value...

Re: change shortest shutter speed
« Reply #11 on: 09 / March / 2011, 10:02:45 »

It's not a problem, I have much experience with such things.

OK, you find the value and its location and then post again.

Re: change shortest shutter speed
« Reply #12 on: 09 / March / 2011, 13:27:24 »
Ok, maybe somebody else can help.. So the question is - can I patch some code/values in the original firmware relatively easily or not?

If you don't know answer to this specific question, please don't post, no offense.

Re: change shortest shutter speed
« Reply #13 on: 09 / March / 2011, 13:43:21 »
Generally, is it possible to patch something in original firmware, eg. some hard-coded value, comparison and so on?

Yes, it is called CHDK.
For example, the movie task is modified to substitute Canon variables with user variables.

Quote
please don't post

OK.
« Last Edit: 09 / March / 2011, 14:06:43 by Microfunguy »


*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: change shortest shutter speed
« Reply #14 on: 09 / March / 2011, 17:07:01 »
Ok, maybe somebody else can help.. So the question is - can I patch some code/values in the original firmware relatively easily or not?

It is possible to write whatever you like over Canon's firmware in Flash (e.g. patching the original firmware), but CHDK doesn't do that and overall it's strongly discouraged because one typo in e.g. address or function syntax could brick your camera beyond repair (JTAG in a Canon factory aside). If you find some code in the firmware dump you want to change, it may not be easy unless you are willing to sacrifice a few cameras in the process. But if it's just something in RAM, it may be as easy as writing to the address in CHDK C code or Lua (poke) at a suitable moment (assuming Canon's fw doesn't overwrite it too often).

CHDK works its magic by replacing some of Canon's tasks with modified versions and launching completely new tasks. CHDK's tasks or hooked tasks can be made to do pretty much whatever you wish, but not everything can be hooked (the entire Canon fw doesn't fit in available RAM).


*

Offline reyalp

  • ******
  • 12865
Re: change shortest shutter speed
« Reply #15 on: 09 / March / 2011, 21:43:01 »
It's not a problem, I have much experience with such things.
The looking at how CHDK does things should give you an idea of what can be modified.
Quote
But this will be useless if I can't patch that value...
That depends on the specific thing you are trying to change. As Microfunguy says, you need to find before you can determine whether it is practical to change that specific value.

Some possible scenarios:
Value in RAM, easy, just poke it. Not likely for max shutter speed.

Constant in ROM that's referenced in one of the tasks we already hook. Easy enough, but you might have to copy a lot of ASM to get to the point where it's referenced.

Constant in ROM that's referenced all over the place. Much harder, probably have to modify the actual value in flash. As fudgey says, we avoid doing this.

Constant value that's used all over the place in ROM code, but built with a series of shifts and adds so you can't even search for the literal value. Yes, these exist ;)
Don't forget what the H stands for.

Re: change shortest shutter speed
« Reply #16 on: 13 / March / 2011, 08:55:21 »
fudgey, reyalp - thank you for detailed answers! That's actually what I wanted to know.

The only reason why I'm asking before finding the exact place to patch is that usually it's much easier to find something when you can easily change code/data, 'run' patched code and see if this was right or wrong place. But it seems that such way isn't possible in this case.

Where I can read more about patching the original fw in flash? I know it's dangerous but if done carefully it's the easiest way to change some constant without finding what task it belongs to.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: change shortest shutter speed
« Reply #17 on: 13 / March / 2011, 15:20:14 »
Where I can read more about patching the original fw in flash? I know it's dangerous but if done carefully it's the easiest way to change some constant without finding what task it belongs to.
Well, I suppose first you need to know your way around the fw disassembly, meaning you'll need to study http://chdk.wikia.com/wiki/For_Developers quite a bit. And after you've found something you think is safe to change, I believe you'd write to flash using Canon's firmware functions using either Lua (native calls enabled) or Canon basic and hope you get it right.

Canon doesn't check the flash for changes/corruption, do they...?


*

Offline reyalp

  • ******
  • 12865
Re: change shortest shutter speed
« Reply #18 on: 13 / March / 2011, 15:51:47 »
Where I can read more about patching the original fw in flash?
In the firmware dump. I'd start with the WriteToRom and EraseSectorOfRom eventprocs. You can find out how these functions are used from the canon crash log code.
Quote
I know it's dangerous but if done carefully it's the easiest way to change some constant without finding what task it belongs to.
Keep in mind that AFAIK no one here has actually done this. We've seen the functions, and decided not to brick our cameras.

Also keep in mind that many constants end up as immediate values that are scattered around the code, and that you can only write complete sectors. Writing a sector that happens to overlap with code the firmware is actually running would be a Bad Thing, since flash must be erased before writing. There might be other issues with this as well.

If you decide to go this route, I strongly suggest getting the cheapest used camera you can find. You may be able to find one that is broken in some way (cracked display, sensor problems etc) but still able to run.

Also, please document your experiences :)

Canon doesn't check the flash for changes/corruption, do they...?
As far as I can tell, they don't. The romstarter does check whether a firmware is present, but that just looks at the first few bytes. There are checksum functions, but I don't think they are called by in the normal boot process (but don't take my word for it!)
Don't forget what the H stands for.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: change shortest shutter speed
« Reply #19 on: 13 / March / 2011, 16:40:36 »
Also keep in mind that many constants end up as immediate values that are scattered around the code, and that you can only write complete sectors. Writing a sector that happens to overlap with code the firmware is actually running would be a Bad Thing, since flash must be erased before writing. There might be other issues with this as well.

Oh, this reminds me of a uc I've worked with that allows erasing its internal flash in 1k sectors but it's really only safe to do it in blocks of 4 sectors unless you only cycle it a couple of times because the other 3 sectors need to be refreshed and may corrupt if you don't. We probably have no clue what sort of caveats like this Canon's flash may have.

 

Related Topics