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

Boot cycle occurs #3

Open
cpzf2022 opened this issue Aug 3, 2022 · 29 comments
Open

Boot cycle occurs #3

cpzf2022 opened this issue Aug 3, 2022 · 29 comments

Comments

@cpzf2022
Copy link

cpzf2022 commented Aug 3, 2022

I use sm-a600fn
The system version is A600FNXXU3BSD2
I flash in the built 0.01 kernel
But unfortunately, it has a boot cycle
When I flash magisk 25.1 into this kernel,enter download mode every time you restart
Should I rebuild a kernel myself or update system ?
Thanks ! I am very interested in this kind of project

@raspiduino
Copy link
Owner

Yes, you should get the kernel source from Samsung, then apply the patch by sleirsgoevy here

@cpzf2022
Copy link
Author

cpzf2022 commented Aug 3, 2022

OK Thanks

@cpzf2022
Copy link
Author

cpzf2022 commented Aug 4, 2022

I'm Sorry to disturb you again
The kernel source code I downloaded from Samsung open source website compiles and reports an error after being patched ( I use git apply kvm.patch)

“CC init/main.o
init/main.c: In function 'start_kernel':
init/main.c:651:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
void preinit_hyp_mode(void);
^
cc1: all warnings being treated as errors
scripts/Makefile.build:257: recipe for target 'init/main.o' failed”

In addition to this error, there are several other errors
So should I try another kernel source code?
Thanks

@raspiduino
Copy link
Owner

raspiduino commented Aug 4, 2022

I'm Sorry to disturb you again
No problems :)

Well, I think you should define function prototype of preinit_hyp_mode in a file called arm.h (or what ever you want it to be), then put that header in include/linux/, then include the header from init/main.c and arch/arm/kvm/arm.c.

For the function vmm_init_kvm, you should create the header vmm-kvm.h for function prototype, then put it into include/linux, then include it from arch/arm/kvm/arm.c and init/vmm-kvm.c

That a brief of the fix (which I did for my a6lte-kvm).

