From 073f1c9bbdda63ff4bc9fe0ddbb7ec1d50e58d4f Mon Sep 17 00:00:00 2001 From: Florian Agbuya Date: Wed, 14 Feb 2024 14:53:18 +0800 Subject: [PATCH] device tree source from u-boot and cleanup --- fast-servo/u-boot.patch | 26 +++++++------- flake.nix | 79 ++++++++++++++++++++++------------------- pr-28.patch | 7 +--- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/fast-servo/u-boot.patch b/fast-servo/u-boot.patch index 6d960bb..bd6d17f 100644 --- a/fast-servo/u-boot.patch +++ b/fast-servo/u-boot.patch @@ -1,31 +1,31 @@ diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile -index 480269fa60..df94fc1213 100644 +index 480269fa60..64b20e4200 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile -@@ -333,6 +333,7 @@ dtb-$(CONFIG_ARCH_UNIPHIER_SLD8) += \ - uniphier-sld8-ref.dtb - - dtb-$(CONFIG_ARCH_ZYNQ) += \ -+ fast-servo.dtb \ - bitmain-antminer-s9.dtb \ - zynq-cc108.dtb \ - zynq-cse-nand.dtb \ +@@ -339,6 +339,7 @@ dtb-$(CONFIG_ARCH_ZYNQ) += \ + zynq-cse-nor.dtb \ + zynq-cse-qspi-single.dtb \ + zynq-dlc20-rev1.0.dtb \ ++ zynq-fast-servo.dtb \ + zynq-microzed.dtb \ + zynq-minized.dtb \ + zynq-picozed.dtb \ diff --git a/configs/xilinx_zynq_virt_defconfig b/configs/xilinx_zynq_virt_defconfig -index 474abc7f6b..5fc86fabfe 100644 +index 474abc7f6b..6e6bbd4aab 100644 --- a/configs/xilinx_zynq_virt_defconfig +++ b/configs/xilinx_zynq_virt_defconfig @@ -80,6 +80,7 @@ CONFIG_CMD_MTDPARTS_SPREAD=y CONFIG_CMD_MTDPARTS_SHOW_NET_SIZES=y CONFIG_CMD_UBI=y CONFIG_OF_BOARD=y -+CONFIG_SYS_CONFIG_NAME="fast-servo" ++CONFIG_SYS_CONFIG_NAME="zynq-fast-servo" CONFIG_OF_LIST="zynq-zc702 zynq-zc706 zynq-zc770-xm010 zynq-zc770-xm011 zynq-zc770-xm011-x16 zynq-zc770-xm012 zynq-zc770-xm013 zynq-cc108 zynq-microzed zynq-minized zynq-picozed zynq-zed zynq-zturn zynq-zturn-v5 zynq-zybo zynq-zybo-z7 zynq-dlc20-rev1.0" CONFIG_ENV_IS_NOWHERE=y CONFIG_ENV_IS_IN_FAT=y -diff --git a/include/configs/fast-servo.h b/include/configs/fast-servo.h +diff --git a/include/configs/zynq-fast-servo.h b/include/configs/zynq-fast-servo.h new file mode 100644 index 0000000000..0aa486a2b7 --- /dev/null -+++ b/include/configs/fast-servo.h ++++ b/include/configs/zynq-fast-servo.h @@ -0,0 +1 @@ +#include diff --git a/flake.nix b/flake.nix index 2e62851..54f8626 100644 --- a/flake.nix +++ b/flake.nix @@ -204,6 +204,39 @@ dontFixup = true; }; + u-boot = { board ? "zc706" }: (pkgs.pkgsCross.armv7l-hf-multiplatform.buildUBoot { + defconfig = "xilinx_zynq_virt_defconfig"; + patches = [] ++ pkgs.lib.optional (board == "fast-servo") ./fast-servo/u-boot.patch; + preConfigure = '' + export DEVICE_TREE=zynq-${board} + ''; + extraConfig = '' + CONFIG_SYS_PROMPT="${board}-boot> " + CONFIG_AUTOBOOT=y + CONFIG_BOOTCOMMAND="${builtins.replaceStrings [ "\n" ] [ "; " ] '' + setenv bootargs 'root=/dev/mmcblk0p2 console=ttyPS0,115200n8 systemConfig=${builtins.unsafeDiscardStringContext not-os-cfg.build.toplevel}' + fatload mmc 0 0x6400000 uImage + fatload mmc 0 0x8000000 ${board}.dtb + fatload mmc 0 0xA400000 uRamdisk.image.gz + bootm 0x6400000 0xA400000 0x8000000 + ''}" + CONFIG_BOOTDELAY=0 + CONFIG_USE_BOOTCOMMAND=y + ''; + extraMeta.platforms = [ "armv7l-linux" ]; + filesToInstall = [ "u-boot.elf" ]; + }).overrideAttrs (oldAttrs: { + postUnpack = '' + cp ${dts-support}/fast-servo.dts $sourceRoot/arch/arm/dts/zynq-fast-servo.dts + ''; + postInstall = '' + mkdir -p $out/dts + cp arch/arm/dts/zynq-fast-servo.dts $out/dts + cp arch/arm/dts/zynq-zc706.dts $out/dts + cp arch/arm/dts/zynq-7000.dtsi $out/dts + ''; + }); + bootimage = { board ? "zc706" }: pkgs.runCommand "${board}-bootimage" { buildInputs = [ mkbootimage ]; @@ -233,47 +266,19 @@ mkdir -p $out DTSDIR=$(mktemp -d /tmp/dts-XXXXXX) cd $DTSDIR - cp ${not-os-cfg.build.kernel}/zynq-zc706.dts . - cp ${not-os-cfg.build.kernel}/zynq-7000.dtsi . - gcc -E -nostdinc -undef -D__DTS__ -x assembler-with-cpp -o zc706.dts zynq-zc706.dts + cp ${u-boot { inherit board; }}/dts/zynq-${board}.dts . - # Fast-servo dts file already pre-processed - cp ${dts-support}/fast-servo.dts . + if [ ${board} == "zc706" ]; then + mv zynq-${board}.dts zynq-${board}-top.dts + cp ${u-boot { inherit board; }}/dts/zynq-7000.dtsi . + gcc -E -nostdinc -undef -D__DTS__ -x assembler-with-cpp -o zynq-${board}.dts zynq-${board}-top.dts + fi - dtc -I dts -O dtb -o ${board}.dtb ${board}.dts - chmod +x ${board}.dtb + dtc -I dts -O dtb -o ${board}.dtb zynq-${board}.dts cp ${board}.dtb $out - rm -rf $DTSDIR ''; - u-boot = { board ? "zc706" }: (pkgs.pkgsCross.armv7l-hf-multiplatform.buildUBoot { - defconfig = "xilinx_zynq_virt_defconfig"; - patches = [] ++ pkgs.lib.optional (board == "fast-servo") ./fast-servo/u-boot.patch; - preConfigure = '' - export DEVICE_TREE=$([ "${board}" = "zc706" ] && echo "zynq-${board}" || echo "${board}") - ''; - extraConfig = '' - CONFIG_SYS_PROMPT="${board}-boot> " - CONFIG_AUTOBOOT=y - CONFIG_BOOTCOMMAND="${builtins.replaceStrings [ "\n" ] [ "; " ] '' - setenv bootargs 'root=/dev/mmcblk0p2 console=ttyPS0,115200n8 systemConfig=${builtins.unsafeDiscardStringContext not-os-cfg.build.toplevel}' - fatload mmc 0 0x6400000 uImage - fatload mmc 0 0x8000000 ${board}.dtb - fatload mmc 0 0xA400000 uRamdisk.image.gz - bootm 0x6400000 0xA400000 0x8000000 - ''}" - CONFIG_BOOTDELAY=0 - CONFIG_USE_BOOTCOMMAND=y - ''; - extraMeta.platforms = [ "armv7l-linux" ]; - filesToInstall = [ "u-boot.elf" ]; - }).overrideAttrs (oldAttrs: { - postUnpack = '' - cp ${dts-support}/fast-servo.dts $sourceRoot/arch/arm/dts/fast-servo.dts - ''; - }); - sd-image = { board ? "zc706" }: let rootfsImage = pkgs.callPackage (pkgs.path + "/nixos/lib/make-ext4-fs.nix") { storePaths = [ not-os-cfg.build.toplevel ]; @@ -376,15 +381,15 @@ packages.armv7l-linux = { not-os = not-os-cfg.build.zynq_image; zc706-fsbl = fsbl { board = "zc706"; }; + zc706-u-boot = u-boot { board = "zc706"; }; zc706-bootimage = bootimage { board = "zc706"; }; zc706-dtb = dtb { board = "zc706"; }; - zc706-u-boot = u-boot { board = "zc706"; }; zc706-sd-image = sd-image { board = "zc706"; }; zc706-qemu = not-os-qemu { board = "zc706"; }; fast-servo-fsbl = fsbl { board = "fast-servo"; }; + fast-servo-u-boot = u-boot { board = "fast-servo"; }; fast-servo-bootimage = bootimage { board = "fast-servo"; }; fast-servo-dtb = dtb { board = "fast-servo"; }; - fast-servo-u-boot = u-boot { board = "fast-servo"; }; fast-servo-sd-image = sd-image { board = "fast-servo"; }; fast-servo-qemu = not-os-qemu { board = "fast-servo"; }; }; diff --git a/pr-28.patch b/pr-28.patch index c589961..6ab2a07 100644 --- a/pr-28.patch +++ b/pr-28.patch @@ -139,7 +139,7 @@ diff --git a/zynq_image.nix b/zynq_image.nix index 3fa23ab..727e3ef 100644 --- a/zynq_image.nix +++ b/zynq_image.nix -@@ -1,66 +1,101 @@ +@@ -1,66 +1,96 @@ -{ config, pkgs, ... }: +{ lib, config, pkgs, ... }: @@ -176,11 +176,6 @@ index 3fa23ab..727e3ef 100644 - }; - customKernelPackages = pkgs.linuxPackagesFor customKernel; + }).overrideAttrs (oa: { -+ postUnpack = '' -+ mkdir -p $out -+ cp $sourceRoot/arch/arm/boot/dts/zynq-7000.dtsi $out -+ cp $sourceRoot/arch/arm/boot/dts/zynq-zc706.dts $out -+ ''; + postInstall = '' + cp arch/arm/boot/uImage $out + ${oa.postInstall}