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

Handling of mem_map when cpu type is "None" #984

Closed
tcal-x opened this issue Jul 30, 2021 · 2 comments
Closed

Handling of mem_map when cpu type is "None" #984

tcal-x opened this issue Jul 30, 2021 · 2 comments

Comments

@tcal-x
Copy link
Collaborator

tcal-x commented Jul 30, 2021

In the Fomu workshop, one of the exercises uses LiteX to create a WishBone bus with peripherals (RAM and RGB LED) but no CPU. This is probably a rare situation that is not much tested. It it part of the reason why we haven't been able to bump litex_boards submodule in the Fomu workshop (im-tomu/fomu-workshop#411).

But now I'm seeing a related issue even with the current submodules. CSRs are supposed to be mapped at 0xE0000000 / 0x60000000 (link), but after the build, they appear at 0x00000000 (see im-tomu/fomu-workshop#509). 0x00000000 should be the ROM region.

I think this behavior originates where the CPU mem_map is merged with the SOC's mem_map:

        self.mem_map.update(self.cpu.mem_map) # FIXME

If I print out the SOC mem_map, the CPU mem_map, and then the SOC mem_map after the update, I see:

soc memmap
{'rom': 0, 'sram': 268435456, 'spiflash': 536870912, 'main_ram': 1073741824, 'csr': 3758096384}
cpu memmap
{'csr': 0}
new soc memmap
{'rom': 0, 'sram': 268435456, 'spiflash': 536870912, 'main_ram': 1073741824, 'csr': 0}

If I add a guard as below, it prevents the CSR region base from being set to zero, and normal behavior is restored.

        if not isinstance(self.cpu, cpu.CPUNone):
            self.mem_map.update(self.cpu.mem_map) # FIXME

Of course, there may be a better fix (such has having an empty mem_map for the CPU when its type is None).

@enjoy-digital
Copy link
Owner

Thanks for the feedback @tcal-x, I indeed wanted to rework this and at least add the override info to the build log (=full traduction of the FIXME I put some time ago :)).

I just used the Fomu target and should have fixed your issue with ce58649.

The CPUNone case is a bit different than others, so I changed the priority in the remapping for it: User's mapping have the priority in this case.

Please let me know if it fixes the issue on your side (and if you have other blockers preventing you from using upstream LiteX).

@enjoy-digital
Copy link
Owner

As described in my previous comment, it should be fixed. I'm closing this but feel free to re-open @tcal-x if it's not the case.

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

No branches or pull requests

2 participants