Remaining RAW+JPG shots + filespace icon/text- done :D - page 2 - General Discussion and Assistance - CHDK Forum

Remaining RAW+JPG shots + filespace icon/text- done :D

  • 175 Replies
  • 63046 Views
*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Correct Calculation of remaining shots (when RAW enabled) - partly solved
« Reply #10 on: 07 / February / 2008, 10:53:45 »
Advertisements
well, one could scan the directory for the existance of a *.crw file and take its size.
but it should suffice that people just edit their raw size in the osd menu (which i could not achieve yet :D)

Any camera knows its RAW-file size because the camera creates this file and must to know the size of data to save. This size-constant is hardcoded for each model. See function "hook_raw_size()".
CHDK Developer.

*

Offline whim

  • ******
  • 2046
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: Correct Calculation of remaining shots (when RAW enabled) - partly solved
« Reply #11 on: 07 / February / 2008, 11:02:53 »
Hi all

I have a question about phyrephox/ewavr's new gui_batt.c code:

why the osd_buff[5] = 0  and osd_buff[8] = 0 statements ? I always thought C automatically
zero-terminates strings ?

 
« Last Edit: 07 / February / 2008, 11:05:20 by whim »

*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Correct Calculation of remaining shots (when RAW enabled) - partly solved
« Reply #12 on: 07 / February / 2008, 11:45:52 »
Hi all

I have a question about phyrephox/ewavr's new gui_batt.c code:

why the osd_buff[5] = 0  and osd_buff[8] = 0 statements ? I always thought C automatically
zero-terminates strings ?

I think it was just copied from an another place. But for that place (from this code was copied) it made sense:  this action explicitly limits the length of string if it exceeds.
CHDK Developer.

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Correct Calculation of remaining shots (when RAW enabled) - partly solved
« Reply #13 on: 07 / February / 2008, 18:07:14 »
hm, i switched from compiling under windows to compiling under linux, and what can i say, everything compiles fine, but my camera tells me "UPDATE FILE ERROR" when i try to upgrade the firmware.
hm, can't even compile a fresh source out of the svn trunk. gotta sort that out first.
any hints on where to look if something doesnt compile the right way?


*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Correct Calculation of remaining shots (when RAW enabled) - partly solved
« Reply #14 on: 08 / February / 2008, 14:50:52 »
okay, a little proceeding here.
by replacing
Code: [Select]
raw_size = 9004; with
Code: [Select]
raw_size = hook_raw_size()/1024; in my script 5 posts above it is possible to calculate remaining raw capacity without knowing the actual size of the raw, so this part of the code is camera-independent (thansk grAnd).
HOWEVER, in order to be really cameramodel-independent we have to find a way to get camera_jpeg_count via a function, not hardcoded. So the script as is, still is only running on a620.

grAnd, ewavr, could you tell me how to find out the JPEG_COUNT_STRING_ADDR? i didnt understand ewavrs post there, i guess it's having to do with analyzing the firmwares of the cameras, right? so i need IDA, right? then i should be able to find out the addresses, and add a new function to the lib.c of the cameras. alright, i think i'll give it a go.

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Correct Calculation of remaining shots (when RAW enabled) - partly solved
« Reply #15 on: 08 / February / 2008, 15:08:59 »
so i need IDA, right? then i should be able to find out the addresses, and add a new function to the lib.c of the cameras. alright, i think i'll give it a go.

Right. In every firmware search string "9999" (it seems that this string occurs only once). In function that uses this string you can find corresponding RAM address (like 0x7F6F8 for A620). Next, in include/lolevel.h you can write:
extern char* camera_jpeg_count_str;
and in every platform/xxx/sub/yyy/stubs_min.S:
DEF(camera_jpeg_count_str, variable address).

Now you can use in your calculations:
jpeg_count_int=atoi(camera_jpeg_count_str);

P.S Currently 26 subplatforms are supported, you need 26 firmware dumps. ;) I have 42 now  :)
« Last Edit: 08 / February / 2008, 15:22:12 by ewavr »

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Correct Calculation of remaining shots (when RAW enabled) - partly solved
« Reply #16 on: 08 / February / 2008, 15:18:22 »
great, thanks. by the way is there ANY alternative to IDA Pro? the free version and the demo cannot load the canon firmware. a friend of mine has ida pro, but i dont want to hassle him everytime i need an address. isn't there some other program? don't really wanna analyze the firmware, just need the address ;)

