Skip to content

Commit

Permalink
Add support for OSD32MP1-RED-V1_2
Browse files Browse the repository at this point in the history
  • Loading branch information
neerajdantu committed Feb 2, 2023
1 parent 2ea50fe commit a5eb6c5
Show file tree
Hide file tree
Showing 12 changed files with 4,002 additions and 14 deletions.
78 changes: 71 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@
# SPDX-License-Identifier: GPL-2.0+

ROOT_DIR = $(PWD)

# version of TF-A to determine path
ATF_VERSION=arm-trusted-firmware-2.4

# version of u-boot to determine path
UBOOT_VERSION = u-boot-2020.10

# version of kernel to determine path
KERNEL_VERSION=linux-5.10

# version of gcnano to determine path
GCNANO_VERSION=6.4.3
GCNANO_SUBVERSION=20200902

# Setting up directories
FSBL_DIR ?= $(realpath bootloader/$(ATF_VERSION))
SSBL_DIR ?= $(realpath bootloader/$(UBOOT_VERSION))
KERNEL_DIR ?= $(realpath kernel/$(KERNEL_VERSION))
Expand All @@ -22,25 +31,45 @@ M4PROJECTS_DIR ?= $(realpath STM32CubeMP1)
DEPLOY_DIR ?= $(PWD)/deploy
BUILDTOOLS_DIR ?= $(realpath build-tools)

# FSBL = First stage boot loader SSBL = Second stage boot loader
# trusted mode is default (FSBL = TF-A, SSBL = U-Boot)
MODE ?= trusted
BOARD_NAME := stm32mp157c-osd32mp1-red

# machine name(name of the device tree file)
BOARD_NAME := stm32mp157c-osd32mp1-red-v1_2

# defconfig for kernel
# costum configuration can be added in build-tools/patches/linux-[version]
KDEFCONFIG ?= multi_v7_defconfig

# boot mode enable. Only enable boot modes you know you have in hardware
# RED supports EMMC and SD
# BRK only supports SD
BOOT_EMMC = 1
BOOT_SD = 1

# Boards supported
BOARD_RED = stm32mp157c-osd32mp1-red
BOARD_BRK = stm32mp157c-osd32mp1-brk
BOARD_RED_V12 = stm32mp157c-osd32mp1-red-v1_2

# Cross compiler setup
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-gnueabihf-

# use as many threads as you can for build
NPROCS=$(shell nproc)
FLAGS=-j $(NPROCS)

# default SD card size = 8GB
SDCARD_SIZE_GB=8192

# Add 1GB to rootfilesystem
ROOTFS_EXTRA_SPACE=1024

.PHONY: setup patch_fsbl patch_ssbl patch_kernel fsbl ssbl kernel bootfs gcnano rootfs vendorfs m4_demo all clean

