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

Rebase with latest 5.4 kernel? #1

Open
onny opened this issue Dec 13, 2019 · 44 comments
Open

Rebase with latest 5.4 kernel? #1

onny opened this issue Dec 13, 2019 · 44 comments

Comments

@onny
Copy link

onny commented Dec 13, 2019

Hey,
thank you for this great work, this looks really interesting. Currently I'm running PostmarketOS on my Samsung i9100 but with Kernel 3.0. I'm looking into flashing a more recent kernel and also trying out ArchLinuxARM on the phone (someone already managed it but it was some time ago).
What changes do I have to make to mainline sources in order to get it running with u-boot and everything?

Thanks and best regards
Jonas

@Sekilsgs2
Copy link
Owner

Sekilsgs2 commented Dec 13, 2019 via email

@onny
Copy link
Author

onny commented Dec 14, 2019

Hey,
thank you for the fast response. This is how I compile latest mainline kernel using your dtb file:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
cd linux-stable
git checkout -b v5.4.3
wget "https://raw.githubusercontent.com/Sekilsgs2/i9100_kernel_mainline_port/6c02dad36b8a76a6f50d26ff1b9abb0d30aacbc9/arch/arm/configs/i9100_defconfig" -O arch/arm/configs/
export ARCH=arm
export CROSS_COMPILE=arm-none-eabi-
make i9100_defconfig
make -j6
cat arch/arm/boot/zImage arch/arm/boot/dts/exynos4210-i9100.dtb > zimage
mkimage -A arm -O linux -T kernel -C none -a 0x40008000 -e 0x40008000 -n Linux-android-sucks -d zimage boot.img
make modules_install INSTALL_MOD_PATH=../

So far, this works fine and I have the boot.img.

Compiling u-boot doesn't seem to work yet:

git clone https://github.com/Sekilsgs2/i9100-uboot.git
git clone https://github.com/Sekilsgs2/toolchain_for_old_uboot.git
cd i9100-uboot
export PATH="../toolchain_for_old_uboot/bin:$PATH"
export ARCH=arm
export CROSS_COMPILE=arm-none-eabi-
make galaxys2_config
make -j6 galaxys2

make gives me the error:

arm-none-eabi-gcc: error: unrecognized -march target: armv5
arm-none-eabi-gcc: note: valid arguments are: armv4 armv4t armv5t armv5te armv5tej armv6 armv6j armv6k armv6z armv6kz armv6zk armv6t2 armv6-m armv6s-m armv7 armv7-a armv7ve armv7-r armv7-m armv7e-m armv8-a armv8.1-a armv8.2-a armv8.3-a armv8.4-a armv8.5-a armv8-m.base armv8-m.main armv8-r iwmmxt iwmmxt2; did you mean 'armv4'?
arm-none-eabi-gcc: error: missing argument to '-march='

Is it possible to also use the latest uboot version? And how do I use heimdall? Flashing u-boot should be done like this, I guess:

heimdall flash --kernel u-boot.bin

And the boot.img kernel from above like this?

heimdall flash --recovery boot.img

Further I would like to boot ArchLinuxARM on the rootfs, this might work since odroid-x is similar to Samsung Galaxy S2 (?, https://archlinuxarm.org/platforms/armv7/samsung/odroid-x) http://os.archlinuxarm.org/os/ArchLinuxARM-odroid-x-latest.tar.gz Otherwise I could try a generic armv7h base system.

I guess @nullie already booted ArchLinuxARM on Samsung Galaxy S2, maybe he could help out on how to use it :)

@onny
Copy link
Author

onny commented Dec 14, 2019

ping @nullie

@nullie
Copy link

nullie commented Dec 14, 2019

Hi, it was ages ago, I don't remember any details

@onny
Copy link
Author

onny commented Dec 15, 2019

Okay got it working, compiling the old u-boot on latest ArchLinux like this:

pacman -U dtc-1.4.1-1-x86_64.pkg.tar.xz # downgrade to older version
pacman -S gcc-arm-none-eabi-bin-49
git clone https://github.com/Sekilsgs2/i9100-uboot.git
git clone https://github.com/Sekilsgs2/toolchain_for_old_uboot.git
cd i9100-uboot
export PATH="/usr/local/arm/gcc-arm-none-eabi-4_9-2015q3/bin:$PATH"
# set -gx PATH /usr/local/arm/gcc-arm-none-eabi-4_9-2015q3/bin $PATH
export ARCH=arm
export CROSS_COMPILE=arm-none-eabi-
make galaxys2_config
make galaxys2

Let's see if I could boot the latest Linux kernel with this :)

@onny
Copy link
Author

onny commented Dec 15, 2019

So I did following:

heimdall flash --KERNEL u-boot.bin
heimdall flash --RECOVERY boot.img

The custom u-boot works fine so far! Using the Linux kernel boot.img from your sources, I get further and two penguins show up and a cursor is blinking. I guess I have to look where I can find the boot parameters and I would like to boot an OS from internal mmc if thats possible.
With the boot.img from my upstream kernel sources, it stucks at "Starting kernel ...". Looks like I have to further find patches you made to the source ...

Is it a big work to port this custom uboot galaxys2 profile to the newest uboot version? I have looked into the source code and uboot changed a lot so I'm not sure. Maybe @astarasikov or @Talustus still know ;)

@Sekilsgs2
Copy link
Owner

Sekilsgs2 commented Dec 16, 2019 via email

@onny
Copy link
Author

onny commented Dec 17, 2019

I got a bit further, having output on the screen :) Unfortunately there seems to be an issue trying to mount the emmc (sdcard) and booting Linux:
image

I'm using following U-Boot parameters:

"galaxy_boot=" \
        /*"setenv verify n; "*/ \
        "setenv loadaddr 0x4EE08000; " \
        /*"setenv dev_extras console=tty0 --no-log lpj=3981312; "*/ \
        "setenv dev_extras console=tty0 lpj=3981312; " \
        "mmc rescan; " \
        "echo Regular boot; " \
        "run boot_android;\0 " \
\

and

"boot_android=" \
        /* "setenv android_cmd loglevel=4 console=ram sec_debug.enable=0 " \ */ \
        "setenv android_cmd loglevel=4 console=ttyS0,115200n8 console=tty0 sec_debug.enable=0 " \
                "sec_debug.enable_user=0 sec_log=0x100000@0x4d900000 " \
                "s3cfb.bootloaderfb=0x5ec00000 ld9040.get_lcdtype=0x2 " \
                "consoleblank=0 lpj=3981312 vmalloc=144m " \
                "root=/dev/mmcblk0p1 rw rootfstype=ext4 rootwait init=/sbin/init ;" \
        "if test $sgs2_bootmode_val -eq 1; then "\
                "setenv android_cmd ${android_cmd} bootmode=2; " \
        "fi ;" \
        "mmc dev 0; " \
        "mmc read ${loadaddr} 0x16000 0x4000; " \
        "setenv bootargs ${android_cmd}; "\
        "echo Command Line: ${bootargs}; " \
        "bootm ${loadaddr}\0" \
\

Unfortunately I have no serial/uart connection, so debbing is a bit hard. Not sure how to solve this yet ...

@Sekilsgs2
Copy link
Owner

Sekilsgs2 commented Dec 17, 2019 via email

@onny
Copy link
Author

onny commented Dec 17, 2019

Thanks that was a good hint! It is finally booting now but I used mmcblk1p1 with rootwait parameter :) ArchLinux is running!

image

Now I'm trying to figure out how to connect to the device. Usb serial is somehow not working (nothing shows up in minicom). Also tried to enable CONFIG_USB_ETH, writing g_ether into /etc/modules-load.d/gether.conf and options g_ether host_addr=12:a5:cf:42:92:fd dev_addr=5e:bc:ca:27:92:b1 idVendor=1317 idProduct=42146 into /etc/modprobe.d/g_ether.conf but at startup I can only read module-load failed :(

Maybe I could try it with wifi? I read here that I have to load firmware files with dhd, is this still correct? https://archlinuxarm.org/forum/viewtopic.php?f=27&t=5284

Anyway thank you for the support so far!

@Sekilsgs2
Copy link
Owner

Sekilsgs2 commented Dec 18, 2019 via email

