Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report 'Memory address 0x1e38 is invalid' when running helloworld.elf in spike #73

Closed
zhangkanqi opened this issue Dec 28, 2023 · 4 comments

Comments

@zhangkanqi
Copy link

Hi,

I find that when running helloworld.elf(exactly~/rsd/Processor/Src/Verification/TestCode/C/HelloWorld/code.elf) in the latest spike, it reports the following message:

image

Do you know how to address this problem? I have no idea at the moment.

Looking forward to your reply:)

@shioyadan
Copy link
Member

Hello,
Apologies for the delayed response.

I believe the error you're encountering stems from a difference between the memory address map used by RSD and one assumed by Spike.

The binaries for RSD are compiled based on the address map defined in the linker script found here: https://github.com/rsd-devel/rsd/blob/master/Processor/Src/Verification/TestCode/rsd-ld.script. However, it seems Spike utilizes a different address map.

If you're looking to run RSD binaries on Spike, it would be advisable to check and align with the address map that Spike assumes.

In case your goal is simply to execute RSD binaries on an emulator, I suggest using an older version of QEMU (around 2017). Recent versions of QEMU appear to have adopted a different address map. However, the memory address map RSD assumes aligns with that of the older QEMU versions. For instance, we previously ran binaries on QEMU as demonstrated in this Makefile: https://github.com/rsd-devel/rsd/blob/master/Processor/Tools/QEMU_SimDriver/Makefile.

@zhangkanqi
Copy link
Author

Can I put the instructions to be executed in the RAM area(pc>=0x8000 0000)? I tried and failed.
I think that might due to the width of pc. Because in rsd, the pc is 19-bit, but RAM starts with 0x8000 0000.

@shioyadan
Copy link
Member

I suspect that the issue is due to the placement in code.hex. Check the contents of your generated code.hex. The first 64KB of code.hex is loaded into the ROM area and the rest into the RAM area (0x8000000000>=). You need to be aware of this when creating binaries.

In the case of Verilator, code.hex is loaded at the following location. (Sorry, the comment is written in Japanese...)

loadHexFile(codeFileName, mainMem, 0, true);

code.hex is generated by the following makefile.
https://github.com/rsd-devel/rsd/blob/3d13af1bc14d2b34a546754973d832d0309d118e/Processor/Src/Verification/TestCode/Makefile.inc

Note that, RSD has 19-bit compressed logical addresses by default, but RSD can use 0x8000000000 >= space with a hack that treats the most significant bit specially.

Also, you can disable this compression feature by disabling the macro on the following line:

`define RSD_NARROW_PC

@zhangkanqi
Copy link
Author

Thanks a lot.
I have modified spike, now it can run instructions in ROM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants