SD980 port - page 6 - DryOS Development - CHDK Forum  

SD980 port

  • 169 Replies
  • 58419 Views
*

Offline reyalp

  • ******
  • 14080
Re: SD980 port
« Reply #50 on: 26 / September / 2009, 19:24:12 »
Advertisements
Interesting. You might want to make a special wrapper for open() that returns an error if the filename is zero length (or maybe if it doesn't start with A/")

That's probably a more convenient way than fixing every instance of this. Remember that open returns -1 on error.

edit:
yeah ;)

edit #2:
BTW, your camera:
DRYOS version 2.3, release #0039

sx200 and some other digic IV cams
DRYOS version 2.3, release #0031

Others are release #23
« Last Edit: 26 / September / 2009, 19:30:05 by reyalp »
Don't forget what the H stands for.

*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #51 on: 26 / September / 2009, 19:29:40 »
Yep, done:
Code: [Select]
int open (const char *name, int flags, int mode )
{
if(name[0]!='A')return -1;//on the SD980, it will crash if a file path doesn't start with A
    return _Open(name, flags, mode);//hmm
}
Later, I'll probably modify it to also log the error, to help with further CHDK ports, if it turns out that new cameras will also act like this. The code works, BTW, I tested it.

*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #52 on: 26 / September / 2009, 19:51:40 »
Next step is do something about stat()
For the life of me, I can't find that function, I spent 4+ hours a few days ago, following functions and stuff.

I noticed that so far, stat() is only used to get the size of a file, so I will make a wrapper around it and use lseek to emulate it.

*

Offline reyalp

  • ******
  • 14080
Re: SD980 port
« Reply #53 on: 26 / September / 2009, 20:10:49 »
You should be able to find stat by
- find a in an existing port that uses stat (get the address from stubs_entry*, find references to that address)
- find the corresponding function in your dump
Don't forget what the H stands for.


*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #54 on: 26 / September / 2009, 20:36:08 »
That's what I did, and I even labeled stat as stat, the function calling stat as stat_2, the function calling that as stat_3, etc. Then I found the equivalent of stat_3 and stat_2 in my dump, but there was trace of stat called from stat_2, which was looking quite different.

*

Offline reyalp

  • ******
  • 14080
Re: SD980 port
« Reply #55 on: 26 / September / 2009, 21:10:02 »
ROM:FF81F90C                 ADR     R0, aAUartr_req ; "A/uartr.req"
ROM:FF81F910                 BL      sub_FF835560 <- some func that calls stat on other cameras

That func looks like it does something very similar to stat, but the layout of the struct may be different.
Don't forget what the H stands for.

*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #56 on: 26 / September / 2009, 21:13:07 »
Can someone explain the logic of
Code: [Select]
   if( stat(CONF_FILE,&st) != 0 && st.st_size < sizeof(int))
        return;

 in conf_restore() ?

stat() is supposed to return 0 on success, -1 on error. So then why do we check both for error AND filesize smaller than 4? Shouldn't that be an OR?

*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #57 on: 26 / September / 2009, 21:15:16 »
ROM:FF81F90C                 ADR     R0, aAUartr_req ; "A/uartr.req"
ROM:FF81F910                 BL      sub_FF835560 <- some func that calls stat on other cameras

That func looks like it does something very similar to stat, but the layout of the struct may be different.


That would be my stat_2 function. On the SX10, that function calls the real stat function. This one doesn't appear to do so.


*

Offline reyalp

  • ******
  • 14080
Re: SD980 port
« Reply #58 on: 26 / September / 2009, 21:27:17 »
Can someone explain the logic of
Code: [Select]
    if( stat(CONF_FILE,&st) != 0 && st.st_size < sizeof(int))
        return;

 in conf_restore() ?

stat() is supposed to return 0 on success, -1 on error. So then why do we check both for error AND filesize smaller than 4? Shouldn't that be an OR?
Because it's a bug (which I apparently put there) ;)

Fixed.
Don't forget what the H stands for.

*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #59 on: 26 / September / 2009, 21:27:52 »
On the SX10, 130a, stat looks like this:
Code: [Select]
FF823C70                 STMFD   SP!, {R4-R6,LR}
FF823C74                 MOV     R5, R1
FF823C78                 MOV     R1, #0
FF823C7C                 MOV     R2, #0
FF823C80                 BL      open
FF823C84                 SUBS    R4, R0, #0
FF823C88                 MOVLLT  R0, 0xFFFFFFFF
FF823C8C                 LDMLTFD SP!, {R4-R6,PC}
FF823C90                 MOV     R2, R5
FF823C94                 MOV     R1, #0x12
FF823C98                 MOV     R0, R4
FF823C9C                 BL      sub_FF819BDC
FF823CA0                 MOV     R5, R0
FF823CA4                 MOV     R0, R4
FF823CA8                 BL      sub_FF819864
FF823CAC                 MOV     R0, R5
FF823CB0                 LDMFD   SP!, {R4-R6,PC}

 

Related Topics