From ce1d047845ada7084530ac88b6b6d4c40980f2a8 Mon Sep 17 00:00:00 2001 From: wanggang26 Date: Thu, 12 Oct 2023 22:09:39 +0800 Subject: [PATCH] mmcsd: fix cmd6 timeout error when repeat calling If CMD6 is sent again before last transmission is complete, a timeout error will be encountered. Signed-off-by: wanggang26 --- drivers/mmcsd/mmcsd_sdio.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/mmcsd/mmcsd_sdio.c b/drivers/mmcsd/mmcsd_sdio.c index c09739c946f..08adfee19e7 100644 --- a/drivers/mmcsd/mmcsd_sdio.c +++ b/drivers/mmcsd/mmcsd_sdio.c @@ -1047,7 +1047,7 @@ static int mmcsd_switch(FAR struct mmcsd_state_s *priv, uint32_t arg) * CMD6(SWITCH) to set the PARTITION_ACCESS bits in the EXT_CSD * register, byte[179].After that, master can use the Multiple Block * read and write commands (CMD23, CMD18 and CMD25) to access the - * RPMB partition. + * specified partition. * PARTITION_CONFIG[179](see 7.4.69) * Bit[2:0] : PARTITION_ACCESS (before BOOT_PARTITION_ACCESS) * User selects partitions to access: @@ -1073,7 +1073,17 @@ static int mmcsd_switch(FAR struct mmcsd_state_s *priv, uint32_t arg) * [2:0] Cmd Set */ + int ret; + + ret = mmcsd_transferready(priv); + if (ret != OK) + { + ferr("ERROR: Card not ready: %d\n", ret); + return ret; + } + mmcsd_sendcmdpoll(priv, MMCSD_CMD6, arg); + priv->wrbusy = true; return mmcsd_recv_r1(priv, MMCSD_CMD6); }