This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to check the free space available on SD/MMC card in u-boot?

Hi,

I have one question related the sd/mmc card. I am able to detect the sd card. with sd card i get the total capacity also. but is there any command or code to calculate the free space available on SD/MMC card in u-boot.

e.g  with disk space we get total size of disk, used space, free space on disk in rootfs. but can i get the such information in u-boot level.

  • You could indirectly get the information using 'mmcinfo', 'mmc part' and 'fatls' (see below).

    U-Boot > mmcinfo
    Device: davinci
    Manufacturer ID: 1c
    OEM: 5356
    Name: SDC 
    Tran Speed: 25000000
    Rd Block Len: 512
    SD version 2.0
    High Capacity: Yes
    Capacity: 3.8 GiB
    Bus Width: 4-bit

    U-Boot > mmc part

    Partition Map for MMC device 0 -- Partition Type: DOS

    Partition Start Sector Num Sectors Type
    1 63 144522 c
    2 160650 1847475 83
    3 2024190 6024375 83

    U-Boot > fatls mmc 0
    140 autorun.inf
    2554048 uimage
    2554712 uimage-rc1
    2371014 quickstartguide.pdf
    37327 mlo-4.6.0.6
    windows_users/
    52 pointercal
    16 .ipaddr
    3004848 uimage-am335x-4.6.0.6
    3006264 uimage-transdma
    2022580 ramdisk-pm.gz
    2458656 uimage-gh
    231320 u-boot-4.6.0.6.img
    2966640 uimage-4b5c2055
    3077336 uimage-b8ecb7b5
    3076848 uimage-1b21543a
    6284012 demo.bin
    6284020 app
    31720 mlo-starterware
    37391 mlo-4.6.0.7-ga
    231340 u-boot-4.6.0.7-ga.img
    3082944 uimage-4.6.0.7-ga

    21 file(s), 1 dir(s)

    U-Boot > ext2ls mmc 0:2
    <DIR> 4096 .
    <DIR> 4096 ..
    <DIR> 4096 opt
    <DIR> 4096 usr
    <DIR> 4096 sys
    <DIR> 4096 bin
    <DIR> 4096 proc
    <DIR> 4096 lib
    <DIR> 4096 var
    <DIR> 4096 sbin
    <DIR> 4096 srv
    <DIR> 4096 etc
    <DIR> 4096 home
    <SYM> 12 linuxrc
    <SYM> 8 tmp
    <DIR> 4096 media
    <DIR> 4096 boot
    <DIR> 4096 mnt
    <DIR> 4096 dev
    <DIR> 4096 test
    <DIR> 4096 debug

    Carlos

  • Thanks Carlos,

    I am able to calculate the free space available on MMC card, using these commands.