2025-05-05 8:50 AM
Starting kernel ...
I/TC: Secondary CPU 1 initializing
I/TC: Secondary CPU 1 switching to normal world boot
Solved! Go to Solution.
2025-05-12 12:16 AM
Hi
Your .config is not correct. One possible reason is that you have a problem during the mergeconfig treatment.
Can you execute the command : build_kernel --verbose=2 defaultconfig
Attached, the expected .config file when all is performed correctly. CONFIG_ARCH_STM32 shall not be added manually but performed thanks to this mergeconfig steps.
Regards
Nicolas
2025-05-06 8:16 AM
Hi
Here, it's first recommended to build once the original kernel, executing:
1- load_kernel
2- build_kernel
See for more details the wiki page on kernel build : https://wiki.st.com/stm32mpu/wiki/How_to_build_kernel_for_Android
Then to build an additional driver as module, you have two cases :
1- case with an driver integrated in the kernel sources
Here you have to enable it in your .config using "build_kernel menuconfig". It's recommended to set it as a module (M).
See for more details the wiki page on customization : https://wiki.st.com/stm32mpu/wiki/How_to_customize_Linux_kernel_for_Android
Then rebuild with install option (build_kernel -i).
2- case with an external driver (not in the kernel source).
You have to build your driver in association with the built kernel.
You have first to check what are the parameters expected to build your driver. In general, you have to find a parameter for the architecture (ARCH for example) and on to give the path to the kernel build artefacts (KERNEL_DIR for example).
make -C <path to your driver source> O=<realpath to out-bsp/stm32mp2/KERNEL_OBJ> LLVM=1 LLVM_IAS=1 CROSS_COMPILE=aarch64-none-linux-gnu- KERNEL_DIR=<realpath to out-bsp/stm32mp2/KERNEL_OBJ> ARCH=arm64
Then you have to copy the build module (.ko) file in the prebuilt directory (device/stm/stm32mp2-kernel/prebuilt/modules/).
Whatever the option to build your driver :
First you have to integrate your module installation in the init.stm.sh script (in the directory "device/stm/stm32mp2/eval/".
Then you have to rebuild your distribution from the root path : make
And reflash all associated partitions (if you have a doubt, reflash all, using provision-device script).
See for more details the wiki page on flashing :
https://wiki.st.com/stm32mpu/wiki/How_to_populate_boards_for_Android
It's important to notice that the original kernel has not been changed except potentially adding your driver if included in the kernel sources. In case, can you share your .config file for the kernel (in out-bsp/stm32mp2/KERNEL_OBJ/ directory) ?
Additionally, if you have more information concerning the driver you have to add in the build ?
Regards
Nicolas
2025-05-07 11:21 AM
Thanks @Nicolas L I'm trying to enable the Bluetooth USB driver right now (btusb.ko). Eventually, I want to enable the Silicon Labs SiWT917 BLE/WIFI module.
I reloaded and re-built the kernel without any extra drivers. I did need to run build menuconfig and set CONFIG_ARCH_STM32=y, otherwise my system failed at the dtbs step in the build_kernel script.
1. load_kernel -f
2. build_kernel mrproper
3. build_kernel menuconfig, enabled CONFIG_ARCH_STM32=y
4. build_kernel
5. build_kernel -i
6. make -j$(nproc) in directory root.
7. flash-device
Unfortunately, I still get the reboot loop. I attached my .config file.
2025-05-12 12:16 AM
Hi
Your .config is not correct. One possible reason is that you have a problem during the mergeconfig treatment.
Can you execute the command : build_kernel --verbose=2 defaultconfig
Attached, the expected .config file when all is performed correctly. CONFIG_ARCH_STM32 shall not be added manually but performed thanks to this mergeconfig steps.
Regards
Nicolas
2025-05-12 8:22 AM
Thanks Nicolas. I ran build_kernel --verbose=2 defaultconfig. There are still quite a few differences between my new config file and your expected config file. I attached updated config file.
Here's what my mergeconfig.log says
./scripts/kconfig/merge_config.sh: 82: [[: not found
The base file 'CONFIG_LSM' does not exist. Exit.
Here's the output of build_kernel mrproper && build_kernel --verbose=2 defaultconfig
[1/2]: Generate .config for stm32mp2
make: Entering directory '/home/ozi/Workspace_STM32/OpenSTDroid/Distribution/device/stm/stm32mp2-kernel/linux-stm32mp2'
make[1]: Entering directory '/home/ozi/Workspace_STM32/OpenSTDroid/Distribution/out-bsp/stm32mp2/KERNEL_OBJ'
GEN Makefile
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/expr.o
LEX scripts/kconfig/lexer.lex.c
YACC scripts/kconfig/parser.tab.[ch]
HOSTCC scripts/kconfig/menu.o
HOSTCC scripts/kconfig/preprocess.o
HOSTCC scripts/kconfig/symbol.o
HOSTCC scripts/kconfig/util.o
HOSTCC scripts/kconfig/lexer.lex.o
HOSTCC scripts/kconfig/parser.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
make[1]: Leaving directory '/home/ozi/Workspace_STM32/OpenSTDroid/Distribution/out-bsp/stm32mp2/KERNEL_OBJ'
make: Leaving directory '/home/ozi/Workspace_STM32/OpenSTDroid/Distribution/device/stm/stm32mp2-kernel/linux-stm32mp2'
=> mergeconfig logs added in /home/ozi/Workspace_STM32/OpenSTDroid/Distribution/out-bsp/stm32mp2/KERNEL_OBJ/mergeconfig.log
[2/2]: Generate corresponding defconfig.default for stm32mp2
make: Entering directory '/home/ozi/Workspace_STM32/OpenSTDroid/Distribution/device/stm/stm32mp2-kernel/linux-stm32mp2'
make[1]: Entering directory '/home/ozi/Workspace_STM32/OpenSTDroid/Distribution/out-bsp/stm32mp2/KERNEL_OBJ'
GEN Makefile
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/expr.o
LEX scripts/kconfig/lexer.lex.c
YACC scripts/kconfig/parser.tab.[ch]
HOSTCC scripts/kconfig/menu.o
HOSTCC scripts/kconfig/preprocess.o
HOSTCC scripts/kconfig/symbol.o
HOSTCC scripts/kconfig/util.o
HOSTCC scripts/kconfig/lexer.lex.o
HOSTCC scripts/kconfig/parser.tab.o
HOSTLD scripts/kconfig/conf
make[1]: Leaving directory '/home/ozi/Workspace_STM32/OpenSTDroid/Distribution/out-bsp/stm32mp2/KERNEL_OBJ'
make: Leaving directory '/home/ozi/Workspace_STM32/OpenSTDroid/Distribution/device/stm/stm32mp2-kernel/linux-stm32mp2'
2025-05-12 9:14 AM
Thanks for all your help Nicolas! I used your config_exp.txt file as my .config and I can successfully flash my device! I will try adding a custom driver now.
Do you know why the build_kernel couldn't merge the config file properly? I followed all the steps, even used the defaultconfig argument. I even re-downloaded the AOSP.
2025-05-12 10:21 AM
Hi
It shall be understood but considering the error, it's may be an error linked to the shell used.
Just to confirm, can you try to replace in the file device/stm/stm32mp2-kernel/linux-stm32mp2/scripts/kconfig/merge_config.sh :
#!/bin/sh
by
#!/bin/bash
And then try again the command : build_kernel --verbose=2 defaultconfig
Regards
Nicolas
2025-05-12 10:29 AM
That fixed it. .config is now identical to your config_exp.txt.