Change Linux Command Line Parameter from U-boot

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box
Tux.png Applies to U-Boot
Naon am387x-dm814x.png Applies to Naon
Maya 03.png Applies to Maya
Dido-main.png Applies to Dido
Diva-am335x-overview.png Applies to Diva
Axel-04.png Applies to Axel Ultra
Axel-lite 02.png Applies to Axel Lite


When booting a Linux kernel, U-Boot, among the other things, take care of passing a string called command line as kernel parameter. U-Boot uses its bootargs environment variable as parameter. This variable can be defined statically in U-Boot environment as follow:

NAON#setenv bootargs 'root=/dev/mmcblk0p1 rw console=ttyO0,115200n8 earlyprintk mem=176M vram=46M notifyk.vpssm3_sva=0xBF900000'
Saving Environment to SPI Flash...
Erasing SPI flash...Writing to SPI flash...done

But a most commonly used approach is to use different environment variables that append a dedicated section of command line. This is more flexible and allow the user to change only a single part of the command line without take care of the whole string.

Runtime Kernel command line creation

As noted above, commonly the command line is created by U-Boot environment variable substitution and string concatenation.

As an example we'll show how to change Naon the frame buffer size by using the default environment variables setup.

Here is a dump of the interesting sections of the environment:

NAON#printenv net_nfs nfsargs addip addcons addmem mem vram
net_nfs=run loadk nfsargs addip addcons addmem; bootm ${buf}
nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath} panic=5
addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gateway}:${netmask}:${hostname}:${ethdev}
addcons=setenv bootargs ${bootargs} console=${console},115200n8 earlyprintk
addmem=setenv bootargs ${bootargs} mem=${mem} vram=${vram} notifyk.vpssm3_sva=${notify_mem}

When using net_nfs configuration, which loads the kernel binary image from TFTP and uses NFS as root file system, U-Boot:

  • initializes bootargs when running nfsargs macro
  • appends network configuration when running addip macro (see [1] for a more detailed explanation of all this parameters)
  • appends console configuration with addcons macro
  • appends memory parameters with addmem macro
    • please note that this macro uses mem, vram and notify_mem variable substitution to setup its parameter

For this reason a simple

NAON#setenv vram 36M
Saving Environment to SPI Flash...
Erasing SPI flash...Writing to SPI flash...done

Will reduce framebuffer memory allocation from 46MiB to 36MiB.

Here is the new boot output:

NAON#run net_nfs
TFTP from server; our IP address is
Bytes transferred = 2688084 (290454 hex)
## Booting kernel from Legacy Image at 81000000 ...
   Image Name:   Linux-2.6.37-naon-0.2.0
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2688020 Bytes = 2.6 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
[    0.000000] Linux version 2.6.37-naon-0.2.0 (ezsdk@ezsdk) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203) ) #2 Mon May 7 18:21:09 CEST 2012
[    0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c53c7f
[    0.000000] CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] Machine: naon
[    0.000000] bootconsole [earlycon0] enabled
[    0.000000] vram size = 37748736 at 0x0
[    0.000000] reserved size = 37748736 at 0x0
[    0.000000] FB: Reserving 37748736 bytes SDRAM for VRAM
[    0.000000] Memory policy: ECC disabled, Data cache writeback
[    0.000000] OMAP chip is TI8148 2.0
[    0.000000] SRAM: Mapped pa 0x40300000 to va 0xfe400000 size: 0x20000
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 35488
[    0.000000] Kernel command line: root=/dev/nfs rw nfsroot= panic=5 ip= console=ttyO0,115200n8 earlyprintk mem=176M vram=36M notifyk.vpssm3_sva=0xBF900000
[    0.000000] PID hash table entries: 1024 (order: 0, 4096 bytes)