Skip to content
Draft
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
99f551c
add initial support for jupiter
Owen-sz Oct 3, 2025
f5f6809
Merge branch 'trunk' into owen/add-jupiter-dev-image
Owen-sz Oct 9, 2025
00278bf
flake: fix duplicate }
Owen-sz Oct 9, 2025
cb1697b
fix flake spacing
Owen-sz Oct 9, 2025
20dc582
fix missing input thing
Owen-sz Oct 9, 2025
19228a4
add license headers to jupiter nix files
Owen-sz Oct 9, 2025
9263f78
add license headers to jupiter cfg file
Owen-sz Oct 9, 2025
e7e1404
add juiter u-boot.txt to REUSE.toml
Owen-sz Oct 9, 2025
b17d347
oops need comma
Owen-sz Oct 9, 2025
d2dda41
add license header to opensbi jupiter patch
Owen-sz Oct 9, 2025
c85372b
Clean up unused lines in genimage file
Owen-sz Oct 9, 2025
517871b
add BSD-3-Clause license file to LICENSES folder
Owen-sz Oct 9, 2025
b4aaf48
add BSD-2-Clause license file to LICENSES folder, remove BSD-3-Clause…
Owen-sz Oct 9, 2025
d9b9e70
fix jupiter package call line in nix flake
Owen-sz Oct 14, 2025
9811ce5
add jupiter to all-images
Owen-sz Oct 31, 2025
78b56ad
fix builds lol, specify genimage thingy
Owen-sz Oct 31, 2025
7b44a8b
fix broken link outputs by renaming img output thing
Owen-sz Oct 31, 2025
da02148
update nixos version needed for genimage
Owen-sz Nov 20, 2025
1c4832e
remove comments in opensbi.nix
Owen-sz Nov 20, 2025
e19c774
fix inputs formatting in flake.nix
Owen-sz Dec 4, 2025
a1c305b
update u-boot.txt
Owen-sz Dec 4, 2025
960032a
Merge branch 'trunk' into owen/add-jupiter-dev-image
Owen-sz Dec 4, 2025
8b5a592
update partition type in jupiter genimage to u-boot-env
Owen-sz Dec 4, 2025
cc0e07d
formating
Owen-sz Dec 4, 2025
15e6ae8
update nix flake
Owen-sz Dec 4, 2025
2da927a
Merge remote-tracking branch 'origin/trunk' into owen/add-jupiter-dev…
Owen-sz Feb 13, 2026
63fe92e
Align to Jupiter hardware
Owen-sz Feb 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions LICENSES/BSD-2-Clause.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
2 changes: 1 addition & 1 deletion REUSE.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version = 1

[[annotations]]
path = [".devcontainer/devcontainer.json", "src/image-milkv-duos-sd/u-boot.txt"]
path = [".devcontainer/devcontainer.json", "src/image-milkv-duos-sd/u-boot.txt", "src/image-milkv-jupiter/u-boot.txt"]
precedence = "aggregate"
SPDX-FileCopyrightText = "2025 ukoOS Contributors"
SPDX-License-Identifier = "GPL-3.0-or-later"
Expand Down
27 changes: 26 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 26 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@
# SPDX-License-Identifier: GPL-3.0-or-later

{
inputs.u-boot-milkv-duos-sd = {
url = "github:UMN-Kernel-Object/u-boot/milkv-duos-sd";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
inputs = {
u-boot-milkv-duos-sd = {
url = "github:UMN-Kernel-Object/u-boot/milkv-duos-sd";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
u-boot-spacemit-k1 = {
url = "github:UMN-Kernel-Object/u-boot/spacemit-k1";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
};
outputs =
Expand All @@ -16,6 +25,7 @@
flake-utils,
nixpkgs,
u-boot-milkv-duos-sd,
u-boot-spacemit-k1,
}:
flake-utils.lib.eachDefaultSystem (
system:
Expand All @@ -30,6 +40,7 @@
];
all-image-targets = [
"milkv-duos-sd"
"milkv-jupiter"
];

ukoos =
Expand Down Expand Up @@ -129,6 +140,16 @@
u-boot-milkv-duos-sd = u-boot-milkv-duos-sd.packages.${system}.default;
ukoos-milkv-duos = packages."ukoos/milkv-duos";
};
"dev-image/milkv-jupiter" = pkgs.callPackage ./src/image-milkv-jupiter {
dev = true;
u-boot-spacemit-k1 = u-boot-spacemit-k1.packages.${system}.default;
ukoos-milkv-jupiter = packages."ukoos/milkv-jupiter";
};
"image/milkv-jupiter" = pkgs.callPackage ./src/image-milkv-jupiter {
dev = false;
u-boot-spacemit-k1 = u-boot-spacemit-k1.packages.${system}.default;
ukoos-milkv-jupiter = packages."ukoos/milkv-jupiter";
};
};
}
);
Expand Down
60 changes: 60 additions & 0 deletions src/image-milkv-jupiter/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# SPDX-FileCopyrightText: 2025 ukoOS Contributors
#
# SPDX-License-Identifier: GPL-3.0-or-later