I think you should put the error log here (remember to put between ``` like this):

Ooops, some error happened...........

Thank you!

@cpzf2022
Copy link
Author

cpzf2022 commented Aug 5, 2022

Thank you very much for your help
But these operations are very difficult for me. So far, I don't have any C language foundation

Fortunately, I recompiled it with your a6lte KVM kernel source code and packed it with the boot of my current system It successfully enters the system and works. I can find /dev/kvm

However, I use the official system of Samsung. The bug you described in REDME.md has not been encountered so far

Finally, thank you for the kernel source code

@raspiduino
Copy link
Owner

Fortunately, I recompiled it with your a6lte KVM kernel source code and packed it with the boot of my current system It successfully enters the system and works. I can find /dev/kvm

Outstanding move :))

@cpzf2022
Copy link
Author

cpzf2022 commented Aug 6, 2022

I would like to ask you another question
KVM can be called by QEMU, but I can't start any Linux system
I used the patched edk2 file provided by you in XDA and the patched dtb.bin provided by sleirsgoevy

I use linux deploy
This is my QEMU start test command:
"qemu-system-aarch64 -machine virt -m 1024M -cpu host -smp 4 -enable-kvm -pflash /sdcard/esShare/EFI_DEBUG.img -device ramfb -serial stdio -drive if=none,file=/sdcard/Download/ubuntu-18.04-server-arm64.iso,id=cdrom,media=cdrom -device qemu-xhci -device usb-kbd -device usb-tablet -dtb /sdcard/esShare/dtb.bin -boot d -device virtio-scsi-device -device scsi-cd,drive=cdrom"

This is the startup log fed back by the serial port
error.log

I would like to know if you have successfully started any Linux system on this device using KVM?

Thank you very much. It will be of great help to me

@raspiduino
Copy link
Owner

I would like to know if you have successfully started any Linux system on this device using KVM?

Yes, but with custom DTB. I have started Raspbian arm64 and it booted to desktop :)

For some reason your log is not completed, like what I can see when I opened it:

20220806_130413

Maybe you should try another build of EDK2 by me. Pass it to QEMU by -pflash flash0.img -pflash flash1.img, then get me the lock in the serial (that should be long)

If possible, please press ESC when EDK2 say start boot option. Then it should boot to a menu, where you can select the EFI file. Browse to the CD and select the Grub's EFI.

If it still not work, then you might need to use the tiny version of Debian here. If you choose that option, you should remove the two -pflash, then add -kernel and -initrd, the use the patched DTB. You also need to add the Debian arm64 CD (I haven't tried Ubuntu CD, but that might work as well) to the USB port by -device usb-storage.

Thanks!

@cpzf2022
Copy link
Author

cpzf2022 commented Aug 6, 2022

Thank you very much
For some reason, only a part of the previous logs were captured

This is the complete startup log
error.log

Unfortunately, Google cloud disk is not available in my area. So can you upload edk2 to other places? Thanks

In addition, I tried to use boot from file in the menu of edk2 to select EFI with G RUB, but it didn't work

@raspiduino
Copy link
Owner

Unfortunately, Google cloud disk is not available in my area. So can you upload edk2 to other places? Thanks

You don't need that anymore, your EDK2 worked

Just curiosity, but where do you live? I though Gdrive is available everywhere?


I can confirm that Ubuntu ISO doesn't work properly. Just download one and try :)

I modified the command line passed to kernel and it has the following panic trace:

[    0.000000] Kernel panic - not syncing: Unable to initialise architected timer.
[    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.15.0-25-generic #25-Ubuntu
[    0.000000] Call trace:
[    0.000000]  dump_backtrace+0x0/0x1ec
[    0.000000]  show_stack+0x24/0x30
[    0.000000]  dump_stack_lvl+0x68/0x84
[    0.000000]  dump_stack+0x18/0x34
[    0.000000]  panic+0x18c/0x39c
[    0.000000]  time_init+0x3c/0x5c
[    0.000000]  start_kernel+0x3a0/0x500
[    0.000000]  __primary_switched+0xc0/0xc8
[    0.000000] ---[ end Kernel panic - not syncing: Unable to initialise architected timer. ]---

It seems that this issue is related to the way Samsung bootloader handle the timer register. I was expecting the custom dtb to fix it, but somehow EDK2 didn't pass it properly to kernel.

I'm thinking of putting DTB into the ISO, then change the GRUB command line.

Will try it now.

@raspiduino
Copy link
Owner

For some reason the ISO won't work properly with virtio devices. So change -device virtio-scsi-device -device scsi-cd,drive=cdrom to -device usb-storage,drive=cdrom


It looks like the Ubuntu ISO booted when I put `dtb.bin` to the iso and edit the boot commands in GRUB.

So here are the steps:

  1. Open the original Ubuntu iso in some ISO editor like UltraISO, or you can extract it and then recreate using genisoimage.

  2. Drop the file dtb.bin to casper folder in the ISO root.

  3. Repack the ISO

  4. Boot the new ISO

  5. When it boot to GRUB menu, quickly press E to edit the command list.

  6. Add the line devicetree /casper/dtb.bin (with 8 spaces before the command). Also, remove the quiet parameter from kernel, and replace with earlycon. And it will look like this:

setparams "Try or Install Ubuntu Server"

        set gfxpayload=keep
        linux /casper/vmlinuz earlycon ---
        initrd /casper/initrd
        devicetree /casper/dtb.bin

Then press F10 to boot.

See if it works for you!

@raspiduino
Copy link
Owner

raspiduino commented Aug 6, 2022

If you encounter this
image

Please note that your Ubuntu is still booting and it's just because your phone is too slow. IDK

For some reason the Debian method does not have this issue (at least for the last time I tried it)
So you can consider using it if you like

@cpzf2022
Copy link
Author

cpzf2022 commented Aug 6, 2022

Well, that sounds great. I'll try it now

@cpzf2022
Copy link
Author

cpzf2022 commented Aug 6, 2022

It succeeded ! great!
It successfully loaded the kernel and entered the installation interface
However, when I tried to perform the installation steps, I was prompted that the CD-ROM could not be mounted
Have you ever encountered this problem?

This is my QEMU startup command
start.txt
I have modified it according to your suggestions

@raspiduino
Copy link
Owner

Hmm, I think you should try scsi-cd

You might want to look at this

@cpzf2022
Copy link
Author

cpzf2022 commented Aug 9, 2022

Sorry for the late reply
Happily, the scsi-cd installer is working
After the installation is successful, I want to start the system with the previous method
But it doesn't work (add devicetree and remove quiet)
I installed UOS,The content of grub edit mode looks like this(Before modification)
I have moved dtb.bin to the grub directory
markup_Screenshot_20220810-052320_VNC Viewer jpg
markup_Screenshot_20220810-052333_VNC Viewer jpg
The system still stops at this step
markup_Screenshot_20220810-052239_VNC Viewer jpg

How can I edit grub to make it work ? Do you have any idea Thank you very much!

@cpzf2022
Copy link
Author

Screenshot_20220810-190231_JuiceSSH

@raspiduino
Copy link
Owner

Wow, you didn't put the devicetree correctly.
Send me the grub edit after you modified it pls

@cpzf2022
Copy link
Author

Is this the way to edit?

markup_Screenshot_20220810-192922_VNC Viewer jpg
But it doesn't work
I put the dtb.bin file here
markup_Screenshot_20220810-192802_VNC Viewer jpg

@raspiduino
Copy link
Owner

Is this the way to edit?

markup_Screenshot_20220810-192922_VNC Viewer jpg But it doesn't work I put the dtb.bin file here markup_Screenshot_20220810-192802_VNC Viewer jpg

Did you saved your changes?
Now you can press F10 to see if it works

@cpzf2022
Copy link
Author

yes
But no effect. It's still like this
Screenshot_20220810-194529_JuiceSSH

@raspiduino
Copy link
Owner

Hmm, strange
I have never faced that

It seems that you are using Deepin Linux, right?

@cpzf2022
Copy link
Author

Yes
Deepin is the development branch of UOS

@raspiduino
Copy link
Owner

Send me the ISO and I will try it for sure :))

@raspiduino
Copy link
Owner

Thank you! I will try it

@raspiduino
Copy link
Owner

Hello, It think somehow the kernel reject the passed device tree blob. I think you should compile a new kernel (remember to set ARCH yo arm64 and use defconfig, then copy the new kernel to this VM disk and boot from it

@raspiduino
Copy link
Owner

BTW is this you?
https://www.bilibili.com/read/cv18956406

(sorry if not, I'm just surprise that my post is crossposted and they actually care about my project :))

@raspiduino
Copy link
Owner

image

Maybe that's really you

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

2 participants