ST32F103RG FatFS Not Initializing on software reset

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

kdsouza
Posts: 14
Joined: Thu Jul 02, 2015 3:26 pm
Has thanked: 1 time

ST32F103RG FatFS Not Initializing on software reset

Postby kdsouza » Tue May 03, 2016 9:00 am

Gentlemen,

I'm running ChibiOS 2.6,

I've got an SD card connected to the STM32F103RG via SPI2 and I was using the FatFS Demo provided in ChibiStudio.

With a 8GB Class 4 transcend card the system works without any issue after a software reset. So it initializes and everything and resumes operation.
Recently we got a pack of 4GB Class4 cards. These cards do not get initialized after a software reset or after pressing the reset button.

InsertHandler exits after mmcConnect

But if i remove power and put it back in, it initializes fine. This issue is only for Reset (button press) or software reset.

I am guessing the card is still active since it's last power on, is there a way to de-init or force init the card?
I tried adding delays in various places but no luck.

This is not a big deal if i use the 8GB cards, but I know these cards won't be around so we need to get the system working with any sort of cards, so this is an important issue.

Any insights?

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: ST32F103RG FatFS Not Initializing on software reset

Postby Giovanni » Tue May 03, 2016 9:05 am

Hi,

It looks like the card is stuck in an initialized state because it does not get the reset like the CPU. I am not sure how this should be fixed, may be sending some kind of "init" command to the card before the normal connection procedure.

You should get the card documentation and see the recommended initialization procedure.

Giovanni

kdsouza
Posts: 14
Joined: Thu Jul 02, 2015 3:26 pm
Has thanked: 1 time

Re: ST32F103RG FatFS Not Initializing on software reset

Postby kdsouza » Tue May 03, 2016 11:18 am

Thanks Sir,

Well so i was following How to Use MMC/SDC from elmchan http://elm-chan.org/docs/mmc/mmc_e.html

Following the 1st step i tried

Code: Select all

 
     palSetPadMode(IOPORT2, 12, PAL_MODE_OUTPUT_PUSHPULL);
        palSetPadMode(IOPORT2, 13, PAL_MODE_OUTPUT_PUSHPULL); //CLK
        palSetPadMode(IOPORT2, 15, PAL_MODE_OUTPUT_PUSHPULL);
        palSetPad(IOPORT2, 12); //STMNS
        palSetPad(IOPORT2, 15); //STM MOSI

        chSysLockFromIsr();
        int x=0;
        for(x=0;x<500;x++)
        {
          palTogglePad(IOPORT2,13);
          chThdSleepMicroseconds(100);
        }
        chSysUnlockFromIsr();


But obviously that doesn't work. Any advice on how i can do the above steps ( 70 clocks with DI and CS high) ?

I am guessing I am close.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: ST32F103RG FatFS Not Initializing on software reset

Postby Giovanni » Tue May 03, 2016 11:26 am

Note that chThdSleepMicroseconds(7) does not actually sleep 7 microseconds, the real resolution is dictated by the system tick.

Anyway, the generation of clock pulses is already done by the driver.

Giovanni

kdsouza
Posts: 14
Joined: Thu Jul 02, 2015 3:26 pm
Has thanked: 1 time

Re: ST32F103RG FatFS Not Initializing on software reset

Postby kdsouza » Tue May 03, 2016 12:11 pm

send_command_R1 returns 1 from Poweroff to start.

On restart the same function returns FF(255). Could it mean it needs more time? Or the sd card is not willing to get resetted?

spiIgnore(mmcp->config->spip, 100); is responsible for the clocks yes?

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: ST32F103RG FatFS Not Initializing on software reset

Postby Giovanni » Tue May 03, 2016 12:40 pm

spiIgnore() generates the clock pulses and puts the card in SPI mode, after the reset the card should already be in SPI mode.

Giovanni

pitdibi
Posts: 1
Joined: Thu Nov 30, 2017 5:25 pm

Re: ST32F103RG FatFS Not Initializing on software reset

Postby pitdibi » Thu Nov 30, 2017 5:36 pm

Hi!
I've the same problem when a power fault pulse does reset microcontroller but doesn't reset the 4GB SD. As described in a precedent post, if I instead use a 32 GB SD, the bug doesn't occur. I've solved this problem inserting a circuit that removes power to SD in initializing phase of the microcontroller. But there is anyone who knows because this happens?
Regards
Pietro


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 13 guests