{
dev ? false,
u-boot-spacemit-k1,

callPackage,
lib,
pkgsCross,
stdenvNoCC,

dosfstools,
genimage,
mtools,
ukoos-milkv-jupiter,
}:

stdenvNoCC.mkDerivation (self: {
pname = "image-milkv-jupiter" + (if dev then "-dev" else "");
inherit (ukoos-milkv-jupiter) version;

nativeBuildInputs = [
dosfstools
genimage
mtools
u-boot-spacemit-k1
];

dontUnpack = true;
buildPhase = ''
runHook preBuild

${lib.optionalString (!dev) ''
install -Dt root/boot ${ukoos-milkv-jupiter}/sys/kernel.elf
''}
install -Dt input ${u-boot-spacemit-k1}/FSBL.bin
install -Dt input ${u-boot-spacemit-k1}/u-boot.itb
install -Dt input ${u-boot-spacemit-k1}/bootinfo_sd.bin
install -Dt input ${self.passthru.opensbi-milkv-jupiter}/fw_dynamic.itb
mkenvimage -s 0x20000 -o input/uboot.env ${./u-boot.txt}
genimage --config ${./genimage.cfg}

runHook postBuild
'';
installPhase = ''
runHook preInstall

install -Dt $out -m 0644 images/ukoos.img

runHook postInstall
'';

passthru = {
opensbi-milkv-jupiter = pkgsCross.riscv64-musl.callPackage ./opensbi.nix {
u-boot = u-boot-spacemit-k1;
};
};
})
37 changes: 37 additions & 0 deletions src/image-milkv-jupiter/genimage.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-FileCopyrightText: 2025 ukoOS Contributors
#
# SPDX-License-Identifier: GPL-3.0-or-later

