Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

ROM initialisation

Altera_Forum
Honored Contributor II
1,499 Views

Hello, 

 

I created a SOPC-builder module with an on-chip ROM component. 

This ROM should be instantiated with the content of on_chip_rom.hex, that is in the Quartus directory and contains just 0s. 

 

I want another content and wrote the following lines in my c-file (totally 512 bytes): 

 

static const unsigned int cardbus_content[] __attribute__ ((section (".on_chip_rom"))) 

= {0x12345678, 0x87654321, 0x22222222, 0x33333333, 0xf70000ff, 0xffffccff, ...}; 

 

The IDE is also rewriting the on_chip_rom.hex file 8as expected) during compilation but with 0's and not my values. 

 

The section in the .objdump file looks like this: 

8 .on_chip_rom 00000000 00801600 00801600 0000ef58 2**0 

CONTENTS 

 

Where is my mistake? 

How do I initialize memories with the IDE? 

 

Best Regards, 

 

damc 

 

P.S. Simply creating the .hex file as it was possible with Nios1 isn't possible anymore, because the IDE is overwriting this file with 0's on every compilation.
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
750 Views

You have to make sure the boot address in SOPC builder is that specific onchip memory. That hex file is probably wiped clean on purpose (since you are not targetting it, the compiler gives you a clean slate). 

 

In the system library select that onchip memory, compile your software, then compile your hardware in quartus. Another thing to keep in mind is depending on the memory you selected (512, M4k, MRAM) you may have different options available (or lack of options). If my memory is correct, to have pre-populated onchip RAM you can't use MRAM (but I think it's ok with onchip ROM in MRAM but don't quote me on that one). If that's an issue for you take a look at the Tri memory document up on the Altera site.
0 Kudos
Altera_Forum
Honored Contributor II
750 Views

I don't want to boot out of this memory. 

It contains static stuff like a serial number, version number and such things and should be only read out by the Nios on demand of the user. 

Therefore I tried the construct above but it seems not to work.
0 Kudos
Altera_Forum
Honored Contributor II
750 Views

Hi damc, 

 

> The section in the .objdump file looks like this: 

> 8 .on_chip_rom 00000000 00801600 00801600 0000ef58 2**0 

> CONTENTS 

 

This indicates that section .on_chip_rom has a length of zero. Better 

check your linker command file.  

 

If you don't reference cardbus_content anywhere in your code, the 

linker might be tossing it into the bit bucket ... so you'll need to either 

wrap a KEEP around your .on_chip_rom input section(s) ... or add some 

dummy code that references cardbus_content. 

 

By default, I don't believe the linker command file in the syslib wraps 

on-chip memory input sections with a KEEP. 

 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
750 Views

Hi damc, 

 

my design uses intern ROM to store a 'parking code' while system RAM is overwritten. I also set up an array with __attribute__((.section)). But if you never use this code or data in another module, it is optimized away and preset with zeros. Make a dummy call in any module to this section or anything else that signals the compiler: this data is used. 

After your hex-file is created, you must compile your cpu with SOPC builder to implement this data in your design. 

 

Mike 

 

edit: (... same tip at same time)
0 Kudos
Altera_Forum
Honored Contributor II
750 Views

Sorry notice that you wanted just a ROM out of it. In the past I would just set up my own hex file and drop that into the hardware folder. The only problem with doing that is it will get overwritten by the IDE. The previous two tips sound like a good solution and probably your best option.

0 Kudos
Altera_Forum
Honored Contributor II
750 Views

Hi smcnutt, MiR, 

 

you have had right, after I inserted a dummy call to that array the on_chip_rom.hex file is now filled with the correct data. 

Thank you very much!!!! 

 

 

Hi BadOmen, 

 

yes in the past everything was much easier and more simple .... 

 

 

Thanks again, 

 

damc
0 Kudos
Altera_Forum
Honored Contributor II
750 Views

Haha, I don't know if what I used to do was more simple (I would create my mif file in Excel and have to do weird character delimiting a pray they were properly formatted). 

 

Good to hear the other solutions worked
0 Kudos
Reply