Hi Bratan.I had the same problem today, I couldn't get an SD card to work with the SD library on an atmega 1284P with the mighty1284P 16 MHz optiboot bootloader.The solution turned out to be a missing definition of the correct chip.

in /Applications/Arduino.app/Contents/Resources/Java/libraries/SD/utility/Sd2PinMap.hone needs to add "|| defined(__AVR_ATmega1284P__)" to the atmega644 line so that it reads: