hexdump0815 / linux-mainline-on-arm-chromebooks

running linux mainline on arm chromebooks - for example: samsung xe303c12 and xe503c12 (snow and peach), acer c100, c101 and c201 (veyron speedy, minnie etc. and gru bob and kevin), medion s2013 and s2015 (veyron jaq, mighty etc.), acer cb5 311 (nyan big), lenovo n23, acer r13 (oak elm and hana), lenovo duet (kukui krane) and most probably many many more over time ...
145 stars 10 forks source link

chromebook_snow: misc: Trying to enable KVM on my Samsung Chromebook ARM "SNOW" model XE303C12 #3

Open Marietto2008 opened 1 year ago

Marietto2008 commented 1 year ago

Hello.

I would like to enable KVM on my old but still functional "Samsung Chromebook ARM "SNOW" model XE303C12" because later I want to virtualize FreeBSD with qemu and kvm. After having read this guide :

https://github.com/hexdump0815/imagebuilder/blob/main/systems/chromebook_snow/readme.md

I've dd ed this image to my MMC card :

https://github.com/hexdump0815/imagebuilder/releases/tag/220619-01

and yeah,it's working great.

BTW I'm not so experienced at understanding how to recompile the kernel (or is it enough to recompile only the modules related to KVM ?) without asking for some help,but if you want to put me in the right path,I can do it. On your github there seems to be a guide that I can follow :

https://github.com/hexdump0815/linux-mainline-and-mali-generic-stable-kernel/blob/master/readme.cbe

It says to grab the kernel source code from here :

https://github.com/hexdump0815/linux-mainline-and-mali-generic-stable-kernel/blob/master/gitrepo

I did it,but later,when I did :

git checkout origin/linux-5.18.y -b linux-5.18.y

I realized that on /usr/lib/modules has been created this folder :

5.18.17-stb-cbe

the problem is that it does not match with the kernel version that I'm running :

Linux changeme 5.18.1-stb-cbe+ #1 SMP PREEMPT Sun Jun 5 14:16:07 CEST 2022 armv7l armv7l armv7l GNU/Linux

at this point I tried with another kernel version :

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/snapshot/linux-5.18.1.tar.gz

Is this the correct one ? At this point I generated the .config file with the command :

make olddefconfig

and I tried adding these flags to the .config file :

CONFIG_HAVE_KVM_IRQCHIP=y CONFIG_KVM_MMIO=y CONFIG_VIRTUALIZATION=y CONFIG_KVM=y CONFIG_KVM_ARM_HOST=y CONFIG_KVM_ARM_MAX_VCPUS=4 CONFIG_KVM_ARM_VGIC=y CONFIG_KVM_ARM_TIMER=y

I added them using two techniques :

1) with a text editor : but it didn't work. It seems that they don't stick inside the .config file

2) with the command : make menuconfig and I looked for the KVM flags inside the other kernel entries,but I found nothing.

Since I'm not so experienced,I don't know what to do further ; I don't understand where the mistake is. -- Mario.

Marietto2008 commented 1 year ago

they say :

If you have followed the Setting up the boot medium chapter and you have a prepared boot device, then you can update u-boot by running:

I don't have that section on the tutorial : http://www.virtualopensystems.com/en/solutions/guides/kvm-on-chromebook/#setting-up-the-boot-medium ; is missing.

Marietto2008 commented 1 year ago

I've made progresses. I'm running the kernel 3.3 with kvm enabled and I've installed ubuntu 14.04 as main os : the only problem I have is that the USB mouse does not work.

Marietto2008 commented 1 year ago

Aren't you interested anymore in help me ? this is the problem that I'm facing :

https://askubuntu.com/questions/1427164/init-exists-but-couldnt-executed-it-error-13

hexdump0815 commented 1 year ago

@Marietto2008 - the problem from my side is that my time is limited and this drifts off of this project to provide as good as possible up to date linux images for some devices quite a bit meanwhile

regarding your problem: might be some symlinking going on between /sbin/init /etc/init etc. - maybe just try init=/bin/sh and see if you get a shell this way - if yes you can check which is the proper init (without any symlinking) and try that

