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

Boot failures when zImage size goes a little over 3MB?

Altera_Forum
Honored Contributor II
1,156 Views

Has anyone else seen an issue like this? 

 

A zImage that's 3.0MB (4.6MB uncompressed), the kernel boots without fault. The vmlinux image, when stored as a u-boot uImage also boots. 

 

When I try to nios2-download a zImage that's 3.2MB (4.9MB uncompressed), the kernel fails to boot in random ways, depending on the size of the kernel. In one case, it was an assert(mm == &init_mm). Another case, it was infinitely looping in the initramfs decompression code. In other cases, the debugger can't generate a backtrace. The size difference is the difference between turning on/off in-kernel UBI support. The failure also happens when I try to boot the kernel as a u-boot uImage also. 

 

I've tried all of the different compression options for initramfs and uImage, with no change in functionality. 

My target system has 16MB of RAM and normally shows plenty of room free: 

/> free 

MemTotal: 13560 kB 

... 

 

Thanks, 

--Steve 

0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
381 Views

Hi Steve, 

 

did you try to increase the parameter 'Link address offset for booting'? 

 

This is from the old NiosWiki: 

 

<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>If your kernel image is large, you will need to change this config. 

 

Processor type and features-->(0x00500000) Link address offset for booting. 

The zImage load address is ( your sdram base address + link address 

offset ). The boot loader will uncompress the code to the beginning of 

sdram. If the uncompressed code is bigger than the default 5M, the two 

area will overlap and corrupt. The compressed image offset should be 

adjusted to a higher value when the kernel image is big, eg, large 

files in romfs dir. You can change this value to about 2/3 of the size 

of your sdram, eg, 20M out fo 32M. I suggest 2/3 because the gzip 

compression ratio is about 1:2. The zImage boot loader does not 

relocate/move itself. 

</div> 

 

We had to increase it to: 

kernel configuration --> Processor type and features ---> (0x01300000) Link address offset for booting  

 

Good luck, 

 

Ricardo.
0 Kudos
Altera_Forum
Honored Contributor II
381 Views

<div class='quotetop'>QUOTE (jasinski @ Jul 10 2009, 04:42 PM) <{post_snapback}> (index.php?act=findpost&pid=23070)</div> 

--- Quote Start ---  

Hi Steve, 

 

did you try to increase the parameter &#39;Link address offset for booting&#39;?[/b] 

--- Quote End ---  

 

 

I haven&#39;t tried that yet. Thanks for the info!
0 Kudos
Altera_Forum
Honored Contributor II
381 Views

Finally, back to this issue... 

 

When I change the link address offset for booting to 0x00800000, zImage still wont load. 

Also, the corresponding linux-2.6.x/vmlinux image wont load from gdb/insight nor when wrapped in a uImage for u-boot. 

 

It&#39;s consistently hitting the BUG(mm == &init_mm); line in linux-2.6/kernel/fork.c:__mmdrop. 

 

In this example, it&#39;s the initramfs being bigger that&#39;s preventing bootup (but turning on UBI and other kernel features causes it as well): 

 

Will load: 

vmlinux: 26028261 

zImage: 3016537 

System.map:__initramfs_start: 0x052919b8 

System.map:_end: 0x05454575 

 

Wont load:  

vmlinux: 26115445 

zImage: 3117081 

System.map:__initramfs_start: 0x052919b8 

System.map:_end: 0x0546cf75 

 

Any other ideas? For PowerPC, they suggested increasing the initial memory map size. I haven&#39;t figured out the nios2 equivalent yet.
0 Kudos
Altera_Forum
Honored Contributor II
381 Views

I&#39;m not sure why this fixes the problem, but this does indeed result in a bootable kernel, even when I built a zImage that came out to 4.7MB. 

Could someone pass the info on to the nios2-dev list? 

 

Thanks, 

--Steve 

 

 

diff --git a/arch/nios2/kernel/vmlinux.lds.S b/arch/nios2/kernel/vmlinux.lds.S 

--- a/arch/nios2/kernel/vmlinux.lds.S 

+++ b/arch/nios2/kernel/vmlinux.lds.S 

@@ -112,6 +112,7 @@ SECTIONS 

__con_initcall_end = .; 

SECURITY_INIT 

+ . = ALIGN(PAGE_SIZE); 

.init.ramfs : 

. = ALIGN(4); 

@@ -119,6 +120,7 @@ SECTIONS 

*(.init.ramfs) 

__initramfs_end = .; 

+ . = ALIGN(PAGE_SIZE); 

__init_end = .; 

_end = . ;
0 Kudos
Altera_Forum
Honored Contributor II
381 Views

Please try this patch instead. And let me know if it fix your problem. 

 

Cheer, 

Hippo 

 

diff --git a/arch/nios2/kernel/vmlinux.lds.S b/arch/nios2/kernel/vmlinux.lds.S index a169ed6..13f289a 100644 --- a/arch/nios2/kernel/vmlinux.lds.S +++ b/arch/nios2/kernel/vmlinux.lds.S @@ -117,6 +117,7 @@ SECTIONS         . = ALIGN(4);         __initramfs_start = .;         *(.init.ramfs) +        . = ALIGN(4);         __initramfs_end = .;     }        __init_end = .;
0 Kudos
Altera_Forum
Honored Contributor II
381 Views

Hi Hippo, 

 

I tried your patch. A 3.0MB and 3.5MB kernel loads, so the patch is good for my purposes. 

 

Thanks, 

--Steve 

0 Kudos
Altera_Forum
Honored Contributor II
381 Views

<div class='quotetop'>QUOTE (pandemic @ Aug 8 2009, 01:08 AM) <{post_snapback}> (index.php?act=findpost&pid=23454)</div> 

--- Quote Start ---  

Hi Hippo, 

 

I tried your patch. A 3.0MB and 3.5MB kernel loads, so the patch is good for my purposes. 

 

Thanks, 

--Steve[/b] 

--- Quote End ---  

 

 

Thanks,Steve. 

 

I will apply this patch when the sopc server is back on Monday. 

 

- Hippo
0 Kudos
Reply