We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

0.3.2 b231 mmc-utils and sdtool not working

  • Hi,

    I needed to implement some micro sd card functions (permamently/temporary readonly) so I tried using https://github.com/BertoldVdb/sdtool. Cross compiled ok, and app works on Omega. I can read lock status but once I try to set temporary lock, I get error:
    mtk-sd 10130000.sdhci: __mmc_blk_ioctl_cmd: cmd error -145
    I also tried to compile mmc-utils but when I try to do anything on sd card, I get the same error. Additional relevant data from dmesg is:
    [ 421.777708] msdc0 -> XXX CMD<42> wait xfer_done<512> timeout!! <- msdc_do_request() : L<1617> PID<mmcqd/0><0x723>
    [ 421.788148] msdc0 -> DMA_SA = 0x7fb7000 <- msdc_do_request() : L<1618> PID<mmcqd/0><0x723>
    [ 421.797059] msdc0 -> DMA_CA = 0x7fb7000 <- msdc_do_request() : L<1619> PID<mmcqd/0><0x723>
    [ 421.805999] msdc0 -> DMA_CTRL = 0x6400 <- msdc_do_request() : L<1620> PID<mmcqd/0><0x723>
    [ 421.814721] msdc0 -> DMA_CFG = 0x3 <- msdc_do_request() : L<1621> PID<mmcqd/0><0x723>
    [ 421.823191] mtk-sd 10130000.sdhci: __mmc_blk_ioctl_cmd: data error -145
    All this looks to me like an error in mtk-sd kernel module. Did anyone experience same problem (and tried to solve the same)? What would be the other possibility to set temporary/permanent sd card lock?

    Kind regards,

  • Also one more (little) thing. If I do:
    ./mmc status get /dev/mmcblk0

    I get this error:
    ioctl: Operation timed out
    Could not read response to SEND_STATUS from /dev/mmcblk0

    while dmesg shows:
    mtk-sd 10130000.sdhci: __mmc_blk_ioctl_cmd: cmd error -145

    Is there any fix to make mmc-utils tool work?

  • We also noticed that there is a mmc-utils on android kernel but we are not sure how to use it!

  • Just to confuse things a little more. I have a similar issue with the Omega2S+ (surface mount version), these are on my own custom PCBs so we use a 3rd party sdcard slot. About 30% of the sdcards function 100%. I noticed that in some cases a perfectly functional sdcard works in one unit but not in any other unit. If I then insert a new card in one of those units that couldn't read the 1st card, sometimes (20% of the time) they work fine.

    There is something fishy going on.

  • @crispyoz

    Hm, maybe you have some hardware issue leading to miss communication? I have also designed custom board using Omega2S+ that uses sd card but standard communication (creating partition, mounting, save and read data) works without any issue. The only problem is when I try to execute ioctl commands using MMC_IOC_CMD: or the command fails with timeout or (a couple of times) I experienced complete linux stall with only forced reset as a solution.
    Based on my research so far, I concluded that mtk-mmc sd implementation is somehow "not compatible" with ioctl in kernel 4.14.81


  • @morfeus As I have more time in a couple of weeks I will get to the bottom of the issue. The sdcard circuit is based up on the reference design so if my PCB is flawed then the reference design is also flawed.

    Anyway this is my 2c. When I have more to offer I iwll post it.

  • Just a little update on this subject. I am unable to make mmc-tools work, but I managed to make sdtool work:) The "trick" was to add this:
    } else if ((opcode == MMC_PROGRAM_CSD && (mmc_cmd_type(cmd) == MMC_CMD_ADTC))){
    rawcmd |= ((1 << 11) | (1 << 13));
    on line 1013 of the file build_dir\target-mipsel_24kc_musl\linux-ramips_mt76x8\linux-4.14.81\drivers\mmc\host\mtk-mmc\sd.c

    That makes PROGRAM_CSD command work.
    As the goal was to be able to make sd card readonly, I won't bother with mmc-utils.
    Hope this helps someone šŸ˜‰


  • @morfeus thanks for sharing

Looks like your connection to Community was lost, please wait while we try to reconnect.