SAMA5D44 msc example simulates not reflecting sd on reset!

Discussion around products based on ARM Cortex-A5 core.

Moderator: nferre

gopi_atmel
Posts: 10
Joined: Thu Apr 09, 2015 10:59 am

SAMA5D44 msc example simulates not reflecting sd on reset!

Sat May 02, 2015 11:14 am

Hi,

I am trying SOFTPACK example of SAMA5D44_Xplained board.The software pack has a example USB Device Mass Storage Example.

The description reads
Purpose
The USB Massstorage Example will help you to get familiar with the USB Device Port(UDP) on SAMA5 microcontrollers. Also it can help you to be familiar with the USB Framework that is used for rapid development of USB-compliant class drivers such as USB Mass Storage class (MSD).


Requirements
This package can be used with all Atmel Xplained board that have USB interface


Description
The demo simulates a SD/MMC USB disk.

 
When an Xplained running this program connected to a host (PC for example), with USB cable, the Xplained appears as a USB Disk for the host. Then the host can format/read/write on the disk.

I am able to run the code on ddram and enumerates the usb device  which shows contents of  samsung micro sdcard (Using adapter) connected in mmc MCI1 port.

But When I delete  ,create file ,nothing is reflected on reset of board and original   files are restored.

As demo says simulates , it is like a virtual copy of sdcard but unable to modify/format or change anything on micro-sdcard using this example.

Is there any tweak to be done to use this to actually read/write the micro sd over USB device? I have read the code but its not clear which part is simualting thing.

Please Advice

