Add fast-servo board support #24

Merged
sb10q merged 1 commits from fsagbuya/nix-servo:fast-servo into master 2024-08-17 17:37:24 +08:00
2 changed files with 34 additions and 36 deletions
Showing only changes of commit afa00efee3 - Show all commits

View File

@ -10,7 +10,6 @@
pkgs = import nixpkgs { system = "x86_64-linux"; };
not-os-cfg = not-os-configured.config.system;
fsbl-support = ./fast-servo/fsbl-support;
dts-support = ./fast-servo/dts-support;
patched-not-os = pkgs.applyPatches {
name = "not-os-patched";
@ -214,38 +213,40 @@
dontFixup = true;
};
u-boot = (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
'';
});
u-boot = let
fast-servo-dts = fast-servo/fast-servo.dts;
in (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}
fsagbuya marked this conversation as resolved Outdated
Outdated
Review

Purpose of this grossly inconsistent test?

Purpose of this grossly inconsistent test?

Updated the name of the device-tree runCommand to device-tree for clarity. This builds the device tree in two ways, one from the dts files committed to the repo and one from not-os build.

Updated the name of the device-tree runCommand to `device-tree` for clarity. This builds the device tree in two ways, one from the dts files committed to the repo and one from `not-os` build.
Outdated
Review

There should be only one source of truth for the device tree, from which other formats are built using open tools and Nix derivations.

There should be only one source of truth for the device tree, from which other formats are built using open tools and Nix derivations.

Ahh.. I get what you mean. Will revise the code to align with a more standard approach.

Ahh.. I get what you mean. Will revise the code to align with a more standard approach.
'';
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 ${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
fsagbuya marked this conversation as resolved Outdated
Outdated
Review

Why does this need to be executable?

Why does this need to be executable?

I have added this before because .dtb file from linux kernel nix build is executable. So I did it as well in fast-servo.dtb for consistency. However from testing, it also boots fine without making it executable. Will just remove this.

I have added this before because `.dtb` file from linux kernel nix build is executable. So I did it as well in fast-servo.dtb for consistency. However from testing, it also boots fine without making it executable. Will just remove this.
cp arch/arm/dts/zynq-zc706.dts $out/dts
cp arch/arm/dts/zynq-7000.dtsi $out/dts
'';
});
bootimage = pkgs.runCommand "${board}-bootimage"
{
@ -274,8 +275,6 @@
}
''
mkdir -p $out
Outdated
Review

Not needed AFAICT? You can always create temporary build files in the current directory in a Nix derivation.

Not needed AFAICT? You can always create temporary build files in the current directory in a Nix derivation.
DTSDIR=$(mktemp -d /tmp/dts-XXXXXX)
cd $DTSDIR
cp ${u-boot}/dts/zynq-${board}.dts .
if [ ${board} == "zc706" ]; then
@ -286,7 +285,6 @@
dtc -I dts -O dtb -o ${board}.dtb zynq-${board}.dts
cp ${board}.dtb $out
rm -rf $DTSDIR
'';
sd-image = let