"Memory card error" for some SD cards - page 5 - DryOS Development - CHDK Forum

"Memory card error" for some SD cards

  • 53 Replies
  • 27455 Views
*

Offline alvm

  • ***
  • 123
Re: "Memory card error" for some SD cards
« Reply #40 on: 21 / December / 2014, 13:20:30 »
Advertisements
Hi srca_4c,

Sorry for my behindhand with an answer.

I got the logs following by your advice, but I didn't find any critical differences, you can take a look.

I've tried write log to file using GetLogToFile() function after error appears but I have message "Unsuccessful. File Create Error" in UART terminal. Also there is this message if I try use  GetLogToFile() just after camera poweron using adapter, but there aren't any error messages in UART terminal after shoot. The function works fine if battery is used.

Thank you for notice about localtime() I'll fix this.

Alex.
« Last Edit: 21 / December / 2014, 13:30:48 by alvm »

*

Offline alvm

  • ***
  • 123
Re: "Memory card error" for some SD cards
« Reply #41 on: 21 / December / 2014, 13:21:19 »
Logs for battery:

*

Offline srsa_4c

  • ******
  • 4451
Re: "Memory card error" for some SD cards
« Reply #42 on: 21 / December / 2014, 17:12:12 »
I got the logs following by your advice, but I didn't find any critical differences, you can take a look.
The only significant difference between the two after_shoot logs is that
UI:DSIC:48,0
shows up more often and much quicker after shoot in the AC powered case.
The default log buffer is rather small unfortunately, the startup log entries are no longer available.

Quote
I've tried write log to file using GetLogToFile() function after error appears but I have message "Unsuccessful. File Create Error" in UART terminal. Also there is this message if I try use  GetLogToFile() just after camera poweron using adapter
This seems to be a much better lead, because it's not GUI code. I did not try to follow that error message, but I bet it's about a failed open() call. If so, you have to determine why (and how) open() fails. You could copy its code to RAM (as you do with the startup sequence) and see which code path is causing it to return with error. (That means you have to create a debugging version of PSM, you can emit console messages from the modified code.)

edit:
addresses are from ixus145 1.00c

The function that returns with failure is sub_FF8265F4. You can choose to copy GetLogToFile -> sub_FF892ADC to RAM and modify the "File Create Error" debug message to print the return value. Or, you can just call sub_FF8265F4 from SpyTask after an appropriate delay, and you can print its return value.

int sub_FF8265F4(char *filename, int unknown, char *buffer, int buffer_size)

"unknown" is usually -1

The function simply writes the buffer's content to a file. It can return many error conditions, would be good to know which one is it in this case.
« Last Edit: 22 / December / 2014, 11:26:24 by srsa_4c »

*

Offline alvm

  • ***
  • 123
Re: "Memory card error" for some SD cards
« Reply #43 on: 22 / December / 2014, 15:58:31 »
Shooting filewritetask() for adapter:

fwt_open() 03

fwt_write() -1

fwt_close() -1

filewritetask() for battery:

fwt_open() 03

fwt_write() 1147161

fwt_close() 00


*

Offline srsa_4c

  • ******
  • 4451
Re: "Memory card error" for some SD cards
« Reply #44 on: 22 / December / 2014, 16:25:32 »
Shooting filewritetask() for adapter:

fwt_open() 03

fwt_write() -1

fwt_close() -1

filewritetask() for battery:

fwt_open() 03

fwt_write() 1147161

fwt_close() 00
That seems like Write() failing after a successful Open()?
This case is getting even more weird...

I'd try to power the camera from a reliable external source (such as a well charged Li-ion battery) through the same battery dummy. But if the power source is unreliable then why is it working correctly without PSM?

Anyway, you should probably continue investigating the failing call - which could potentially be fairly hard because SD IO is done in another layer...

edit:
It could be that the file descriptor becomes invalid before it is passed to Write(), if you make custom code, you could try
int a = open("A/test.bin", O_WRONLY|O_CREAT, 0777);
a = close(a);
... and see whether close returns normally.
« Last Edit: 22 / December / 2014, 16:31:12 by srsa_4c »

*

Offline alvm

  • ***
  • 123
Re: "Memory card error" for some SD cards
« Reply #45 on: 22 / December / 2014, 16:33:37 »
sub_FF8265F4() return 155189259 (0x940000B) for adapter and file wasn't created vs 0x00 for battery with file on SD card. The value 0x940000B is set in sub_FF8263D0() after calling sub_FF827320().

sub_FF827320() -> sub_FF8271C4() is _Write() function.
« Last Edit: 22 / December / 2014, 16:50:18 by alvm »

*

Offline srsa_4c

  • ******
  • 4451
Re: "Memory card error" for some SD cards
« Reply #46 on: 22 / December / 2014, 16:52:15 »
sub_FF8265F4() return 155189259 (0x940000B) for adapter and file wasn't created vs 0x00 for battery with file on SD card. The value 0x940000B is set in sub_FF8263D0().
That also indicates a failed Write()... Can you check the simple open() -> close() test I suggested?
I think that the SD driver fails for some reason and invalidates the descriptor.

*

Offline alvm

  • ***
  • 123
Re: "Memory card error" for some SD cards
« Reply #47 on: 22 / December / 2014, 17:00:51 »
Can you check the simple open() -> close() test I suggested?

char buf[20];
            
int a = _Open("A/test.bin", O_WRONLY|O_CREAT, 0777);
            
sprintf(buf, "%02d\n", a);   
_psm_printf(buf);
            
a = _Close(a);

sprintf(buf, "%02d\n", a);   
_psm_printf(buf);

open() return 03, close() return -1 for adapter vs 03, 00 for battery. Test.bin is in SD card for battery.

File can't be closed for adapter??
« Last Edit: 22 / December / 2014, 17:11:10 by alvm »

*

Offline srsa_4c

  • ******
  • 4451
Re: "Memory card error" for some SD cards
« Reply #48 on: 22 / December / 2014, 17:10:44 »
open() return 03, close() return -1 for adapter vs 03, 00 for battery.
That seems to support my theory, all writing operations fail (even the one that would update the FAT and directory entries).
I suppose there is no such problem if you try to read() files (of course don't attempt to write when you try this)?

*

Offline alvm

  • ***
  • 123
Re: "Memory card error" for some SD cards
« Reply #49 on: 22 / December / 2014, 17:13:14 »
That seems to support my theory, all writing operations fail (even the one that would update the FAT and directory entries).
I suppose there is no such problem if you try to read() files (of course don't attempt to write when you try this)?

Yes, read operation is fine. Do FAT and directory entries update at close stage?
« Last Edit: 22 / December / 2014, 17:19:11 by alvm »

 

Related Topics


SimplePortal © 2008-2014, SimplePortal