Hi Joel,

On 18/3/22 14:28, Cédric Le Goater wrote:
From: Joel Stanley <j...@jms.id.au>

The userdata size is derived from the file the user passes on the
command line, but we must take into account the boot areas.

Signed-off-by: Joel Stanley <j...@jms.id.au>
Signed-off-by: Cédric Le Goater <c...@kaod.org>
---
  hw/sd/sd.c | 6 ++++++
  1 file changed, 6 insertions(+)

@@ -655,6 +656,11 @@ static void sd_reset(DeviceState *dev)
      }
      size = sect << 9;
+ if (sc->bootpart_offset) {
+        unsigned int boot_capacity = sd->ext_csd[EXT_CSD_BOOT_MULT] << 17;

What about adding a tiny helper?

static unsigned sd_boot_capacity_bytes(SDState *sd)
{
    return sd->ext_csd[EXT_CSD_BOOT_MULT] << 18;
}

+        size -= boot_capacity * 2;
+    }
+
      sect = sd_addr_to_wpnum(size) + 1;
sd->state = sd_idle_state;


Reply via email to