LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   how kernel figure out DDR RAM size when bootargs's mem not specified? (http://www.linuxquestions.org/questions/linux-kernel-70/how-kernel-figure-out-ddr-ram-size-when-bootargss-mem-not-specified-948165/)

gluo88 06-02-2012 02:02 PM

how kernel figure out DDR RAM size when bootargs's mem not specified?
 
I have a 2.6.35 Kernel runnning on rescue mode, booting wiht u-boot, on powerpc, on in-house card, with 512M RAM.

The Kernel boots well when
1) bootargs has mem=512M, or
2) mem is not specified in bootargs.

Therefore, if bootargs does not specify any value for mem, my linux kernel looks to be able to figure out the DDR RAM 512M that is configured by u-boot from my testing.

Does anyone know how Kernel figured out the size of DDR RAM hat is configured by u-boot without learning the size from bootargs's mem argument ?


Thanks a lot for help.

syg00 06-02-2012 09:32 PM

The kernel probes the hardware to find out what's present - including how much memory.
That is a kernel parameter that is generally used to cause the kernel to use less than the total memory installed. On x86 the bootloaders don't know anything about that parameter and pass it on (uninterpreted and ignored) to the kernel. Probably the same on Power.

gluo88 06-02-2012 09:45 PM

Thank you very much for your help.

Although my kernel boots well when
1) if bootargs has mem=512M, or 2) mem is not specified.

I need to reserve some memnory for not being touched by Kernel.
However, if I reserve 1M mewmory with mem=511M, the kernel traped
when unpacking rootfs at the following location.

The trap is ppc 0x300 exception - mmu data access error.

May someone point me some clue to figure out the reason of the issue?

Thanks a lot for help.


------ More details as below:
packages/linux-centaur/init/initramfs.c: printk(KERN_INFO "Trying to unpack rootfs image as initramfs...\n")
err = unpack_to_rootfs((char *)initrd_start,
initrd_end - initrd_start);

58.124361] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 58.143896] Trying to unpack rootfs image as initramfs...
[ 58.159819] Unable to handle kernel paging request for data at address 0xddba1000
[ 58.182215] Faulting instruction address: 0xc05e6e88
[ 58.197066] Oops: Kernel access of bad area, sig: 11 [#1]
[ 58.227535] last sysfs file:
[ 58.236394] Modules linked in:
[ 58.245513] NIP: c05e6e88 LR: c05e6d84 CTR: 00000000
[ 58.260364] REGS: d7879e40 TRAP: 0300 Not tainted (2.6.35.10)
[ 58.278339] MSR: 00029000 <EE,ME,CE> CR: 24044024 XER: 00000000
[ 58.296577] DEAR: ddba1000, ESR: 00000000
[ 58.308562] TASK = d7870000[1] 'swapper' THREAD: d7878000 CPU: 0
[ 58.326016] GPR00: 00000000 d7879ef0 d7870000 d7912000 000000d0 00000000 00000000 c0b0b184
[ 58.351027] GPR08: 14000000 c05e0000 00000000 c05e0000 24044042 10121270 c05e64c4 c05e6708
[ 58.376039] GPR16: c0680700 d7879ef8 c0610000 00000000 00000000 c06806fc c0614cf8 c0661860
[ 58.401050] GPR24: ddba1000 012cb845 c0614cf8 c05e6d70 d7912000 00002000 c0630000 d7879ef0
[ 58.426591] NIP [c05e6e88] unpack_to_rootfs+0x218/0x480
[ 58.442217] LR [c05e6d84] unpack_to_rootfs+0x114/0x480
[ 58.457586] Call Trace:
[ 58.464884] [d7879ef0] [c05e6d84] unpack_to_rootfs+0x114/0x480 (unreliable)
[ 58.485727] [d7879f60] [c05e7974] populate_rootfs+0x80/0x12c
[ 58.502663] [d7879f80] [c0001da8] do_one_initcall+0x4c/0x204
[ 58.519596] [d7879fb0] [c05e444c] do_basic_setup+0x84/0xa8
[ 58.536009] [d7879fd0] [c05e4538] kernel_init+0xc8/0x170

syg00 06-02-2012 11:21 PM

Can't help with ppc - I've asked the mods to move this to somewhere more appropriate.

Maybe you should be looking for ppc specific list(s).

colucix 06-03-2012 04:06 AM

Unfortunately there is not a specific ppc section at LQ, but since it is a kernel related question I've moved this thread to Linux - Kernel for better exposure. Maybe some kernel expert could step in.

gluo88 06-03-2012 10:54 AM

thanks to syg00 and colucix for your help.

I switched from vxWorks work to Linux's embedded kernel work only a few of months. Hopefully I can get some help from Kernel expert.

gluo88 08-16-2012 10:20 AM

I figured this out.
uboot's bootm command will modify the dts/dtb file's memory section, and pass the memory size into Kernel by dts/dtb file.

Initially, memory section is as below.
memory {
device_type = "memory";
};

After the change, it is as below:
memory {
reg = <0x0 0x0 0x0 0x20000000>;
device_type = "memory";
};

chosen section is added too as below:

chosen {
linux,initrd-end = <0xffff2ca>;
linux,initrd-start = <0xeda9000>;
linux,stdout-path = "/socp2020@fffe00000/serial@4500";
boottype = "rescue";
bootargs = "rw nosmp console=ttyS0,38400 mem=496M";
};


All times are GMT -5. The time now is 12:39 AM.