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

Minimal MMU linux hangs on DE1 board

Altera_Forum
Honored Contributor II
1,947 Views

Hi all, when trying to build my first MMU linux on a DE1 board system hangs just after nios2-terminal with: 

 

 

nios2-terminal: connected to hardware target using JTAG UART on cable 

nios2-terminal: "USB-Blaster [USB 6-1.1]", device 1, instance 0 

nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate) 

 

Linux version 2.6.34-00692-g5bc7853-dirty (root@mcesarpc4114c.sec.upm.es) (gcc version 4.1.2)# 62 Wed Jun 23 19:31:26 CEST 2010 

bootconsole [early0] enabled 

 

 

and that's all. The system is a bare minimum one comprising only: 

  • linux_cpu (JTAG_debug at 0x07ff_f800) 

  • linux_timer_1ms (0x0840_0000, IRQ 11) 

  • fast_tlb_miss_ram_1k (0x07ff_f400, both slaves) 

  • cfi_flash (thru tsb_cpu_cfi, 0x0000_0000, 4MB) 

  • sdram (0x1000_0000, 8MB) 

  • jtag_uart (0x0840_0020, IRQ 1)
all working at 100 MHz, except for the sdram running at 50 (this is the CII_Starter_SD_Card_Audio DE1 example without SRAM, LEDs & PIOs). I've followed steps reported in the wiki, used the sopc-create-header-files script, disabled GPIO, DMA, LEDs with make menuconfig, ... 

 

Can anybody help me? 

 

Thanks & regards.
0 Kudos
23 Replies
Altera_Forum
Honored Contributor II
867 Views

S O L V E D 

 

I've changed cache sizes downto 4 kB and now takes longer to hang 

 

B U T 

 

still hangs after: 

 

nios2-terminal: connected to hardware target using JTAG UART on cable 

nios2-terminal: "USB-Blaster [USB 6-1.1]", device 1, instance 0 

nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate) 

Linux version 2.6.34-00692-g5bc7853-dirty (root@mcesarpc4114c.secLinux version 2.6.34-00692-g5bc7853-dirty (root at mcesarpc4114c.sec.upm.es) (gcc version 4.1.2)# 100 Thu Jun 24 19:01:16 CEST 2010 

bootconsole [early0] enabled 

early_console initialized at 0xe8400020 

 

Linux/Nios II-MMU 

init_bootmem_node(?,0x10421, 0x10000, 0x10800) 

free_bootmem(0x10421000, 0x3df000) 

reserve_bootmem(0x10421000, 0x100) 

Built 1 zonelists in Zone order, mobility grouping off. Total pages: 2032 

Kernel command line:  

PID hash table entries: 32 (order: -5, 128 bytes) 

Dentry cache hash table entries: 1024 (order: 0, 4096 bytes) 

Inode-cache hash table entries: 1024 (order: 0, 4096 bytes) 

We have 67584 pages of RAM 

Memory available: 3876k/4224k RAM, 0k/0k ROM (1175k kernel code, 3048k data) 

Hierarchical RCU implementation. 

NR_IRQS:32 

Calibrating delay loop... 5.72 BogoMIPS (lpj=28608) 

Mount-cache hash table entries: 512 

init_BSP(): registering device resources 

bio: create slab <bio-0> at 0 

Switching to clocksource timer 

 

 

 

Says 0k/0k ROM as I have removed the CFI flash for now. 

 

As before, any help will be wellcome.
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Well, after adjusting SDRAM's timing & PLL I found that the problem is not enough memory. Eight MB seems to little for even a bare minimum MMU linux to work. I switched back to uClinux.

0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Please try turn on this config. It will reduce the shared lib size in the image. 

 

Blackfin build options &#9472;> 

 

[*] Cull unused ELF shared libraries 

 

- Hippo
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Thanks hippo. Using that option and trimming a lot more I finally managed to boot MMU with only 8 MB SDRAM. Unfortunately the system is almost unusable as, even with functionalities keep to a minimum, remains really short on RAM and apps sometimes fire oom-killer. 

 

 

[mcesar@mcesarpc4114c uClinux-dist]$ nios2-terminal 

nios2-terminal: connected to hardware target using JTAG UART on cable 

nios2-terminal: "USB-Blaster [USB 6-1.1]", device 1, instance 0 

nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate) 

