Shut down my Pi today and thought to make a copy of files in its SD card. This is what
mount /dev/sdf2 /mnt had to say:
mount: wrong fs type, bad option, bad superblock on /dev/sdf2,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
Great. After trying
fsck, it became apparent that for some reason, the root partition is marked as being 1 block longer than the physical card. Must be a bug with Raspbian partition expansion or something.
Thankfully, I found this gold nugget which suggested using
resize2fs to fix it. Turns out I had to run e2fsck first (and say “y” a couple of times):
sudo e2fsck /dev/sdf2
sudo resize2fs /dev/sdf2
mount /dev/sdf2 /mnt
Voilá! Fully functioning filesystem again.
Finally back! Sorry for taking a while, but getting the SD cards to work required quite a bit of research! In this part of the tutorial, we’ll start talking with the SD card. Once you get that working, adding the FAT library developed in the previous part will be easy.
This tutorial will most likely be the most challenging covered in my blog so far, so beware: You may need to do some troubleshooting on this one! If you encounter problems, I recommend you to ask any questions at the AVR Freaks tutorial forum topic, so more people might be able to help you than just me!
Basic hardware setup: ATmega88 with UART console
The 3.3V UART I covered just a while ago will form the basis for this project. Only change we will be doing is to replace ATtiny2313 with ATmega88. This is because SPI, SD and FAT code will eat up almost 3 kB of program memory, and the ATtiny chips with that much program memory and separate RX/TX and SPI pins are not that common, while ATmega88 is readily available (48 and 168 work as well, of course). To accommodate the new chip, the following hardware changes are made to the ATtiny2313 version:
- ATmega88 will require two ground connections
- In addition to VCC, also AVCC for analog circuitry needs to be wired to VCC
- Additional capacitor between AVCC and GND is recommended (I used 10 uF)
- Programming header MOSI/MISO/SCK are also in different place
Continue reading Simple FAT and SD Tutorial Part 3