I also get some error related to dma on enumeration as below in console:
-- USB Device Mass Storage Example 1.2 --
-- sama5d4x-Xplained
-- Compiled: May  2 2015 14:22:06 --
-I- connect to solt 1
-I- SdMmcIdentify.Cmd5: 3
-I- SDHC MEM
-I- Card Type 3, CSD_STRUCTURE 0
-I-  .TRAN_SPEED         0x32
-W- SD 4-bit mode
-E- Can't free channel
-W- SD HS Enabled
-I- Set SD/MMC clock to 44000K
-I- SD/MMC card initialization successful
-I- MEM Card OK, size: 15645 MB, 31291392 * 512B
-I- ======= CID =======-I- ===================
-I-  .MID Manufacturer ID             1B
-I-  .CBX Card/BGA (eMMC)             3
-I-  .OID OEM/Application ID (SD)     SM
-I-  .OID OEM/Application ID (MMC)    4d
-I-  .PNM Product name (SD)           00000
-I-  .PNM Product name (MMC)          00000
-I-  .PRV Product revision (SD)       10
-I-  .PRV Product revision (MMC)      2d
-I-  .PSN Product serial number (SD)  2D9B020F
-I-  .PSN Product serial number (MMC) 9B020F00
-I-  .MDT Manufacturing date (SD)     2015/01
-I-  .MDT Manufacturing date (MMC)    2012/01
-I-  .CRC checksum              31
-I- ======== CSD ========-I- ===================
-I-  .CSD_STRUCTURE      0x1
-I-  .SPEC_VERS (eMMC)   0x0
-I-  .TAAC               0xE
-I-  .NSAC               0x0
-I-  .TRAN_SPEED         0x5A
-I-  .CCC                0x5B5
-I-  .READ_BL_LEN        0x9
-I-  .READ_BL_PARTIAL    0x0
-I-  .WRITE_BLK_MISALIGN 0x0
-I-  .READ_BLK_MISALIGN  0x0
-I-  .DSR_IMP            0x0
-I-  .C_SIZE             0x1
-I-  .C_SIZE_HC          0x775D
-I-  .VDD_R_CURR_MIN     0x6
-I-  .VDD_R_CURR_MAX     0x7
-I-  .VDD_W_CURR_MIN     0x2
-I-  .VDD_W_CURR_MAX     0x7
-I-  .C_SIZE_MULT        0x2
-I-  .ERASE_BLK_EN       0x1
-I-  .SECTOR_SIZE        0x7F
-I-  .WP_GRP_SIZE        0x0
-I-  .WP_GRP_ENABLE      0x0
-I-  .R2W_FACTOR         0x2
-I-  .WRITE_BL_LEN       0x9
-I-  .WRITE_BL_PARTIAL   0x0
-I-  .FILE_FORMAT_GRP    0x0
-I-  .COPY               0x0
-I-  .PERM_WRITE_PROTECT 0x0
-I-  .TMP_WRITE_PROTECT  0x0
-I-  .FILE_FORMAT        0x0
-I-  .ECC (MMC)          0x0
-I-  .CRC                0x3A
-I-  .MULT               0x10
-I-  .BLOCKNR            0x20
-I-  .BLOCKNR_HC         0x1DD7800
-I-  .BLOCK_LEN          0x200
-I-  -TOTAL_SIZE         0x4000
-I-  -TOTAL_SIZE_HC      0xBAF00000
-I- ======= EXT_CSD =======
-I-  .S_CMD_SET            : 0x0
-I-  .BOOT_INFO            : 0x0
-I-  .BOOT_SIZE_MULTI      : 0x0
-I-  .ACC_SIZE             : 0x0
-I-  .HC_ERASE_GRP_SIZE    : 0x0
-I-  .ERASE_TIMEOUT_MULT   : 0x0
-I-  .REL_WR_SEC_C         : 0x0
-I-  .HC_WP_GRP_SIZE       : 0x0
-I-  .S_C_VCC              : 0x0
-I-  .S_C_VCCQ             : 0x0
-I-  .S_A_TIMEOUT          : 0x0
-I-  .SEC_COUNT            : 0x0
-I-  .MIN_PERF_W_8_52      : 0x0
-I-  .MIN_PERF_R_8_52      : 0x0
-I-  .MIN_PERF_W_8_26_4_52 : 0x0
-I-  .MIN_PERF_R_8_26_4_52 : 0x0
-I-  .MIN_PERF_W_4_26      : 0x0
-I-  .MIN_PERF_R_4_26      : 0x0
-I-  .PWR_CL_26_360        : 0x0
-I-  .PWR_CL_52_360        : 0x0
-I-  .PWR_CL_26_195        : 0x0
-I-  .PWR_CL_52_195        : 0x0
-I-  .CARD_TYPE            : 0x0
-I-  .CSD_STRUCTURE        : 0x0
-I-  .EXT_CSD_REV          : 0x0
-I-  .CMD_SET              : 0x0
-I-  .CMD_SET_REV          : 0x0
-I-  .POWER_CLASS          : 0x0
-I-  .HS_TIMING            : 0x0
-I-  .BUS_WIDTH            : 0x0
-I-  .ERASED_MEM_CONT      : 0x0
-I-  .BOOT_CONFIG          : 0x0
-I-  .BOOT_BUS_WIDTH       : 0x0
-I-  .ERASE_GROUP_DEF      : 0x0
MEDSdusb init
-I- VBus configuration
-I- VBUS conn
Rsm -I- conn
Susp Rsm -E- Can't free channel
-E- MTranState.Cmd18: 3
-E- Can't free channel
-E- MTranState.Cmd18: 3
-E- Can't free channel
-E- MTranState.Cmd18: 3
-E- Can't free channel
-E- MTranState.Cmd18: 3
-E- Can't free channel
-E- MTranState.Cmd18: 3
Susp -E- Can't free channel
-E- MTranState.Cmd18: 3
Rsm -E- Can't free channel
-E- MTranState.Cmd18: 3
-E- Can't free channel
-E- MTranState.Cmd18: 3
-E- Can't free channel
-E- MTranState.Cmd18: 3
-E- Can't free channel
-E- MTranState.Cmd18: 3
-E- Can't free channel
-E- MTranState.Cmd18: 3
-E- Can't free channel
-E- MTranState.Cmd18: 3
-E- Can't free channel
-E- MTranState.Cmd18: 3
-E- Can't free channel
-E- MTranState.Cmd18: 3
-E- Can't free channel
-E- MTranState.Cmd18: 3
-E- Can't free channel
-E- Can't free channel
-E- Can't free channel

Main.c snippet

Code: Select all

