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++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Uncompressing Linux...ERROR

Altera_Forum
Honored Contributor II
1,443 Views

Dear all, 

 

I meet a weird problem on building image. 

 

The source I use is uClinux-dist-20060803 with patch v18. 

 

There are also some custom applications added into the image. 

 

All compiles are done without any error and the image can be generated successfully. 

 

When I download the generated image into target board, some generated images will cause problems. The error message is below: 

 

Uncompressing Linux... 

ERROR 

length error 

 

-- System halted 

 

Here are the stpes I build the image: 

 

make clean 

make vendor_hwselect SYSPTF=~/project/ptf/nios2.ptf 

make romfs 

make 

make 

make linux image 

 

When the problem occurs, I do the above steps again and again without any code modification. Sometimes I can get a workable image(it can enter shell mode and execute all applications on the initramfs). 

 

It is really really weird. Use same sources/configurations, but get different results. Although I can get the good image finally, but it does spends me lots of time on development. 

 

Is there anyone can explain me what's going on ?...
0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
552 Views
0 Kudos
Altera_Forum
Honored Contributor II
552 Views

removed.

0 Kudos
Altera_Forum
Honored Contributor II
552 Views

removed.

0 Kudos
Altera_Forum
Honored Contributor II
552 Views

Hi, 

 

I had the same problem when I tried to upload my image to the board. 

It worked with the nios2download program, but it did not work sometimes with my own bootloader. 

My bootloader loads the image from a serial flash into DDR by using a small program in a Mk4 block of the FPGA. 

The problem turned out to be byte alignment. 

Sometimes the zImage was even length then it worked, but when it was odd length it didn't. 

To solve the problem I added 1 byte to the binary to make it even length, then it always worked. 

Mybe your problem is similar to mine. 

Note: I converted the elf format to binary to store it in my serial flash.
0 Kudos
Altera_Forum
Honored Contributor II
552 Views

you are right, nacide. 

 

although my problem happens with nios2-download program, 

 

it is also the byte alignment issue. 

 

after tracing the booting process, 

 

i found that if the size of generated vmlinux.bin.gz (in linux-2.6.x/arch/nios2nommu/boot/compressed/) is odd, 

 

i will get "length error" during uncompressing kernel. 

 

it is because that in function gunzip (linux-2.6.x/lib/inflate.c), 

 

it always gets wrong length value when size of vmlinux.bin.gz is odd. 

 

orig_crc[23:00] is correct, but orig_crc[31:24](the last byte we get) is wrong. 

 

the length value in zImage is correct, but it gets wrong value during uncompressing. 

 

what i did is trying to add some spaces at the end of .data section in linux-2.6.x/arch/nios2nommu/boot/compressed/vmlinux.scr in order to make sure that we can get correct orig_crc[31:24] byte without byte alignment issue. 

 

SECTIONS {   .data : {      input_len = .;      LONG(input_data_end - input_data) input_data = .;      *(.data)      input_data_end = .;      LONG(0) /* for byte alignment issue */   } } 

 

now i can always get the workable image after that patch. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/cool.gif  

 

here are steps i do to generate image. 

 

1. make clean vendor_hwselect SYSPTF=~/project/ptf/nios2.ptf 

2. make romfs 

3. make 

4. make linux image
0 Kudos
Altera_Forum
Honored Contributor II
552 Views

Great. I updated the nios2 patches to ver 21. Please check if it works for odd size gz. 

 

SECTIONS {  .data : {     input_len = .;     LONG(input_data_end - input_data) input_data = .;     *(.data)     . = ALIGN(4);     input_data_end = .;     } }
0 Kudos
Altera_Forum
Honored Contributor II
552 Views

yes, it works. 

 

thanks for your nios2 patch, hippo. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/biggrin.gif
0 Kudos
Reply