AVR_BOOT not working as expected seems ELM Petit FatFS causing issues

I'm trying to use Zevero's avr_boot to use with AVR bootload via a SD card. However I encountered an issue which I assume is due to the SPI clock speed (bit-bang) causing for some SD cards.

These problematic SD cards are working fine when using in the same hardware with arduino standard SD library or arduino FatFs library to perform Read/Writes, they are working fine.

However when using this AVR_BOOT bootloader, diskio.c function disk_initialize( ) fails with STA_NOINIT during initialization.

Have anyone else encountered this issue before?

The bootloader is using ELM Petit FatFs where I don't know whether it's causing some timing issues in the SPI bit-banging functionality causing the SD card initialization fails.

Here is the problematic function/module: https://github.com/zevero/avr_boot/blob/master/diskio.c

Appreciate your help. And sorry if this been a duplicate question.

Are the problematic cards SDHC cards by chance, or even on purpose?

No, all cards I was testing are 1GB SD cards, not SDHC.

If the card is SD, and formatted to FAT16, then I think it should work. The only other thing I can think of is if you aren’t using the expected I/O pin for Card Select for the Arduino you’re using. I think it’s usually pin 4 or pin 10, but can be anything. And I guess the other thing is whether you are using an Arduino that can have a 4K bootloader section, as I think avr_boot would require. Which Arduino are you using?

Pert is the one to ask about this. He’s the only one I know of here who knows much about avr_boot.

By the way, I’m not sure what you mean by bit-banging. I think the SPI module is used, which handles the shifting automatically. I really doubt your problem is related to clock speed. I’ve done an SD card bootloader for a TI processor, and found that cards are very forgiving about clock speed.

But looking at diskio.c, the error just means that for some reason it can’t determine what type of card it is. So it’s not getting an expected response to a command. Are you able to put a scope on the MISO line to see if the card is responding at all?

Sorry I don’t have a silver bullet.

I'm going to ignore the fact of any hardware faults like CS line etc as this hardware is WORKING when I use exact configuration with the sdFat library. I'm using AtMega1284p.

Bit banging is petit don't use hardware SPI module, its driver is simply toggling MISO/CLK pins and sampling MOSI.

I haven't probe a scope, will do bit more testing over the weekend.

las2211: I'm going to ignore the fact of any hardware faults like CS line etc as this hardware is WORKING when I use exact configuration with the sdFat library. I'm using AtMega1284p.

Bit banging is petit don't use hardware SPI module, its driver is simply toggling MISO/CLK pins and sampling MOSI.

I haven't probe a scope, will do bit more testing over the weekend.

It may be working fine with sdFat, but does avr-boot use the same pins for SPI?

I understand now about the bit banging. I'm not sure why he did that. Well, that might indeed explain the problem you're having if the clock is too fast or the duty cycle is strange.