Ignore:
Timestamp:
May 16, 2013, 3:01:37 PM (11 years ago)
Author:
cfuguet
Message:

Modifications in tsar/trunk/softs/tsar_boot:

  • Improving the boot_ioc_read when using a SD card in FPGA platform.
  • Adding some instrumentation on the SD card driver (under preprocessor conditional directives).
  • Including Doxyfile for generate documentation using doxygen.
  • Improving the Makefile to include doc generation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/softs/tsar_boot/src/boot_ioc.c

    r347 r388  
    22
    33#ifndef SOCLIB_IOC
     4
     5static struct sdcard_dev  _sdcard_device;
     6static struct spi_dev   * _spi_device   = ( struct spi_dev * )IOC_BASE;
    47
    58#ifndef SYSCLK_FREQ
    69#warning "Using default value for SYSCLK_FREQ = 50000000"
    710#define SYSCLK_FREQ 50000000U
    8 #endif
    9 
    10 static struct sdcard_dev  _sdcard_device;
    11 static struct spi_dev   * _spi_device   = ( struct spi_dev * )IOC_BASE;
    12 #endif
    13 
    14 
     11#endif // end ifndef SYSCLK_FREQ
     12
     13#endif // end ifndef SOCLIB_IOC
     14
     15#define SDCARD_RESET_ITER_MAX 4
     16
     17inline void boot_sleep(int cycles)
     18{
     19    int i;
     20    for (i = 0; i < cycles; i++);
     21}
     22
     23#if INSTRUMENTATION
     24inline unsigned int boot_proctime()
     25{
     26    unsigned int ret;
     27    asm volatile ("mfc0 %0, $9":"=r" (ret));
     28    return ret;
     29}
     30#endif // end if INSTRUMENTATION
     31
     32#ifndef SOCLIB_IOC
    1533int boot_ioc_init()
    1634{
    17 #ifdef SOCLIB_IOC
    18     return 0;
    19 #else
    2035    unsigned char sdcard_rsp;
    2136
     
    3752     * Initializing the SD Card
    3853     */
    39     if ( (sdcard_rsp = sdcard_dev_open(&_sdcard_device, _spi_device, 0)) )
    40         return sdcard_rsp;
    41 
    42     if ( (sdcard_rsp = sdcard_dev_set_blocklen(&_sdcard_device, 512)) )
    43         return sdcard_rsp;
     54    unsigned int iter = 0;
     55    while(1)
     56    {
     57        boot_puts("Trying to initialize SD card... ");
     58
     59        sdcard_rsp = sdcard_dev_open(&_sdcard_device, _spi_device, 0);
     60        if (sdcard_rsp == 0)
     61        {
     62            boot_puts("OK\n");
     63            break;
     64        }
     65
     66        boot_puts("KO\n");
     67        boot_sleep(1000);
     68        if (++iter >= SDCARD_RESET_ITER_MAX)
     69        {
     70            boot_puts("\nERROR: During SD card reset to IDLE state\n"
     71                      "/ card response = ");
     72            boot_putx(sdcard_rsp);
     73            boot_puts("\n");
     74            boot_exit();
     75        }
     76    }
     77
     78    /**
     79     * Set the block length of the SD Card
     80     */
     81    sdcard_rsp = sdcard_dev_set_blocklen(&_sdcard_device, 512);
     82    if (sdcard_rsp)
     83    {
     84        boot_puts("ERROR: During SD card blocklen initialization\n");
     85        boot_exit();
     86    }
    4487
    4588    /**
     
    4891    spi_dev_config (
    4992        _spi_device ,
    50         10000000    , /**< SPI_clkL 10 Mhz */
    51         SYSCLK_FREQ , /**< Sys_clk         */
    52         -1          , /**< Charlen: 8      */
     93        10000000    , /**< SPI_clk 10 Mhz */
     94        SYSCLK_FREQ , /**< Sys_clk        */
     95        -1          , /**< Charlen: 8     */
    5396        -1          ,
    5497        -1
     
    58101
    59102    return 0;
    60 #endif
    61 }
     103}
     104#endif // end ifndef SOCLIB_IOC
    62105
    63106/**
     
    137180
    138181#else
     182
    139183///////////////////////////////////////////////////////////////////////////////
    140184// FPGA version of the boot_ioc_read function
     
    143187{
    144188    unsigned int sdcard_rsp;
     189    unsigned int i;
    145190
    146191    sdcard_dev_lseek(&_sdcard_device, lba);
    147192
    148     unsigned int i;
     193#if INSTRUMENTATION
     194    unsigned int start_time;
     195    unsigned int end_time;
     196    boot_puts("[ DEBUG ] Reading blocks ");
     197    boot_putd(lba);
     198    boot_puts(" to ");
     199    boot_putd(lba + count - 1);
     200
     201    start_time = boot_proctime();
     202#endif
     203
    149204    for(i = 0; i < count; i++)
    150205    {
     
    161216
    162217            return 1;
    163         }   
    164     }
     218        }
     219    }
     220
     221#if INSTRUMENTATION
     222    end_time = boot_proctime();
     223
     224    boot_puts(" / cycles for transfert: ");
     225    boot_putd(end_time - start_time);
     226    boot_puts("\n");
     227#endif
    165228
    166229    return 0;
Note: See TracChangeset for help on using the changeset viewer.