cancel
Showing results for 
Search instead for 
Did you mean: 

Linux Kernel headers for STM32MP157(openstlinux-weston)

Kanthan
Associate

I am trying to get started on Linux kernel development on STM32MP157F-DK2 board. Thus far I have been able to,

1. Flash the started package and get Linux booting successfully

2. Download the developer package, add extra logs and update the linux kernel on the board

I am trying to get started on kernel drivers and was not able to find linux headers in the sdk include path. I am getting linux/init.h as not found.

I tried to update the include path by adding the headers from the linux source code from the developer package but am facing a lot of include errors. I tried looking for a way to download the linux headers for the openst linux image online but wasn't able to find any so far.

I have the following queries,

1. Can someone provide a way to download the linux headers for cross compilation?

2. If possible can someone share a simple wiki/example of a custom kernel module/driver on the openstlinux.

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Kanthan
Associate

Hey Jean,

Thanks for your response, I was caught up with some other stuff and couldn't get to the post till now.

I had gone through the two packages and the time of posting and the chapter “Modifying a built-in Linux kernel device driver” was helpful but that would require modifying and building the kernel every time.

The final solution I figured out was actually as follows,

1.  https://wiki.st.com/stm32mpu/wiki/STM32MPU_Developer_Package - use this download, install the SDK and download the various sources (u-boot, linux, tfa etc.)

2. Build the linux from source using the README steps in the linux folder.

3. Post building you will have a build folder that contains the various headers and the libraries etc., the path to this build folder can be used to build kernel modules.

For eg.

Let's say you have built the kernel in /home/user/linux_source/build

For compiling any kernel module you can use the following makefile (makefile taken from bing chat) as a template,

 

# Define the module name
obj-m := my_module.o

# Specify the kernel source directory
KDIR := /home/user/linux_source/build

# Specify the current directory
PWD := $(shell pwd)

# Default target
all:
$(MAKE) -C $(KDIR) M=$(PWD) modules

# Clean target
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean

 

The KDIR path simply had to point to the where the kernel was built.

View solution in original post

2 REPLIES 2

Hi @Kanthan,

I could suggest that you have a look at the STM32 MPU wiki (https://wiki.st.com/stm32mpu/wiki/Main_Page).

 The following articles might be interesting for you:

* https://wiki.st.com/stm32mpu/wiki/STM32MPU_Developer_Package: this article gives the step-by-step approach to download and install the OpenSTLinux components, and proposes some guidelines to upgrade (add, remove, configure, improve...) any piece of software.

* https://wiki.st.com/stm32mpu/wiki/How_to_cross-compile_with_the_Developer_Package: this article provides simple examples for the Developer Package of the OpenSTLinux distribution, that illustrate cross-compilation with the SDK (especially, the chapter “Modifying a built-in Linux kernel device driver” gives a very simple example that might help you).

Hope this information helps.

Regards,

JC.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
Kanthan
Associate

Hey Jean,

Thanks for your response, I was caught up with some other stuff and couldn't get to the post till now.

I had gone through the two packages and the time of posting and the chapter “Modifying a built-in Linux kernel device driver” was helpful but that would require modifying and building the kernel every time.

The final solution I figured out was actually as follows,

1.  https://wiki.st.com/stm32mpu/wiki/STM32MPU_Developer_Package - use this download, install the SDK and download the various sources (u-boot, linux, tfa etc.)

2. Build the linux from source using the README steps in the linux folder.

3. Post building you will have a build folder that contains the various headers and the libraries etc., the path to this build folder can be used to build kernel modules.

For eg.

Let's say you have built the kernel in /home/user/linux_source/build

For compiling any kernel module you can use the following makefile (makefile taken from bing chat) as a template,

 

# Define the module name
obj-m := my_module.o

# Specify the kernel source directory
KDIR := /home/user/linux_source/build

# Specify the current directory
PWD := $(shell pwd)

# Default target
all:
$(MAKE) -C $(KDIR) M=$(PWD) modules

# Clean target
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean

 

The KDIR path simply had to point to the where the kernel was built.