iMX8M Passing bootargs from U-Boot without using command line

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

iMX8M Passing bootargs from U-Boot without using command line

跳至解决方案
4,691 次查看
bharatkumarbach
Contributor III

I am trying to understand how the bootargs are being passed to the kernel from U-Boot. I am not interested in using U-Boot prompt to setup environment variables.
Is there any fixed address the kernel looks at? or Is it stored in some RAM location and the address is passed onto kernel through "x" registers?

Board: iMX8M 

Thanks and Regards,
Bharat Kumar.

标记 (3)
1 解答
4,060 次查看
felixradensky
Contributor IV

U-boot passes kernel command line arguments via /chosen node in DTS.

See https://www.kernel.org/doc/Documentation/devicetree/usage-model.txt 

在原帖中查看解决方案

3 回复数
4,061 次查看
felixradensky
Contributor IV

U-boot passes kernel command line arguments via /chosen node in DTS.

See https://www.kernel.org/doc/Documentation/devicetree/usage-model.txt 

4,060 次查看
radhikasomaiya
Senior Contributor II

Hi bharatkumarbacha‌,

Kindly find my answers inline :

I am trying to understand how the bootargs are being passed to the kernel from U-Boot. I am not interested in using U-Boot prompt to setup environment variables.

When u-boot starts kernel code by bootm for example, it will pass the start address and end address of the command line string, and kernel takes it from there.
Is there any fixed address the kernel looks at? or Is it stored in some RAM location and the address is passed onto kernel through "x" registers?

Yes. U-Boot has it's predefined addresses from where the kernel gets the information about boot arguments. You can check the address in u-Boot source code - <uboot_src>/git/include/configs/<your_board.h>

The MACRO will be named as "CONFIG_ENV_OFFSET"

Hope this will help you.

4,060 次查看
bharatkumarbach
Contributor III

Hi radhika.somaiya@volansystech.com‌,

Thanks for the quick response.

When u-boot starts kernel code by bootm for example, it will pass the start address and end address of the command line string, and kernel takes it from there.

As per Kernel requirements, U-Boot uses 4 registers X0(FDT), X1(res), X2(res), and X3(res) to pass arguments. It would be of great help if you can brief about how the start and end addresses are passed to the kernel.

Yes. U-Boot has it's predefined addresses from where the kernel gets the information about boot arguments. You can check the address in u-Boot source code - <uboot_src>/git/include/configs/<your_board.h>

The MACRO will be named as "CONFIG_ENV_OFFSET"

I thought so and to verify it, I opened the boot prompt and entered the following commands.

u-boot=>setenv bootargs root=/dev/mmcblk0p1

u-boot=>run bootargs

Used the following to read from MMC

u-boot=> mmc read <ram address> <Sector of CONFIG_ENV_OFFSET> <CONFIG_ENV_SIZE/512>

u-boot=>md.b <ram address> <CONFIG_ENV_SIZE>

I expected the bootargs to be saved in the memory I read, but it was not the case unless I do

u-boot=> saveenv

Usually, the kernel can be booted without calling saveenv and I wild guess bootargs are copied into RAM and passed.

Thanks.

Regards,

Bharat Kumar Bacha.