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++
12603 Discussions

Nios won't boot uCLinux with data cache greater than 8k

Altera_Forum
Honored Contributor II
989 Views

We are running uCLinux (non-mmu community version)on a NIOS II SOPC 11.0 system, on our own hardware, Booting from EPCS copying the operating system and application code from EPCS to the external SDRAM. Once copied the system then runs from SDRAM. 

 

In a bid to speed up the Ethernet operation we have experimented increasing the size of the instruction and data caches in the NIOS. This has given us massive improvements with each increase in cache.  

 

We now have the instruction cache set to 64K and have managed to increase the data cache to 8K.  

 

The problem is. If we try and increase the data cache beyond 8K the system will not boot. 

 

Please does anyone have any ideas on things to try?  

Thanks
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
300 Views

I have the same problem... 

Can an Guru help us ? 

 

Thanks
0 Kudos
Altera_Forum
Honored Contributor II
300 Views

I once heard that for some queer write-back reason greater (data) cache size is not supported. Maybe you can find the appropriate thread here or in the NIOS-develop mailing list, or maybe in an Altera hardware forum. 

 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
300 Views

Watch out for the reply from our Ian Abbott, He has found the problem

0 Kudos
Altera_Forum
Honored Contributor II
300 Views

I think I've found the solution. In arch/nios2/mm/memory.c, change the icache_push function to flush the data cache before invalidating the instruction cache. This can be done by inserting the line: cache_invalidate_data(vaddr, len); so the whole function is as follows: 

 

void icache_push(unsigned long vaddr, int len) { cache_invalidate_data(vaddr, len); cache_invalidate_inst(vaddr, len); }  

 

(Note that cache_invalidate_data() is a bit of a misnomer as it actually writes dirty cache lines to memory before invalidating them. Also, I'm using the 'test-nios2' branch of Thomas Chou's git repository.) 

 

The reason this is needed is that load_flat_file() in fs/binfmt_flat.c (which is responsible for loading executables in FLAT or ZFLAT format) calls flush_icache_range() after loading the executable into memory. The NiosII implementation of flush_icache_range() in include/asm-nios2/cacheflush.h) just calls the icache_push() function described above. However, with the old version of icache_push() there may still be dirty data cache lines that have not yet been written to memory. If the CPU reads instructions from these memory addresses before the data cache lines have been flushed, it will be reading invalid (stale) instructions. 

 

flush_icache_range() is also called when loading kernel modules. 

 

Presumably with an 8K or less data cache it's only been working by chance so far!
0 Kudos
Reply