> This won't work on read-only storage. > > > + } > > } > > qdev_realize_and_unref(flash, BUS(fiu->spi), &error_fatal); > > > > @@ -194,7 +206,8 @@ static void npcm845_evb_init(MachineState *machine) > > qdev_realize(DEVICE(soc), NULL, &error_fatal); > > > > npcm8xx_load_bootrom(machine, soc); > > - npcm8xx_connect_flash(&soc->fiu[0], 0, "w25q256", drive_get(IF_MTD, 0, > > 0)); > > + npcm8xx_connect_flash(&soc->fiu[0], 0, "mx66l1g45g", > > + drive_get(IF_MTD, 0, 0)); > > npcm845_evb_i2c_init(soc); > > npcm845_evb_fan_init(NPCM8XX_MACHINE(machine), soc); > > npcm8xx_load_kernel(machine, soc); > Indeed, we didn't consider the read-only storage case. Should we add bdrv_is_read_only() to check as shown in the code below? Thanks.
if (bdrv_is_read_only(bs)) { // Handle read-only storage if (blk_size < fiu->flash_size) { error_report("Read-only storage is too small for flash device"); return; } } else { // Handle writable storage if (blk_size < fiu->flash_size) { blk_get_perm(blk, &perm, &shared_perm); blk_set_perm(blk, BLK_PERM_ALL, BLK_PERM_ALL, &error_abort); blk_truncate(blk, fiu->flash_size, true, PREALLOC_MODE_OFF, BDRV_REQ_ZERO_WRITE, &error_abort); blk_set_perm(blk, perm, shared_perm, &error_abort); } } -- Best regards, Tim Lee