(ntested!) implementation of firmware_to_ram routine