@Sekilsgs2
Copy link
Owner

Sekilsgs2 commented Dec 18, 2019 via email

@onny
Copy link
Author

onny commented Dec 18, 2019

@Sekilsgs2 thanks for the info. I skipped the usb networking/serial part and plugged in an usb keyboard with usb-otg. It is working fine and I can now access the phone :)

Now I'm trying to get wifi working but ip a doesn't show me any device yet. I downloaded this nvram txt file and copied it to /usr/lib/firmware/brcm/brcmfmac4330-sdio.samsung,i9100.txt since brcmfmac was asking for it. lsmod shows that brcmfmac is loaded. dmesg has no further errors but also doesn't show any activity regarding a wifi device :( The package linux-firmware is providing the file brcmfmac4330-sdio.bin in ArchLinuxArm.

dmesg tells bluetooth is working after I downloaded BCM4330B1.hcd and copied it to /usr/lib/firmware/brcm.

@Sekilsgs2
Copy link
Owner

Sekilsgs2 commented Dec 18, 2019 via email

@onny
Copy link
Author

onny commented Dec 18, 2019

Thanks this worked! Next step is try to use mainline kernel provided by ArchLinuxArm by supplying the dtb file. Maybe this is possible :)

@onny
Copy link
Author

onny commented Dec 20, 2019

I was able to boot kernel 5.4.5 :) These are the commands I used:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
cd linux-stable
git checkout tags/5.4.5
wget "https://raw.githubusercontent.com/Sekilsgs2/i9100_kernel_mainline_port/6c02dad36b8a76a6f50d26ff1b9abb0d30aacbc9/arch/arm/configs/i9100_defconfig" -O arch/arm/configs/i9100_defconfig
wget "https://raw.githubusercontent.com/Sekilsgs2/i9100_kernel_mainline_port/master/arch/arm/boot/dts/exynos4210-i9100.dts" -O arch/arm/boot/dts/exynos4210-i9100.dts
wget "https://raw.githubusercontent.com/Sekilsgs2/i9100_kernel_mainline_port/master/arch/arm/boot/dts/exynos4210.dtsi" -O arch/arm/boot/dts/exynos4210.dtsi
# patch file arch/arm/boot/dts/Makefile
export ARCH=arm
export CROSS_COMPILE=arm-none-eabi-
make i9100_defconfig
make -j6
make dtbs
cat arch/arm/boot/zImage arch/arm/boot/dts/exynos4210-i9100.dtb > zimage
mkimage -A arm -O linux -T kernel -C none -a 0x40008000 -e 0x40008000 -n Linux-android-sucks -d zimage boot.img
make modules_install INSTALL_MOD_PATH=../
# heimdall flash --kernel u-boot.bin

It is booting so far but USB-OTG isn't working anymore so I'm unable to plug-in and use the keyboard. Not sure yet if this is due to the new kernel, unmodified patches you made or kernel configuration.

I had to comment following section in arch/arm/boot/dts/exynos4210-i9100.dts in order to make make dtbs work, I guess this section is referencing a patched file:

&pinctrl_0 {
        pinctrl-names = "default";
        pinctrl-0 = <&sleep0>;


        sleep0: sleep-states {
                PIN_SLP(gpa0-0, INPUT, NONE);
                PIN_SLP(gpa0-1, OUT0, NONE);
                PIN_SLP(gpa0-2, INPUT, NONE);
                PIN_SLP(gpa0-3, OUT1, NONE);
    };
};

The screen output is also upside down

@pcercuei
Copy link

pcercuei commented Mar 8, 2020

@onny could you share your u-boot.bin? I'm on Debian and the process of compiling the downstream u-boot for i9100 looks like a PITA.

@onny
Copy link
Author

onny commented Mar 9, 2020

@pcercuei Have a look at this older thread, you'll get precompiled images there https://forum.xda-developers.com/galaxy-s2/general/uboot-bootloader-true-multiboot-t1680898

@Sekilsgs2
Copy link
Owner

@pcercuei Have a look at this older thread, you'll get precompiled images there https://forum.xda-developers.com/galaxy-s2/general/uboot-bootloader-true-multiboot-t1680898

No this dont have ext4 support. I'm can build but next days - now no time..

@Sekilsgs2
Copy link
Owner

@onny could you share your u-boot.bin? I'm on Debian and the process of compiling the downstream u-boot for i9100 looks like a PITA.

But why problem download from my repo compiller and compile this?

@pcercuei
Copy link

pcercuei commented Mar 9, 2020

@Sekilsgs2 the old uboot is fine; I don't need ext4, I just boot the kernel's uImage from the recovery partition.

I successfully booted 5.6-rc4. It went relatively smooth. PostmarketOS with Phosh is working. 3D acceleration works. eUSB-ethernet works too (didn't try OTG). Next on my list is WiFi / bluetooth.

IMG_20200308_182536

@onny
Copy link
Author

onny commented Mar 9, 2020

@pcercuei Great work, this looks really nice! I wrote an instruction for proprietary firmware files here https://wiki.postmarketos.org/wiki/Samsung_Galaxy_SII_(samsung-i9100)#Firmware_files . Would be cool if we could package them for PostmarketOS and further package an i9100-linux mainline kernel

@pcercuei
Copy link

pcercuei commented Mar 9, 2020

@onny will give it a try, thanks.
Right now I'm using an unpatched kernel with the right devicetree, so I don't think we even need a i9100-linux package.

About the screen being backwards: on postmarketOS' UI, press power to turn off the screen, then turn it on again, and the rotation is gone. Strange. But then the UI is usable with the touchscreen.

@pcercuei
Copy link

@Sekilsgs2, @onny - I'm going to try to send the i9100's devicetree file upstream. I cleaned it a bit so that the DT maintainer will be happy. Some things have been tweaked too, e.g. the LDO13 regulator is now 3.0V instead of 3.3V.

Here's the future patchset: torvalds/linux@v5.6-rc5...OpenDingux:for-upstream-i9100

Did you modify parts of it? If so I'll need you to sign the patchset as well since you have a copyright.

@Sekilsgs2
Copy link
Owner

Yes - this dt my work. What need?
Stenkin Evgeniy [email protected]

@pcercuei
Copy link

Updated the patchset: torvalds/linux@v5.6-rc5...OpenDingux:for-upstream-i9100

I set you as the devicetree patch's author, added your copyright in the file's header, and added:
Signed-off-by: Stenkin Evgeniy <[email protected]>

If you're OK I'll submit it later today.

@Sekilsgs2
Copy link
Owner

Yes - all good.

@pcercuei
Copy link

How can I boot it without u-boot?

@Sekilsgs2
Copy link
Owner

Sekilsgs2 commented Mar 18, 2020

Good question :) I'm think no way or i'm dont know
Why you need load without u-boot?

@pcercuei
Copy link

The original i9100 v3.0 kernel that comes with PostmarketOS is flashed to the KERNEL partition, and has the initramfs in RECOVERY. I want to do the same, but it looks like that right now the upstream kernel can only start using u-boot.

@onny
Copy link
Author

onny commented Mar 18, 2020

It's the same with Galaxy S III mini: https://wiki.postmarketos.org/wiki/Samsung_Galaxy_S_III_mini_(samsung-golden)#Installation

The mainline kernel can only be booted through U-Boot, not directly with the Samsung bootloader. U-Boot is installed as intermediate bootloader on the boot partition, so it does not replace the Samsung bootloader entirely. pmbootstrap can only support one bootloader configuration at the moment, which is why U-Boot is also recommended when installing the downstream kernel.

@pcercuei
Copy link

I think we need u-boot + Linux flashed to the KERNEL partition (Linux flashed at an offset that u-boot reads from). Then it would work with PostmarketOS.

@pcercuei
Copy link

Looks like the devicetree was accepted upstream :)

Another issue I noticed: with the mainline kernel the contrast on the display is terrible. The black is not black, but grey.

@Sekilsgs2
Copy link
Owner

Thank :)
I'm think gamma related to other lcd driver configs - need compare to stock

@astarasikov
Copy link

Btw back in 2012/2013 I tried getting I9100 to work with the upstream kernel (Linaro 3.3 at the moment).
https://github.com/astarasikov/i9100-proper-linux-kernel/commits/i9100_linaro_33

