jk27
Posts: 2
Joined: Sat Jan 26, 2019 9:29 pm

Pi v2 Camera Corrupts SD card

Sat Jan 26, 2019 9:42 pm

Hi everyone,

I am having a problem with my pi v2 camera and the SD card. I am recording video with my camera from terminal with the following command:

raspivid -o video.h264 -t 10000

The time is variable, I record snippits over the course of maybe half an hour. Everything works for a while, and then the frames start freezing and I get an error in terminal that says certain frames cannot be written to the disk. This is fine and I keep recording. Then, the camera will not record video for more than a few milliseconds. I then restart the pi and I can not log in. I either get a black screen with a cursor forever, or I type in my username and password and it takes me back to the username and password screen. When I try the camera on another pi, it no longer records video. This happened twice already and I don't know what the cause is. The pi itself is ok (pi 3), but it seems like there is something wrong with the SD card. Has anyone had this problem?

It seems to me like the camera breaks first, maybe it shorts or something, and that triggers a failure in the SD card. Help?

Thanks

User avatar
Joel_Mckay
Posts: 266
Joined: Mon Nov 12, 2012 10:22 pm
Contact: Website

Re: Pi v2 Camera Corrupts SD card

Sun Jan 27, 2019 3:09 am

First try it with CVLC to see if it is still hanging the system.

As a precaution, disable the HAT eeprom i2c bus, as the Camera module can interfere with i2c bus access.
In theory, an open-collector bus drive contention can't cause a "short", but can corrupt the protocol in bizarre ways.

Other than that, it sounds like you may have to under-clock the card if it is new (we get about a 25% i/o performance boost using 80MHz U1 compliant cards)..... and or do a low level F3 scan to see if the card is failing. As a side note, at one point we did find changing default pi voltages for overclocking will also cause random corruption issues with many types of cards.

We used a ram-dive overlayfs on our clubs OS, and a patched kernel to workaround a known vc4_drm fragmentation bug: https://sourceforge.net/projects/microm ... pberry-pi/
Since this is a snapshot of a heavily used configuration, it may at least be possible to narrow down what is happening.

If your power supply is OK, than this is a bizarre issue indeed... ;-)

Best of luck,
J
Last edited by Joel_Mckay on Sun Jan 27, 2019 8:29 am, edited 1 time in total.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 21676
Joined: Sat Jul 30, 2011 7:41 pm

Re: Pi v2 Camera Corrupts SD card

Sun Jan 27, 2019 7:15 am

Joel_Mckay wrote:
Sun Jan 27, 2019 3:09 am
First try it with CVLC to seen if it is still hanging the system.

As a precaution, disable the HAT eeprom i2c bus, as the Camera module can interfere with i2c bus access.
In theory, an open-collector bus drive contention can't cause a "short", but can corrupt the protocol in bizarre ways.

Other than that, it sounds like you may have to under-clock the card if it is new (we get about a 25% i/o performance boost using 80MHz U1 compliant cards)..... and or do a low level F3 scan to seen if the card is failing. As a side note, at one point we did find changing default pi voltages for overclocking will also cause random corruption issues with many types of cards.

We used a ram-dive overlayfs on our clubs OS, and a patched kernel to workaround a known vc4_drm fragmentation bug: https://sourceforge.net/projects/microm ... pberry-pi/
Since this is a snapshot of a heavily used configuration, it may at least be possible to narrow down what is happening.

If your power supply is OK, than this is a bizarre issue indeed... ;-)

Best of luck,
J
This post seems mostly unrelated to the issue in hand.

No, the camera cannot interfere with the HAT I2C.

I thought the fragmenation issue had been fixed, last year.

As for the issue here, sounds like a power problem. The camera takes upwards of 200mA, the H264 another 50-70. So if your power suply is borderline, you could be running out of jiuce. However, no reports of lightning bolts or log reports, which I woudl have expected.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

rohtua
Posts: 66
Joined: Sat Jul 16, 2016 9:01 am

Re: Pi v2 Camera Corrupts SD card

Sun Jan 27, 2019 7:50 am

Just out of curiosity how big is the sd card and what class. I've had similar issues where my pi stopped working and won't boot when I've been recording with the camera.

For me the issue was I was filling the storage on the card. Once the storage was full the pi would just crash and wouldn't come back on. It turns out the script I was using to move the files off the pi to my nas wasn't working correctly and needed a bit of tweaking.

However for me this was over a period of solid recording for 24hrs. So it seems unlikely for a recording around half an hour unless it's a small card. You could also be seeing recording issues if it's a slow card and can't keep up with data being written from the camera.

User avatar
Joel_Mckay
Posts: 266
Joined: Mon Nov 12, 2012 10:22 pm
Contact: Website

Re: Pi v2 Camera Corrupts SD card

Sun Jan 27, 2019 9:04 am

jamesh wrote:
Sun Jan 27, 2019 7:15 am
No, the camera cannot interfere with the HAT I2C.
My mistake, as it has been a few years.... this was probably what I was thinking about.
jamesh wrote:
Thu Oct 09, 2014 8:25 am
I'm not sure there is a fix. At least not with sane timescales.

The problem as I remember it is that the GPU need access to the I2C to talk to the camera. If you start using it from a different driver on the Arm at the same, all hell breaks lose. There isn't an easy fix.
I assumed in the unlikely event a bus was getting probed/reset it may pose an issue, and crippling the devices at the overlay stage would narrow the scope of the issue. However, my experience was mostly with the older model camera modules, and the relatively new v4l driver at the time.

I will head back to fortnight instead of the forum.. best of luck. ;-)

Cheers,
J

jk27
Posts: 2
Joined: Sat Jan 26, 2019 9:29 pm

Re: Pi v2 Camera Corrupts SD card

Tue Feb 12, 2019 3:57 pm

Thank you so much for the replies! I still not sure what happened, but it stopped happening and my SD cards have been fine. My SD card was 16GB but I had about 7GB left to fill. Thanks again!

Return to “Troubleshooting”