Configuration file in U-boot - u-boot

Is there any config file in U-boot similar to config files(in arch/arm/configs/ for ARM) in Linux.
My doubht here is, while building U-boot it is taking CPUDIR(in the top Makefile) as "arch/arm/cpu/armv7". I am trying to understand from where it is taking the configuration as "arm" and "armv7".

If you see the U-Boot tree on the directory
/configs
you will have the board default configuration files.

I believe the header files in include/configs are what you're looking for. You'll need to determine which file is used for your board.
From http://www.stlinux.com/u-boot/modifying:
Configuration files
The important configuration information for U-Boot is defined in the file:
include/configs/<board>.h
For example, the Espresso board default configuration file is:
include/configs/espresso.h

Related

How to use custom device tree source correctly in buildroot?

I made a copy of the dts from <linux>/board/arch/arm/boot/dts/imx28-evk.dts for using with my custom board. My custom device-tree is named imx28-custom.dts and is pointed in the Out of tree custom DTS menu entry (BR2_LINUX_KERNEL_CUSTOM_DTS_PATH) in the Buildroot config.
However u-boot is configured to use the existing MX28 board config. After building a kernel I have imx28-custom.dtb and zImage in the <buildroot>/output/images folder.
When the system boots, u-boot tells that imx28-evk.dtb is not found. Why was imx28-custom.dtb built but is not found by u-boot? Why u-boot doesn't find its own device-tree (imx28-evk.dtb) for itself and my custom device-tree for the kernel? I assumed that BR2_LINUX_KERNEL_CUSTOM_DTS_PATH relates only to the kernel. How can my custom device-tree be passed to the kernel if u-boot tries to use its own imx28-evk.dtb for this?
u-boot complaining about not finding the device-tree is related to the Linux kernel: when booting, u-boot loads the device-tree and kernel image from the storage to specified addresses in the memory and then passes control to the kernel. The default configuration for the i.MX28-EVK board is to pass the imx28-evk.dtb file.
The BR2_LINUX_KERNEL_CUSTOM_DTS_PATH only serves to include the custom device-tree in the files to build and install but does not configure u-boot to use it.
Which device-tree u-boot passes to the kernel is defined by u-boot's CONFIG_DEFAULT_FDT_FILE option (you can edit this by typing make uboot-menuconfig (see my note at the end) then going under Boot to set the Default fdt file). This option should be set to something like imx28-custom.dtb.
How to configure u-boot from Buildroot is described here and here to make them permanent.
In the case of the i.MX28-EVK, Buildroot uses the Legacy build system (which is to be used up to u-boot 2015.04, but the config uses 2020.04) which does not allow the use of the make uboot-menuconfig command. You should safely be able to change that. You need to set the Build system to Kconfig and set the Board defconfig to mx28evk.

u-boot.cfg file in U-boot

I am understanding the U-boot build, it seems the selected config options in Kconfig are updated in u-boot.cfg file.
Can you guide to understand how it is created and the usage of this file(who will use this file).
The current U-Boot configuration options are stored in file .config.
You can create a default configuration my using one of the filenames in configs/, e.g.
make qemu_arm64_defconfig
To adjust the configuation use
make menuconfig
https://opensource.com/article/18/10/kbuild-and-kconfig has some more detail about the internals of the Kconfig system.
The u-boot.cfg file is produced when you build U-Boot. It is just there to let you see what config options were selected.
Normally you edit the configs/..._defconfig files to actually change the configuration of U-Boot for a board.

Loading my own device driver as builtin in Yocto on my own meta layer

