3

Is there some way in Buildroot to change the kernel version string displayed with the "uname -a" command? For example:

# uname -a
Linux buildroot 5.1.0 #1 PREEMPT Wed Nov 6 13:10:04 MST 2019 armv5tejl GNU/Linux

I would like to append something so the version look like: "5.1.0-xxxx-xx".

I check this post but it doesn't make sense to me. Which .config file does it refer to? I see 4 in my Buildroot directory, the default one at the root and three more under "./output", which come from other repos.

Thanks, Dave.

DaveR
  • 1,295
  • 1
  • 13
  • 35

2 Answers2

3

You need to set the LOCALVERSION configuration parameter of the Linux kernel (the kernel version string is a kernel feature, not a Buildroot feature).

  1. from Buildroot enter the Linux configuration interface: make linux-menuconfig
  2. Go in General setup and set Local version - append to kernel release to -foo-bar
  3. Exit menuconfig saving your changes
  4. Build the whole Buildroot image: make

Now uname -a will show: Linux buildroot 5.1.0-foo-bar #1 PREEMPT Wed Nov 6 13:10:04 MST 2019 armv5tejl GNU/Linux.

To know how to make these changes persistent, read "Storing the configuration of other components" in the Buildroot user manual.

Luca Ceresoli
  • 1,591
  • 8
  • 19
  • Can you explain how the  BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE and BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG variables work? Do they need to be used together? It seem I cant set the former without first setting the latter. I find the documentation a little confusing because it says I can "directly specify this file in the Buildroot configuration, using BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG" but that variable only takes "Y/N" value. – DaveR Nov 13 '19 at 20:29
  • 1
    When you set the `BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG` variable to `y`, the `BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE` option will appear. – Arnout Nov 16 '19 at 12:56
0

Arnout was kind enough to give me steps and pointers to the information I needed to figure this out but for completeness, I'll list all the steps I did to make this happen. I used Buildroots "make xconfig" to set the BR_* variables:

  1. Set BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y

  2. As recommended in Recommended Directory Structure,I created a <BR_ROOT>/board/<company>/<board-name> directory and created an empty linux.config file in that directory.

  3. Set BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE equal to the path in Step 2 i.e BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=board/<company>/<board-name>/linux.config

  4. Executed the command "make linux-update-defconfig" to store my Linux configuration in the file I created in Step 3.

  5. Followed the steps Arnout listed in his response to my original question.

  6. Rebuilt my kernel and rootfs with "make".

Once I verified that everything was correct, I saved my new configuration with "make savedefconfig".

DaveR
  • 1,295
  • 1
  • 13
  • 35