Skip to content

Commit 26b9477

Browse files
Merge pull request #423 from trabucayre/sdcard_boot
buildroot: added rootfs.ext4 creation, updated genimage.cfg to adds rootfs as second SDCard partition
2 parents 2fb5a36 + e10f3cc commit 26b9477

File tree

8 files changed

+34
-6
lines changed

8 files changed

+34
-6
lines changed

buildroot/board/litex_vexriscv/genimage.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ image sdcard.img {
2121
bootable = "true"
2222
image = "boot.vfat"
2323
}
24+
25+
partition rootfs {
26+
partition-type = 0x83
27+
image = "rootfs.ext4"
28+
}
2429
}

buildroot/board/litex_vexriscv/post-image.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ LINUX_ON_VEXRISCV_OUT_DIR=$BR2_EXTERNAL_LITEX_VEXRISCV_PATH/../images
1010
DST_DTB=$LINUX_ON_VEXRISCV_OUT_DIR/rv32.dtb
1111
DST_OPENSBI=$LINUX_ON_VEXRISCV_OUT_DIR/opensbi.bin
1212
DST_IMAGE=$LINUX_ON_VEXRISCV_OUT_DIR/Image
13-
DST_ROOTFS=$LINUX_ON_VEXRISCV_OUT_DIR/rootfs.cpio
13+
DST_ROOTFS_CPIO=$LINUX_ON_VEXRISCV_OUT_DIR/rootfs.cpio
14+
DST_ROOTFS_EXT4=$LINUX_ON_VEXRISCV_OUT_DIR/rootfs.ext4
1415

15-
rm -f $DST_OPENSBI $DST_ROOTFS $DST_IMAGE
16+
rm -f $DST_OPENSBI $DST_ROOTFS_CPIO $DST_ROOTFS_EXT4 $DST_IMAGE
1617
ln -s $BINARIES_DIR/fw_jump.bin $DST_OPENSBI
1718
ln -s $BINARIES_DIR/Image $DST_IMAGE
18-
ln -s $BINARIES_DIR/rootfs.cpio $DST_ROOTFS
19+
ln -s $BINARIES_DIR/rootfs.cpio $DST_ROOTFS_CPIO
20+
ln -s $BINARIES_DIR/rootfs.ext4 $DST_ROOTFS_EXT4
1921

2022
if [ ! -e $DST_DTB ]; then
2123
echo ""

buildroot/configs/litex_vexriscv_defconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ BR2_TARGET_GENERIC_GETTY_PORT="console"
3030

3131
# Filesystem
3232
BR2_TARGET_ROOTFS_CPIO=y
33+
BR2_TARGET_ROOTFS_EXT2=y
34+
BR2_TARGET_ROOTFS_EXT2_4=y
3335

3436
# Image
3537
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_LITEX_VEXRISCV_PATH)/board/litex_vexriscv/post-image.sh"

buildroot/configs/litex_vexriscv_usbhost_defconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ BR2_TARGET_GENERIC_GETTY_PORT="console"
3030

3131
# Filesystem
3232
BR2_TARGET_ROOTFS_CPIO=y
33+
BR2_TARGET_ROOTFS_EXT2=y
34+
BR2_TARGET_ROOTFS_EXT2_4=y
3335

3436
# Image
3537
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_LITEX_VEXRISCV_PATH)/board/litex_vexriscv/post-image.sh"

images/boot_mmcblk0p2.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"Image" : "0x40000000",
3+
"rv32.dtb" : "0x40ef0000",
4+
"opensbi.bin" : "0x40f00000"
5+
}
File renamed without changes.

make.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import re
1111
import sys
1212
import argparse
13+
import shutil
1314

1415
from litex.soc.integration.builder import Builder
1516
from litex.soc.cores.cpu.vexriscv_smp import VexRiscvSMP
@@ -59,6 +60,9 @@ def main():
5960
parser.add_argument("--spi-data-width", default=8, type=int, help="SPI data width (max bits per xfer).")
6061
parser.add_argument("--spi-clk-freq", default=1e6, type=int, help="SPI clock frequency.")
6162
parser.add_argument("--fdtoverlays", default="", help="Device Tree Overlays to apply.")
63+
parser.add_argument("--rootfs", default="ram0", help="Location of the RootFS.",
64+
choices=["ram0", "mmcblk0p2"]
65+
)
6266
VexRiscvSMP.args_fill(parser)
6367
args = parser.parse_args()
6468

@@ -174,12 +178,15 @@ def main():
174178
builder.build(run=args.build, build_name=board_name)
175179

176180
# DTS --------------------------------------------------------------------------------------
177-
soc.generate_dts(board_name)
181+
soc.generate_dts(board_name, args.rootfs)
178182
soc.compile_dts(board_name, args.fdtoverlays)
179183

180184
# DTB --------------------------------------------------------------------------------------
181185
soc.combine_dtb(board_name, args.fdtoverlays)
182186

187+
# boot.json --------------------------------------------------------------------------------
188+
shutil.copyfile(f"images/boot_{args.rootfs}.json", "images/boot.json")
189+
183190
# PCIe Driver ------------------------------------------------------------------------------
184191
if "pcie" in board.soc_capabilities:
185192
from litepcie.software import generate_litepcie_software

soc_linux.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,17 @@ def configure_ethernet(self, remote_ip):
7373

7474
# DTS generation ---------------------------------------------------------------------------
7575

76-
def generate_dts(self, board_name):
76+
def generate_dts(self, board_name, rootfs="ram0"):
7777
json_src = os.path.join("build", board_name, "csr.json")
7878
dts = os.path.join("build", board_name, "{}.dts".format(board_name))
79+
initrd = "enabled" if rootfs == "ram0" else "disabled"
7980

8081
with open(json_src) as json_file, open(dts, "w") as dts_file:
81-
dts_content = generate_dts(json.load(json_file), polling=False)
82+
dts_content = generate_dts(json.load(json_file),
83+
initrd = initrd,
84+
polling = False,
85+
root_device = rootfs
86+
)
8287
dts_file.write(dts_content)
8388

8489
# DTS compilation --------------------------------------------------------------------------

0 commit comments

Comments
 (0)