Q:

SD card initialization problem - CMD8 wrong response

I am trying to interface an microSD card to a microcontroller board (FRDM-KE06Z) using FatFS code. I only modified SPI parts for my application. Besides digging into FatFS code also I checked this guide
When I send CMD0 to the card the reply is correct:

But when I send CMD8 to identify the card the response is totally wrong (after 0xFF there should be anything with MSB set to zero):

I have checked:

Different SPI modes 0/1/2/3, clock speeds 75kHz and 150kHz
Two different SD cards (brand new 32GB SanDisk Ultra HC 1 and an old SanDisk 2GB)
I do send dummy clock cycles after power, I also wait a couple of seconds before doing anything with the card
Wiring is short, so signal integrity should not be the problem
The same happens with and without logic analyzer attached
Plugging the card after MCU pins are initialized, waiting a couple of seconds and starting the code
CS timing is very relaxed (couple of miliseconds before data is sent, many miliseconds between CMD0 and CMD8)

What can be the reason my cards are failing to properly respond to CMD8, while responding correctly to CMD0?

A:

I was designing FPGA configuration and writing driver for SD-card a year or so ago, and caught very similar set of issues. My solutions to wrong responses / misbehave of SD-card was simple:

when you end command, you do not stop clock just after command completion, you keep supplying clock for 8 or 16 spare cycles - with CS being active or inactive. I think I supply 8 when CS is still active, and another 8 after it deactivates;
when you start command, you do the same as above - before activating CS you supply 8 spare clocks, after you activate CS you also supply 8 spare clocks and only then start the command, which is then sensed by octet's first bit being 0 (command start bit).

The clock signal is required for card to complete some its internal operations (the most obvious example is recovering from the data/command error). If your design would supply clock without interruptions you would not catch this issue.
Update: looking to your waveforms supplied I think you should have MOSI being high when CS is not activated and when command is not in progress. Look here, you may find it useful (however not sufficient) to design the SD-card interface.