hmm, just tested the things you wrote, chdk would boot (compiled though there was an error) but cam would immediately shutdown. i guess i did something wrong (C is so complex with all its pointers etc :D).
so i put
Code: [Select]
char *camera_jpeg_count_str()
{
    return (char*)0x7F6F8;
}
in lib.c and my function in gui_batt.c now looks
Code: [Select]
camera_jpeg_count=atoi(camera_jpeg_count_str());
this compiles just fine, and chdk boots and has the desired functionality.

IS there a specific reason why you suggested patching lolevel.h and stubs_min.S? or in other words: it is okay to just patch lib.c? Is there a disadvantage?
so, off i go to find the addresses of the different firmware...
« Last Edit: 08 / February / 2008, 15:49:15 by phyrephox »

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Correct Calculation of remaining shots (when RAW enabled) - partly solved
« Reply #17 on: 08 / February / 2008, 15:55:20 »
ANY alternative to IDA Pro?
I don't know. Every developer must have it (I don't say "buy").

But you can try other method: read camera manuals and calculate average jpeg size for every size and quality.

My old method (for A710):
Code: [Select]
static int file_size_table[3][5]={{3110,2562,1666,1057,288},       // for superfine quality in KB
  {1954,1441, 928, 608,176},     // for fine quality in KB
  {960,  736, 480, 320,112}};   // for normal quality in KB
long jpegs_size_Kb(){
 long size,quality;
 get_property_case(23, (void *)&quality, 4);
 get_property_case(24, (void *)&size, 4);
 if ((size>4) || (quality>2)) return 0;
 return file_size_table[quality][size]
}


IS there a specific reason why you suggested patching lolevel.h and stubs_min.S? or in other words: it is okay to just patch lib.c? Is there a disadvantage?

No, but your method can only read variable, not write.
« Last Edit: 08 / February / 2008, 16:01:57 by ewavr »


*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: Correct Calculation of remaining shots (when RAW enabled) - partly solved
« Reply #18 on: 08 / February / 2008, 16:26:11 »
okay, i loaded a620 firmware into IDA, found the address by searching for "9999".
next i loaded s3is firmware (mainly because i know barney has a s3is and i'm sure he would be willing to test my compiled firmware :)) and also searched for "9999". there are a few occurances, among them
Code: [Select]
LDR     R1, =a9999 just like in a620. but unlike a620 there is no
Code: [Select]
LDR     R6, =0xXXXXXX above it, just
Code: [Select]
BLS     loc_FFA95900. either i can't use ida (noob here :)) or your described way of finding jpegstring does not work.?
reading the manuals is not an option, so either the people who want to use this feature have to find the address themselves and post them here, or i don't know :D

Quote
No, but your method can only read variable, not write.
as i see it, there is no need to write something, right? the address will always stay the same, depending on firmware, of course (i guess? :D)
thanks for the help so far :)

edit: attached compiled a620 firmware, my function is running well :D
« Last Edit: 19 / February / 2008, 17:34:19 by PhyrePhoX »

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Correct Calculation of remaining shots (when RAW enabled) - partly solved
« Reply #19 on: 08 / February / 2008, 16:35:37 »
S3IS:
Code: [Select]
ROM:FFA958D8                 LDR     R4, =0x6BC28   
ROM:FFA958DC                 ADD     R3, R3, #0xE   
ROM:FFA958E0                 CMP     R2, R3          ;
ROM:FFA958E4                 LDR     R5, =0x9320   
ROM:FFA958E8                 LDR     R1, =aD_2     
ROM:FFA958EC                 MOV     R0, R4         
ROM:FFA958F0                 BLS     loc_FFA95900 
ROM:FFA958F4                 LDR     R1, =a9999   
ROM:FFA958F8                 BL      sprintf         

Prototype: sprintf(char* s, char* st, ....). Therefore s in R0 register, st in R1 register before call sprintf().
So, your address is 0x6BC28.

 

Related Topics