Home ·
  • SAM-BA sdmmc applet
  • SAM-BA sdmmc applet

    The sdmcc applet drives any High Speed Multimedia Card Interface (HSMCIx) or the Secure Digital Multi-Media Card (SDMMCx) to program an external SD Card or e.MMC embedded on the board and connected to the SAM MPU device.

    Applet initialization

    The list of parameters to initialize the sdmmc applet can be displayed with the following command:

    sam-ba -p <port> -d <device> -a sdmmc:help
    
    $ sam-ba -p serial -d sama5d2 -a sdmmc:help
    Syntax: sdmmc:[<instance>]:[<ioset>]:[<partition>]:[<bus_width>]:[<voltages>]
    Parameters:
        instance   SDMMC controller number
        ioset      SDMMC I/O set
        partition  Partition number (0=user partition, x>0=boot partition x)
        bus_width  Data bus width (0=controller max, 1=1-bit, 4=4-bit, 8=8-bit)
        voltages   Supported voltages (bitfield: 1=1.8V, 2=3.0V, 4=3.3V)
    Examples:
        sdmmc           use default board settings
        sdmmc:0:1:1:8:5 use fully custom settings (SDMMC0, IOSET1, first boot partition, 8-bit, 1.8V/3.3V)
        sdmmc:0::1      use default board settings but force use of SDMMC0, first boot partition

    Instance and I/O Set

    An instance parameter x tells the sdmmc applet to use the HSMCIx or SDMMCx controller. The ioset parameter is an index that represents a group of I/O pins muxed to the HSMCIx/SDMMCx controller. The {Instance, I/O set} pairs are device specific; please refer to the sdmmc section of the device configuration:

    Partition

    The partition parameter is only relevant for e.MMC and must be set to zero for SD Cards. For e.MMC it represents the memory area where data should be erased/read from/written into. The 3 possibles values are:

    Bus Width

    The bus_width parameter represents the number of data pins used to transfer data to the SD Card/e.MMC. Possible values are:

    Voltage

    The voltage parameter is a bitmask of supported voltages for the SD Card/e.MMC. Possible voltages are encoded with the following bitmasks:

    Supported commands

    The list of commands supported by the sdmmc applet can be displayed with the following commands:

    sam-ba -p <port> -d <device> -a sdmmc -c help
    
    $ sam-ba -p serial -d sama5d2 -a sdmmc -c help

    The write and writeboot commands

    The write and writeboot commands program data from a binary file into the SD Card or e.MMC. Prior to what both command do, the writeboot command also modifies the relevant unused ARM exception vector to store the size of the bootstrap binary, as required by the ROM code during the boot process.

    The writeboot command should be used only when programming a bootstrap into some e.MMC boot partition, whereas the write command should be used instead to program an SD Card image into either any SD Card or the user partition of any e.MMC.

    The sdcard.img file contains the raw data of the SD Card. It must begin with a Master Boot Record (MBR) and its valid partition table. The first partition must be formatted in FAT12, FAT16 or FAT32. This FATx file-system must include a boot.bin file in the root folder. This boot.bin file is actually the bootstrap as loaded then executed by the ROM code.

    $ sam-ba -p serial -b sam9x60-ek -a sdmmc -c write:help
    * write - write to memory from a file
    Syntax:
        write:<filename>:[<addr>]
    Examples:
        write:sdcard.img            write sdcard.img to start of memory
    
    $ sam-ba -p serial -b sam9x60-ek -a sdmmc -c writeboot:help
    Syntax:
        writeboot:<filename>
    Example:
        writeboot:bootstrap.bin     write bootstrap.bin as boot program at start of memory

    The read command

    The read command loads data from the SD Card/e.MMC into a binary file.

    $ sam-ba -p serial -b sam9x60-ek -a sdmmc -c read:help
    * read - read from memory to a file
    Syntax:
        read:<filename>:[<addr>]:[<length>]
    Examples:
        read:firmware.bin              read all to firmware.bin
        read:firmware.bin:0x1000       read from 0x1000 to end into firmware.bin
        read:firmware.bin:0x1000:1024  read 1024 bytes from 0x1000 into firmware.bin
        read:firmware.bin::1024        read 1024 bytes from start of memory into firmware.bin

    The verify and verifyboot commands

    The verify and verifyboot compare the data programmed in the SD Card/e.MMC with the content of a given binary file. Unlike the verify command, the verifyboot command ignores the actual value of the relevant unused ARM exception vector in the binary file and does as if the value were the size of the binary file.

    $ sam-ba -p serial -b sam9x60-ek -a sdmmc -c verify:help
    * verify - verify memory from a file
    Syntax:
        verify:<filename>:[<addr>]
    Examples:
        verify:sdcard.img           verify that start of memory matches sdcard.img
        verify:firmware.bin:0x1000  verify that memory at offset 0x1000 matches firmware.bin
    
    $ sam-ba -p serial -b sam9x60-ek -a sdmmc -c verifyboot:help
    * verifyboot - verify boot program from a file
    Syntax:
        verifyboot:<filename>
    Example:
        verifyboot:bootstrap.bin     verify that start of memory matches boot program bootstrap.bin


    Copyright © 2018 Microchip Technology
    SAM-BA Documentation