I ported the sound driver (look above) and made it work somehow without Android userspace (at least for the speaker/headphones part for music), although good luck getting that one upstreamed. I also enabled the camera (FIMC) with open-source upstream drivers but never managed to confirm it works because there were no userspace apps that supported videobuf2 API back then.

For the phone part (if you're interested), I've added all the necessary changes to Replicant's "libsamsung-ril" so there is open-source userspace/RIL at least for Android. I have not however managed to get ofono or other non-Android stacks to work back then.

If you're interested in sound and camera, check out this post by Replicant developers. They got the sound driver to work without hacking the driver, but only for Android.
https://code.paulk.fr/article9/galaxy-s2-replicant-port-status-update

The links from the blog post have expired but here are some mirrors.
https://git.replicant.us/replicant/device_samsung_galaxys2/log/
https://github.com/GrimKriegor/replicant-device_samsung_galaxys2-common/commits/replicant-4.2/camera

P.S. for booting without u-boot, Linux has two options: concatenated DTB and hardcoding command line into the kernel config (so that it does not use the one from the bootloader).

@pcercuei
Copy link

I did write a few codec and sound drivers, so I can have a look at this one. Not promising anything.

Having support for the camera would be great, too. I did not look that much into it, but I know the two sensors are supported by the upstream kernel.

The problem for booting without u-boot is that Samsung's sboot starts its payload with the MMU enabled and caches not reset, and Linux is not able to cope with that without a patch that was not accepted upstream.

@astarasikov
Copy link

astarasikov commented Apr 15, 2020 via email

@Mis012
Copy link

Mis012 commented Aug 26, 2020

could you please fix the missing git history? thx

@onny
Copy link
Author

onny commented Aug 26, 2020

Wow that's great, the device tree for this device is upstream now :D Thanks @pcercuei @Sekilsgs2
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/arch/arm/boot/dts/exynos4210-i9100.dts?h=v5.8.3

@Sekilsgs2
Copy link
Owner

could you please fix the missing git history? thx

No.. im work on pc without commiting history and simple load all files to git. You can make diff with stock and my to see differents.

@HexagonWin
Copy link

Hi people. sorry for suddenly question post..
Can I please ask what is currently working in this mainline kernel?
I guess the GPU accel and boot, display, wifi are working as the posts above. (Phosh I saw that)
However is that screen upside down?
And other things..? Like sound.. I guess they do not work as of now?
Thanks. :)

Hexagonwin

@pcercuei
Copy link

Last time I tested it the display was upside-down, yes. I don't remember if sound works. WiFi / Bluetooth probably work, I didn't test them last time as I didn't have the firmware files.

@Sekilsgs2
Copy link
Owner

Привет народ. извините за неожиданный вопрос .. Могу я спросить, что в настоящее время работает в этом основном ядре? Я предполагаю, что ускорение и загрузка графического процессора, дисплей, Wi-Fi работают как сообщения выше. (Фош, я это видел) Но разве этот экран перевернут? И другие вещи..? Вроде звук .. Полагаю, они пока не работают? Спасибо. :)

Hexagonwin

On this kernel - lcd working normal - without any rotations - maybe mainline have such problems- dont know..
Sound not working and i'm think never - need porting very old yamaha driver - maybe using bluetooth for sound? :)
gfx mali - dont know...

@HexagonWin
Copy link

Привет народ. извините за неожиданный вопрос .. Могу я спросить, что в настоящее время работает в этом основном ядре? Я предполагаю, что ускорение и загрузка графического процессора, дисплей, Wi-Fi работают как сообщения выше. (Фош, я это видел) Но разве этот экран перевернут? И другие вещи..? Вроде звук .. Полагаю, они пока не работают? Спасибо. :)
Hexagonwin

On this kernel - lcd working normal - without any rotations - maybe mainline have such problems- dont know.. Sound not working and i'm think never - need porting very old yamaha driver - maybe using bluetooth for sound? :) gfx mali - dont know...

Then things like RIL and Sound not working?
I am planning to get a S2 some time later, planning to also document the mainline stuff on postmarketOS wiki. :)

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

7 participants