2024-12-13 12:16 PM
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.
Solved! Go to Solution.
2024-12-25 03:53 AM
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.
2024-12-16 02:45 AM
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.
2024-12-25 03:53 AM
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.