image ukoos.img {
hdimage {
partition-table-type = "gpt"
}
partition bootinfo {
offset = 0
in-partition-table = false
image = "bootinfo_sd.bin"
size = 80
}
partition fsbl {
offset = "128K"
image = "FSBL.bin"
size = 256K
}
partition env {
# When we can use genimage version 19, replace with 'u-boot-env,' version 19 will come with NixOS 25.11
partition-type-uuid = "3de21764-95bd-54bd-a5c3-4abe786f38a8"
offset = "384K"
image = "uboot.env"
size = 256K
}
partition opensbi {
offset = "1M"
image = "fw_dynamic.itb"
size = 1M
}
partition uboot {
offset = "2M"
image = "u-boot.itb"
size = 2M
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
SPDX-FileCopyrightText: 2024 Michael Neuling <michaelneuling@tenstorrent.com>

SPDX-License-Identifier: BSD-2-Clause

From 9d9464268a0bb3a627240197575609eb9e02ca42 Mon Sep 17 00:00:00 2001
From: Michael Neuling <michaelneuling@tenstorrent.com>
Date: Sat, 21 Dec 2024 21:38:50 +0530
Subject: [PATCH] include: sbi: Fix compiling with C23 enabled compilers

C23 pre-defines bool so we need to gate our defines.

Signed-off-by: Michael Neuling <michaelneuling@tenstorrent.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
---
include/sbi/sbi_types.h | 10 ++++++----
platform/generic/andes/andes_sbi.c | 2 +-
2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/include/sbi/sbi_types.h b/include/sbi/sbi_types.h
index def88bba..6ad902e1 100644
--- a/include/sbi/sbi_types.h
+++ b/include/sbi/sbi_types.h
@@ -44,7 +44,12 @@ typedef unsigned long long uint64_t;
#error "Unexpected __riscv_xlen"
#endif

-typedef int bool;
+#if __STDC_VERSION__ < 202000L
+typedef _Bool bool;
+#define true 1
+#define false 0
+#endif
+
typedef unsigned long ulong;
typedef unsigned long uintptr_t;
typedef unsigned long size_t;
@@ -61,9 +66,6 @@ typedef uint32_t be32_t;
typedef uint64_t le64_t;
typedef uint64_t be64_t;

-#define true 1
-#define false 0
-
#define NULL ((void *)0)

#define __packed __attribute__((packed))
diff --git a/platform/generic/andes/andes_sbi.c b/platform/generic/andes/andes_sbi.c
index 3e89fb9c..037d7cdf 100644
--- a/platform/generic/andes/andes_sbi.c
+++ b/platform/generic/andes/andes_sbi.c
@@ -29,7 +29,7 @@ static bool andes45_iocp_disabled(void)

static bool andes45_apply_iocp_sw_workaround(void)
{
- return andes45_cache_controllable() & andes45_iocp_disabled();
+ return andes45_cache_controllable() && andes45_iocp_disabled();
}

int andes_sbi_vendor_ext_provider(long funcid,
--
2.51.0

66 changes: 66 additions & 0 deletions src/image-milkv-jupiter/opensbi.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# SPDX-FileCopyrightText: 2025 ukoOS Contributors
#
# SPDX-License-Identifier: GPL-3.0-or-later

{
u-boot,

dtc,
fetchgit,
pkgsCross,
stdenvNoCC,
python3
}:

stdenvNoCC.mkDerivation {
pname = "opensbi";
version = "2.2.27";

src =
fetchgit {
url = "https://gitee.com/bianbu-linux/opensbi.git";
hash = "sha256-Vd/a1gIP3bBqLpmz5HAU6HyrK5SuFDnI2m1T2DrtkwE=";
};
patches = [
./opensbi-patches/0001-include-sbi-Fix-compiling-with-C23-enabled-compilers.patch
];

nativeBuildInputs = [
dtc
pkgsCross.riscv64-musl.stdenv.cc.bintools.bintools
pkgsCross.riscv64-musl.stdenv.cc.cc
python3
u-boot
];

patchPhase =''
runHook prePatch

patchShebangs .

runHook postPatch
'';

buildPhase = ''
runHook preBuild

make \
''${enableParallelBuilding:+-j''${NIX_BUILD_CORES}} \
ARCH=riscv \
CROSS_COMPILE=riscv64-unknown-linux-musl- \
PLATFORM=generic \
PLATFORM_DEFCONFIG=k1_defconfig

runHook postBuild
'';

installPhase = ''
runHook preInstall

install -Dt $out -m 0644 build/platform/generic/firmware/fw_dynamic.itb

runHook postInstall
'';

enableParallelBuilding = true;
}
20 changes: 20 additions & 0 deletions src/image-milkv-jupiter/u-boot.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
autoload=0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs testing on real hw; lmk when you did

autostart=no
bootdelay=0
bootfile=kernel.elf
loadaddr=0x200000
startaddr=0x80080000

bootcmd=run custom_bootcmd || bootmenu

bootmenu_0=Default boot order=run bootcmd_sd || run bootcmd_emmc || while true; do run bootcmd_net; done

bootmenu_1=Boot from SD=run bootcmd_sd
bootcmd_sd=echo Trying to boot from SD...; mmc dev 0 && fatload mmc 0 ${loadaddr} ${bootfile} && bootelf -p ${loadaddr} && gok ${startaddr} ${fdtcontroladdr}

bootmenu_2=Boot from eMMC=run bootcmd_emmc
bootcmd_emmc=echo Trying to boot from eMMC...; mmc dev 1 && fatload mmc 1 ${loadaddr} ${bootfile} && bootelf -p ${loadaddr} && gok ${startaddr} ${fdtcontroladdr}

bootmenu_3=Boot from Ethernet (TFTP)=run bootcmd_net
bootcmd_net=echo Running a TFTP server...; run get_ip && tftpsrv ${loadaddr} && bootelf -p ${loadaddr} && gok ${startaddr} ${fdtcontroladdr}
get_ip=dhcp || linklocal
Loading