Uncompressing Linux... Ok, booting the kernel. 

Linux version 2.6.34-00693-ga32ca88-dirty () (gcc version 4.1.2)# 300 PREEMPT Tue Jul 6 20:28:07 CEST 2010 

bootconsole [early0] enabled 

early_console initialized at 0xe1001420 

 

Linux/Nios II-MMU 

init_bootmem_node(?,0x101c9, 0x10000, 0x10800) 

free_bootmem(0x101c9000, 0x637000) 

reserve_bootmem(0x101c9000, 0x100) 

Built 1 zonelists in Zone order, mobility grouping off. Total pages: 2032 

Kernel command line: 

PID hash table entries: 32 (order: -5, 128 bytes) 

Dentry cache hash table entries: 1024 (order: 0, 4096 bytes) 

Inode-cache hash table entries: 1024 (order: 0, 4096 bytes) 

We have 67584 pages of RAM 

Memory available: 6276k/1825k RAM, 0k/0k ROM (904k kernel code, 920k data) 

NR_IRQS:32 

Calibrating delay loop... 49.35 BogoMIPS (lpj=246784) 

Mount-cache hash table entries: 512 

init_BSP(): registering device resources 

Switching to clocksource timer 

ttyJ0 at MMIO 0x1001420 (irq = 1) is a Altera JTAG UART 

console [ttyJ0] enabled, bootconsole disabled 

console [ttyJ0] enabled, bootconsole disabled 

Freeing unused kernel memory: 772k freed (0xd00e3000 - 0xd01a3000) 

devpts: called with bogus options 

ifconfig: socket: Function not implemented 

Welcome to 

____ _ _ 

/ __| ||_| 

_ _| | | | _ ____ _ _ _ _ 

| | | | | | || | _ \| | | |\ \/ / 

| |_| | |__| || | | | | |_| |/ \ 

| ___\____|_||_|_| |_|\____|\_/\_/ 

| | 

|_| 

For further information check: 

 

BusyBox v1.16.2 (2010-07-06 20:15:46 CEST) hush - the humble shell 

/# free 

total used free shared buffers 

Mem: 7048 2876 4172 0 0 

Swap: 0 0 0 

Total: 7048 2876 4172 

/#  

0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Maybe you can try root fs ext2/3 on sd card (mmc_spi), jffs2 on 4M cfi flash. 

 

- Hippo
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Or use nfs for most or all file systems for the development phase (seems to be recommended for easy development of user software, anyway), and when doing a PCB for the project design it with at least 16 MB (AFAIR the smallest DDR 2 is 32 MB, anyway). 

 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

 

--- Quote Start ---  

Unfortunately the system is almost unusable as, even with functionalities keep to a minimum, remains really short on RAM and apps sometimes fire oom-killer. 

--- Quote End ---  

 

The default uClinux-dist setup is a bit too aggressive with the oom-killer. You can adjust when it fires with settings in /proc/sys/vm. The init script (rc file) that came in the Altera vendor directory had this: 

# the default calculated values for these kernel controls are too small for # an embedded nommu system, so override them. For more info check out # - ./Documentation/sysctl/vm.txt # - ./Documentation/filesystems/proc.txt # echo 4096 > /proc/sys/vm/min_free_kbytes 

This isn't a nommu system, and making the value *bigger* for a small memory system doesn't make any sense to me. I've changed it to 

echo 1024 > /proc/sys/vm/min_free_kbytes 

