[yocto] Limit RAM for Linux

Nathan Rossi nathan at nathanrossi.com
Thu Jun 11 05:27:31 PDT 2015


On Wed, Jun 10, 2015 at 2:03 AM, Edward Wingate <edwingate8 at gmail.com> wrote:
> Thanks, Nathan, for your help. It worked, with a little oddity I don't
> understand.
>
> In my uEnv.txt, I set both fdt_high and initrd_high to 0x10000000 and
> fdt/initrd are now loaded to 1st 256 MB:
>    Loading Kernel Image ... OK
>    Loading Ramdisk to 0f44c000, end 0ffff2f2 ... OK
>    Loading Device Tree to 0f443000, end 0f44bf40 ... OK
>
> However, with bootarg "mem=256MB", the kernel doesn't boot.
> With "mem=257M", it does:
>
> /proc/iomem:
> 00000000-100fffff : System RAM
>    00008000-00584b03 : Kernel code
>    005b6000-0061d5df : Kernel data
>
> I'd be OK with this, but just want to understand why I can't specify
> mem=256M?  I could probably also lower initrd_high and fdt_high a bit
> more to make mem=256M work, but why would that be necessary?

Not sure it sounds like something might not be accounting for the
first 0x8000 for interrupts or something, what error/messages do you
see when it fails to boot? or do you see nothing output on the serial
port?

I tried setting mem=256M with qemu, and it has no issues:
[    0.000000] Kernel command line: earlyprintk root=/dev/ram rw
console=ttyPS0 mem=256M
[    0.000000] PID hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Memory: 248948K/262144K available (4282K kernel code,
220K rwdata, 1336K rodata, 192K init, 192K bss, 13196K reserved, 0K
highmem)

Which leads me to think its an issue with how u-boot is booting the
kernel. (qemu puts the initrd and dtb at the bottom of memory instead
of the top)

>
> Also, in the device tree entry for memory, should I leave "reg = <0x0
> 0x20000000>" or change that to reflect 256MB?  Changing it to "reg =
> <0x0 0x10000000>" didn't seem to have any effect.  The mem bootarg
> seems to be the thing that actually works to limit the amount of
> memory Linux sees.

You shouldn't really have to change the device-tree to limit the
memory seen or used by the kernel. But it should still have an effect
on the amount of memory the kernel sees, if you observe that changing
the device tree has no result you might want to check to make sure
that you are loading the changed device-tree and or that the device
tree is being generated correctly (dtc -I dtb -O dts <dtbfile>).

Regards,
Nathan

>
>
> On Mon, Jun 8, 2015 at 9:45 PM, Nathan Rossi <nathan at nathanrossi.com> wrote:
>> On Tue, Jun 9, 2015 at 4:06 AM, Edward Wingate <edwingate8 at gmail.com> wrote:
>>
>> Those values are generated via u-boot based on the value of fdt_high
>> and initrd_high which are set in the u-boot environment. (At least for
>> Zynq)
>>
>> If you have a look at the default environment you will see them set to
>> 0x20000000:
>> http://git.denx.de/?p=u-boot.git;a=blob;f=include/configs/zynq-common.h;h=1a52e7d538261a9d36b078d61e00e60bf8918227;hb=HEAD#l217
>>
>> You can override those environment variables with your uEnv.txt file,
>> setting it to 0x10000000 will make sure they fdt/initrd is loaded into
>> the first 256M.
>>
>> Regards,
>> Nathan
>>



More information about the yocto mailing list