STM32 Standard Peripheral Library in eCos

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

STM32 Standard Peripheral Library in eCos

Oleg Uzenkov
Dear All,

I have a question regarding STM32 Standard Peripheral Library and using
this library with eCos.

Is there any way (a HAL wrapper or something) to interface drivers from
this library in application with eCos?

Do you reckon it is feasible to make an eCos port for a driver from this
library? I started doing so for SDIO but got overwhelmed with how much
staff needs rewriting in the eCos way.

There are some drivers like SDIO to interface SD card that are not
implemented in eCos yet, and it would great to have such support.

I would be grateful for any information on this.

Oleg

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Re: STM32 Standard Peripheral Library in eCos

Jerzy Dyrda-2
Hello Oleg,

On Wednesday 18 of June 2014 11:18:09 Oleg Uzenkov wrote:

> I have a question regarding STM32 Standard Peripheral Library and using
> this library with eCos.
>
> Is there any way (a HAL wrapper or something) to interface drivers from
> this library in application with eCos?
No. Writing ETH driver for STM32 I used  STM32 Standard Peripheral Library
as a source of knowledge.

IMHO STM32 Standard Peripheral Library doesn't fit to any driver oriented OS but
due to fact that it exists some system just incorporate it as it i.e. agreed for its drawbacks.

> Do you reckon it is feasible to make an eCos port for a driver from this
> library? I started doing so for SDIO but got overwhelmed with how much
> staff needs rewriting in the eCos way.
>
> There are some drivers like SDIO to interface SD card that are not
> implemented in eCos yet, and it would great to have such support.

Please look at this discussion :

https://sourceware.org/ml/ecos-discuss/2014-06/msg00005.html
https://sourceware.org/ml/ecos-discuss/2014-06/msg00009.html

Best regards,
jerzy

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Re: STM32 Standard Peripheral Library in eCos

Oleg Uzenkov
Thanks Jerzy,

On 18.06.14 12:16, Jerzy Dyrda wrote:

> Hello Oleg,
>
> On Wednesday 18 of June 2014 11:18:09 Oleg Uzenkov wrote:
>
>> I have a question regarding STM32 Standard Peripheral Library and using
>> this library with eCos.
>>
>> Is there any way (a HAL wrapper or something) to interface drivers from
>> this library in application with eCos?
> No. Writing ETH driver for STM32 I used  STM32 Standard Peripheral
> Library
> as a source of knowledge.
>
> IMHO STM32 Standard Peripheral Library doesn't fit to any driver
> oriented OS but
> due to fact that it exists some system just incorporate it as it i.e.
> agreed for its drawbacks.
Please, could you name some OS that incorporate it? I was looking for
any, out of curiosity, but could not find any, apart from RTX Real Time
Operating System (first time heard of it).

>
>> Do you reckon it is feasible to make an eCos port for a driver from this
>> library? I started doing so for SDIO but got overwhelmed with how much
>> staff needs rewriting in the eCos way.
>>
>> There are some drivers like SDIO to interface SD card that are not
>> implemented in eCos yet, and it would great to have such support.
> Please look at this discussion :
>
> https://sourceware.org/ml/ecos-discuss/2014-06/msg00005.html
> https://sourceware.org/ml/ecos-discuss/2014-06/msg00009.html
>
> Best regards,
> jerzy
>

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Re: STM32 Standard Peripheral Library in eCos

Jerzy Dyrda-2
Hello Oleg,

On Wednesday 18 of June 2014 12:39:04 Oleg Uzenkov wrote:
[snip]
> > IMHO STM32 Standard Peripheral Library doesn't fit to any driver
> > oriented OS but
> > due to fact that it exists some system just incorporate it as it i.e.
> > agreed for its drawbacks.
> Please, could you name some OS that incorporate it?
E.g. FreeRTOS.

> Does anyone know of any examples using MMC SPI driver in ecos to interface
> SD card (any platform)? I would appreciate any links or sample code.
#include <pkgconf/system.h>
#ifdef CYGPKG_DEVS_DISK_MMC
#include <pkgconf/io_fileio.h>
#include <pkgconf/fs_fat.h>
#endif

#include <cyg/infra/cyg_type.h>
#include <cyg/infra/testcase.h>           // Test macros
#include <cyg/infra/cyg_ass.h>            // Assertion macros
#include <cyg/infra/diag.h>               // Diagnostic output
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <dirent.h>
#include <stdio.h>

