Restricting memory area for linux kernel

5,870

Solution 1

To add detail to David Schwartz's answer, by specifying the kernel boot parameter to set the amount and start address used by the kernel, you can do what you want.

For example, add the following command to your kernel boot args:

mem=256M@0x80000000

Will indicate the kernel should use 256M starting at 0x80000000, which is what you require.

You should revert the CONFIG settings to their original values, and verify your kernel will boot correctly in its default configuration (with no mem= setting).

You can first try out mem= by specifying

mem=256M

which will give you a reduced memory area starting at 0, with the top 256M being unused. Once that is seen to work, use the 256M with offset as above.

Take care also where in RAM you load the initial compressed image by uBoot, to ensure it does not conflict with the eventual kernel memory area.

Solution 2

I think you're going to have to do it the other way around, and leave the top 256MB unused. CONFIG_PHYSICAL_START doesn't do what you seem to think it does. It controls where the kernel is loaded, not which physical pages the kernel uses.

Share:
5,870

Related videos on Youtube

linge
Author by

linge

Updated on September 18, 2022

Comments

  • linge
    linge over 1 year

    I am running ltib Linux on P1022RDK (P1022 Core) platform. I have 512 MB = 0x20000000 memory. I want my Linux kernel to use the second half of the board memory (i.e from 256 MB to 512 MB) and want the first half of memory to be reserved for some other purpose.

    For this I am building the Linux kernel using ltib, and setting the following kernel configuration. Please suggest if I am doing it the right way.

    CONFIG_LOWMEM_SIZE = 0x10000000 # 256 MB 
    CONFIG_PHYSICAL_START = 0x10000000 # Starting from 256MB (second half of memory)

    On the Uboot I am loading the kernel the following way:

    setenv loadaddr 0x11000000 # Kernel base = 0x10000000 + 0x01000000 (offset) 
    setenv fdtaddr 0x10c00000 # Kernel base = 0x10000000 + 0x00c00000 (offset) 
    bootm $loadaddr - $fdtaddr My kernel Load address is 0x10000000 & kernel entry point is 0x10000000

    Using the above configuration/steps my kernel is stuck at the following on Uboot:

    Booting kernel from Legacy Image at 11000000 ...
    
    Image Name: Linux-2.6.32.13 
    Image Type: PowerPC Linux Kernel Image (gzip compressed) 
    Data Size: 3352851 Bytes = 3.2 MB 
    Load Address: 10000000 
    Entry Point: 10000000 
    Verifying Checksum ... OK
    
    Flattened Device Tree blob at 10c00000
    
    Booting using the fdt blob at 0x10c00000 
    Uncompressing Kernel Image ... OK

    It should uncompress FDT here & continue

    Any thoughts?

  • ransh
    ransh almost 9 years
    Isn't using memmap parameter should be used for reserving memory ?
  • ransh
    ransh almost 9 years
    Isn't using memmap parameter should be used for reserving memory ?
  • Mixaz
    Mixaz over 6 years
    Just for reference about memmap kernel parameter: kernel.org/doc/html/v4.14/admin-guide/kernel-parameters.html