int main( void )
{
    uint8_t sdConnected[BOARD_NUM_MCI];
    uint8_t i;
    sSdCard *pSd;
 
    /* Disable watchdog */
    WDT_Disable( WDT ) ;
  
    /* Enable MMU, Icache and Dcache */
    MMU_Initialize((uint32_t *)0x20C000);
    CP15_EnableMMU();
    CP15_EnableDcache();
    CP15_EnableIcache();

 
    printf("-- USB Device Mass Storage Example %s --\n\r", SOFTPACK_VERSION);
    printf("-- %s\n\r", BOARD_NAME);
    printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__);

 
    /* If they are present, configure Vbus & Wake-up pins */
    PIO_InitializeInterrupts(0);

 
    /* Initialize all USB power (off) */
    USBPower_Configure();
    /* Initialize PIO pins */
    _ConfigurePIOs();
 
    /* Initialize drivers */
    _ConfigureDrivers();

 
    gNbMedias = 2;

 
    /* Infinite loop */
    for (i = 0; i < BOARD_NUM_MCI; i ++) sdConnected[i]=0;
    for (i = 0; i < BOARD_NUM_MCI; i ++)
    {
        if (CardIsConnected(i)) {
            if (sdConnected[i] == 0) {
                sdConnected[i] = 1;
                printf("-I- connect to solt %x \n\r",i);
                CardInit(i);
                pSd = &sdDrv[i];
                SD_DumpCID(pSd->CID);
                SD_DumpCSD(pSd->CSD);
                SD_DumpExtCSD(pSd->EXT);
                MEDSdusb_Initialize(&medias[i], pSd);
            }
        }
        else if (sdConnected[i]) {
            sdConnected[i] = 0;
            printf("** Card %d Disconnected\n\r",i);
        }
    }


     //commented lun[0]  part here as MCI0 adapter is not soldered on xplained    board  (also uncommenting  makes no diff)
    //LUN_Init(&(luns[0]), &(medias[0]),  msdBuffer1, MSD_BUFFER_SIZE, 0, 0, 0, 0, MSDCallbacks_Data);
    LUN_Init(&(luns[1]), &(medias[1]),  msdBuffer2, MSD_BUFFER_SIZE, 0, 0, 0, 0, MSDCallbacks_Data);
    
    /* BOT driver initialization */
    MSDDriver_Initialize(&msdDriverDescriptors, luns, MAX_LUNS);




    /* connect if needed */
    VBus_Configure();
    while (1) {


        /* Mass storage state machine */
        if (USBD_GetState() < USBD_STATE_CONFIGURED){}//printf("%x",USBD_GetState());}
        else MSDDriver_StateMachine();
    }
}


/**
 * Initialize driver instances.
 */
static void _ConfigureDrivers(void)
{
     uint32_t i;
    /* Initialize the DMA driver */
    XDMAD_Initialize(&dmaDrv, 0);
    AIC_EnableIT(ID_XDMAC0);
    AIC_EnableIT(ID_XDMAC1);
    /* Initialize the HSMCI driver */
    MCID_Init(&mciDrv[0], HSMCI0, ID_HSMCI0, BOARD_MCK, &dmaDrv, 0 ) ;
    AIC_EnableIT(ID_HSMCI0);
    MCID_Init(&mciDrv[1], HSMCI1, ID_HSMCI1, BOARD_MCK, &dmaDrv, 0 ) ;
    AIC_EnableIT(ID_HSMCI1);
    /* Initialize SD driver */
    for (i = 0; i < BOARD_NUM_MCI; i ++)
    {
        SDD_InitializeSdmmcMode(&sdDrv[i], &mciDrv[i], 0);
    }
}




/**
 * Run init on the inserted card
 * \param iMci Controller number.
 */
static void CardInit(uint8_t iMci)
{
    sSdCard *pSd = &sdDrv[iMci];
    uint8_t error;
    uint8_t retry = 2;
    while(retry --)
    {
        error = SD_Init(pSd);
        if (error == SDMMC_OK) break;
    }
    if (error)
    {
        printf("-E- SD/MMC card initialization failed: %d\n\r", error);
        return;
    }
    printf("-I- SD/MMC card initialization successful\n\r");
    if (SD_GetCardType(pSd) & CARD_TYPE_bmSDMMC)
    {
        printf("-I- MEM Card OK, size: %d MB", (int)SD_GetTotalSizeKB(pSd)/1000);
        printf(", %d * %dB\n\r", (int)SD_GetNumberBlocks(pSd), (int)SD_GetBlockSize(pSd));
    }
    if (SD_GetCardType(pSd) & CARD_TYPE_bmSDIO)
    {
        printf("-E- IO Card Detected \n\r");
    }
}

Thanks
Last edited by gopi_atmel on Mon May 11, 2015 11:41 am, edited 2 times in total.
gopi_atmel
Posts: 10
Joined: Thu Apr 09, 2015 10:59 am

Re: SAMA5D44 msc example simulates not reflecting sd on re

Mon May 11, 2015 11:39 am

Any help from Atmel? How can i get support from atmel? :?

Return to “SAMA5D Cortex-A5 MPU”

Who is online

Users browsing this forum: No registered users and 6 guests