Hi Stefan, > > Indentation is off here. One way of formatting it: > > address_space_write(&s->as, i * NRF51_PAGE_SIZE, > MEMTXATTRS_UNSPECIFIED, s->empty_page, > NRF51_PAGE_SIZE);
Good catch. >> +static void nrf51_nvm_reset(DeviceState *dev) >> +{ >> + NRF51NVMState *s = NRF51_NVM(dev); >> + >> + memset(s->uicr_content, '\0', sizeof(s->uicr_content)); >> +} > > We will zero UICR. Does UICR come zero-initialized on a real micro:bit? > > I remember there was an issue with .hex files that set UICR values. > Will nrf51_nvm_reset() overwrite values from .hex files when the generic > loader devices is used (-device loader,file=test.hex)? > UICR comes 0xFF initialized ([1] 8.1) and yes we had a conflict with the js-runtime. I now moved the memset to init just before mapping the region: memset(s->uicr_content, 0xFF, sizeof(s->uicr_content)); memory_region_init_io(&s->uicr, NULL, &uicr_ops, s, "nrf51_soc.uicr", sizeof(s->uicr_content)); ysbus_init_mmio(sbd, &s->uicr); That should do the trick. A reset without loading of a new firmware blob will not change the (flash) user memory any longer, which should match the real device. Best, Steffen [1] http://infocenter.nordicsemi.com/pdf/nRF51_RM_v3.0.pdf