mirror of
https://github.com/sipeed/LicheeRV-Nano-Build.git
synced 2026-11-09 18:04:55 -06:00
Update the vendored FSBL from Sophgo sg200x-dev commit 426d1e7eccce84b34169e5f21de7d6e7da1804a1 to 5a80c127cf614dea7f534d5b5352886a1c720d37, incorporating 24 upstream commits. Keep the local plat/sg200x symlink to cv181x. Import the upstream DDR, clock, storage and boot-image changes together with their platform support, prebuilt firmware and licensing files. All 935 upstream files match the target revision. Validation on LicheeRV Nano (SG2002/C906, SD, DDR3-1866 x16): - Cross-build BL2 with the existing Xuantie GCC 10.2.0 toolchain. - Repack FIP while preserving the installed OpenSBI and U-Boot byte for byte; verify headers, payload checksums, entry addresses and LZMA. - Software reboot and power-cycle boot succeed; memtester 16M 1 passes all 18 checks. Validation covers the FSBL update with existing later boot stages. Full firmware builds, A53 and video/HID acceptance are not covered.
241 lines
6.9 KiB
Makefile
241 lines
6.9 KiB
Makefile
.PHONY: FORCE
|
|
# Default goal is build all images
|
|
.DEFAULT_GOAL := all
|
|
|
|
# Avoid any implicit propagation of command line variable definitions to
|
|
# sub-Makefiles, like CFLAGS that we reserved for the firmware images'
|
|
# usage. Other command line options like "-s" are still propagated as usual.
|
|
MAKEOVERRIDES =
|
|
|
|
S := $(shell printf '\033[1;34;40m MAKECMDGOALS %s \033[0m\n' '${MAKECMDGOALS}')
|
|
$(info ${S})
|
|
|
|
ARCH ?=
|
|
|
|
ifneq ($(origin CROSS_COMPILE),command line)
|
|
ifeq ($(ARCH),riscv)
|
|
CROSS_COMPILE := ${CROSS_COMPILE_GLIBC_RISCV64}
|
|
BOOT_CPU ?= riscv
|
|
else
|
|
CROSS_COMPILE := ${CROSS_COMPILE_64}
|
|
BOOT_CPU := aarch64
|
|
ARCH := aarch64
|
|
endif
|
|
endif
|
|
|
|
ifeq (${CHIP_ARCH},)
|
|
$(error CHIP_ARCH is undefined)
|
|
endif
|
|
|
|
ifeq (${CROSS_COMPILE},)
|
|
$(error CROSS_COMPILE is undefined)
|
|
endif
|
|
|
|
################################################################################
|
|
# Default values for build configurations, and their dependencies
|
|
################################################################################
|
|
MAKE_HELPERS_DIRECTORY := make_helpers/
|
|
|
|
V ?= 1
|
|
DEBUG := 0
|
|
LOG_LEVEL := 2
|
|
ENABLE_ASSERTIONS := 1
|
|
PRINTF_TIMESTAMP := 0
|
|
|
|
NANDBOOT_V2 := 1
|
|
|
|
|
|
ifeq ($(STORAGE),spinor)
|
|
CFLAGS += -DBOOT_SPINOR
|
|
endif
|
|
|
|
ifeq ($(STORAGE),emmc)
|
|
CFLAGS += -DBOOT_EMMC
|
|
endif
|
|
|
|
ifeq ($(STORAGE),spinand)
|
|
CFLAGS += -DBOOT_SPINAND
|
|
endif
|
|
|
|
# Verbose flag
|
|
ifeq (${V},0)
|
|
Q:=@
|
|
else
|
|
Q:=
|
|
endif
|
|
export Q
|
|
|
|
PRINTABLE := abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
|
|
PRINTABLE_TR := v1JfTUIeqdsE7P0oiczuVbW9aLnOFySG5YtDQ3lHN4rRpZABwmkCg2XhjM6x8K
|
|
CHIP_ARCH := $(shell echo '${CHIP_ARCH}' | tr A-Z a-z)
|
|
CHIP_ARCH_ALT := $(shell echo '${CHIP_ARCH}' | tr '${PRINTABLE}' '${PRINTABLE_TR}')
|
|
BUILD_BASE := ./build
|
|
|
|
O ?= ${BUILD_BASE}/${CHIP_ARCH}
|
|
BUILD_PLAT = ${O}
|
|
|
|
BUILD_STRING := g$(shell git rev-parse --short HEAD 2> /dev/null)
|
|
BUILD_STRING := ${BUILD_STRING}$(shell if git diff-index --name-only HEAD | grep -q "."; then echo -dirty; fi)
|
|
VERSION_STRING := ${CHIP_ARCH_ALT}:${BUILD_STRING}
|
|
|
|
################################################################################
|
|
# Toolchain
|
|
################################################################################
|
|
HOSTCC := gcc
|
|
export HOSTCC
|
|
|
|
CC := ${CROSS_COMPILE}gcc
|
|
CPP := ${CROSS_COMPILE}cpp
|
|
AS := ${CROSS_COMPILE}gcc
|
|
AR := ${CROSS_COMPILE}ar
|
|
LD := ${CROSS_COMPILE}ld
|
|
OC := ${CROSS_COMPILE}objcopy
|
|
OD := ${CROSS_COMPILE}objdump
|
|
NM := ${CROSS_COMPILE}nm
|
|
PP := ${CROSS_COMPILE}gcc -E
|
|
READELF := ${CROSS_COMPILE}readelf
|
|
GDB := ${CROSS_COMPILE}gdb
|
|
|
|
################################################################################
|
|
# Generic definitions
|
|
################################################################################
|
|
include ${MAKE_HELPERS_DIRECTORY}unix.mk
|
|
include ${MAKE_HELPERS_DIRECTORY}build_macros.mk
|
|
include ${MAKE_HELPERS_DIRECTORY}plat_helpers.mk
|
|
|
|
################################################################################
|
|
# Common sources and include directories
|
|
################################################################################
|
|
include lib/stdlib/stdlib.mk
|
|
|
|
################################################################################
|
|
# Convert building option
|
|
################################################################################
|
|
FSBL_SECURE_BOOT_SUPPORT := $(call yn10,${FSBL_SECURE_BOOT_SUPPORT})
|
|
|
|
################################################################################
|
|
# CPU and platform
|
|
################################################################################
|
|
$(call print_var,CHIP_ARCH)
|
|
$(call print_var,BOOT_CPU)
|
|
|
|
include ${PLAT_MAKEFILE_FULL}
|
|
|
|
# Check CPU define
|
|
$(eval $(call add_define,$(shell echo '${BOOT_CPU}' | tr a-z A-Z)))
|
|
ifeq (${BOOT_CPU},aarch64)
|
|
|
|
else ifeq (${BOOT_CPU},riscv)
|
|
else
|
|
$(error "BOOT_CPU=${BOOT_CPU} is not supported")
|
|
endif
|
|
|
|
CPPFLAGS += \
|
|
${DEFINES} ${INCLUDES} \
|
|
-nostdinc \
|
|
-Wmissing-include-dirs -Werror
|
|
|
|
TF_CFLAGS += -ggdb3 -gdwarf-2
|
|
ASFLAGS += -g -Wa,--gdwarf-2
|
|
|
|
# Include the CPU specific operations makefile
|
|
include lib/cpu/${BOOT_CPU}/cpu.mk
|
|
|
|
INCLUDES += -Ibuild
|
|
INCLUDES += -Iinclude/cpu
|
|
|
|
ifeq (${STORAGE_TYPE},spinand)
|
|
$(eval $(call add_define,BOOT_FROM_NAND))
|
|
endif
|
|
ifeq (${STORAGE_TYPE},emmc)
|
|
$(eval $(call add_define,BOOT_FROM_EMMC))
|
|
endif
|
|
ifeq (${STORAGE_TYPE},spinor)
|
|
$(eval $(call add_define,BOOT_FROM_NOR))
|
|
endif
|
|
################################################################################
|
|
# Build options checks
|
|
################################################################################
|
|
$(eval $(call assert_boolean,DEBUG))
|
|
$(eval $(call assert_boolean,ENABLE_ASSERTIONS))
|
|
$(eval $(call assert_boolean,NANDBOOT_V2))
|
|
$(eval $(call assert_boolean,NANDBOOT_V2))
|
|
$(eval $(call assert_boolean,PAGE_SIZE_64KB))
|
|
$(eval $(call assert_boolean,TEST_FROM_SPINOR1))
|
|
$(eval $(call assert_boolean,PRINTF_TIMESTAMP))
|
|
|
|
################################################################################
|
|
# Add definitions to the cpp preprocessor based on the current build options.
|
|
# This is done after including the platform specific makefile to allow the
|
|
# platform to overwrite the default options
|
|
################################################################################
|
|
$(call print_var,TEST_FROM_SPINOR1)
|
|
$(call print_var,PAGE_SIZE_64KB)
|
|
|
|
$(eval $(call add_define,TEST_FROM_SPINOR1))
|
|
$(eval $(call add_define,PAGE_SIZE_64KB))
|
|
$(eval $(call add_define,PRINTF_TIMESTAMP))
|
|
|
|
$(eval $(call add_define,ENABLE_ASSERTIONS))
|
|
$(eval $(call add_define,LOG_LEVEL))
|
|
$(eval $(call add_define,__CVITEK__))
|
|
$(eval $(call add_define,NANDBOOT_V2))
|
|
|
|
ifeq (${BOOT_CPU},riscv)
|
|
$(eval $(call add_define_val,TOC_HEADER_NAME,0xC906B001))
|
|
else
|
|
$(eval $(call add_define_val,TOC_HEADER_NAME,0xAA640001))
|
|
endif
|
|
|
|
ifeq (${RTOS_ENABLE_FREERTOS},y)
|
|
$(eval $(call add_define,RTOS_ENABLE_FREERTOS))
|
|
$(eval $(call add_define_val,RTOS_DUMP_PRINT_SZ_IDX,${RTOS_DUMP_PRINT_SZ_IDX}))
|
|
$(eval $(call add_define_val,RTOS_FAST_IMAGE_TYPE,${RTOS_FAST_IMAGE_TYPE}))
|
|
$(eval $(call add_define_val,RTOS_DUMP_PRINT_ENABLE,$(call yn10,${RTOS_DUMP_PRINT_ENABLE})))
|
|
endif
|
|
|
|
ifeq ($(OD_CLK_SEL),y)
|
|
$(eval $(call add_define,OD_CLK_SEL))
|
|
endif
|
|
|
|
ifeq ($(ENABLE_BURN_BUTTON),y)
|
|
$(eval $(call add_define,ENABLE_BURN_BUTTON))
|
|
$(eval $(call add_define_val,GPIO_GRP,${GPIO_GRP}))
|
|
$(eval $(call add_define_val,GPIO_PIN,${GPIO_PIN}))
|
|
endif
|
|
|
|
$(eval $(call add_define,FSBL_SECURE_BOOT_SUPPORT))
|
|
$(eval $(call add_define, USB_DL_BY_FSBL))
|
|
|
|
ifeq ($(SUSPEND),y)
|
|
$(eval $(call add_define,CONFIG_SUSPEND))
|
|
endif
|
|
|
|
ifeq (${SWITCH_32K_XTAL},y)
|
|
$(eval $(call add_define,SWITCH_32K_XTAL))
|
|
endif
|
|
################################################################################
|
|
# Build targets
|
|
################################################################################
|
|
.PHONY: all fip clean bl-check bl-build fake-blcp
|
|
.SUFFIXES:
|
|
|
|
export BUILD_PLAT NM
|
|
|
|
|
|
all: fip bl2 blmacros
|
|
|
|
|
|
include ${MAKE_HELPERS_DIRECTORY}fip.mk
|
|
|
|
$(eval $(call MAKE_BL,2))
|
|
|
|
# Convert '#define ...' to ELF symbols
|
|
BLMACROS_LINKERFILE := make_helpers/get_macros.ld.S
|
|
BLMACROS_ELF := ${BUILD_PLAT}/blmacros/blmacros.elf
|
|
$(eval $(call MAKE_BL,macros))
|
|
|
|
clean:
|
|
$(print_target)
|
|
$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
|