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

Linux - a question about linux fs in flash

Altera_Forum
Honored Contributor II
1,240 Views

Hello, does anyone know if the Microtronix ROMfs is cached in RAM upon bootup? I mean does the fs take up the same amount of RAM as it occupies in flash? 

 

I have a custom board with a 2MB flash (but im only "allowed" to use 1MB) and a 2MB SDRAM-chip. When I bootup my kernel Linux says that the kernel takes up about 813KB: 

 

Memory available: 1048k/512k RAM, 0k/0k ROM (813k kernel code, 122k data) 

 

But when linux later on is running the init-routine I get an out-of memory error: 

 

... Free pages:         132kB (0kB HighMem) Active:0 inactive:12 dirty:0 writeback:0 unstable:0 free:33 slab:197 mapped:0 pagetables:0 DMA free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB Normal free:132kB min:128kB low:256kB high:384kB active:0kB inactive:48kB present:2048kB HighMem free:0kB min:128kB low:256kB high:384kB active:0kB inactive:0kB present:0kB DMA: empty Normal: 1*4kB 2*8kB 3*16kB 0*32kB 1*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 132kB HighMem: empty Unable to allocate RAM for process text/data, errno 12 /bin/expand: program too big DMA per-cpu: empty Normal per-cpu: cpu 0 hot: low 2, high 6, batch 1 cpu 0 cold: low 0, high 2, batch 1 HighMem per-cpu: empty Free pages:         128kB (0kB HighMem) Active:7 inactive:0 dirty:0 writeback:0 unstable:0 free:32 slab:198 mapped:0 pagetables:0 DMA free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB Normal free:128kB min:128kB low:256kB high:384kB active:28kB inactive:0kB present:2048kB HighMem free:0kB min:128kB low:256kB high:384kB active:0kB inactive:0kB present:0kB DMA: empty Normal: 0*4kB 2*8kB 3*16kB 0*32kB 1*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 128kB HighMem: empty Kernel panic: Out of memory and no killable processes... 

 

Because if the fs isn't cached in RAM - then what is eating up all my RAM - I mean I have 2MB and the kernel only occupies 813KB? 

 

Next question: If the fs take up the same amount of RAM as the fs occupies in flash......is there then a way to disable this? I mean rather a system that are running slow than a system that aren't running at all ;-) 

 

Hope you guys can help me with this one! 

 

Regards 

 

Goon
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
546 Views

Hi Goon, 

 

It is the kernel, not romfs, that eating up your memory. The 813K + 122K is the static size of your kernel (code + data + bss). But the kernel dynamically allocates a lot of stuff during the booting, thus eating up your remaining 1M RAM.  

 

Regards,
0 Kudos
Altera_Forum
Honored Contributor II
547 Views

Hi Goon, 

 

I noticed that your screen output showing the total memory: 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

Memory available: 1048k/512k RAM, 0k/0k ROM (813k kernel code, 122k data)[/b] 

--- Quote End ---  

 

 

was not correct. It should be, 

Memory available: 1048k/2048k RAM, 0k/0k ROM (813k kernel code, 122k data) 

 

There is no harm from this bug, since it is only for printing out on the console. But if you want to fix it, you can go to modify the file linux/arch-nios2nommu/mm/init.c. Change the code: 

void mem_init(void) { ...     extern unsigned int _ramend, _rambase; ... 

 

to: 

void mem_init(void) { ...     extern unsigned char _ramend, _rambase; ... 

 

Regards,
0 Kudos
Reply