to reduce the oom-killer needlessly firing. 1MiB is the minimum one should use for this value according to the kernel documentation.
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Thanks a lot ykozlov. Now it runs great! 

 

In any case I'm still trying to use the Flash memory to mount the filesystem there, but without success until now. What options in menuconfig must I enable? What are the /dev names for the Flash drive? 

 

Thanks a lot & regards.
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Well, finally managed to store filesystem in Flash, now I've much more free memory in my DE1 board. here it is: 

 

nios2-terminal: connected to hardware target using JTAG UART on cable 

nios2-terminal: "USB-Blaster [USB 6-1.1]", device 1, instance 0 

nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate) 

 

Linux version 2.6.34-00693-ga32ca88-dirty (mcesar@mcesarpc4114c.sec.upm.es) (gcc version 4.1.2)# 331 PREEMPT Tue Jul 13 20:28:55 CEST 2010 

 

 

Linux/Nios II-MMU 

init_bootmem_node(?,0x101bf, 0x10000, 0x10800) 

free_bootmem(0x101bf000, 0x641000) 

reserve_bootmem(0x101bf000, 0x100) 

Built 1 zonelists in Zone order, mobility grouping off. Total pages: 2032 

Kernel command line: root=/dev/mtdblock0 rootfstype=jffs2 ro 

PID hash table entries: 32 (order: -5, 128 bytes) 

Dentry cache hash table entries: 1024 (order: 0, 4096 bytes) 

Inode-cache hash table entries: 1024 (order: 0, 4096 bytes) 

We have 67584 pages of RAM 

Memory available: 6316k/1785k RAM, 0k/0k ROM (1402k kernel code, 382k data) 

NR_IRQS:32 

Calibrating delay loop... 49.15 BogoMIPS (lpj=245760) 

Mount-cache hash table entries: 512 

init_BSP(): registering device resources 

bio: create slab <bio-0> at 0 

Switching to clocksource timer 

JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc. 

JFS: nTxBlock = 49, nTxLock = 394 

io scheduler noop registered (default) 

ttyJ0 at MMIO 0x1801420 (irq = 1) is a Altera JTAG UART 

console [ttyJ0] enabled 

physmap platform flash device: 00400000 at 01400000 

physmap-flash.0: Found 1 x16 devices at 0x0 in 8-bit bank 

Amd/Fujitsu Extended Query Table at 0x0040 

number of CFI chips: 1 

cmdlinepart partition parsing not available 

RedBoot partition parsing not available 

Using physmap partition information 

Creating 2 MTD partitions on "physmap-flash.0": 

0x000000200000-0x000000400000 : "romfs/jffs2" 

0x000000000000-0x000000200000 : "loader/kernel" 

VFS: Mounted root (jffs2 filesystem) readonly on device 31:0. 

Freeing unused kernel memory: 44k freed (0xd0160000 - 0xd016a000) 

ifconfig: socket: Function not implemented 

Welcome to 

____ _ _ 

/ __| ||_|  

_ _| | | | _ ____ _ _ _ _  

| | | | | | || | _ \| | | |\ \/ / 

| |_| | |__| || | | | | |_| |/  

| ___\____|_||_|_| |_|\____|\_/\_/ 

| | 

|_| 

 

For further information check: 

http://www.uclinux.org/ 

 

 

 

BusyBox v1.16.2 (2010-07-12 20:38:43 CEST) hush - the humble shell 

Enter 'help' for a list of built-in commands. 

 

root:/> free 

total used free shared buffers 

Mem: 6360 3124 3236 0 0 

Swap: 0 0 0 

Total: 6360 3124 3236 

root:/> mount 

rootfs on / type rootfs (rw) 

/dev/root on / type jffs2 (ro,relatime) 

proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) 

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) 

devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,mode=600) 

var on /var type ramfs (rw,relatime) 

tmp on /tmp type tmpfs (rw,nosuid,nodev,relatime) 

root:/>  

