2024-10-16 07:47 PM
Sorry for my 3rd XIP post on this board, but the more I learn about this process, the more questions I have.
Going through the XIP template code, I think I have a decent understanding of what it does.
1. Set up the XSPI Peripherals, one NOR Flash and one SDRAM
2. Prepare both peripherals to be in memory mapped mode
3. Set both peripherals to be memory mapped.
4. Put the Program Counter at the start of NOR Flash, and start the application code from there.
What I thought I would see in this template, is the bootloader writing instructions to the SDRAM from the NOR flash, and setting the program counter at the start of SDRAM, instead of NOR Flash.
Is the SDRAM even getting used?
It seems quite important to the process, but even in the disassembly, all the addresses we're executing instructions from are in the 0x7000 0000 range, which is all NOR Flash.
I'd really like to be able to do random writes to the external SDRAM. But I also really don't want to go overwriting my program where it's getting executed from.
Thanks,
-Hal
2024-10-18 05:21 PM
XIP means execute in place. If code is copied from somewhere to RAM before execution - it is not "execute in place".
> Is the SDRAM even getting used?
Of course, as data (R/W) memory.
2024-10-19 09:15 AM
Nice to see you again Pavel, thanks for de-mystifying the process a bit.
So, I guess the follow up questions would be:
- Is there a way to block off certain areas of SDRAM in the bootloader or application to not be used by XIP? It seems like there is some space in the SDRAM that needs to be usable for the bootloader to operate as expected. I'm wondering if I can just upsize the chip, and have a dedicated section for the data structure I need for this project. Maybe the MPU is good for this?
- In the bootloader, it seems like every time I boot, the entire external SDRAM is filled with data, and the same hex values are in the same locations every time. Even when over written, it goes back to the same values stored in it, right when you enable external Memory Mapped mode in the MCU. I'm really confused about where this data is coming from, since I wouldn't think that the system would just start allocating it before it was memory mapped. And there's no where in the template that seems to be doing explicit data writes to the SDRAM, only sending data in instruction mode. Why does it get filled up with data every restart, and the same data every time?
I basically just need to make sure that I'm not over-writing somewhere I shouldn't be.
I could go through the bootloader and application to make sure that every allocation has an address that isn't external SDRAM, but I'm still a little concerned that something could be going on under the hood that I don't fully understand.
Thanks for the help!
-Hal