Changeset 388


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.
Location:
trunk/softs/tsar_boot
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/softs/tsar_boot/Makefile

    r368 r388  
    1 ifndef PLATFORM_DIR
    2 $(error please define PLATFORM_DIR 'make PLATFORM_DIR=foo')
    3 else
     1ifndef MAKECMDGOALS
     2  MAKECMDGOALS=none
     3endif
     4
     5ifneq ($(MAKECMDGOALS),$(filter $(MAKECMDGOALS),clean distclean clean-doc doc))
     6  ifndef PLATFORM_DIR
     7    $(error please define PLATFORM_DIR 'make PLATFORM_DIR=foo')
     8  else
     9    ifdef SOCLIB
     10      DEFS+= -DSOCLIB_IOC
     11      DTS=platform_soclib.dts
     12      $(info Making for $(PLATFORM_DIR), SocLib variant)
     13    else
     14      DTS=platform_fpga.dts
     15      $(info Making for $(PLATFORM_DIR), FPGA variant)
     16    endif
     17  endif
     18endif
    419
    520LD             := mipsel-unknown-elf-ld
     
    1227DTC            := dtc
    1328HEXDUMP    := hexdump
     29DOXYGEN    := doxygen
    1430
    1531BUILD_DIR  := build
     
    5066TARGET     := bin.soft
    5167
    52 ifdef SOCLIB
    53 
    54 DEFS+= -DSOCLIB_IOC
    55 DTS=platform_soclib.dts
    56 $(info Making for $(PLATFORM_DIR), SocLib variant)
    57 
    58 else
    59 
    60 DTS=platform_fpga.dts
    61 $(info Making for $(PLATFORM_DIR), FPGA variant)
    62 
    63 endif
    6468
    6569ifdef SYSCLK_FREQ
    66 DEFS+= -DSYSCLK_FREQ
     70DEFS+= -DSYSCLK_FREQ=$(SYSCLK_FREQ)
    6771endif
    68 
    6972
    7073all: $(TARGET)
    7174
    7275$(TARGET): $(BUILD_DIR) $(OBJS) $(PLATFORM_DIR)/ldscript $(BUILD_DIR)/platform.ld
    73         $(ECHO) "[   LD   ]     $@"
     76        $(ECHO) "[   LD    ]     $@"
    7477        $(LD) -o $@ -T $(PLATFORM_DIR)/ldscript $(OBJS)
    7578        $(DU) -D $@ > $@.txt
    7679
    7780$(BUILD_DIR)/platform.ld: $(BUILD_DIR)/platform.dtb
     81        $(ECHO) "[ HEXDUMP ]     $(notdir $<)"
    7882        $(HEXDUMP) -v -e '"BYTE(0x" 1/1 "%02X" ")\n"' $< > $@
    7983
    8084$(BUILD_DIR)/platform.dtb: $(DTS)
    81         ${DTC} -O dtb -o $@ $<
     85        $(ECHO) "[   DTC   ]     $(notdir $<)"
     86        touch $@;#${DTC} -O dtb -o $@ $< &> /dev/null
    8287
    8388$(BUILD_DIR):
    8489        $(MKDIR) $@
    8590
     91doc: Doxyfile
     92        $(DOXYGEN) Doxyfile
     93
    8694clean:
    8795        $(RM) $(TARGET).txt $(TARGET) *~ $(BUILD_DIR)
    8896
    89 distclean: clean
     97clean-doc:
     98        $(RM) doc
     99
     100distclean: clean clean-doc
    90101
    91102# =============================================================================
     
    93104
    94105$(BUILD_DIR)/%.o: %.c
    95         $(ECHO) "[   CC   ]     $(notdir $<)"
     106        $(ECHO) "[   CC    ]     $(notdir $<)"
    96107        $(CC) $(DEFS) $(CFLAGS) $(INCLUDE) -c -o $@ $<
    97108        $(DU) -D $@ > $@.txt
    98109
    99110$(BUILD_DIR)/%.o: %.S
    100         $(ECHO) "[   AS   ]     $(notdir $<)"
     111        $(ECHO) "[   AS    ]     $(notdir $<)"
    101112        $(CC) $(DEFS) ${INCLUDE} -g -mips32 -c -o $@ $<
    102113        $(DU) -D $@ > $@.txt
    103114
    104115.SILENT:
    105 endif
  • trunk/softs/tsar_boot/README.txt

    r347 r388  
    88include/    Header files
    99
    10 conf/       Platform specific files and ldscript.
     10conf/       Platform specific files and ldscript examples.
    1111            For each platform, we must define a new directory.
    1212
     
    3838
    3939      --->  platform_fpga.dts:
     40
    4041             Device tree file. It is mandatory if compiling
    4142             for a FPGA platform. If the application to execute does not use
     
    4344
    4445      --->  ldscript:
     46
    4547             LD script defining the segments of this boot loader.
    4648             We define two segments:
     
    5456            Arguments to pass:
    5557
    56              ---> PLATFORM_DIR=conf/<platform_dir>
     58             ---> PLATFORM_DIR=<platform_dir>
    5759   
    5860                   Defines the directory where to find the plateform specific
  • trunk/softs/tsar_boot/conf/platform_fpga_de2-115/defs_platform.h

    r347 r388  
    77#define CACHE_LINE_SIZE 64//bytes
    88
     9#define INSTRUMENTATION 0
     10
    911#define IOC_BASE        0xFB000000
    1012#define VCIBD_BASE      0xFB000000
  • trunk/softs/tsar_boot/include/boot_ioc.h

    r347 r388  
    33
    44#ifndef SOCLIB_IOC
    5     #include <sdcard.h>
    6     #include <spi.h>
     5#include <sdcard.h>
     6#include <spi.h>
    77#else
    8     #include <block_device.h>
     8#include <block_device.h>
    99#endif
    1010
  • trunk/softs/tsar_boot/include/spi.h

    r292 r388  
    9898void spi_dev_config (
    9999        struct spi_dev * spi,
    100         int spi_freq        ,
    101         int sys_freq            ,
    102         int char_len            ,
    103         int tx_edge                     ,
    104         int rx_edge                     );
     100        int spi_freq        ,
     101        int sys_freq        ,
     102        int char_len        ,
     103        int tx_edge         ,
     104        int rx_edge         );
    105105
    106106/**
     
    121121#define SPI_RXTX_MASK          (  0xFF   ) /**< Mask for the an RX/TX value   */
    122122
    123  /**
    124   * \param  x   :  Initialized pointer to the SPI controller
    125   *
    126   * \return 1 if there is an unfinished transfer in the SPI controller
    127   *
    128   * Check the GO_BUSY bit of the SPI Controller
    129   */
     123/**
     124 * \param  x : Initialized pointer to the SPI controller
     125 *
     126 * \return 1 if there is an unfinished transfer in the SPI controller
     127 *
     128 * \brief Check the GO_BUSY bit of the SPI Controller
     129 */
    130130#define SPI_IS_BUSY(x)         ((ioread32(&x->ctrl) & SPI_CTRL_GO_BSY) != 0) ? 1 : 0
    131131
  • trunk/softs/tsar_boot/src/boot_elf_loader.c

    r292 r388  
    7373            {
    7474                boot_puts (
    75                                         "ERROR: "
    76                                         "IOC_FAILED"
    77                                         "\n"
    78                                 );
     75                    "ERROR: "
     76                    "IOC_FAILED"
     77                    "\n"
     78                );
    7979
    8080                boot_exit();
    8181            }
    82            
     82
    8383            nb_block    += 1;
    8484            nb_available = 512;
     
    102102                    nb_rest = elf_header_ptr->e_phnum * elf_header_ptr->e_phentsize;
    103103
    104                                         /* Verification of ELF Magic Number */
    105                                         if (
    106                                                 (elf_header_ptr->e_ident[EI_MAG0] != ELFMAG0) ||
    107                                                 (elf_header_ptr->e_ident[EI_MAG1] != ELFMAG1) ||
    108                                                 (elf_header_ptr->e_ident[EI_MAG2] != ELFMAG2) ||
    109                                                 (elf_header_ptr->e_ident[EI_MAG3] != ELFMAG3) )
    110                                         {
    111                                                 boot_puts(
    112                                                         "ERROR: "
    113                                                         "Input file does not use ELF format"
    114                                                         "\n"
    115                                                 );     
    116 
    117                                                 boot_exit();
    118                                         }
    119 
    120                                         /*
    121                                         * Verification of Program Headers table size. It must be
    122                                         * smaller than the work size allocated for the
    123                                         * elf_pht[PHDR_ARRAY_SIZE] array
    124                                         **/
     104                    /* Verification of ELF Magic Number */
     105                    if (
     106                        (elf_header_ptr->e_ident[EI_MAG0] != ELFMAG0) ||
     107                        (elf_header_ptr->e_ident[EI_MAG1] != ELFMAG1) ||
     108                        (elf_header_ptr->e_ident[EI_MAG2] != ELFMAG2) ||
     109                        (elf_header_ptr->e_ident[EI_MAG3] != ELFMAG3) )
     110                    {
     111                        boot_puts(
     112                            "ERROR: "
     113                            "Input file does not use ELF format"
     114                            "\n"
     115                        ); 
     116
     117                        boot_exit();
     118                    }
     119
     120                    /*
     121                    * Verification of Program Headers table size. It must be
     122                    * smaller than the work size allocated for the
     123                    * elf_pht[PHDR_ARRAY_SIZE] array
     124                    **/
    125125                    if (elf_header_ptr->e_phnum > PHDR_ARRAY_SIZE)
    126126                    {
    127127                        boot_puts(
    128                                                         "ERROR: "
    129                                                         "ELF PHDR table size is bigger than "
    130                                                         "the allocated work space"
    131                                                         "\n"
    132                                                 );
     128                            "ERROR: "
     129                            "ELF PHDR table size is bigger than "
     130                            "the allocated work space"
     131                            "\n"
     132                        );
    133133
    134134                        boot_exit();
     
    257257
    258258    boot_puts (
    259                 "Finishing boot_elf_loader function.\n"
    260                 "Entry point address: "
    261         );
     259        "Finishing boot_elf_loader function.\n"
     260        "Entry point address: "
     261    );
    262262    boot_putx(elf_header_ptr->e_entry);
    263263    boot_puts("\n");
  • 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;
  • trunk/softs/tsar_boot/src/exceptions.c

    r292 r388  
    44 * \author  : Manuel Bouyer
    55 *
    6  * This file defines a simple exeptions handler
     6 * This file defines a simple exceptions handler
    77 */
    88
  • trunk/softs/tsar_boot/src/sdcard.c

    r292 r388  
    4343static void _sdcard_gen_tick(struct sdcard_dev * sdcard, unsigned int tick_count)
    4444{
    45     volatile register int i = 0;
     45    register int i = 0;
    4646    while(i++ < tick_count) spi_put_tx(sdcard->spi, 0xFF, 0);
    4747}
     
    213213
    214214    for (i = 0; i < 4; i++)
     215    {
    215216        args[i] = (sdcard->access_pointer >> (32 - (i+1)*8)) & 0xFF;
     217    }
    216218
    217219    _sdcard_enable(sdcard);
  • trunk/softs/tsar_boot/src/spi.c

    r292 r388  
    1 /*
     1/**
    22 * \file    spi.c
    3  * \data    31 August 2012
     3 * \date    31 August 2012
    44 * \author  Cesar Fuguet <cesar.fuguet-tortolero@lip6.fr>
    55 */
     
    1515static void _spi_wait_if_busy(struct spi_dev * spi)
    1616{
    17     volatile register int delay;
     17    register int delay;
    1818
    1919    while(SPI_IS_BUSY(spi))
    2020    {
    21         for (delay = 0; delay < 10000; delay++);
     21        for (delay = 0; delay < 100; delay++);
    2222    }
    2323}
     
    5858        iowrite8(&spi->rx_tx[index % 4], byte);
    5959        _spi_init_transfer(spi);
    60 
    61         asm volatile("sync");
    6260    }
    6361    _spi_wait_if_busy(spi);
     
    104102    if (spi_freq > 0 && sys_freq > 0)
    105103        iowrite32(&spi->divider, _spi_calc_divider_value(spi_freq, sys_freq));
    106 
    107104}
    108105
Note: See TracChangeset for help on using the changeset viewer.