MICROBLAZE: Using external instruction memory

Hi all,

I'm trying to design a Microblaze system which uses an external SRAM as instruction memory. I'm using the V2MB1000 board from Insight Memec with P160 Communication module.

The SRAM is conected to Microblaze through an external memory controller conected to the Instruction side OPB bus. The thing is that I don't know how to save my "executable.elf" file to the external SRAM. I've seen other microprocessors that firstly they copy the program from flash or another Read Only storage device to a faster memory, such as SRAM. They use a boot program, stored in FLASH, to do this.

But in my system I don't know neither how to save it to the FLASH because my program is too large and it can't be stored in the Block RAMs.

I'll very grateful if someone could help me.

Thanks a lot.

Arkaitz.

Reply to
Arkaitz
Loading thread data ...

Hi Arkaitz,

You can always download the executable to the external memory from the host using the xmd tool.

Göran

Arkaitz wrote:

Reply to
Goran Bilski

you create a small flash loader that you use to program your flash, then you run your programs from flash. optionally you may copy to sram but it in your case I think it doesnt make sense.

the flash loader is not a problem, but for programs that are then executed from flash you need to use custom linker script and optionally copy some segments to sram, also you should use sram for stack and heap, as the blockrams get low for that too.

if you have not done that before it will take you approx 2 weeks to get fully it runnging and set up.

antti

Reply to
Antti Lukats

Hi Antti,

I've done a flash loader but I don't know which file do I have to store in flash in order to enable to execute it.

I've proved storing the "executable.elf" file which contains the crt0.o initialization code linked and then I jump to that address from a program stored in the Block RAMS, but as I supposed it doesn't work.

So may be I'm wrong but what I have in mind is to have a program stored in flash and then store a simple program in the Block RAMs where there is only a branch to the flash base address.

What do you think about this and how would it be done?

Thanks a lot,

Arkaitz.

Reply to
arkaitz

you must use mb-objdump utility to convert the elf file into an executable binary image. elf files themselves cannot be directly executed, they must be loaded, have the relocations resolved, etc etc. You want something like:

mb-objcopy -O binary --remove-section=.stab --remove-section=.stabstr executable.elf executable.bin

The --remove-section options are specifying not to copy debug string information into the final binary.

Then, once you have your executable.bin file - that is the code you want to place into flash, prior to being copied into RAM for execution.

This is how kernel images for microblaze uClinux (and most other uClinux ports) are done.

Regards,

John

Reply to
John Williams

^^^^^^^^^

oops I meant objcopy of course!

Reply to
John Williams

Thanks John,

Now, where can I find some information related to the "elf" extension file? If I'm not wrong it's used in Linux, isn't it?

Just another question: I've been looking to the MicroBlaze's manual but I haven't found anything about "mb-objcopy". Is it in the manual?

Thanks again for your help.

Arkaitz.

Reply to
arkaitz

Yes - it's the standard object file format used by Gnu-based compilers (GCC)

No - it's just part of the gnu tools distributed in EDK. Get a login on a linux box and do "man objcopy" - mb-objcopy is just the cross-platform version. mb-objcopy --help will probably tell you something too.

formatting link
has an excellent documentation section - lots and lots of details about the linkers and compilers and so on - since mb-gcc and friends are direct descendants, 99.99% of that info is still highly relevant and useful.

Regards,

John

Reply to
John Williams

Thanks a lot.

But, I don't understand how can I execute an "elf" file that affects only to the internal registers of MicroBlaze enabling the timer, interrupts, etc. but when I create a "hello world" program which contains only a "print" code-line it doesn't work.

Have you done a flash programmer. How have done it? Via XMD or Serial?

Thanks aga> > Thanks John,

Reply to
arkaitz

don't forget you need to link your executable in "executable" mode, not xmdstub.

then, once you run make (or generate from the xps), in the directory /microblaze0/code will be a file executable.elf - that's the one you run objcopy over.

i started with xmd-based routines (they are still up on my website somewhere, i think under downloads), but now that uclinux is pretty much done, and i have network support i copy new images directly over the network into the flash, just using standard linux tools (NFS mounting, dd, MTD flash drivers and so on). For small systems this might not me an option.

formatting link

Regards,

John

--
Dr John Williams, Research Fellow,
Reconfigurable Computing, School of ITEE
University of Queensland, Brisbane, Australia
Ph : (07) 3365 8305
Reply to
John Williams

re-reading your messages, it occurs to me - are you hoping to execute the code directly from the flash? In that case, you will need a custom link script, because otherwise your data segment (read/write) will also be located in the flash address space, and of course that won't work at all!

In my applications I simply use the flash as somewhere to store the image when the power is off - at bootup I copy the image from flash, down into RAM to the address at which it was originally linked, then jump to it. You will need to modify this sequence somewhat...

Regards,

John

Reply to
John Williams

Hi John,

My first idea was to execute it directly from flash memory, but now I will first try copying to it SRAM before I execute it.

I will use an specific linker script later to execute it directly.

I have resolved the problem. Was that I was creating the elf file in XMDSTUB mode instead of EXECUTABLE mode.

Thanks a lot for your time.

Arkaitz.

Reply to
arkaitz

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.