Porting a camera sx530hs - page 17 - DryOS Development - CHDK Forum

Porting a camera sx530hs

  • 300 Replies
  • 138786 Views
*

Offline srsa_4c

  • ******
  • 4451
Re: Porting a camera sx530hs
« Reply #160 on: 02 / May / 2016, 13:17:11 »
Advertisements
I think I found something (still not the root cause, but at least something). To prove my theory, I need early camera logs.

@blackhole
Can you do this:
Insert something in the early part of spytask (in core/main.c), for example right before this line:
Code: [Select]
conf_restore();that causes a crash.
A line like this
Code: [Select]
int crashit = *(int*)0x76543210;should be sufficient.

Crash the camera using the bad card, retrieve the romlog using a good card.
Then, once again, crash the camera using a good card then retrieve the romlog using a non-crashing CHDK.
My suspicion is that this entry won't be present when booting using a bad card:
Code: [Select]
00000220: UI:Button:0x000010C2:WriteEnableMediaI still don't know where it comes from, searching for 0x10c2 doesn't find it.

edit:
it might be possible that the compiler will remove the unnecessary memory access, in that case try writing nonexistent memory like this:
*(int*)0x76543210 = 42;
« Last Edit: 02 / May / 2016, 13:21:43 by srsa_4c »

*

Offline blackhole

  • *****
  • 940
  • A590IS 101b
    • Planetary astrophotography
Re: Porting a camera sx530hs
« Reply #161 on: 02 / May / 2016, 15:22:22 »
Quote
Crash the camera using the bad card, retrieve the romlog using a good card.
Then, once again, crash the camera using a good card then retrieve the romlog using a non-crashing CHDK.
Files attached:

*

Offline srsa_4c

  • ******
  • 4451
Re: Porting a camera sx530hs
« Reply #162 on: 02 / May / 2016, 15:58:42 »
Quote
Crash the camera using the bad card, retrieve the romlog using a good card.
Then, once again, crash the camera using a good card then retrieve the romlog using a non-crashing CHDK.
Files attached:
Thanks. Well, it's again not what I expected, the 0x10c2 event is present in both logs.

Here's some details about what I seem to have found:
WriteSDCard is never called because sub_FF0300DC checks for a flag at [0x1d60] which is zero on 'bad' cards. I think [0x1d60] is zero because IsControlEventActive(0x10c2) returns false in sub_FF02F794. 0x10c2 is "WriteEnableMedia". I don't currently have an idea about why and when WriteEnableMedia becomes false.

I'll try to work out a method to switch WriteEnableMedia back to true (I can't use 0x10c2 for set_control_event unless I'm wrong). There's also "WriteProtectMedia", it's ID is 0x10c1.
If this switch-back is permanent (and done early enough), it might be used as _workaround_.

It would be nice to find the root cause, because I suspect this might be happening due to some kind of memory corruption...

In the meantime, you can experiment with
*(int*)1d60 = 1;
(you can put it before conf_restore() again, for example), and see if it's permanent or not. Since WriteEnableMedia will remain false, this method will likely not help too much.

*

Offline blackhole

  • *****
  • 940
  • A590IS 101b
    • Planetary astrophotography
Re: Porting a camera sx530hs
« Reply #163 on: 02 / May / 2016, 17:24:38 »
Quote
In the meantime, you can experiment with
*(int*)1d60 = 1;
(you can put it before conf_restore() again, for example), and see if it's permanent or not. Since WriteEnableMedia will remain false, this method will likely not help too much.
With
Code: [Select]
*(int*)0x1d60 = 1;
conf_restore();
all 'bad' cards work well. :)
File browser is OK,ptp works,Lua is loaded.
I can't see any problems. :D


*

Offline srsa_4c

  • ******
  • 4451
Re: Porting a camera sx530hs
« Reply #164 on: 02 / May / 2016, 18:46:45 »
With
Code: [Select]
*(int*)0x1d60 = 1;
conf_restore();
all 'bad' cards work well. :)
File browser is OK,ptp works,Lua is loaded.
I can't see any problems. :D
Finally, something.
Try shooting photos and videos too to confirm.

