Skip to content

Commit

Permalink
feat: replace MTD drives with PMEM drives
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Oct 6, 2023
1 parent adcc95a commit 48be7e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
13 changes: 4 additions & 9 deletions src/cartesi-machine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ where options are:
--flash-drive=<key>:<value>[,<key>:<value>[,...]...]
defines a new flash drive, or modify an existing flash drive definition
flash drives appear as /dev/mtdblock[1-7].
flash drives appear as /dev/pmem[0-7].
<key>:<value> is one of
label:<label>
Expand Down Expand Up @@ -401,8 +401,8 @@ local memory_range_replace = {}
local ram_image_filename = images_path .. "linux.bin"
local ram_length = 64 << 20
local dtb_image_filename = nil
local dtb_bootargs = "console=hvc0 rootfstype=ext2 root=/dev/mtdblock0 rw quiet \z
swiotlb=noforce init=/opt/cartesi/bin/init random.trust_bootloader=on"
local dtb_bootargs = "console=hvc0 rootfstype=ext2 root=/dev/pmem0 rw quiet \z
swiotlb=noforce init=/opt/cartesi/bin/init"
local rollup
local uarch
local rollup_advance
Expand Down Expand Up @@ -1358,18 +1358,13 @@ else
uarch = uarch,
flash_drive = {},
}
local mtdparts = {}
for i, label in ipairs(flash_label_order) do
for _, label in ipairs(flash_label_order) do
config.flash_drive[#config.flash_drive + 1] = {
image_filename = flash_image_filename[label],
shared = flash_shared[label],
start = flash_start[label],
length = flash_length[label] or -1,
}
mtdparts[#mtdparts + 1] = string.format("flash.%d:-(%s)", i - 1, label)
end
if #mtdparts > 0 then
config.dtb.bootargs = append(config.dtb.bootargs, "mtdparts=" .. table.concat(mtdparts, ";"))
end

config.dtb.bootargs = append(append(config.dtb.bootargs, append_dtb_bootargs), quiet and " splash=no" or "")
Expand Down
11 changes: 4 additions & 7 deletions src/dtb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,13 @@ void dtb_init(const machine_config &c, unsigned char *dtb_start, uint64_t dtb_le
fdt.end_node();
}

// flash
// drives
int drive_index = 0;
for (const auto &f : c.flash_drive) {
fdt.begin_node_num("flash", f.start);
fdt.prop_u32("#address-cells", 2);
fdt.prop_u32("#size-cells", 2);
fdt.prop_string("compatible", "mtd-ram");
fdt.prop_u32("bank-width", 4);
fdt.begin_node_num("pmem", f.start);
fdt.prop_string("compatible", "pmem-region");
fdt.prop_u64_list<2>("reg", {f.start, f.length});
fdt.prop_string("linux,mtd-name", "flash."s + std::to_string(drive_index));
fdt.prop_empty("volatile");
fdt.end_node();
drive_index++;
}
Expand Down
4 changes: 1 addition & 3 deletions tools/benchmarks/run-benchmarks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ local function build_machine(exec_args)
},
dtb = {
bootargs = (
"console=hvc0 rootfstype=ext2 root=/dev/mtdblock0 rw "
.. "quiet mtdparts=flash.0:-(root) -- "
.. exec_args
"console=hvc0 rootfstype=ext2 root=/dev/pmem0 rw quiet -- " .. exec_args
),
},
ram = {
Expand Down

0 comments on commit 48be7e3

Please sign in to comment.