-
Notifications
You must be signed in to change notification settings - Fork 4
add: initial support for Milk-V Jupiter/SpacemiT K1 #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Owen-sz
wants to merge
27
commits into
UMN-Kernel-Object:trunk
Choose a base branch
from
Owen-sz:owen/add-jupiter-dev-image
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
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 f5f6809
Merge branch 'trunk' into owen/add-jupiter-dev-image
Owen-sz 00278bf
flake: fix duplicate }
Owen-sz cb1697b
fix flake spacing
Owen-sz 20dc582
fix missing input thing
Owen-sz 19228a4
add license headers to jupiter nix files
Owen-sz 9263f78
add license headers to jupiter cfg file
Owen-sz e7e1404
add juiter u-boot.txt to REUSE.toml
Owen-sz b17d347
oops need comma
Owen-sz d2dda41
add license header to opensbi jupiter patch
Owen-sz c85372b
Clean up unused lines in genimage file
Owen-sz 517871b
add BSD-3-Clause license file to LICENSES folder
Owen-sz b4aaf48
add BSD-2-Clause license file to LICENSES folder, remove BSD-3-Clause…
Owen-sz d9b9e70
fix jupiter package call line in nix flake
Owen-sz 9811ce5
add jupiter to all-images
Owen-sz 78b56ad
fix builds lol, specify genimage thingy
Owen-sz 7b44a8b
fix broken link outputs by renaming img output thing
Owen-sz da02148
update nixos version needed for genimage
Owen-sz 1c4832e
remove comments in opensbi.nix
Owen-sz e19c774
fix inputs formatting in flake.nix
Owen-sz a1c305b
update u-boot.txt
Owen-sz 960032a
Merge branch 'trunk' into owen/add-jupiter-dev-image
Owen-sz 8b5a592
update partition type in jupiter genimage to u-boot-env
Owen-sz cc0e07d
formating
Owen-sz 15e6ae8
update nix flake
Owen-sz 2da927a
Merge remote-tracking branch 'origin/trunk' into owen/add-jupiter-dev…
Owen-sz 63fe92e
Align to Jupiter hardware
Owen-sz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }; | ||
| }; | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } | ||
62 changes: 62 additions & 0 deletions
62
...v-jupiter/opensbi-patches/0001-include-sbi-Fix-compiling-with-C23-enabled-compilers.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| autoload=0 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.