UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
9,781 Views
Registered: ‎04-20-2009

How to get ELF and MEM file data to different portions of the same BlockRAM?

Jump to solution

Hi all!

Once again, a stupid question: I have a MicroBlaze project where the first stage boot loader is to reside in a 64k BlockRAM at address 0x0000_0000 – 0x0000_FFFF. This gets into the .bit-file by including the .elf file from the boot loader SW project in the bitgen command. This works fine.

 

Question is, can I then add a few bytes of data to the upper few addresses of the same BlockRAM using data2mem and a .mem-file without corrupting the boot loader? I tried this but by looking at the .bit files before and after data2mem, it seems there are far too many differences considering that my .mem file only contains something like this:

 

    @FFFC 0000007B

 

…and thus only should alter a single byte in the .bit file.

 

Is there a better way to do this? As you might expect, the extra few bytes are to hold a build version for the FPGA so that the version can be checked by the SW. Many have devised ways to get build version information into the FPGA, this way seemed like a good idea at the time, but now I am beginning to wonder… I am not versed enough I scripting to try to patch in the data in the existing .elf file, even though this might be an option.

 

BTW, is there a way to extract the BlockRAM data from the .bit-file to a .mem file? My naïve approach would be “data2mem –bm design_bd.bmm -bt design.bit -bx .\”, but that produces no output. If I could do that, I could compare the .mem files for the entire BlockRAM before and after data2mem and convince myself that I had done what I hoped. If not, I will have to pester the SW guys to test it for me.

 

Cheers!

/Lars

 

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Adventurer
Adventurer
17,325 Views
Registered: ‎04-20-2009

Re: How to get ELF and MEM file data to different portions of the same BlockRAM?

Jump to solution

Hi all!

I think I have cracked it. It's really simple once you figure it out:

 

Use data2mem to dump the .elf file as a .mem file: "data2mem -bd <file>.elf -d -o m <file>.mem"

 

Add the desired information as a new record at the end of <file>.mem using the existing records as a template. In my case the .mem file contained three records, so I just added a fourth that filled a non-used memory segment at the end of the RAM with arbitrary data.

 

Use the resulting .mem file in bitgen (or data2mem).

 

Now I just have to figure out how to script these operations, but that should be a SMOP (Simple Matter Of Programming).

 

Cheers!

/Lars

 

0 Kudos
4 Replies
Adventurer
Adventurer
9,758 Views
Registered: ‎04-20-2009

Re: How to get ELF and MEM file data to different portions of the same BlockRAM?

Jump to solution

Hi again!

I think I can confirm that data2mem will in fact fill the entire RAM described in the .bmm file with data, regardless of how much data is present in the .mem or .elf file. It seems non-specified addresses are filled with zeros. I verified this in three steps:

 

- Generate a bootable .bit file with the "-bd <elf file>" option

- Run data2mem with the "-bd <mem file>" option

- Run data2mem again, this time with the "-bd <elf file>" option

 

Comparing the three .bit files in ASCII form after running "data2mem -bm <bmm file> -bt <bit file> -d > <ASCII dump file>" on the different bit files reveal the first and last to be identical as far as BRAM content is concerned, whereas the one in the middle differs with largely zeros in the BRAMs in question.

 

So that leaves me high and dry. I can either have the boot code or the version number in the RAM but not both. Any other ideas as to how to patch a small amount of data into a portion of a BRAM?

 

Cheers!

/Lars

 

0 Kudos
Scholar stephenm
Scholar
9,726 Views
Registered: ‎05-06-2012

Re: How to get ELF and MEM file data to different portions of the same BlockRAM?

Jump to solution
Can you try changing the ADDRESS_SPACE in the BMM file to the location that you want to write to. This might prevent the memory being set to 0


0 Kudos
Adventurer
Adventurer
9,717 Views
Registered: ‎04-20-2009

Re: How to get ELF and MEM file data to different portions of the same BlockRAM?

Jump to solution

Hi Stephen!

Sorry, that doesn't seem to work. My 64 kByte BRAM is organized as 32 instances of 16k by 1 bit BlockRAM and that makes it hard to stich it any other way than as a contiguous unit. Just changing the ADDRESS_SPACE from [0x00000000:0x0000FFFF] to [0x0000F000:0x0000FFFF] produces the following:

 

ERROR:Data2MEM:29 - Inconsistent address space size in ADDRESS_SPACE 'microblaze_0.microblaze_0_bram_block_combined'.   ADDRESS_SPACE was defined as 0x00001000 bytes, but the ADDRESS_RANGE total is 0x00010000 bytes.

 

A work-around would be to add a second lmb_bram_if_cntrl and a separate bram_block just for the version information. That seems to work as I have verified that updating one of the now separate ADDRESS_SPACE units in the .bmm file does not corrupt the other, but that would consume more resources and even though we might be able to afford it at this stage in the project, things may change later on as the performance demands might increase…

 

Also, to organize the existing memory as e.g. 32 instances of 512 words by 32 bits or 1024 words by 16 bits (to possibly be able to describe them as separate ADDRESS_SPACEs) would result in a large MUX on the read data path, severely limiting the performance of the entire MicroBlaze system. That we definitely can’t afford!

 

Thanks anyway! Any other ideas?

/Lars

0 Kudos
Highlighted
Adventurer
Adventurer
17,326 Views
Registered: ‎04-20-2009

Re: How to get ELF and MEM file data to different portions of the same BlockRAM?

Jump to solution

Hi all!

I think I have cracked it. It's really simple once you figure it out:

 

Use data2mem to dump the .elf file as a .mem file: "data2mem -bd <file>.elf -d -o m <file>.mem"

 

Add the desired information as a new record at the end of <file>.mem using the existing records as a template. In my case the .mem file contained three records, so I just added a fourth that filled a non-used memory segment at the end of the RAM with arbitrary data.

 

Use the resulting .mem file in bitgen (or data2mem).

 

Now I just have to figure out how to script these operations, but that should be a SMOP (Simple Matter Of Programming).

 

Cheers!

/Lars

 

0 Kudos