Skip to content
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

Ramdisk #4

Merged
merged 11 commits into from
Feb 21, 2024
Merged

Ramdisk #4

merged 11 commits into from
Feb 21, 2024

Conversation

redhog
Copy link
Contributor

@redhog redhog commented Feb 17, 2024

Support an arbitrarily sized ramdisk using PMEM kernel driver.

Why not initrd? Because initrd and initramdisk have size limitations, for larger disks, it gets stuck loading the disk (probably copying and extracting the entire disk at boot). PMEM containing a normal filesystem, such as ext3 or squashfs can store an arbitrary number of files with no performance penalty at boot or when just accessing a small number of them.

@franzflasch
Copy link
Owner

franzflasch commented Feb 18, 2024

Hi! Thanks for your PR! I really appreciate this!

Just some remarks:

  • please don't add device tree binaries to the repository. It should only contain the sources not the compilations
  • Can you reorganize the device-trees please? I would like to keep the original device-trees as they are.
  • You can add a new one e.g. "riscv_em_rd.dts"
  • How can such a ramdisk be built?
  • If this should be added I would like to have something like a "how-to build a ramdisk for riscv_em". Otherwise this might end up being there but no one knows how to actually use it.

Thanks!

@redhog
Copy link
Contributor Author

redhog commented Feb 18, 2024

There are many ways to build such a ramdisk, as it's just a filesystem image. For squashfs, you

    cd filesystemtree; mksquashfs ./ ../myimage.squashfs -Xcompression-level 9

For ext3 etc, you'd have to make an empty file of the right size, then run mkfs.ext3 myimage.ext3, then mount -o loop myimage.ext3 /mnt; cp -a filesystemtree/* /mnt; umount /mnt.

So pretty straight forward to make (but what files to put in it is entirely up to the user, if you want to use it as a root disk, obviously you'd need to use buildroot or something).

@redhog
Copy link
Contributor Author

redhog commented Feb 18, 2024

Added some docs on the ramdisk usage, including explaining why this uses pmem over initrd/initramdisk.

src/core/riscv_config.h Show resolved Hide resolved
src/main.c Outdated Show resolved Hide resolved
@@ -113,6 +116,11 @@ void rv_soc_init(rv_soc_td *rv_soc, char *fw_file_name, char *dtb_file_name)

write_mem_from_file(fw_file_name, soc_ram, sizeof(soc_ram));

if (initrd_file_name != NULL) {
printf("XXXXXXXXXXXXXXXXXXXXXXXXXXX\n");
Copy link
Owner

Choose a reason for hiding this comment

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

Please remove this print statement or change it to something meaningful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oups... again, leftover from experimentation...

@@ -31,9 +31,14 @@

sram: memory@80000000 {
device_type = "memory";
reg = <0x0 0x80000000 0x0 0x8000000>;
reg = <0x0 0x80000000 0x0 0x40000000>;
Copy link
Owner

Choose a reason for hiding this comment

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

Why the increase of the main memory? Please keep the old setting.

@franzflasch franzflasch merged commit b921774 into franzflasch:master Feb 21, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants