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

register_rom weirdness #96

Open
keesj opened this issue Jan 29, 2019 · 2 comments
Open

register_rom weirdness #96

keesj opened this issue Jan 29, 2019 · 2 comments

Comments

@keesj
Copy link

keesj commented Jan 29, 2019

Hi,

I am trying to get the papilo pro build working and the first error I got was :

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/dus/projects/sdfsadfsd/migen/misoc/misoc/targets/papilio_pro.py", line 103, in <module>
    main()
  File "/home/dus/projects/sdfsadfsd/migen/misoc/misoc/targets/papilio_pro.py", line 97, in main
    soc = BaseSoC(**soc_sdram_argdict(args))
  File "/home/dus/projects/sdfsadfsd/migen/misoc/misoc/targets/papilio_pro.py", line 87, in __init__
    self.register_rom(self.spiflash.bus)
  File "/home/dus/projects/sdfsadfsd/migen/misoc/misoc/integration/soc_core.py", line 138, in register_rom
    assert self.cpu_reset_address < rom_size
AssertionError

The code in question looks like the following and really looks strange to me

    def register_rom(self, interface, rom_size=0xa000):
        self.add_wb_slave(self.mem_map["rom"], rom_size, interface)
        assert self.cpu_reset_address < rom_size
        self.add_memory_region("rom", self.cpu_reset_address,
                               rom_size-self.cpu_reset_address)

I can understand that the reset address needs to point to a valid part (and preferably the reset vectors of the CPU) but why does the address need to be smaller than the rom_size. should this code not read

assert cpu_reset_address >= mem_map["rom"]
and
assert cpu_reset_address < mem_map["rom"] + rom_size

the next strange thing is the next line. why is the memory region set to the start address of the cpu reset and not simply the mem_map["rom"] address. I am even more intrigued by the size of the region that is set to rom_size-self.cpu_reset_address.

To me it looks like the code only really will work if the reset_address is 0 (and this is often the case)

I have tried to create a patch that would do something more meaningful but I think I might be lacking some context.

The register_rom function (in my case) is called from https://github.com/m-labs/misoc/blob/master/misoc/targets/papilio_pro.py#L87 (to map the boot code to be flash I guess for being executed xip?).

@sbourdeauducq
Copy link
Member

assert cpu_reset_address >= mem_map["rom"]
and
assert cpu_reset_address < mem_map["rom"] + rom_size

Should be mem_map["rom"] <= cpu_reset_address < mem_map["rom"] + rom size.

why is the memory region set to the start address of the cpu reset

So the linker knows where the startup code begins.

@keesj
Copy link
Author

keesj commented Feb 5, 2019

I updated the pull request to fix the above issues and allow booting from spi flash.

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