4. SD/MMC card operation guide

4.1. Operation preparation

  • Use U-boot and kernel in SDK

  • File system:

    For SD/MMC cards, the SDK supports only the FAT file system, which can be read and written. After the kernel is started, mount it to the /mnt/sd directory or a directory as required.

  • Partitioning can be done through the fdisk tool.

  • Cv180x/cv181x SD supports 2.0 and 3.0:

At present, the cv180x/cv181x SD/MMC card supports only 3.3V VDDIO. Please Note that!

4.2. Operation Flow

  1. By default, all SD/MMC driver modules have been compiled into the kernel. There is no need to run any additional loading commands.

  2. Insert the card and power it on. You can view the card content by running fat commands in the U-boot.

  3. When boot platform reaching the kernel, response nodes /dev/mmcblk0 and /dev/mmcblk0p1 are automatically scanned and identified.

  4. In Uboot SD does not support hot plugging, but the kernel supports hot plugging. You can insert an SD card into the kernel to perform operations on the SD card. For details, see 3.3 Operation Examples.

4.3. Operation example

Examples of read and write operations for SD cards are as follows.

Initialization and application:

After the SD card is inserted, do the following (X below is the partition number whose value is determined by the fdisk tool when partitioning):

The specific directory for the specified fdisk operation is: ~ $ fdisk/dev/mmcblk0

Step 1. Check partition information

  1. If p1 is not displayed, the SD card is not partitioned yet. Please partition with fdisk tool on Linux or format the SD card on Windows system before proceeding to Step 2.

  2. If the partition information P1 is displayed, the SD card has been detected and partitioned and can be mounted in step 2.

Step 2. Mount

  1. ~ $ mount /dev/mmcblk1pX /mnt/sd ,This command mounts the Xth partition on the SD card to the /mnt/sd directory

4.4. Points to Pay Attention to in Operation

  1. Make sure that the SD card has good connection with the slot hardware pin. If the connection is not good, there may be detection errors or error information related to read and write data errors, which may lead to read and write failures.

  2. Each time an SD card is inserted, a mount operation is required to read and write the SD card. If the SD card is already mounted to the file system, you must do an umount operation before unplugging, otherwise you may not see the SD card partition after the next insertion of the SD card. In addition, unloading actions are also required for abnormal card unplugging.

  3. You must ensure that the SD card has created a partition and formatted it as FAT or FAT32 file system (using the fdisk command under LINUX or the disk management tool under Windows).

  4. Operation not allowed during normal operation:

    • Do not unplug the SD card when reading or writing it, otherwise some error message will be printed, and the file system in the card may be damaged.

    • If the current directory is under a mounted directory such as /mnt/sd, the unmount operation cannot be performed. You must leave the current directory such as /mnt/sd to perform the umount operation.

    • When there are reading or writing operation on mounted directories in the system, it cannot be umount until those operations have been completely ended. The task of operating mounted directories must be completely completed before umount can proceed properly.

    • When an exception occurs during the operation:

      1. If the file system is damaged due to reading and writing data or other unknown reasons, there may be file system error messages when reading and writing SD cards. Umount, unplug, insert and mount the card again to read and write SD cards normally again.

      2. Because the initialization of SD card takes some time for the detection/remove process, it is possible that no SD card can be detected if the card is inserted quickly after the card is unplugged.

      3. If the card is unplugged abnormally during the test, the user needs to press ctrl+c to exit back to the kernel shell, otherwise the error message will be printed continuously.

      4. When there is more than one partition on the SD card, you can switch between mounting partitions by mounting, but make sure that the number of mount operations is equal to the number of unmount operations to ensure that all mounted partitions are completely umount.