Marietto2008 commented 1 year ago

You are not focused to this project anymore (at the beginning you were) ; in my humble opinion you are looking at the problem with superficiality ; the problem is not the init process,but the incompatibility between the kernel 3.3 and the userland of ubuntu 16 and as lastest try,with ubuntu 18.04. Check at the new and interesting situation below where I'm using the kernel 3.3 with ubuntu 18.04 :

index

the problem is that at this point I'm not able to use the kernel 5.4 because it freezes without giving errors and I don't know what to do to debug it. Instead,if I use the kernel 3.3 I see a lot of error messages and I can look a fix for them.

Marietto2008 commented 1 year ago

Possible solution for the first problem found here :

https://www.linuxquestions.org/questions/linux-general-1/boot-problem-failed-to-insert-module-%27autofs4%27-4175485121/

Try to recompile your kernel and modify your .config file, in that file you must change the option CONFIG_AUTOFS4_FS=m to CONFIG_AUTOFS4_FS=y, and then compile the new kernel.

Marietto2008 commented 1 year ago

Unfortunately it is already configured to y

Screenshot_2022-09-02_23-44-28

Marietto2008 commented 1 year ago

I'm on :

root@marietto-BHYVE:/compile/source/linux-4.0.9# uname -a
Linux marietto-BHYVE 3.13.0-rc8-66318-g4d0ca38 #1 SMP PREEMPT Thu Aug 11 16:12:30 CEST 2022 armv7l armv7l armv7l GNU/Linux

and I'm trying to recompile the kernel 4.0.9 with the KVM flags. This time the problem is that it does not produce the exynos5250-snow.dtb file. I've used the .config file provided bv the website virtualopensystems and I've issued the following command :

make -j 4 zImage dtbs modules

Can you imagine why ? without exynos5250-snow.dtb It will not boot.

hexdump0815 commented 1 year ago

the dtb's live in arch/arm/boot/dts - so either the dtb (dts there as the source file for the dtb) is named there differently, not around at all or not referenced in the Makefile of that dir

Marietto2008 commented 1 year ago

I need to understand what are the necessary requisites that produce the exynos5250-snow.dtb file.

Marietto2008 commented 1 year ago

I would like to make a new experiment. I would like to try to update the u-boot bootloader that I have installed on the sdcard of my chromebook. On your github I've found this :

/u-boot/v2020.04-cbe/

inside of it there are two interesting files :

uboot.img.cbe and uboot.kpart.cbe :

I want to know which is the right file that I can install on the first partition of the sd card,in my case it should be /dev/sde1 :


Disk /dev/sde: 183.35 GiB, 196865949696 bytes, 384503808 sectors
Disk model: Storage Device  
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 5A31E155-924C-4DA4-8408-7D967B570A86

Dispositivo   Start      Fine   Settori   Size Tipo
/dev/sde1      2048     34815     32768    16M ChromeOS kernel
/dev/sde2     34816     67583     32768    16M ChromeOS kernel
/dev/sde3     67584   1116159   1048576   512M Linux filesystem
/dev/sde4   1116160 384503774 383387615 182.8G Linux filesystem

using this command :

sudo dd if=nv_uboot-snow.kpart of=/dev/sde1

could it be : uboot.kpart.cbe ? in this case you could have renamed this file into : uboot.cbe.kpart. Infact reading below,you can see that the extension of the file should be called kpart :

If successful, a message about how to copy the bootloader on the USB flash disk or SD card will appear. We will use it later when preparing the boot medium to start our system. If you have followed the Setting up the boot medium chapter and you have a prepared boot device, then you can update u-boot by running:

$ sudo dd if=nv_uboot-snow.kpart of=/dev/sdX1

source :

http://www.virtualopensystems.com/en/solutions/guides/kvm-on-chromebook/#setting-up-the-boot-medium

what's the difference between those two files ?

hexdump0815 commented 1 year ago

here: https://github.com/hexdump0815/u-boot-chainloading-for-arm-chromebooks/blob/master/readme.cbe is explained how those files were created - the kpart one is the one in chrombook bootloader format, so the one to write to the first partition

Marietto2008 commented 1 year ago

I did it,it freezes on the loading kernel image and then on the screen appears odd colors and characters,but it seems that,apart this,it loads the rest of the os. It's a shame that I can't be sure because the messages on the screen are damaged.

Marietto2008 commented 1 year ago

I have installed u-boot (uboot.kpart.cbe vers. 2020) on the first partition (with the command sudo dd if=nv_uboot-snow.kpart of=/dev/sde1) and it required to rename uImage-5.4.3-stb-cbe+ (not sure if I have recompiled it with the adding the KVM flags) in uImage and that the exynos5250-snow.dtb file that should be on the root of the sd card. Furthermore I've installed ubuntu 22.04 on the root partition. What happens ? that it freezes on the screen,telling : "loading kernel image" and then nothing happens anymore. Instead,the u-boot file provided by VOS seems to work better. It works with the kernel provided by them (vers. 3.13) only. Maybe uboot.kpart.cbe vers. 2020 works with ubuntu 14.04 as userland,but the screen is broken and I'm not sure. The kernel that freezes on the screen is a very familiar problem. It happens even when I didn't install u-boot on the first partition. This problem has never been solved :

https://github.com/hexdump0815/linux-mainline-on-arm-chromebooks/issues/3#issuecomment-1228503961

Marietto2008 commented 1 year ago

I'm out of ammunition.

hexdump0815 commented 1 year ago

i also have no further ideas and limited time for this topic - maybe just let it sit there for a while - sometimes new ideas come after a while - or give up on the kvm idea on this machine, maybe its simply not possible with what is around on u-boot, kernels etc.

best wishes - hexdump

Marietto2008 commented 1 year ago

Hello. Do you remember me ? Do you still have a spare "google / samsung / arm chromebook" with you ? I've asked to my friend,who works on a shop where he fixes mobile phones,desktop computers and so on,to unlock the bootloader of my arm chromebook. Infact I've found the tutorial below which explains how to do it :

https://krblogs.com/post/63809988096/bootloader-unlock-on-samsung-arm-chromebook

did you already tried ? my friend repeated the task two times,but the bootloader is still locked.

in the post below,a guy tells that he has been also able to unlock the bootloader.

https://groups.google.com/a/chromium.org/g/chromium-os-discuss/c/HnpGOIlikFY

so,what ? any reason why it does not work for me ? what could be the reason ?

hexdump0815 commented 1 year ago

sure i remember you ... i did not play around with the snow bootloader yet and do not plan to do it as i'm quite happy with the boot situation so far: all 32bit armv7l chromebooks have a working and consistent boot strategy by chainloading a mainline u-boot which does all i want from it - i do not plan to touch this anymore as it works well for all of them and most probably no more new 32bit chromebook will appear in the future :)

Marietto2008 commented 1 year ago

Without unlocking the bootloader I can't install directly every os I want. I've asked to apply the hardware modification because I wanted to install linux or freebsd without using the chainloader method. And also because I hoped that it can allows to enable kvm on top of linux,beause it would be installed directly.

hexdump0815 commented 1 year ago

i think kvm support for 32bit arm was dropped somewhere in v5.x, so no real future for it

Marietto2008 commented 1 year ago

wait a moment. I know. We have understood this together 6 months ago. But my doubt is that it could not work because I'm forced to use the patches created for the kernel 3.x by virtual systems. I would like to use kvm for the latest kernel that I can use. I tried to do this,but it didn't work,probably because the patches that I have used come from the kernel 3. The virtual systems didn't reply when I have asked the source code of their patches. I'm not able to recreate those patches for a 5.x kernel.

hexdump0815 commented 1 year ago

