linux4sam / at91bootstrap

Second level bootloader for Microchip SoC (aka AT91)
https://www.linux4sam.org/linux4sam/bin/view/Linux4SAM/AT91Bootstrap4
114 stars 232 forks source link

Are configurations with "mem=" in kernel command line known to work with recent kernels (>=4.9)? #90

Closed antonsviridenko closed 5 years ago

antonsviridenko commented 5 years ago

Are you aware if following configurations exist and successfully work in production? Like this one https://github.com/linux4sam/at91bootstrap/blob/8b9064beb6169f2c3be089fa99c5080b2182639f/board/at91sam9261ek/Config.in.linux_arg#L2

and others with "mem=" in command line. Btw, why "mem=NN" is used when RAM size can be set in the device tree?

I observe kernel crashes when "mem=64M" is appended to command line, please see this post

http://lists.infradead.org/pipermail/linux-arm-kernel/2018-November/613095.html

ehristev commented 5 years ago

Hi Anton,

Thank you for reporting this,

It is possible that the DTB memory node is modified by the bootloader, but I am not sure. I will have a look and let you know of my findings.

PS. The kernel cmd line in general is used to easily override the DT nodes... such that you dont need to rebuild the DTB, just tweak from cmd line. Cmdline takes precedence over the DT nodes Eugen

antonsviridenko commented 5 years ago

It is possible that the DTB memory node is modified by the bootloader, but I am not sure. I will have a look and let you know of my findings.

Yes, according to sources, memory size is passed to kernel by modifying DTB: https://github.com/linux4sam/at91bootstrap/blob/master/driver/load_kernel.c#L85

PS. The kernel cmd line in general is used to easily override the DT nodes... such that you dont need to rebuild the DTB, just tweak from cmd line. Cmdline takes precedence over the DT nodes

I expect this behavior too

ehristev commented 5 years ago

I see that the arm-kernel guys have answered this very well, I will post here a summary: mem=size@address otherwise address is 0 by default hence a crash. Need to be careful where in DDR kernel and DTB is loaded, so kernel can access this DDR Careful with bootloaders ram initialization (U-boot can relocate the DTB to an area of DDR where kernel does not have access to).

I see that the "mem=..." need to be reworked to have a base address, etc. Feel free to submit patches to address this issue you found. However to make sure we do not break anything, testing would be required so if someone has the boards, a Tested-by tag would be sufficient to have this merged into the main branch.

Thanks ! Eugen