1. Kernel Source Preparation
Begin by extracting the source package from the ST repository:
cd /linux/atk-mpl/stm32mp1-openstlinux-5.4-dunfell-mp1-20-06-24/sources/arm-ostl-linux-gnueabi/linux-stm32mp-5.4.31-r0/
tar -vxf linux-5.4.31.tar.xz
Apply Patches
Process all patch files in the parent directory:
cd linux-5.4.31/
find .. -name "*.patch" -exec patch -p1 < {} \;
Generate Configuration
Create initial configuration with fragment files:
make ARCH=arm stm32mp1_devkit_defconfig CONFIG_FRAGMENT="fragment*.config"
for f in ../fragment*.config; do scripts/kconfig/merge_config.sh -m -r .config $f; done
yes "" | make ARCH=arm oldconfig
Save the final configuration:
cp .config ./arch/arm/configs/stm32mp1_devkit_defconfig
2. Building the Kernel
Create build script stm32mp1_devkit.sh:
#!/bin/sh
make distclean
make stm32mp1_devkit_defconfig
make menuconfig
make uImage dtbs LOADADDR=0XC2000040 -j16
Execute the build:
chmod +x stm32mp1_devkit.sh
./stm32mp1_devkit.sh
Network Driver Integration
Copy driver files to kernel source:
cp motorcomm.c drivers/net/phy/
cp motorcomm_phy.h include/linux/
Update drivers/net/phy/Makefile:
obj-$(CONFIG_MOTORCOMM_PHY) += motorcomm.o
Add to drivers/net/phy/Kconfig:
config MOTORCOMM_PHY
tristate "Motorcomm PHY Support"
---help---
Enables support for YT8010, YT8510, YT8511, YT8512 PHY chips.
Enable in menuconfig:
Device Drivers → Network device support → PHY Device support → Motorcomm PHYs
3. Device Tree Customization
Create New Device Tree Files
cd arch/arm/boot/dts/
cp stm32mp15xx-edx.dtsi stm32mp157d-devkit.dtsi
cp stm32mp157d-ed1.dts stm32mp157d-devkit.dts
Modify Device Tree
Update stm32mp157d-devkit.dtsi with power management and hardware configuration:
/ {
memory@c0000000 {
reg = <0xC0000000 0x40000000>;
};
vddcore: buck1 {
compatible = "regulator-fixed";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1350000>;
};
v3v3: regulator-3p3v {
compatible = "regulator-fixed";
regulator-min-microvolt = <3300000>;
};
};
&cpu0 {
cpu-supply = <&vddcore>;
};
ðernet0 {
status = "okay";
phy-mode = "rgmii-id";
phy-handle = <&phy0>;
};
&sdmmc1 {
vmmc-supply = <&v3v3>;
status = "okay";
};
Update Build System
Add to arch/arm/boot/dts/Makefile:
dtb-$(CONFIG_ARCH_STM32MP1) += stm32mp157d-devkit.dtb
4. System Deployment
Image Packaging
Create boot filesystem:
dd if=/dev/zero of=bootfs.ext4 bs=1M count=10
mkfs.ext4 -L bootfs bootfs.ext4
mkdir -p /mnt/bootfs
mount bootfs.ext4 /mnt/bootfs
cp uImage stm32mp157d-devkit.dtb /mnt/bootfs/
umount /mnt/bootfs
EMMC Flashing
Transfer bootfs.ext4 to STM32CubeProgrammer and flash to EMMC. Configure U-Boot:
setenv bootcmd 'ext4load mmc 1:2 c2000000 uImage; ext4load mmc 1:2 c4000000 stm32mp157d-devkit.dtb; bootm c2000000 - c4000000'
saveenv
boot