0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Hi mcesar,  

 

I am using NEEK, however, my board hangs after few minutes, do you think the problem lies in insufficient memory? I am curious to know the following 

1. what things you store in Flash? 

2. what HW components do you have? and what are their settings? 

3. what kernel menuconfig do you do? 

4. what must I read to be able to do like you did? 

 

Thanks.
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Don't know if it is insufficient memory. It hangs but what error reports do you get? 

 

1.- I store in flash both OS Image and filesystem 

2.- See whole thread 

3.- modified DE2 

4.- The wiki (carefully)
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Hello, i am having similar problem. 

 

I've done everything Hippio said (Edit the RC file and the blackfin option), however my linux hangs after: 

Linux version 2.6.34-00692-g5bc7853-dirty (aprado@localhost.localdomain) (gcc version 4.1.2)# 37 Mon Nov 1 15:54:39 BRST 2010 bootconsole enabled early_console initialized at 0xe1801440 Linux/Nios II-MMU init_bootmem_node(?,0xce6, 0x800, 0x1000) free_bootmem(0xce6000, 0x31a000) reserve_bootmem(0xce6000, 0x100) 

 

(Before i saw this thread it was hangin on the first paragraph) 

 

I am using a DE2 , my design has a NIOS(f), onchipmemory, 8 MB SDRAM, JTAG UART, EPCS and a flash. Really simple. 

 

 

Any suggestions?
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

I can download rootfs.jffs2 to flash but don't know how to tell it kernel to use it. Pls help

0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Hi , 

 

We are also using the same method to bring up DE1 board with bare minimum MMU support on the uClinux. 

And tried compiling uclinux by taking a refrence board 3c120 and it gets compiled properly with our own mmu project. When i load the image on the board it gets hangs giving below error  

 

Uncompressing Linux... 

 

ERROR 

bad gzip magic numbers  

 

Please provide a solution to move further 

 

Thanks and regards 

Tejeshwar
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Now i am done with uncompressing. But before booting the kernel after uncompressing system hangs while flushing the data cache. Below is the assembly code being used to flush dcache. 

 

movia r1, NIOS2_DCACHE_SIZE 

movui r2, NIOS2_DCACHE_LINE_SIZE 

 

1: flushd 0(r1) 

sub r1, r1, r2 

call debug_print 

bgt r1, r0, 1b 

 

NIOS2_DCACHE_SIZE = 2k 

NIOS2_DCACHE_LINE_SIZE = 32 

 

I am not able to figure out . Please help. 

 

Thanks  

Tejeshwar
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Not sure you want a print call in that loop! 

I'd expect r2 to have the value 32 (line size) 

r0 initialised to some cache address. 

r1 initialised to r2 + cache size.
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

That print debug_print i have put it for debug purpose.  

 

 

This is the code which executes before starting the linux  

 

 

/* 

* linux/arch/nios2/boot/compressed/head.S 

* This code can be loaded anywhere, eg FLASH ROM as reset vector, 

* as long as output does not overlap it. 

*/ 

 

# include <asm/asm-offsets.h> 

# include <asm/asm-macros.h> 

 

.text 

.set noat 

.global _start 

_start: 

wrctl status, r0 /* disable interrupt */ 

/* invalidate all instruction cache */ 

movia r1, NIOS2_ICACHE_SIZE 

movui r2, NIOS2_ICACHE_LINE_SIZE 

1: initi r1 

sub r1, r1, r2 

bgt r1, r0, 1b 

/* invalidate all data cache */ 

movia r1, NIOS2_DCACHE_SIZE 

movui r2, NIOS2_DCACHE_LINE_SIZE 

1: initd 0(r1) 

sub r1, r1, r2 

bgt r1, r0, 1b 

 

nextpc r1 /* Find out where we are */ 

chkadr: 

movia r2, chkadr 

beq r1, r2, finish_move /* We are running in correct address, done */ 

