Closed AndrolGenhald closed 1 year ago
I was able to work around the issue by adding an "Extended Linear Address" at the start of the eeporm file to indicate that the addressing should start at 0x100000:
:020000040010EA
This causes the eeprom to be loaded correctly, but as of yet I haven't figured out if it's possible to get simavr to save modified eeprom back to the file. It would be great to better document the eeprom functionality.
The loading code does not seem to have changed much since eeprom loading was introduced in 5d6254c8da54127276ecdd48069f00f19788693f. Not checking loadBase before loading flash does seem a straightforward bug. I think the reason that the eeprom address check is done both with and without loadBase is to accommodate two sorts of eeprom-containing ihex files: one that respects the convention used by avr-ld with the usual scripts (eeprom start address 0x81000) and one where eeprom contents are based at 0. I guess you have the second sort.
A fix might also handle multiple non-overlapping chunks of both flash and eeprom, and non-increasing addresses in the ihex file.
An option to save eeprom in reloadable form also looks useful.
Serendipity - I hit the same problem: PR to fix has been submitted.
I'm trying to simulate the atmega328p with ihex firmware and eeprom using
simavr -m atmega328p -f 16000000L -ff firmware.hex -ee eeprom.hex -v -v -v
, but it's loading the eeprom as flash and crashing:I see here that
-ee
setsloadBase
toAVR_SEGMENT_OFFSET_EEPROM
, which is defined here to be0x00810000
, but insim_setup_firmware
the check for whether it's loading eeprom or flash ischunk[ci].baseaddr < (1*1024*1024)
, which doesn't account forloadBase
. The ihex format only allows 16 bits for the base address, so the max address is 65535, making it impossible to get simavr to load a file as eeprom instead of flash.The condition for eeprom checks both the base address by itself and base address +
loadBase
, but since this happens after the flash condition which only checks base address, it can't be reached. It's unclear to me whyloadBase
isn't used in both conditions, and why the eeprom condition checks both with and without it.