# Apply patches to FSBL
patch_fsbl:
for file in $(BUILDTOOLS_DIR)/patches/$(ATF_VERSION)/*.patch; do \
git apply --check --directory=bootloader/$(ATF_VERSION) $$file > /dev/null 2>&1; \
Expand All @@ -51,6 +80,7 @@ patch_fsbl:
done
touch $(KERNEL_DIR)/.scmversion

# Apply patches to SSBL
patch_ssbl:
for file in $(BUILDTOOLS_DIR)/patches/$(UBOOT_VERSION)/*.patch; do \
git apply --check --directory=bootloader/$(UBOOT_VERSION) $$file > /dev/null 2>&1; \
Expand All @@ -61,6 +91,7 @@ patch_ssbl:
done
touch $(KERNEL_DIR)/.scmversion

# Apply patches to kernel
patch_kernel:
for file in $(BUILDTOOLS_DIR)/patches/$(KERNEL_VERSION)/*.patch; do \
git apply --check --directory=kernel/$(KERNEL_VERSION) $$file > /dev/null 2>&1; \
Expand All @@ -72,6 +103,8 @@ patch_kernel:
cp $(BUILDTOOLS_DIR)/patches/$(KERNEL_VERSION)/fragment-* kernel/$(KERNEL_VERSION)/arch/arm/configs
touch $(KERNEL_DIR)/.scmversion

# setup fiptool to generate fip binary that packages u-boot for TF-A
# create bootfs deploy directory to store FSBL/SSBL and boot related files
setup:
PWD=$(FSBL_DIR)/tools/fiptool $(MAKE) -C $(FSBL_DIR)/tools/fiptool
cp $(FSBL_DIR)/tools/fiptool/fiptool /bin/
Expand All @@ -81,8 +114,11 @@ setup:
cp $(BUILDTOOLS_DIR)/files/flash-tools/create_sdcard_from_flashlayout.sh $(DEPLOY_DIR)/
patch --ignore-whitespace $(DEPLOY_DIR)/create_sdcard_from_flashlayout.sh $(BUILDTOOLS_DIR)/files/flash-tools/sdcard-script.patch

# First stage bootloader
# Build First stage bootloader
# Add to if statement for custom board
# currently generating the binary is handled by Makefile.sdk in build-tools/files/fsbl/Makefile.sdk
# To add a custom board, update Makefile.sdk to add new machine name
# FSBL binary is copied to /deploy directory
fsbl: setup patch_fsbl
cp $(BUILDTOOLS_DIR)/files/fsbl/Makefile.sdk $(FSBL_DIR)
PWD=$(FSBL_DIR) $(MAKE) $(FLAGS) -C $(FSBL_DIR) -f Makefile.sdk stm32
Expand All @@ -95,13 +131,17 @@ fsbl: setup patch_fsbl
fi


# Second stage bootloader
# Build Second stage bootloader
# For custom boards, need to add machine name to build-tools/files/ssbl/Makefile.sdk
# SSBL binary is generated in /deploy directory
ssbl: setup fsbl patch_ssbl
cp $(BUILDTOOLS_DIR)/files/ssbl/boot.scr.cmd $(SSBL_DIR)
cp $(BUILDTOOLS_DIR)/files/ssbl/Makefile.sdk $(SSBL_DIR)
PWD=$(SSBL_DIR) FIP_DEPLOYDIR_FIP=$(DEPLOY_DIR) FIP_DEPLOYDIR_TFA=$(FIP_TFA_DIR) FIP_DEPLOYDIR_FWCONF=$(FIP_FWCONF_DIR) $(MAKE) $(FLAGS) -C $(SSBL_DIR) -f Makefile.sdk all UBOOT_CONFIG=trusted UBOOT_DEFCONFIG=stm32mp15_trusted_defconfig UBOOT_BINARY=u-boot.dtb FIP_CONFIG="trusted" FIP_BL32_CONF="tfa," DEVICETREE=$(BOARD_NAME)


# Apply fragment configs
# Generate kernel binary and store in /deply/bootfs/
# also copy the machine device tree to /deploy/bootfs/
kernel: setup patch_kernel
$(MAKE) $(FLAGS) -C $(KERNEL_DIR) $(KDEFCONFIG) fragment*.config
yes '' | $(MAKE) -C $(KERNEL_DIR) oldconfig
Expand All @@ -110,6 +150,13 @@ kernel: setup patch_kernel
mkimage -A arm -O linux -T kernel -C none -a 0xC2000040 -e 0xC2000040 -n "Linux kernel" -d $(KERNEL_DIR)/arch/arm/boot/zImage $(DEPLOY_DIR)/bootfs/uImage
cp $(KERNEL_DIR)/arch/arm/boot/dts/$(BOARD_NAME).dtb $(DEPLOY_DIR)/bootfs


# Create boot file system
# Contains:
# 1. Kernel Binary(uImage)
# 2. Machine device tree
# 3. board extlinux file for boot time configuration(Need to create for custom board)
# 4. boot script for u-boot and splash image
bootfs: kernel
# Generate extlinux files
$(BUILDTOOLS_DIR)/$(BOARD_NAME)-extlinux.sh -d $(DEPLOY_DIR)/bootfs
Expand All @@ -123,6 +170,7 @@ bootfs: kernel
sync
mkfs.ext4 -b 1024 -d $(DEPLOY_DIR)/bootfs -L bootfs $(DEPLOY_DIR)/octavo-bootfs-debian-lxqt-$(BOARD_NAME).ext4

# Compile gcnano binaries for gpu
gcnano: kernel
if [ ! -d $(GCNANO_DRV_DIR)/ ]; then \
tar xvf $(GCNANO_DIR)/gcnano-driver-*.tar.xz -C $(GCNANO_DIR); \
Expand All @@ -138,6 +186,8 @@ gcnano: kernel
# Signing out of tree galcore module
$(KERNEL_DIR)/scripts/sign-file sha256 $(KERNEL_DIR)/certs/signing_key.pem $(KERNEL_DIR)/certs/signing_key.x509 $(GCNANO_DRV_DIR)/galcore.ko


# Make rootfilesystem
rootfs: kernel gcnano m4_demo
$(MAKE) $(FLAGS) -C $(MULTISTRAP_DIR) all

Expand Down Expand Up @@ -174,6 +224,13 @@ ifeq ($(BOARD_NAME), $(BOARD_RED))
cp $(BUILDTOOLS_DIR)/files/demo_red/OSD32MP1_RED_intro_360p.mp4 $(ROOTFS_DIR)/home/debian;
endif

# Install demo files for OSD32MP1-RED-V12
ifeq ($(BOARD_NAME), $(BOARD_RED_V12))
cp $(BUILDTOOLS_DIR)/files/demo_red/demo_camera.sh $(ROOTFS_DIR)/home/debian; \
cp $(BUILDTOOLS_DIR)/files/demo_red/demo_video.sh $(ROOTFS_DIR)/home/debian; \
cp $(BUILDTOOLS_DIR)/files/demo_red/OSD32MP1_RED_intro_360p.mp4 $(ROOTFS_DIR)/home/debian;
endif

# Instll demo files for OSD32MP1-BRK
ifeq ($(BOARD_NAME), $(BOARD_BRK))
mkdir -p $(ROOTFS_DIR)/usr/local/demo/; \
Expand All @@ -196,9 +253,8 @@ endif
fi





# Build vendor file system
# Contains GCNANO binaries
vendorfs: setup gcnano
dd if=/dev/zero of=$(DEPLOY_DIR)/octavo-vendorfs-debian-lxqt-$(BOARD_NAME).ext4 bs=1M count=16
sync
Expand All @@ -210,12 +266,15 @@ vendorfs: setup gcnano

mkfs.ext4 -b 1024 -d $(GCNANO_USR_DIR)/usr/ -L vendorfs $(DEPLOY_DIR)/octavo-vendorfs-debian-lxqt-$(BOARD_NAME).ext4

# Build M4 projects from STM32MP1CUBE package
m4_demo: setup
if [ ! -d $(M4PROJECTS_DIR)/deploy ]; then \
cp $(BUILDTOOLS_DIR)/files/m4projects/* $(M4PROJECTS_DIR); \
cd $(M4PROJECTS_DIR) ; ./build_m4projects.sh; \
fi

# Build image
# Generate TSV handles eMMC and SD as per RED board interface definition
image: fsbl ssbl bootfs rootfs vendorfs
if [ $(BOOT_SD) -eq 1 ]; then \
$(DEPLOY_DIR)/generate_tsv.sh -b $(BOARD_NAME) -m $(MODE) -d 0; \
Expand All @@ -225,26 +284,31 @@ image: fsbl ssbl bootfs rootfs vendorfs
$(DEPLOY_DIR)/generate_tsv.sh -b $(BOARD_NAME) -m $(MODE) -d 1; \
fi

# Build all
all: ssbl fsbl bootfs rootfs vendorfs image

# Clean FSBL directory
fsbl_clean:
$(MAKE) $(FLAGS) -C $(FSBL_DIR) clean
$(MAKE) $(FLAGS) -C $(FSBL_DIR) distclean
git --git-dir=$(FSBL_DIR)/.git --work-tree=$(FSBL_DIR) reset --hard HEAD
git --git-dir=$(FSBL_DIR)/.git --work-tree=$(FSBL_DIR) clean -f -d

# Clean SSBL directory
ssbl_clean:
$(MAKE) $(FLAGS) -C $(SSBL_DIR) clean
$(MAKE) $(FLAGS) -C $(SSBL_DIR) distclean
git --git-dir=$(SSBL_DIR)/.git --work-tree=$(SSBL_DIR) reset --hard HEAD
git --git-dir=$(SSBL_DIR)/.git --work-tree=$(SSBL_DIR) clean -f -d

# Clean Kernel directory
kernel_clean:
$(MAKE) $(FLAGS) -C $(KERNEL_DIR) clean
$(MAKE) $(FLAGS) -C $(KERNEL_DIR) distclean
git --git-dir=$(KERNEL_DIR)/.git --work-tree=$(KERNEL_DIR) reset --hard HEAD
git --git-dir=$(KERNEL_DIR)/.git --work-tree=$(KERNEL_DIR) clean -f -d

# Clean all
clean: ssbl_clean fsbl_clean kernel_clean
$(MAKE) $(FLAGS) -C $(MULTISTRAP_DIR) clean
@rm -rf $(GCNANO_DRV_DIR)
Expand Down
12 changes: 6 additions & 6 deletions files/fsbl/Makefile.sdk
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ TF_A_BINARY_optee ?= tf-a
TF_A_MAKE_TARGET_optee ?= dtbs

# Init default config settings
TF_A_DEVICETREE_trusted ?= stm32mp157a-dk1 stm32mp157d-dk1 stm32mp157c-dk2 stm32mp157f-dk2 stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-brk
TF_A_DEVICETREE_trusted ?= stm32mp157a-dk1 stm32mp157d-dk1 stm32mp157c-dk2 stm32mp157f-dk2 stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-brk stm32mp157c-osd32mp1-red-v1_2
TF_A_EXTRA_OPTFLAGS_trusted ?= AARCH32_SP=sp_min
TF_A_BINARY_trusted ?= tf-a
TF_A_MAKE_TARGET_trusted ?= bl32 dtbs

# Init default config settings
TF_A_DEVICETREE_emmc ?= stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red
TF_A_DEVICETREE_emmc ?= stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-red-v1_2
TF_A_EXTRA_OPTFLAGS_emmc ?= STM32MP_EMMC=1
TF_A_BINARY_emmc ?= tf-a
TF_A_MAKE_TARGET_emmc ?= all
Expand All @@ -52,19 +52,19 @@ TF_A_BINARY_nor ?= tf-a
TF_A_MAKE_TARGET_nor ?= all

# Init default config settings
TF_A_DEVICETREE_sdcard ?= stm32mp157a-dk1 stm32mp157d-dk1 stm32mp157c-dk2 stm32mp157f-dk2 stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-brk
TF_A_DEVICETREE_sdcard ?= stm32mp157a-dk1 stm32mp157d-dk1 stm32mp157c-dk2 stm32mp157f-dk2 stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-brk stm32mp157c-osd32mp1-red-v1_2
TF_A_EXTRA_OPTFLAGS_sdcard ?= STM32MP_SDMMC=1
TF_A_BINARY_sdcard ?= tf-a
TF_A_MAKE_TARGET_sdcard ?= all

# Init default config settings
TF_A_DEVICETREE_uart ?= stm32mp157a-dk1 stm32mp157d-dk1 stm32mp157c-dk2 stm32mp157f-dk2 stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-brk
TF_A_DEVICETREE_uart ?= stm32mp157a-dk1 stm32mp157d-dk1 stm32mp157c-dk2 stm32mp157f-dk2 stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-brk stm32mp157c-osd32mp1-red-v1_2
TF_A_EXTRA_OPTFLAGS_uart ?= STM32MP_UART_PROGRAMMER=1
TF_A_BINARY_uart ?= tf-a
TF_A_MAKE_TARGET_uart ?= all

# Init default config settings
TF_A_DEVICETREE_usb ?= stm32mp157a-dk1 stm32mp157d-dk1 stm32mp157c-dk2 stm32mp157f-dk2 stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-brk
TF_A_DEVICETREE_usb ?= stm32mp157a-dk1 stm32mp157d-dk1 stm32mp157c-dk2 stm32mp157f-dk2 stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-brk stm32mp157c-osd32mp1-red-v1_2
TF_A_EXTRA_OPTFLAGS_usb ?= STM32MP_USB_PROGRAMMER=1
TF_A_BINARY_usb ?= tf-a
TF_A_MAKE_TARGET_usb ?= all
Expand All @@ -83,7 +83,7 @@ NM =
EXTRA_OEMAKE ?= CROSS_COMPILE=arm-linux-gnueabihf- DEBUG=1 LOG_LEVEL=40 PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7

# Configure overall devicetree list for FIP
TF_A_DEVICETREE_ALL = stm32mp157a-dk1 stm32mp157a-ev1 stm32mp157c-dk2 stm32mp157c-ed1 stm32mp157c-ev1 stm32mp157d-dk1 stm32mp157d-ev1 stm32mp157f-dk2 stm32mp157f-ed1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-brk
TF_A_DEVICETREE_ALL = stm32mp157a-dk1 stm32mp157a-ev1 stm32mp157c-dk2 stm32mp157c-ed1 stm32mp157c-ev1 stm32mp157d-dk1 stm32mp157d-ev1 stm32mp157f-dk2 stm32mp157f-ed1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-brk stm32mp157c-osd32mp1-red-v1_2

# Display TF-A config details
define tf-configs
Expand Down
7 changes: 7 additions & 0 deletions files/rootfs/fstab_emmc_stm32mp157c-osd32mp1-red-v1_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/dev/root / auto defaults 1 1
proc /proc proc defaults 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0
tmpfs /var/volatile tmpfs defaults 0 0
/dev/mmcblk2p2 /boot ext4 defaults,sync 0 1
/dev/mmcblk2p3 /vendor ext4 defaults,sync 0 1
7 changes: 7 additions & 0 deletions files/rootfs/fstab_sdcard_stm32mp157c-osd32mp1-red-v1_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/dev/root / auto defaults 1 1
proc /proc proc defaults 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0
tmpfs /var/volatile tmpfs defaults 0 0
/dev/mmcblk1p4 /boot ext4 defaults,sync 0 1
/dev/mmcblk1p5 /vendor ext4 defaults,sync 0 1
2 changes: 1 addition & 1 deletion files/ssbl/Makefile.sdk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ UBOOT_LOCALVERSION =

# Configure default U-Boot configs
UBOOT_CONFIGS ?= stm32mp15_trusted_defconfig,trusted,u-boot.dtb stm32mp15_basic_defconfig,basic,u-boot.img
DEVICE_TREE ?= stm32mp157a-dk1 stm32mp157d-dk1 stm32mp157c-dk2 stm32mp157f-dk2 stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-brk
DEVICE_TREE ?= stm32mp157a-dk1 stm32mp157d-dk1 stm32mp157c-dk2 stm32mp157f-dk2 stm32mp157c-ed1 stm32mp157f-ed1 stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157c-osd32mp1-red stm32mp157c-osd32mp1-brk stm32mp157c-osd32mp1-red-v1_2

# Configure default fip feature
ENABLE_FIP ?= "1"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 9a7e86d095a1bcd15cace673bac2536a036a59d0 Mon Sep 17 00:00:00 2001
From: Neeraj Dantu <[email protected]>
Date: Tue, 22 Nov 2022 17:05:56 -0600
Subject: [PATCH] Fix device tree for 800MHz speedgrade MP1 to work with 650MHz
config

---
fdts/stm32mp15xa.dtsi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fdts/stm32mp15xa.dtsi b/fdts/stm32mp15xa.dtsi
index 5ed7e594f..59da3e5dc 100644
--- a/fdts/stm32mp15xa.dtsi
+++ b/fdts/stm32mp15xa.dtsi
@@ -8,6 +8,6 @@
opp-650000000 {
opp-hz = /bits/ 64 <650000000>;
opp-microvolt = <1200000>;
- opp-supported-hw = <0x1>;
+ opp-supported-hw = <0x1 0x2>;
};
};
--
2.25.1

Loading

0 comments on commit a5eb6c5

Please sign in to comment.