From 78a320b1fd7c1141e76d11b2703e99fc43c7fe1b Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Wed, 7 Jul 2021 17:34:40 +0200 Subject: [PATCH] edge: ODROID N2/N2+ mainline U-boot; keep odroid-2015 u-boot for legacy and current - Armbian already had all the FIP-magic needed, just use it. - Introduce USE_ODROID_UBOOT with a list of branches that use Odroid's 2015 u-boot - this is mostly in preparation for non-Odroid G12B/meson64 boards (Khadas VIM3...) - In case $BRANCH is listed in USE_ODROID_UBOOT: - use BOOTCONFIG_ODROID and BOOTSCRIPT_ODROID from board.conf - build 2015 u-boot just like before - Small hack into boot-meson64.cmd to handle u-boot vs kernel: n2_plus vs n2-plus DTB/FDT naming mismatch - overrides the default $fdtfile based on $variant - armbianEnv still has final say if $fdtfile is set there (it isn't for n2/n2plus) - Extra: - remove unused n2-mainline bootscript (maybe from a previous try?) - comments about FIP trees being identical across N2/N2Plus and C4/HC4 families so no future time wastage - only set CPUMIN/CPUMAX/GOVERNOR in meson64_common.inc if not already set by the board.conf - Add some ${bootargs} debugging to mainline/default boot-meson64.cmd Signed-off-by: Ricardo Pardini --- config/boards/odroidn2.conf | 24 +++- config/bootscripts/boot-meson64.cmd | 14 ++- .../bootscripts/boot-odroid-n2-mainline.ini | 112 ------------------ .../families/include/meson64_common.inc | 7 +- config/sources/families/meson-g12b.conf | 46 ++++--- config/sources/families/meson-sm1.conf | 1 + 6 files changed, 66 insertions(+), 138 deletions(-) delete mode 100644 config/bootscripts/boot-odroid-n2-mainline.ini diff --git a/config/boards/odroidn2.conf b/config/boards/odroidn2.conf index 8a087a5ef..78b7bcf17 100644 --- a/config/boards/odroidn2.conf +++ b/config/boards/odroidn2.conf @@ -1,12 +1,26 @@ # Amlogic S922X hexa core 2GB/4GB RAM SoC 1.8-2.4Ghz eMMC GBE USB3 SPI RTC BOARD_NAME="Odroid N2" BOARDFAMILY="meson-g12b" -BOOTCONFIG="odroidn2_config" -CPUMIN=1000000 -CPUMAX=2400000 -MODULES_LEGACY="media_clock firmware #decoder_common #stream_input #amvdec_mh264 #amvdec_h264 #amvdec_h264mvc #amvdec_h265 #amvdec_mmjpeg #amvdec_mpeg12 #amvdec_mmpeg4 #amvdec_mpeg4 #amvdec_vc1 #amvdec_vp9" -MODULES_BLACKLIST_LEGACY="spidev spi_gpio spi_bitbang" KERNEL_TARGET="legacy,current,edge" FULL_DESKTOP="yes" FORCE_BOOTSCRIPT_UPDATE="yes" BOOT_LOGO="desktop" + +# Odroid N2 requires Odroid's u-boot for stable operation for mainline kernel +# and also for legacy booting. These vars will be handled by the family (meson-g12b.conf) +# and possibibly in the future will be refactored into VENDOR=odroid. +# 'edge' should use mainline, allowing for stabilizing development. +USE_ODROID_UBOOT="legacy,current" +BOOTCONFIG="odroid-n2_defconfig" # For mainline uboot +BOOTCONFIG_ODROID="odroidn2_config" # For odroid uboot +BOOTSCRIPT_ODROID="boot-odroid-n2.ini:boot.ini" # For odroid uboot, default BOOTSCRIPT is boot-meson64.cmd for mainline (in meson64_common.inc) + +# MAX might be different for N2/N2+, for now use N2+'s +CPUMIN=1000000 +CPUMAX=2400000 +GOVERNOR=ondemand # some people recommend performance to avoid random hangs after 24+ hours running. + +# U-boot has detection code for the ODROID boards. +# https://github.com/u-boot/u-boot/blob/v2021.04/board/amlogic/odroid-n2/odroid-n2.c#L35-L106 +# Unfortunately it uses n2_plus instead of n2-plus as the Kernel expects it. +# So there is a hack at and around config/bootscripts/boot-meson64.cmd L90 diff --git a/config/bootscripts/boot-meson64.cmd b/config/bootscripts/boot-meson64.cmd index 287be8786..1a5025f4e 100644 --- a/config/bootscripts/boot-meson64.cmd +++ b/config/bootscripts/boot-meson64.cmd @@ -76,6 +76,15 @@ setenv max_freq_a55 "1908" #setenv max_freq_a55 "2100" setenv maxcpus "4" +# Show what uboot default fdtfile is +echo "U-boot default fdtfile: ${fdtfile}" +echo "Current variant: ${variant}" +# there is a mismatch between u-boot and kernel in the n2-plus/n2_plus DTB filename. +if test "${variant}" = "n2_plus"; then + setenv fdtfile "amlogic/meson-g12b-odroid-n2-plus.dtb" + echo "For variant ${variant}, set default fdtfile: ${fdtfile}" +fi + # legacy kernel values from boot.ini if test -e ${devtype} ${devnum} ${prefix}armbianEnv.txt; then @@ -88,6 +97,7 @@ fi if test "${devtype}" = "mmc"; then part uuid mmc ${devnum}:1 partuuid; fi if test "${console}" = "display"; then setenv consoleargs "console=tty1"; fi +echo "Current fdtfile after armbianEnv: ${fdtfile}" if test -e ${devtype} ${devnum} ${prefix}zImage; then # legacy kernel boot @@ -98,6 +108,7 @@ if test -e ${devtype} ${devnum} ${prefix}zImage; then if test "${bootlogo}" = "true"; then setenv consoleargs "bootsplash.bootfile=bootsplash.armbian ${consoleargs}"; fi setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} consoleblank=0 coherent_pool=2M loglevel=${verbosity} ${amlogic} no_console_suspend fsck.repair=yes net.ifnames=0 elevator=noop hdmimode=${hdmimode} cvbsmode=576cvbs max_freq_a55=${max_freq_a55} maxcpus=${maxcpus} voutmode=${voutmode} ${cmode} disablehpd=${disablehpd} cvbscable=${cvbscable} overscan=${overscan} ${hid_quirks} monitor_onoff=${monitor_onoff} ${cec_enable} sdrmode=${sdrmode}" + echo "Legacy bootargs: ${bootargs}" load ${devtype} ${devnum} ${k_addr} boot/zImage load ${devtype} ${devnum} ${dtb_loadaddr} boot/dtb/${fdtfile} @@ -112,9 +123,10 @@ else if test "${console}" = "display" || test "${console}" = "both"; then setenv consoleargs "console=ttyAML0,115200 console=tty1"; fi if test "${console}" = "serial"; then setenv consoleargs "console=ttyAML0,115200"; fi if test "${bootlogo}" = "true"; then setenv consoleargs "bootsplash.bootfile=bootsplash.armbian ${consoleargs}"; fi - setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} consoleblank=0 coherent_pool=2M loglevel=${verbosity} ubootpart=${partuuid} libata.force=noncq usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}" + setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} consoleblank=0 coherent_pool=2M loglevel=${verbosity} ubootpart=${partuuid} libata.force=noncq usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}" if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=memory swapaccount=1"; fi + echo "Mainline bootargs: ${bootargs}" load ${devtype} ${devnum} ${ramdisk_addr_r} ${prefix}uInitrd load ${devtype} ${devnum} ${kernel_addr_r} ${prefix}Image diff --git a/config/bootscripts/boot-odroid-n2-mainline.ini b/config/bootscripts/boot-odroid-n2-mainline.ini deleted file mode 100644 index 904c00fff..000000000 --- a/config/bootscripts/boot-odroid-n2-mainline.ini +++ /dev/null @@ -1,112 +0,0 @@ -ODROIDN2-UBOOT-CONFIG - -setenv rootdev "/dev/mmcblk0p1" -setenv rootfstype "ext4" - -# Default Console Device Setting -setenv condev "console=ttyAML0,115200n8 console=tty1 loglevel=1" # on both - -# Auto Detection of Monitor settings based on your Screen information -setenv display_autodetect "true" - -# HDMI Mode -# Resolution Configuration -# Symbol | Resolution -# ----------------------+------------- -# "480x320p60hz" | 480x320 Progressive 60Hz -# "480p60hz" | 720x480 Progressive 60Hz -# "576p50hz" | 720x576 Progressive 50Hz -# "720p60hz" | 1280x720 Progressive 60Hz -# "720p50hz" | 1280x720 Progressive 50Hz -# "1080p60hz" | 1920x1080 Progressive 60Hz -# "1080p50hz" | 1920x1080 Progressive 50Hz -# "1080p30hz" | 1920x1080 Progressive 30Hz -# "1080p24hz" | 1920x1080 Progressive 24Hz -# "1080i60hz" | 1920x1080 Interlaced 60Hz -# "1080i50hz" | 1920x1080 Interlaced 50Hz -# "2160p60hz" | 3840x2160 Progressive 60Hz -# "2160p50hz" | 3840x2160 Progressive 50Hz -# "2160p30hz" | 3840x2160 Progressive 30Hz -# "2160p25hz" | 3840x2160 Progressive 25Hz -# "2160p24hz" | 3840x2160 Progressive 24Hz -# "smpte24hz" | 3840x2160 Progressive 24Hz SMPTE -# "2160p60hz420" | 3840x2160 Progressive 60Hz YCbCr 4:2:0 -# "2160p50hz420" | 3840x2160 Progressive 50Hz YCbCr 4:2:0 -# "640x480p60hz" | 640x480 Progressive 60Hz -# "800x480p60hz" | 800x480 Progressive 60Hz -# "800x600p60hz" | 800x600 Progressive 60Hz -# "1024x600p60hz" | 1024x600 Progressive 60Hz -# "1024x768p60hz" | 1024x768 Progressive 60Hz -# "1280x800p60hz" | 1280x800 Progressive 60Hz -# "1280x1024p60hz" | 1280x1024 Progressive 60Hz -# "1360x768p60hz" | 1360x768 Progressive 60Hz -# "1440x900p60hz" | 1440x900 Progressive 60Hz -# "1600x900p60hz" | 1600x900 Progressive 60Hz -# "1600x1200p60hz" | 1600x1200 Progressive 60Hz -# "1680x1050p60hz" | 1680x1050 Progressive 60Hz -# "1920x1200p60hz" | 1920x1200 Progressive 60Hz -# "2560x1080p60hz" | 2560x1080 Progressive 60Hz -# "2560x1440p60hz" | 2560x1440 Progressive 60Hz -# "2560x1600p60hz" | 2560x1600 Progressive 60Hz -# "3440x1440p60hz" | 3440x1440 Progressive 60Hz -setenv hdmimode "1080p60hz" - -# Overscan percentage -# This value scales down the actual screen size by the percentage below -# valid range is 80 to 100 -setenv overscan "100" - -### voutmode : hdmi or dvi -setenv voutmode "hdmi" -# setenv voutmode "dvi" - -# HPD enable/disable option -setenv disablehpd "false" - -# max cpu frequency for big core, A73 in MHz unit -# setenv max_freq_a73 "2004" # 2.004 GHz -# setenv max_freq_a73 "1992" # 1.992 GHz -# setenv max_freq_a73 "1908" # 1.908 GHz -setenv max_freq_a73 "1800" # 1.8 GHz, default value -# setenv max_freq_a73 "1704" # 1.704 GHz - -# max cpu frequency for little core, A53 in MHz unit -# setenv max_freq_a53 "1992" # 1.992 GHz -setenv max_freq_a53 "1896" # 1.896 GHz, default value -# setenv max_freq_a53 "1704" # 1.704 GHz - - -# max cpu-cores -# Note: -# CPU's 0 and 1 are the A53 (small cores) -# CPU's 2 to 5 are the A73 (big cores) -# Lowering this value disables only the bigger cores (the last cores). -# setenv maxcpus "4" -# setenv maxcpus "5" -setenv maxcpus "6" - -# Bootlogo -setenv bootlogo "false" - -### Normal HDMI Monitors -if test "${display_autodetect}" = "true"; then hdmitx edid; fi -if test "${hdmimode}" = "custombuilt"; then setenv cmode "modeline=${modeline}"; fi -if ext4load mmc ${devno}:1 0x44000000 /boot/armbianEnv.txt || fatload mmc ${devno}:1 0x44000000 armbianEnv.txt || ext4load mmc ${devno}:1 0x44000000 armbianEnv.txt; then env import -t 0x44000000 ${filesize}; fi - -# Boot Args -if test "${bootlogo}" = "true"; then setenv bootsplash "bootsplash.bootfile=bootsplash.armbian"; fi -setenv bootargs "root=${rootdev} rootwait ${bootsplash} rootflags=data=writeback rw clk_ignore_unused rootfstype=${rootfstype} ${condev} ${amlogic} no_console_suspend fsck.repair=yes net.ifnames=0 elevator=noop hdmimode=${hdmimode} cvbsmode=576cvbs max_freq_a53=${max_freq_a53} max_freq_a73=${max_freq_a73} maxcpus=${maxcpus} voutmode=${voutmode} ${cmode} disablehpd=${disablehpd} cvbscable=${cvbscable} overscan=${overscan}" - -# Set load addresses -setenv dtb_loadaddr "0x1000000" -setenv k_addr "0x01080000" -setenv loadaddr "0x1B00000" -setenv initrd_loadaddr "0x3700000" - -# Load kernel, dtb and initrd -ext4load mmc ${devno}:1 ${k_addr} boot/uImage -ext4load mmc ${devno}:1 ${dtb_loadaddr} boot/dtb/amlogic/meson-g12b-odroid-n2.dtb -ext4load mmc ${devno}:1 ${initrd_loadaddr} boot/uInitrd - -# boot -bootm ${k_addr} ${initrd_loadaddr} ${dtb_loadaddr} diff --git a/config/sources/families/include/meson64_common.inc b/config/sources/families/include/meson64_common.inc index da52f11c3..108436cff 100644 --- a/config/sources/families/include/meson64_common.inc +++ b/config/sources/families/include/meson64_common.inc @@ -15,9 +15,10 @@ if [[ $BOARD == lafrite ]]; then UBOOT_TARGET_MAP="u-boot-dtb.img;;u-boot.bin:u-boot.bin u-boot-dtb.img" fi -CPUMIN=500000 -CPUMAX=1536000 -GOVERNOR=ondemand +# Set CPUMIN et al if not already set in the board config. +CPUMIN=${CPUMIN:-500000} +CPUMAX=${CPUMAX:-1536000} +GOVERNOR=${GOVERNOR:-ondemand} case $BRANCH in diff --git a/config/sources/families/meson-g12b.conf b/config/sources/families/meson-g12b.conf index a559f6943..13d05c3f5 100644 --- a/config/sources/families/meson-g12b.conf +++ b/config/sources/families/meson-g12b.conf @@ -1,24 +1,36 @@ source "${BASH_SOURCE%/*}/include/meson64_common.inc" ASOUND_STATE="asound.state.meson64" -UBOOT_TARGET_MAP=';;sd_fuse/u-boot.bin' + [[ ${BRANCH} == legacy ]] && SERIALCON=ttyS0 -UBOOT_USE_GCC='< 4.9' -UBOOT_TOOLCHAIN2="arm-none-eabi-:< 5.0" -UBOOT_COMPILER="aarch64-none-elf-" -BOOTSOURCE='https://github.com/hardkernel/u-boot.git' -BOOTBRANCH='branch:odroidg12-v2015.01' -BOOTPATCHDIR='u-boot-odroid' -BOOTDIR='u-boot-odroid' +if [[ -n ${USE_ODROID_UBOOT} ]] && [[ "${USE_ODROID_UBOOT}" == *"${BRANCH}"* ]]; then + # Current BRANCH is listed in USE_ODROID_UBOOT; use _ODROID variants if set. + BOOTCONFIG="${BOOTCONFIG_ODROID:-${BOOTCONFIG}}" + BOOTSCRIPT="${BOOTSCRIPT_ODROID:-${BOOTSCRIPT}}" -UBOOT_TARGET_MAP=';;sd_fuse/u-boot.bin' -BOOTSCRIPT="boot-odroid-n2.ini:boot.ini" + # Enable Odroid's legacy u-boot building. This requires old toolchains etc, but does NOT require FIP trees. + UBOOT_TARGET_MAP=';;sd_fuse/u-boot.bin' + UBOOT_USE_GCC='< 4.9' + UBOOT_TOOLCHAIN2="arm-none-eabi-:< 5.0" + UBOOT_COMPILER="aarch64-none-elf-" -CPUMIN=1000000 -CPUMAX=2400000 -GOVERNOR=ondemand + BOOTSOURCE='https://github.com/hardkernel/u-boot.git' + BOOTBRANCH='branch:odroidg12-v2015.01' + BOOTPATCHDIR='u-boot-odroid' + BOOTDIR='u-boot-odroid' -write_uboot_platform() -{ - dd if=$1/u-boot.bin of=$2 bs=512 seek=1 conv=fsync > /dev/null 2>&1 -} + write_uboot_platform() { + dd if=$1/u-boot.bin of=$2 bs=512 seek=1 conv=fsync >/dev/null 2>&1 + } + +else + # Mainline u-boot, everything is done by meson64_common.inc, we just need to handle FIP blobs + + # Handling of FIP blobs + uboot_custom_postprocess() { + # FIP trees 'odroid-n2-plus' and 'odroid-n2' are identical. + if [[ $BOARD == odroidn2* ]]; then + uboot_g12_postprocess "$SRC"/cache/sources/amlogic-boot-fip/odroid-n2 g12b + fi + } +fi diff --git a/config/sources/families/meson-sm1.conf b/config/sources/families/meson-sm1.conf index 5cc381c46..77287a0f6 100644 --- a/config/sources/families/meson-sm1.conf +++ b/config/sources/families/meson-sm1.conf @@ -13,6 +13,7 @@ family_tweaks() uboot_custom_postprocess() { + # FIP trees for C4 and HC4 are identical as of 30/06/2021 if [[ $BOARD == odroid-c4 ]]; then uboot_g12_postprocess $SRC/cache/sources/amlogic-boot-fip/odroid-c4 g12a fi