I wrote my own USB driver for hardware and I want to add this driver as builtin. I have seen this post where they create a recipe to set as module and not builtin.
http://wiki.kaeilos.com/index.php/Howto_build_a_kernel_module_out_of_the_kernel_tree
Can you please guys help me in creating a recipe to set the module as builtin.
Thanks for your time.
You can't have external modules built into Linux Kernel. So you need to place your driver into drivers/usb/ (based on the hardware type it needs to be placed in drivers/usb/host/ if it is host controller driver or drivers/usb/dwc* or drivers/usb/gadget/udc if it is gadget driver) of your Linux Kernel tree.
Then you need to add according configuration in Kconfig and Makefile in drivers/usb. Finally you need to enable this as build in driver in defconfig/.config for building.
In short,
Place your driver in drivers/usb
Add Kconfig and Makefile. For example, CONFIG_USB_HW_HCD
Add to defconfig as CONFIG_USB_HW_HCD=y. In Yocto you can specify the defconfig file as file://defconfig in your SRC_URI.
EDIT:
As you are using meta-intel directly, you can create patch and bbappend to it. To do it,
git clone "intel kernel repo"
Add driver as mentioned above. Copy to drivers/usb, add Kconfig, Makefile entry.
Add this driver to git repo using git add + git commit
Create patch using git format-patch
Create a .bbappend file and add this patch. You can place this .bbappend file in any of your custom layer or in meta-intel itself.
Add defconfig fragment also into the .bbappend file for your Linux Kernel.
This way you don't need to have separate repo of same Linux Kernel.
I hope your initial module will have module_init() and module_exit calls.
To make this usb module to be part of builtin kernel, very first thing is to modify you source code to remove module_init or module_exit calls add platform calls probe, init, etc./
Copy your source file to appropriate source directory like "driver/usb/*"
Add a entry in KCONFIG file with some description of that driver and also add rules for its dependencies
Add entry in Makefile for conditional compilation.
Configure your kernel using make menuconfig to enable your config tag and build your kernel

Compiling an individual kernel module (Debian/Ubuntu)

I need to modify the ELF loader's kernel implementation of an Ubuntu 14.04 distribution. Having downloaded the sources using:
sudo apt-get source linux-image-$(uname -r)
I ran the configuration script:
make config
in the root source tree. After a seemingly endless sequence of input requests, the script created the .config file needed to build the kernel(or a set of modules). The kernel version I am using is linux-3.13.0 and has the following source tree layout:
$ ls
arch COPYING crypto Documentation dropped.txt FileSystemMakefile fs init Kbuild kernel MAINTAINERS mm README samples security sound ubuntu virt
block CREDITS debian.master drivers elf.dat firmware include ipc Kconfig lib Makefile net REPORTING-BUGS scripts shortcuts tools usr
The ELF loader is located in /path/to/source/fs/binfmt_elf.c. Following this question,in order to compile an individual module it is sufficient to run
make /path/to/module/directory.
In this case that would be:
make ./path/to/source/fs
The compilation is quite lengthy; it takes about twenty minutes(on a virtual machine) and the output is written(by default) in the same directory in which the module is located. I've found the object files by running:
find . -name "*.o"
in /path/to/source/fs. Filtering by name the ELF loader can be located by running:
find . -name "*elf*.o"
In the current sources it is written(by default) in:
/path/to/source/fs/binfmt_elf.o
Having gone through this tutorial, I've noticed that kernel modules have the naming convention [module_name].ko in order to distinguish them from user space object files.
My question is how can I insert the new(modified) ELF loader into the kernel given that the current ELF loader is present(as unloading it may prevent binaries from being executed)?
What you have described is not really compiling a "kernel module" as it is commonly referred to. You have built an object that is statically linked into the kernel and there is no way that you can load just that object into a running kernel.
"kernel module" usually refers to "loadable kernel module" (LKM). Building and loading the fs as an LKM is what you need/want. Take a look at the below HOWTO. Follow that to build the desired fs as an LKM. Then you can just replace that one LKM (.ko) file and reboot (normally you can dynamically remove and insert LKMs but not sure how that will affect something fundamental like the ELF fs - you can try rmmod/modprobe without a reboot first if you ike).
http://www.tldp.org/HOWTO/Module-HOWTO/x73.html

What are the files/directories we need to build a module in linux kernel?

I am using beaglebone, that contains Angstrom distribution. In that there is no build directory, so I have downloaded the kernel source from kernel.org, but the size of that is too much for my SD card (~430 MB). So I thought of removing some unwanted files or directories.
Which directories are not necessary to build a kernel module? And is there any other method to get those files only?
You can cross-compile kernel on your PC - it would be faster and much more comfortable.
All you have to do is to get cross-compiler. As i remember there were some prepared for beagleboard so you can try to use them. Of course you can build it by yourself - there are tools such as crosstool-ng or buildroot, which can help you a lot.

Resources