From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI Linux Real-Time Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Working with the Linux Kernel on NI LabVIEW RT targets - Exercise 1

Exercise 1 - Building the kernel

Exercise 2 - Kbuild and enabling functionality

Exercise 3 - Out-of-tree modules and kernel debugging

 

 

 

 

In this video, we explore what's required to build a kernel for NI Linux RT targets and walk through building a kernel using the same source and kernel configuration used to build the shipping kernel.

 

Video

 

Links from the video:

Github kernel instructions - https://github.com/ni/nilrt/blob/nilrt/15.0/KERNEL_SOURCE.txt

 

Slides

Attached to this document

Comments
Chuck_81
Active Participant
Active Participant
on

Hi Brad, I followed your steps on the video but I've a behavior that is different than yours. I'm able to create the .config file after issuing the command

make ARCH=arm CROSS_COMPILE=/usr/local/oecore-x86_64/sysroots/x86_64-nilrtsdk-linux/usr/bin/armv7a-vfp-neon-nilrt-linux-gnueabi/arm-nilrt-linux-gnueabi- nati_zynq_defconfig menuconfig

(I had to se the env variables inlined with the make command since using export commands before issuing make doesn't seem to work). I get the .config file that I attached

However when I issue make -j6 ni-pkg I get this depency unmet warning and the kernel configuration is somehow restarted:

sudo make -j6 ni-pkg

scripts/kconfig/conf --silentoldconfig Kconfig

warning: (USB_ZYNQ_DR_OF) selects USB_ULPI which has unmet direct dependencies (USB_SUPPORT && ARM)

*

* Restart config...

*

*

* Linux/x86 3.14.46 Kernel Configuration

*

64-bit kernel (64BIT) [Y/n/?] (NEW)

I don't get where the issue comes from. I'm using a Lubuntu Virtual machine with the following system setup

Linux tux 4.2.0-27-generic #32~14.04.1-Ubuntu SMP Fri Jan 22 15:32:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Any hint?

Fabio M.
NI
Principal Engineer
BradM
Active Participant
Active Participant
on

Hi there Chuck_81,

You need to make sure to either always include the ARCH and CROSS_COMPILE variables in your commands or export them so that they will alway be available to the command that you're running. Basically, what happened here is that you told the Kbuild system to configure the kernel for ARCH=arm and then told it to build for ARCH=(figure out calling OS's ARCH)x86_64

Before you do anything additional, run make clean and make mrproper without any variables to clear out the kernel source directory from the x86_64 bits that got pulled in as a result of running make ni-pkg without ARCH=arm.

Final note, there's no reason to use sudo when issuing the build command.

Chuck_81
Active Participant
Active Participant
on

It was a trivial issue about permissions. Sorry for bothering.

thanks for the help.

Fabio M.
NI
Principal Engineer
BradM
Active Participant
Active Participant
on

Chuck_81 wrote:


                       

It was a trivial issue about permissions.

All the more reason to not unneccesarily use the sudo command. Glad that you are un-stuck (at least on this issue)

Daklu
Active Participant
Active Participant
on

Brad,

Thanks for the step-by-step instructions and video.  It is very helpful for those of us who are new to this aspect of programming.

I've run into an error when issuing the 'make nati_zynq_defconfig' command.  It returns the following error:

 

  HOSTCC  scripts/basic/fixdep
scripts/basic/fixdep.c:106:23: fatal error: sys/types.h: No such file or directory
 #include <sys/types.h>
                       ^
compilation terminated.
make[1]: *** [scripts/basic/fixdep] Error 1

make: *** [scripts_basic] Error 2

 

The fixdep.c file is located in linux/scripts/basic, but there's no linux/scripts/basic/sys directory containing a types.h file (which is where I assume it is looking.)  I've found lots of types.h files in the oecore installation directory, but I don't know which (if any) one is the correct one to link to.  Any ideas why I'm seeing this error?  (My host OS is Linux Mint 17.3.)

metux
Member
Member
on
The fixdep.c file is located in linux/scripts/basic, but there's no linux/scripts/basic/sys directory containing a types.h file (which is where I assume it is looking.) I've found lots of types.h files in the oecore installation directory, but I don't know which (if any) one is the correct one to link to. Any ideas why I'm seeing this error? (My host OS is Linux Mint 17.3.)
It comes from the toolchain (more precisely: libc). You'll have to build the kernel w/ the proper toolchain and sysroot. As the beginner, just use the distro build system (in your case OE), instead of trying everything by foot.
Linux Embedded / Kernel Hacker / BSP / Driver development / Systems engineering
BradM
Active Participant
Active Participant
on

 Daklu, sorry I missed your post.

 

What version of the toolchain are you using when attempting to build the kernel?

shansen1
Member
Member
on

For those who find this thread with the same issue, I had the same problem as Daklu and fixed it by defining the TGT_EXTRACFLAGS environment var as described in KERNEL_SOURCE.md on NI's github for linux-rt:

 

export TGT_EXTRACFLAGS="--sysroot=/path/to/target/sysroot"