where are the kernel command line arguments stored?

Post new topic   This topic is locked: you cannot edit posts or make replies.    DD-WRT Forum Index -> Generic Questions
Author Message
MuzzleVelocity
DD-WRT User


Joined: 23 Apr 2010
Posts: 125

PostPosted: Wed Jul 21, 2021 13:58    Post subject: where are the kernel command line arguments stored? Reply with quote
when I look at dmesg i see
Code:
Kernel command line: console=ttyMSM0,115200n8 rootfstype=squashfs noinitrd console=ttyHSL1,115200n8 init=/sbin/init rootfstype=squashfs root=31:14


where is that string of text defined? in a text file somewhere? hardcoded in the CFE? hardcoded in some binary? in an NVRAM location?

(This isn't an "XY problem", i'm not trying to accomplish anything here, just curious about learning how things work under the hood)

Thanks!
Sponsor
MuzzleVelocity
DD-WRT User


Joined: 23 Apr 2010
Posts: 125

PostPosted: Sat Jul 24, 2021 16:43    Post subject: Reply with quote
I am close to figuring it out. My router is an EA8500 (QCA IPQ806X CPU) running "DD-WRT v3.0-r46885 std (06/05/21)" (4.9 kernel.)

I looked in the source-code, and in src\linux\universal\linux-4.9\.config_generic on line 1858 it has:
Code:
CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/mtdblock1 rootfstype=squashfs noinitrd  init=/sbin/init"


promising, but not exactly what dmesg is showing me. in that same directory there is a .config_ipq806x file, which i ASSume is what would get used when compiling for my specific router. but on line 567 that just says
Code:
CONFIG_CMDLINE=""


so where exactly is my kernel command line coming from? from one of BS's secret Makefiles?
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14125
Location: Texas, USA

PostPosted: Sat Jul 24, 2021 17:53    Post subject: Reply with quote
Find the most complete Linux reference book you can get. Read it cover to cover; read again; rinse and repeat until you start understanding; and keep reading.

P.S. You can also find loads of information on the Internet these days.

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
MuzzleVelocity
DD-WRT User


Joined: 23 Apr 2010
Posts: 125

PostPosted: Sun Jul 25, 2021 2:22    Post subject: Reply with quote
kernel-panic69 wrote:
Find the most complete Linux reference book you can get. Read it cover to cover; read again; rinse and repeat until you start understanding; and keep reading.

P.S. You can also find loads of information on the Internet these days.

I appreciate the cleverness of your reply, and you are correct in implying that I have never actually sat down and read a book on Linux.

The problem with my specific question is that most information on the internet (and I assume in print) regarding kernel boot parameters assume you are using GRUB or something similar. I can't find much info on CFE or whatever bootloaders these routers are using nowadays.

Name a book on compiling DD-WRT firmware images and I'll read it cover to cover...
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14125
Location: Texas, USA

PostPosted: Sun Jul 25, 2021 2:30    Post subject: Reply with quote
Kernel command line parameters don't rely on what bootloader you are using AFAIK. If such a book existed, I'd share my copy, lol. There used to be a thread about it, but it got removed somehow...
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
MuzzleVelocity
DD-WRT User


Joined: 23 Apr 2010
Posts: 125

PostPosted: Sun Jul 25, 2021 2:59    Post subject: Reply with quote
kernel-panic69 wrote:
Kernel command line parameters don't rely on what bootloader you are using AFAIK.
I might be mixing up some terms. but with GRUB there is a /boot/grub.cfg file that contains the kernel command line. my understanding was that GRUB is the bootloader, and it starts the kernel using the cmd line in its cfg file.

on a router things obviously work differently. it is tickling my curiosity bone...
mrjcd
DD-WRT Guru


Joined: 31 Jan 2015
Posts: 6268
Location: Texas

PostPosted: Sun Jul 25, 2021 3:47    Post subject: Reply with quote
MuzzleVelocity wrote:
on a router things obviously work differently. it is tickling my curiosity bone...

https://forum.dd-wrt.com/forum/viewtopic.php?p=1183198
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14125
Location: Texas, USA

PostPosted: Sun Jul 25, 2021 10:23    Post subject: Reply with quote
Some devices use uboot; some use (Broadcom) CFE; some use RedBoot (or a special micro redboot); and x86 uses grub, I think. I mean, this is a totally loaded question and discussion, lol. You could read through the buildroot documentation and perhaps find some answers, or get even more lost, whichever. You would have to dig in and run strings on each mtd partition and pipe grep for a specific string to find what you're looking for on the router flash itself.
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
MuzzleVelocity
DD-WRT User


Joined: 23 Apr 2010
Posts: 125

PostPosted: Sun Jul 25, 2021 17:19    Post subject: Reply with quote
kernel-panic69 wrote:
I mean, this is a totally loaded question and discussion, lol.

I don't want to come across as a troll, I just find this in-depth technical stuff so interesting! but this topic did get a lot more complex than i had expected...

FWIW, I did find my answer, and I'll post it here in case anyone is ever wondering, and also for my own future reference:

I read the link that mrjcd posted and it had some good hints. I did "cat /proc/mtd" to discover what partition my bootloader is on. (It's u-boot, not CFE, as KernelPanic pointed out). Qualcom calls the u-boot bootloader APPSBL. I used "strings /dev/mtd9|grep -i boot" to show some interesting things from inside the bootloader, including a defintion of "bootargs" which matched the kernel command line reported by dmesg!

so theres my answer: the kernel command line is hardcoded into the u-boot bootloader from the manufacturer. Thanks Kernel and mrjcd for nudging me in the right direction.
MuzzleVelocity
DD-WRT User


Joined: 23 Apr 2010
Posts: 125

PostPosted: Fri Jul 30, 2021 0:28    Post subject: Reply with quote
MuzzleVelocity wrote:
so theres my answer: the kernel command line is hardcoded into the u-boot bootloader from the manufacturer

this is actually incorrect. It is in the bootloader, but its not hardcoded, its stored in flash memory. If i interrupt the boot process from the serial port I get to the IPQ prompt of the bootloader. "printenv" shows this:
Code:

(IPQ) # printenv

altkern=3780000
auto_recovery=yes
baudrate=115200
boot_part=2
boot_part_ready=3
boot_ver=1.0.12
bootargs=console=ttyHSL1,115200n8
bootcmd=bootipq
bootdelay=2
ethact=eth0
ethaddr=XX:XX:2b:11:XX:XX
flashimg=tftp $loadaddr $image;nand erase $prikern $imgsize;nand write $loadaddr $prikern $filesize
flashimg2=tftp $loadaddr $image;nand erase $altkern $imgsize;nand write $loadaddr $altkern $filesize
image=wraith.bin
imgsize=2800000
ipaddr=192.168.1.1
loadaddr=42000000
machid=1260
netmask=255.255.255.0
partbootargs=console=ttyHSL1,115200n8 init=/sbin/init rootfstype=squashfs root=31:14
partbootargs2=console=ttyHSL1,115200n8 init=/sbin/init rootfstype=squashfs root=31:16
prikern=f80000
serverip=192.168.1.254
stderr=serial
stdin=serial
stdout=serial

so if i wanted to I could change partbootargs with a setenv command and screw up my kernel command line however I see fit...
Display posts from previous:    Page 1 of 1
Post new topic   This topic is locked: you cannot edit posts or make replies.    DD-WRT Forum Index -> Generic Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum