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

Compilation instructions? #4

Closed
ParzivalWolfram opened this issue Mar 30, 2021 · 17 comments
Closed

Compilation instructions? #4

ParzivalWolfram opened this issue Mar 30, 2021 · 17 comments

Comments

@ParzivalWolfram
Copy link
Member

I've been following progress on Linux 3DS since I dropped it, and I was wondering what your procedure for compiling is, as I'm willing to test commits on my N3DSXL.

@nickdesaulniers
Copy link
Member

$ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi make -j$(nproc) nintendo3ds_defconfig
$ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi make -j$(nproc)
$ ARCH=arm CROSS_COMPILE=arm-linux-gnueabi make -j$(nproc) nintendo3ds_ctr.dtb

see also 1, 2, 3.

@Wolfvak
Copy link
Member

Wolfvak commented Mar 30, 2021

We will eventually release a buildroot system to compile the kernel + a small initramfs but as of right now you can disable the hardcoded rootfs directory and use the cpio from the original release.
Keeping this open until that happens.

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Mar 30, 2021

https://gist.github.com/xerpi/3c720d345820691a2985502fcd80268f#gistcomment-3684668 has directions for a basic buildroot image that works. Just need to modify the dts file to tell it not to power down the machine immediately.

But it would be good to add a buildroot repo to this gh project.

@nickdesaulniers
Copy link
Member

I plan to rewrite the readme for each project with build steps.

@ParzivalWolfram
Copy link
Member Author

ParzivalWolfram commented Mar 31, 2021 via email

@nickdesaulniers
Copy link
Member

I think it would be better to keep the kernel build out of buildroot. It's simpler the other way around IMO; build a buildroot image as an initrd, then place it in the kernel sources and leave it in the kernel tree as rootfs.cpio.gz. The kernel build will produce the zImage with the ramdisk bundled.

I would create a separate git repo under this org that has a script and uses git submodules to clone all relevant sources, and orchestrate the build via shell scripts. It would also be nice for us to provide prebuilt binaries, since most of the time during development not all pieces change and it's generally easier for users to test with those (though they can still use our build scripts if they want).

I think that's a better approach than including patch files for kernel sources in buildroot. That won't scale when we break up the currently single commit for upstreaming.

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Mar 31, 2021

Since we don't want to pollute the linux dir with documentation (at least at this point. We can add documentations to Documentation/ later) for how to build or simply how to run this, do folks have thoughts on either approaches/ideas:

  1. enable the wiki for this repo? This makes it quicker to edit/add/change, no commits or git necessary.
  2. create a docs repo. Can create a gh-pages branch to have github host a url for us.
  3. collaborate with https://3ds.hacks.guide/, https://github.com/hacks-guide/Guide_3DS . Perhaps we should have something more polished first?

I think it would be good to have separate docs for fellow developers vs users that just want to run linux. I guess they don't need to be separate per se. Thoughts?

@ParzivalWolfram
Copy link
Member Author

Honestly, i'd be in favor of using the repo wiki. Too many repos will have build instructions, downloads, etc. in a gist or on some other page, which feels somewhat jarring, personally.

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Mar 31, 2021

SGTM. Yes gists aren't editable from others IIRC, so let's avoid those for documentation. @Wolfvak can you please enable wikis on all repos? One issue is that we wont be able to host binaries on the wiki pages, I think.

@Wolfvak
Copy link
Member

Wolfvak commented Mar 31, 2021

Done

@ParzivalWolfram
Copy link
Member Author

I can get Buildroot to spit out a zImage when I fix the hardcoded path in the defconfig, but it doesn't contain a rootfs. I'm not sure how to fix that, as Buildroot won't spit out a rootfs until well after you pass that point.

@nickdesaulniers
Copy link
Member

right, because the kernel will fail to build because the kernel config says "look for rootfs.cpio.gz in the current working directory and include it in the build of the kernel." When you build the kernel via buildroot, you're building these in the wrong order. You need to build the buildroot image without building the kernel at all. Then you take the resulting rootfs.cpio.gz and put that in the kernel sources. Then you build the kernel.

@ParzivalWolfram
Copy link
Member Author

right, because the kernel will fail to build because the kernel config says "look for rootfs.cpio.gz in the current working directory and include it in the build of the kernel." When you build the kernel via buildroot, you're building these in the wrong order. You need to build the buildroot image without building the kernel at all. Then you take the resulting rootfs.cpio.gz and put that in the kernel sources. Then you build the kernel.

