SDIO port to STM32F4x

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: SDIO port to STM32F4x

Post by barthess »

Giovanni wrote:Do you have the embsys register plugin for Eclipse installed?

Thanks for hint. Looks very useful.

Giovanni wrote:I still have to update all the halconf.h and mcuconf.h in all the demos

What changes you mind? Probably it worth to create simple bash script for this job?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: SDIO port to STM32F4x

Post by Giovanni »

Hehe, the boring part is to make sure to add all the new settings to all configuration files and make sure those are all aligned. Probably there should be templates also for the mcuconf.h files.

A script is a good idea, the hard part is to make it retain the settings for the specific demo while updating.

Probably it would also be a good idea to check the OS version numbers from inside the configuration files in order to ensure those are aligned with the version in use. It is easily overlooked when updating and can create problems.

Giovanni
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: SDIO port to STM32F4x

Post by barthess »

Hm... simple append of some strings to the end of files is trivial, but it anyway must be checked later by hand. Quick and dirty solution:

Code: Select all

#/bin/sh

# $1 is first command line argument for script
echo $1
echo '/*
 * SDC driver system settings.
 */
#define STM32_SDC_SDIO_DMA_STREAM           STM32_DMA_STREAM_ID(2, 3)
#define STM32_SDC_SDIO_DMA_PRIORITY         3
#define STM32_SDC_SDIO_IRQ_PRIORITY         9
#define STM32_SDC_SDIO_UNALIGNED_SUPPORT    TRUE' >> $1

save this to "testhal/STM32F4xx/update_mcuconf.sh". I think content of script is self descriptive.

than cd to "testhal/STM32F4xx" and call from command line (it works in Cygwin too)

Code: Select all

find . -name 'mcuconf.h' -exec ./update_mcuconf.sh '{}' \;

probably after that you must call

Code: Select all

find . -name 'mcuconf.h' -exec unix2dos '{}' \;

to fix new line symbols.

Insertion of code somewhere in middle of halconf.h needs special markers (something like /* end of HAL_USE */ )
Jacon
Posts: 143
Joined: Wed Dec 08, 2010 7:52 am
Has thanked: 50 times
Been thanked: 5 times

Re: SDIO port to STM32F4x

Post by Jacon »

Giovanni wrote:Do you have the embsys register plugin for Eclipse installed? it allows to inspect HW registers for many MCUs (not sure if SDIO is included).

https://sourceforge.net/projects/embsysregview/

It is often very useful.

But not for us STM32-F4's due lack of proper register xml files ;)
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: SDIO port to STM32F4x

Post by Giovanni »

I finally tested the new driver on the F1xx, apparently everything is OK. I am not sure about the use of critical zones (inherited from the old driver), I am going to review those.

I also wish to add some kind of channels-like generic interface in order to make the MMC_SPI and SDC drivers compatible at interface level. This will make integration with FS simpler.

Giovanni
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: SDIO port to STM32F4x

Post by barthess »

Hi Giovanni,
Did you test it on F4x? On my board OS locks on dmaWaitCompletion(sdcp->dma) function (sdc_lld.c line 181).
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: SDIO port to STM32F4x

Post by Giovanni »

I don't have HW to test it on the F4, the board I have is wired to use SPI.

dmaWaitCompletion() should wait the end of the operation and then disable the channel.

There are two possible possible causes if it stops there:
1) The NDTR register never counts down to zero for some reason.
2) The STM32_DMA_CR_EN bit does not go to zero after clearing it.

Code: Select all

#define dmaStreamClearInterrupt(dmastp) {                                   \
  *(dmastp)->ifcr = STM32_DMA_ISR_MASK << (dmastp)->ishift;                 \
}

#define dmaStreamDisable(dmastp) {                                          \
  (dmastp)->stream->CR &= ~STM32_DMA_CR_EN;                                 \
  while (((dmastp)->stream->CR & STM32_DMA_CR_EN) != 0)                     \
    ;                                                                       \
  dmaStreamClearInterrupt(dmastp);                                          \
}

#define dmaWaitCompletion(dmastp) {                                         \
  while ((dmastp)->stream->NDTR > 0)                                        \
    ;                                                                       \
  dmaStreamDisable(dmastp);                                                 \
}


Both would be very strange.

Giovanni
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: SDIO port to STM32F4x

Post by barthess »

I remember. Checking content of NDTR register is not usable for SDIO because it always set to maximum value because peripheral is flow controller. Probably we must use #ifdef clause for F4x/F2x with my old code checking the end of transaction.
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: SDIO port to STM32F4x

Post by barthess »

Fixed in rev.4123
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: SDIO port to STM32F4x

Post by Giovanni »

I see, thanks, the only problem I have with that is not with the code itself, but with the abstraction that is not sufficient to hide that detail away. Not a real problem anyway because F1 and F2/F4 already have separate code paths in several other places.

Giovanni
Post Reply