From fe5a2783ca48cc3f76624580a006ca1768f2d22b Mon Sep 17 00:00:00 2001 From: bernard Date: Sun, 18 Oct 2026 19:33:52 +0800 Subject: [PATCH 1/2] [sdio] set block size after block configuration - initialize block_size only after the host block size is applied - avoid exposing card_blksize before it is configured on the device - keep sector-based geometry consistent for partition probing --- components/drivers/sdio/dev_block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/drivers/sdio/dev_block.c b/components/drivers/sdio/dev_block.c index f0437c10c25b..5272a6acf823 100644 --- a/components/drivers/sdio/dev_block.c +++ b/components/drivers/sdio/dev_block.c @@ -391,7 +391,6 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card) max_blk_size = host->max_blk_count * host->max_blk_size; blk_dev->max_req_size = (max_dma_size < max_blk_size ? max_dma_size : max_blk_size) / MMCSD_SECTOR_SIZE; blk_dev->geometry.bytes_per_sector = MMCSD_SECTOR_SIZE; - blk_dev->geometry.block_size = card->card_blksize; blk_dev->geometry.sector_count = card->card_capacity * (1024 / MMCSD_SECTOR_SIZE); /* Set blk size before partitions probe, Why? */ @@ -399,6 +398,7 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card) { goto _fail; } + blk_dev->geometry.block_size = blk_dev->geometry.bytes_per_sector; rt_thread_mdelay(1); #ifdef RT_USING_DM From 6124d26d7b649964941a8f6193b0fe481feba538 Mon Sep 17 00:00:00 2001 From: bernard Date: Sun, 18 Oct 2026 20:41:38 +0800 Subject: [PATCH 2/2] [sdio] initialize write block counter - initialize the block counter before the SEND_NUM_WR_BLKS request - fix the cppcheck uninitvar warning in mmcsd_num_wr_blocks() --- components/drivers/sdio/dev_block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/drivers/sdio/dev_block.c b/components/drivers/sdio/dev_block.c index 5272a6acf823..8b26db482aea 100644 --- a/components/drivers/sdio/dev_block.c +++ b/components/drivers/sdio/dev_block.c @@ -111,7 +111,7 @@ static int card_busy_detect(struct rt_mmcsd_card *card, unsigned int timeout_ms, rt_int32_t mmcsd_num_wr_blocks(struct rt_mmcsd_card *card) { rt_int32_t err; - rt_uint32_t blocks; + rt_uint32_t blocks = 0; struct rt_mmcsd_req req; struct rt_mmcsd_cmd cmd;