i just checked: v5.4 will be supported until at least december 2025 (https://www.kernel.org/category/releases.html) - so still a bit of support there for it ... so in case you get anything working it might be good to add some info here for others maybe trying the same ... i'll not work on this as i have barely enough time right now to move all the images slowly forward

good luck and best wishes - hexdump

Marietto2008 commented 1 year ago

I don't understand what I can do because from the virtualopensystems I read that they had developed some patches to make kvm work. I suspect that those patches are "in house" patches which works for the kernel 3.3. But they dont work for the kernel 5.4.

hexdump0815 commented 1 year ago

then maybe there is no chance to get it working i guess

Marietto2008 commented 1 year ago

But I'm not so sure. Can you give a look at the whole web page of virtualopensystems ? just to be sure that they used some custom patches. you are more experienced than me. If you say that they haven't used them,I can try again :

http://www.virtualopensystems.com/en/solutions/guides/kvm-on-chromebook/?vos=tech

or maybe it is explained better here :

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/virtualization-on-the-chromebook-using-kvm-tool

when he says :

To do this we will build a version of u-boot. Rather than use upstream’s u-boot source tree, we will use Virtual Open Systems’ tree as they have integrated many of the fixes needed to fully support Hyp mode, and also have an easy to use script for building u-boot.

which fixes he is talking about ?

hexdump0815 commented 1 year ago

to me it looks like they used those sources for their experiments:

the u-boot repo contains things like this: https://github.com/virtualopensystems/u-boot/commit/ef990998597348757ce38d7b71738295f3a7f121 so seems to deal with kvm specific stuff on snow

all this looks very non trivial to get working if it is still possible at all today

Marietto2008 commented 1 year ago

Hello. It's again me. I've found a freebsd developer who wants to help me to port FreeBSD,not on the "Samsung Chromebook ARM "SNOW" model XE303C12" but on the "Samsung Nexus 10" tablet. I didn't still realized that these two devices have the same cpu (which I have both) :

Samsung Nexus 10 :

Processore: Samsung Exynos 5250 1,7 GHz Dual-core A15
Grafica: Quad-core Mali T604
Fotocamera: Frontale da 1.9 Megapixel - Posteriore da 5 Megapixel
Memoria interna: 16, 32 GB
RAM: 2 GB DDR3L

Samsung Chromebook ARM "SNOW" :

Exynos 5250 Dual-Core @ 1.7Ghz
2GB DDR3L
16GB eMMC
11.6" / 1366x768
802.11 a/b/g/n (Dual Band)
VGA (dongle)
HDMI
1x USB 3.0 / 1x USB 2.0
SD/SDHC/SDXC

several years ago I've bought the nexus 10 and now it's getting dust within the drawer. So,I'm thinking if I can reuse what I have learnt here with you to do the same on the Nexus 10. Let's say that as first step I will unlock the Nexus 10 bootloader (there are several tutorials on internet about how to do that) and then ? what should I do ? Is enough to install this version of debian :

https://github.com/hexdump0815/imagebuilder/releases/tag/230220-01

on the nexus 10 ? but how ? maybe using the multiloader rom that's showed here :

https://sudonull.com/post/79349-Install-Sailfish-OS-on-your-smartphone-using-the-Nexus-5-as-an-example

I also see that a premilinary version of sailfish-os has been installed on the nexus 10 several years ago :

https://forum.xda-developers.com/t/rom-wip-sailfish-os-2-1-nexus-10.3726525/

hexdump0815 commented 1 year ago

i guess getting this working is even more complicated than trying to get kvm working on snow ... android tablets and chromebooks are very different in the way they boot etc.

Marietto2008 commented 1 year ago

I found these resources :

https://forum.xda-developers.com/t/kernel-mainlining-manta-kernel.4461617/ https://github.com/jmarcgit/manta-mainline

but I'm confused about what I could try to do now. Maybe I should recompile the kernel and apply the patches ? But I don't see the instructions. And I need them :P

Marietto2008 commented 1 year ago

Hello man. It's again me. This project won't die. Probably because I want really achieve what I want. I found this interesting exynos patch :

https://github.com/sleirsgoevy/exynos-kvm-patch

the google chromebook has an exynos cpu such as my tablet nexus 10. This patch should be applied to an android kernel,not to a linux kernel. Both the devices (arn chromebook and nexus 10) can run on an android kernel,right ? what's the default os of the arm cromebook ? please would you help me to clarify my ideas if it is doable or not to try to apply that patch to my devices to enable kvm ? thanks.