Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
!/.gitignore
!/.gitmodules
!/.github
!/iob_linux.py
!/config.mk
!/Dockerfile
!/Makefile
Expand Down
21 changes: 12 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
LINUX_OS_DIR ?= $(CURDIR)
OS_SOFTWARE_DIR := $(LINUX_OS_DIR)/software
OS_BUILD_DIR ?= $(OS_SOFTWARE_DIR)/OS_build
OPENSBI_PLATFORM_DIR ?= $(OS_SOFTWARE_DIR)/opensbi_platform/iob_soc
OPENSBI_PLATFORM:=$(shell basename $(OPENSBI_PLATFORM_DIR))
OS_SUBMODULES_DIR := $(LINUX_OS_DIR)/submodules
MACROS_FILE ?= $(LINUX_OS_DIR)/build_macros.txt
REL_BUILD_DIR :=`realpath $(OS_BUILD_DIR) --relative-to=$(LINUX_OS_DIR)`
Expand All @@ -13,10 +15,10 @@ $(OS_BUILD_DIR):

## OpenSBI Linux on RISC-V stage 1 Bootloader (Implements the SBI interface)
build-opensbi: clean-opensbi $(OS_BUILD_DIR)
cp -r $(OS_SOFTWARE_DIR)/opensbi_platform/* $(OS_SUBMODULES_DIR)/OpenSBI/platform/
$(LINUX_OS_DIR)/scripts/replace_macros.py $(OS_SUBMODULES_DIR)/OpenSBI/platform/iob_soc/platform.c $(MACROS_FILE)
CROSS_COMPILE=riscv64-unknown-linux-gnu- $(MAKE) -C $(OS_SUBMODULES_DIR)/OpenSBI run PLATFORM=iob_soc OS_BUILD_DIR=../../$(REL_BUILD_DIR)
rm -r $(OS_SUBMODULES_DIR)/OpenSBI/platform/iob_soc/
cp -r $(OPENSBI_PLATFORM_DIR) $(OS_SUBMODULES_DIR)/OpenSBI/platform/
$(LINUX_OS_DIR)/scripts/replace_macros.py $(OS_SUBMODULES_DIR)/OpenSBI/platform/$(OPENSBI_PLATFORM)/platform.c $(MACROS_FILE)
CROSS_COMPILE=riscv64-unknown-linux-gnu- $(MAKE) -C $(OS_SUBMODULES_DIR)/OpenSBI run PLATFORM=$(OPENSBI_PLATFORM) OS_BUILD_DIR=../../$(REL_BUILD_DIR)
rm -r $(OS_SUBMODULES_DIR)/OpenSBI/platform/$(OPENSBI_PLATFORM)/

## Linux Kernel Makefile Variables and Targets
LINUX_VERSION?=5.15.98
Expand All @@ -37,13 +39,14 @@ $(LINUX_DIR):
@wget https://cdn.kernel.org/pub/linux/kernel/v5.x/$(LINUX_NAME).tar.xz && \
tar -xf $(LINUX_NAME).tar.xz -C $(OS_SUBMODULES_DIR)

## IOb-SoC Device Tree target
## Device Tree target
DTS_FILE ?= $(OS_SOFTWARE_DIR)/iob_soc.dts
SYSTEM_NAME := $(basename $(notdir $(DTS_FILE)))
build-dts: $(OS_BUILD_DIR)
cp $(DTS_FILE) $(OS_BUILD_DIR)/iob_soc_tmp.dts
$(LINUX_OS_DIR)/scripts/replace_macros.py $(OS_BUILD_DIR)/iob_soc_tmp.dts $(MACROS_FILE)
dtc -O dtb -o $(OS_BUILD_DIR)/iob_soc.dtb $(OS_BUILD_DIR)/iob_soc_tmp.dts
rm $(OS_BUILD_DIR)/iob_soc_tmp.dts
cp $(DTS_FILE) $(OS_BUILD_DIR)/$(SYSTEM_NAME)_tmp.dts
$(LINUX_OS_DIR)/scripts/replace_macros.py $(OS_BUILD_DIR)/$(SYSTEM_NAME)_tmp.dts $(MACROS_FILE)
dtc -O dtb -o $(OS_BUILD_DIR)/$(SYSTEM_NAME).dtb $(OS_BUILD_DIR)/$(SYSTEM_NAME)_tmp.dts
rm $(OS_BUILD_DIR)/$(SYSTEM_NAME)_tmp.dts

## Buildroot Makefile Variables and Targets
BUILDROOT_VERSION=buildroot-2022.02.10
Expand Down
23 changes: 23 additions & 0 deletions iob_linux/iob_linux.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SPDX-FileCopyrightText: 2025 IObundle
#
# SPDX-License-Identifier: MIT

import os
import shutil


def setup(py_params_dict):
# Copy iob_linux to the build dir submodules/
src = os.path.join(os.path.dirname(__file__), "..")
dst = os.path.join(py_params_dict["build_dir"], "submodules/iob_linux")
os.makedirs(os.path.dirname(dst), exist_ok=True)
shutil.copytree(src, dst, dirs_exist_ok=True)
# Hack for Nix: Files copied from Nix's py2hwsw package do not contain write permissions
os.system("chmod -R ug+w " + dst)

attributes_dict = {
"generate_hw": False,
"instantiate": False,
}

return attributes_dict
4 changes: 4 additions & 0 deletions scripts/replace_macros.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env python3

"""
Replace macros/placeholders inside a file with their corresponding value.
"""

import re
import sys

Expand Down
2 changes: 1 addition & 1 deletion scripts/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pkgs.mkShell {
bash
gnumake
dtc
(callPackage ./riscv-gnu-toolchain.nix { })
(callPackage ./scripts/riscv-gnu-toolchain.nix { })
# Linux kernel build packages
libyaml
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
# Script to verify linux functioning
echo "Test passed!" > /tmp/test.log
# Send file via UART with Zmodem
echo "Transfering 'test.log' file via ZMODEM. Press Ctrl-X five or more times during the transfer to abort."
sz -e /tmp/test.log