I think bad cards would still crash the camera during formatting (due to the WriteEnableMedia issue), but that's not something the average user does.

I'd still like to get a bit more insight. The attached boot.c logs WriteEnableMedia and the value in 0x1d60, in the InitFileModules task. The logged values can be retrieved with the
rmem 0x40000000 6 -i32
chdkptp command.

Can you get me those values in a good and a bad case?
(Please remove the core/main.c hack, this boot.c does set 0x1d60 to 1 when finished with logging)

*

Offline blackhole

  • *****
  • 940
  • A590IS 101b
    • Planetary astrophotography
Re: Porting a camera sx530hs
« Reply #165 on: 02 / May / 2016, 19:36:29 »
Quote
Try shooting photos and videos too to confirm.
I checked, images and videos are saved on the card.
Quote
I think bad cards would still crash the camera during formatting (due to the WriteEnableMedia issue), but that's not something the average user does.
No,camera after formatting works.
Quote
I'd still like to get a bit more insight. The attached boot.c logs WriteEnableMedia and the value in 0x1d60, in the InitFileModules task. The logged values can be retrieved with the
rmem 0x40000000 6 -i32
chdkptp command.

Can you get me those values in a good and a bad case?
(Please remove the core/main.c hack, this boot.c does set 0



Code: [Select]
bad card:

> rmem 0x40000000 6 -i32
0x40000000 24
0x40000000: 0x00000000  0x00000000  0x00000000 0x00000000
0x40000010: 0x00000001  0x00000000



good card:

> rmem 0x40000000 6 -i32
0x40000000 24
0x40000000: 0x00000000  0x00000000  0x00000000 0x00000000
0x40000010: 0x00000001  0x00000001

If you going to do patch for boot.c, can you please add MOVIE_REC.C in code-gen.

*

Offline srsa_4c

  • ******
  • 4451
Re: Porting a camera sx530hs
« Reply #166 on: 03 / May / 2016, 16:17:36 »
No,camera after formatting works.
That, and your latest logs appear to tell the following (this is still just a guess though):

On some cards, the WriteEnableMedia control event appears to arrive too late. The routine that evaluates the state of WriteEnableMedia therefore decides that the card is not writable, and sets a flag accordingly. The responsible routines are called from sub_FF0B0B84 in InitFileModules task. The flag is located at 0x1d60, and is evaluated each time WriteSDCard is called (this happens in sub_ff0300dc).

The current workaround is: setting the flag to 1 right after sub_FF0B0B84, in the InitFileModules task.

Quote
If you going to do patch for boot.c, can you please add MOVIE_REC.C in code-gen.
What would be your plan with that? Movie bitrate features are not implemented in any recent camera ports (yet).

edit:
link
« Last Edit: 03 / May / 2016, 16:21:25 by srsa_4c »

*

Offline blackhole

  • *****
  • 940
  • A590IS 101b
    • Planetary astrophotography
Re: Porting a camera sx530hs
« Reply #167 on: 03 / May / 2016, 16:33:08 »
Quote
What would be your plan with that? Movie bitrate features are not implemented in any recent camera ports (yet).
I was thinking about the quality features.


*

Offline srsa_4c

  • ******
  • 4451
Re: Porting a camera sx530hs
« Reply #168 on: 03 / May / 2016, 16:40:58 »
Quote
What would be your plan with that? Movie bitrate features are not implemented in any recent camera ports (yet).
I was thinking about the quality features.
I have started working on it (on my ixus150). Will let you know if I managed to make it work.

For now, you could post updated test builds and maybe we should consider enabling autobuild.

It would also be great if people with different firmware version cameras (sx520/530) turned up here, because there are at least 2 other known firmware versions...

*

Offline blackhole

  • *****
  • 940
  • A590IS 101b
    • Planetary astrophotography
Re: Porting a camera sx530hs
« Reply #169 on: 03 / May / 2016, 17:50:25 »
New test build with solved SD card issue.
Video features are not supported.

 

Related Topics