I tried that, since you stated to do it in the PR I made, but it still spits out a bad zImage.

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Mar 31, 2021

but it still spits out a bad zImage.

If the rootfs.cpio.gz was not in the kernel sources, the kernel build should fail.

If the rootfs.cpio.gz is invalid, non-decompressable, or init is not executable, you should see a kernel panic (that's relatively good, at least the kernel image isn't bad, just the ramdisk is).

===

I've now recompiled firm_linux_loader (instructions) and arm9linuxfw (instructions) and verified they work.

I haven't tried this fork of the kernel yet, maybe something is messed up there with that. Let me verify and see if that's possibly the issue @ParzivalWolfram is hitting.

Where/how should I post binaries of what I have?

@ParzivalWolfram
Copy link
Member Author

ParzivalWolfram commented Mar 31, 2021

If the rootfs.cpio.gz was not in the kernel sources, the kernel build should fail.

If the rootfs.cpio.gz is invalid, non-decompressable, or init is not executable, you should see a kernel panic (that's relatively good, at least the kernel image isn't bad, just the ramdisk is).

It's failing immediately on boot as it can't mount the rootfs. The rootfs i'm building is almost 23MB, the zImage that should contain it is just over 5MB.

20210331_002519

@ParzivalWolfram
Copy link
Member Author

This is my buildroot config. (For some reason, I have to hardcode the commit for the kernel header specifically, I can't just tell it to use the master branch like I can the kernel itself.)
config.zip

@nickdesaulniers
Copy link
Member

Please see:

  1. the Table of Contents linked from any project in this org's wikis.
  2. the twitch stream I did this past weekend.

The directions will change more in the future, but we'll try to keep the wikis up to data. Might do more fomal HTML/MD pages. Might upload that twitch video to YT.

timoreo22 pushed a commit to timoreo22/linux-3ds that referenced this issue Dec 2, 2023
We had kernel panic, it is caused by unload module and last
close confirmation.

call trace:
[1196029.743127]  free_sess+0x15/0x50 [rtrs_client]
[1196029.743128]  rtrs_clt_close+0x4c/0x70 [rtrs_client]
[1196029.743129]  ? rnbd_clt_unmap_device+0x1b0/0x1b0 [rnbd_client]
[1196029.743130]  close_rtrs+0x25/0x50 [rnbd_client]
[1196029.743131]  rnbd_client_exit+0x93/0xb99 [rnbd_client]
[1196029.743132]  __x64_sys_delete_module+0x190/0x260

And in the crashdump confirmation kworker is also running.
PID: 6943   TASK: ffff9e2ac8098000  CPU: 4   COMMAND: "kworker/4:2"
 #0 [ffffb206cf337c30] __schedule at ffffffff9f93f891
 linux-3ds#1 [ffffb206cf337cc8] schedule at ffffffff9f93fe98
 linux-3ds#2 [ffffb206cf337cd0] schedule_timeout at ffffffff9f943938
 linux-3ds#3 [ffffb206cf337d50] wait_for_completion at ffffffff9f9410a7
 linux-3ds#4 [ffffb206cf337da0] __flush_work at ffffffff9f08ce0e
 linux-3ds#5 [ffffb206cf337e20] rtrs_clt_close_conns at ffffffffc0d5f668 [rtrs_client]
 linux-3ds#6 [ffffb206cf337e48] rtrs_clt_close at ffffffffc0d5f801 [rtrs_client]
 linux-3ds#7 [ffffb206cf337e68] close_rtrs at ffffffffc0d26255 [rnbd_client]
 linux-3ds#8 [ffffb206cf337e78] free_sess at ffffffffc0d262ad [rnbd_client]
 linux-3ds#9 [ffffb206cf337e88] rnbd_clt_put_dev at ffffffffc0d266a7 [rnbd_client]

The problem is both code path try to close same session, which lead to
panic.

To fix it, just skip the sess if the refcount already drop to 0.

Fixes: f7a7a5c ("block/rnbd: client: main functionality")
Signed-off-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Reviewed-by: Gioh Kim <gi-oh.kim@cloud.ionos.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
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

No branches or pull requests

3 participants