/* move code, r1: src, r2: dest, r3: last dest */ 

addi r1, r1, (_start - chkadr) /* Source */ 

movia r2, _start /* Destination */ 

movia r3, __bss_start /* End of copy */ 

1: ldw r8, 0(r1) /* load a word from [r1] */ 

stw r8, 0(r2) /* stort a word to dest [r2] */ 

addi r1, r1, 4 /* inc the src addr */ 

addi r2, r2, 4 /* inc the dest addr */ 

blt r2, r3, 1b 

/* flush the data cache after moving */ 

movia r1, NIOS2_DCACHE_SIZE 

movui r2, NIOS2_DCACHE_LINE_SIZE 

1: flushd 0(r1) 

sub r1, r1, r2 

call debug_print 

bgt r1, r0, 1b 

movia r1, finish_move 

jmp r1 /* jmp to linked address */ 

 

finish_move: 

/* zero out the .bss segment (uninitialized common data) */ 

movia r2, __bss_start /* presume nothing is between */ 

movia r1, _end /* the .bss and _end. */ 

1: stb r0, 0(r2) 

addi r2, r2, 1 

bne r1, r2, 1b 

/* 

* set up the stack pointer, some where higher than _end. 

* The stack space must be greater than 32K for decompress. 

*/ 

movia sp, 0x10000 

add sp, sp, r2 

/* save args passed from u-boot, maybe */ 

addi sp, sp, -16 

stw r4, 0(sp) 

stw r5, 4(sp) 

stw r6, 8(sp) 

stw r7, 12(sp) 

/* decompress the kernel */ 

call decompress_kernel 

/* pass saved args to kernel */ 

ldw r4, 0(sp) 

ldw r5, 4(sp) 

ldw r6, 8(sp) 

ldw r7, 12(sp) 

 

/* flush all data cache after decompressing */ 

movia r1, NIOS2_DCACHE_SIZE 

movui r2, NIOS2_DCACHE_LINE_SIZE 

1: flushd 0(r1) 

sub r1, r1, r2 

call debug_print 

bgt r1, r0, 1b 

/* flush all instruction cache */ 

movia r1, NIOS2_ICACHE_SIZE 

movui r2, NIOS2_ICACHE_LINE_SIZE 

1: flushi r1 

sub r1, r1, r2 

bgt r1, r0, 1b 

flushp 

/* jump to start real kernel */ 

movia r1, (LINUX_SDRAM_START | KERNEL_REGION_BASE_ASM) 

call debug_print 

jmp r1 

 

 

data cache flush is happening in the subroutine chkadr and there its working fine , but in the subroutine finish_move the same thing flushing of data cache is going in an infinite loop. 

 

Pls help me out what could be the issue.
0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Unless you debug_print code saves all the registers, remove all the calls - it will break that code.

0 Kudos
Altera_Forum
Honored Contributor II
867 Views

Now uncompress is happening . but linux is not booting . What could be the issue ?? 

 

On the console i see .. 

 

Uncompressing Linux... Ok, booting the kernel. 

 

It stops here. Please help me how to debug or what can the issue 

 

Thanks and regards 

Tejeshwar
0 Kudos
Altera_Forum
Honored Contributor II
783 Views

 

--- Quote Start ---  

Not sure you want a print call in that loop! 

I'd expect r2 to have the value 32 (line size) 

r0 initialised to some cache address. 

r1 initialised to r2 + cache size. 

--- Quote End ---  

 

 

Hi , 

 

I am following the steps for compiling the linux as explained in the below address, 

 

http://www.alterawiki.com/wiki/uclinuxdist 

But the uclinux hangs after uncompressing , on the console i get 

Uncompressing linux ... Ok booting kernel , 

and stops here. 

 

I have attached sopcinfo, ptf and sof file . 

 

Can u help me is there any problem in the design. 

 

Regards, 

Tejeshwar K
0 Kudos
Reply