#include <cyg/hal/hal_arch.h>             // CYGNUM_HAL_STACK_SIZE_TYPICAL
#include <cyg/hal/hal_if.h>
#include <cyg/kernel/kapi.h>
#include <string.h>
#include CYGHWR_MEMORY_LAYOUT_H
#ifdef CYGPKG_NET_LWIP
#include <lwip.h>
#endif // CYGPKG_NET_LWIP
#ifdef CYGPKG_DEVS_DISK_MMC
#include <cyg/fileio/fileio.h>
#include <cyg/fs/fatfs.h>
#endif


externC int hello_world(void);
void do_version (void);

#ifdef CYGPKG_DEVS_DISK_MMC

#ifdef CYGPKG_DEVS_SPI_CORTEXM_STM32
#include <cyg/io/spi_stm32.h>
CYG_DEVS_SPI_CORTEXM_STM32_DEVICE (
    cyg_spi_mmc_dev0, 3, 0, false, 0, 0, 5000000, 1, 1, 1
);
#else
#error "Needed SPI connection to MMC card"
#endif

void checkcwd( const char *cwd )
{
    static char cwdbuf[PATH_MAX];
    char *ret;

    ret = getcwd( cwdbuf, sizeof(cwdbuf));
    if( ret == NULL ) diag_printf("Error getcwd\n");

    if( strcmp( cwdbuf, cwd ) != 0 )
    {
        diag_printf( "cwdbuf %s cwd %s\n",cwdbuf, cwd );
        diag_printf( "Current directory mismatch");
    }
}
static void listdir( char *name, int statp, int numexpected, int *numgot )
{
    int err;
    DIR *dirp;
    int num=0;

    diag_printf("<INFO>: reading directory %s\n",name);

    dirp = opendir( name );
    if( dirp == NULL ) diag_printf("Can't opendir\n");

    for(;;)
    {
        struct dirent *entry = readdir( dirp );

        if( entry == NULL )
            break;
        num++;
        diag_printf("<INFO>: entry %14s",entry->d_name);
#ifdef CYGPKG_FS_FAT_RET_DIRENT_DTYPE
        diag_printf(" d_type %2x", entry->d_type);
#endif
        if( statp )
        {
            char fullname[PATH_MAX];
            struct stat sbuf;

            if( name[0] )
            {
                strcpy(fullname, name );
                if( !(name[0] == '/' && name[1] == 0 ) )
                    strcat(fullname, "/" );
            }
            else fullname[0] = 0;
           
            strcat(fullname, entry->d_name );
           
            err = stat( fullname, &sbuf );
            if( err < 0 )
            {
                if( errno == ENOSYS )
                    diag_printf(" <no status available>");
                else diag_printf( "stat=%d err=%x\n", stat, err );
            }
            else
            {
                diag_printf(" [mode %08x ino %08x nlink %d size %ld]",
                            sbuf.st_mode,sbuf.st_ino,sbuf.st_nlink,(long)sbuf.st_size);
            }
#ifdef CYGPKG_FS_FAT_RET_DIRENT_DTYPE
            if ((entry->d_type & S_IFMT) != (sbuf.st_mode & S_IFMT))
              diag_printf("File mode's don't match between dirent and stat");
#endif
        }

        diag_printf("\n");
    }
       
    err = closedir( dirp );
    if( err < 0 ) diag_printf( "stat=%d err=%x\n", stat, err );
    if (numexpected >= 0 && num != numexpected)
        diag_printf("Wrong number of dir entries\n");
    if ( numgot != NULL )
        *numgot = num;
}
#endif

int main(void)
{
#ifdef CYGPKG_DEVS_DISK_MMC
    int existingdirents=-1;

    diag_printf("Mounting MMC disk\n");
    if (ENOERR != mount( "/dev/mmcdisk0/", "/disk", "fatfs" ))
        diag_printf("MMC disk not mounted\n");

    if (ENOERR != chdir( "/disk" ))
         diag_printf("Changing directory to /disk failed\n");

    checkcwd( "/disk" );

    listdir( "/disk", true, -1, &existingdirents );

#endif

Best regards,
jerzy

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Re: STM32 Standard Peripheral Library in eCos

Oleg Uzenkov
Many thanks for your help, Jerzy!


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss