Author Topic: Need cross compile tutorials.  (Read 1586 times)

cain2pang

  • Newbie
  • *
  • Posts: 24
    • View Profile
Need cross compile tutorials.
« on: September 18, 2019, 12:07:00 am »
Hi, I'm trying to build linux kernel for c3100, can anybody give me some cross compile tutorials.

Thanks in advance
Sharp Zaurus C3100 (Borzoi) running Arch Linux ARM.
GPD MicroPC running Manjaro XFCE.

Varti

  • Administrator
  • Hero Member
  • *****
  • Posts: 1085
    • View Profile
Need cross compile tutorials.
« Reply #1 on: September 18, 2019, 07:58:56 am »
Hi, you should ask for help to our Zaurus kernel expert, greguu. Why would you want to compile it yourself btw, is there any feature or module in the current kernel which you need and is missing?

Varti
Planet Gemini PDA WiFi/LTE with Mediatek x27
SL-C1000 running Arch Linux ARM May2017, K30225 Wi-Fi CF Card, 64GB SDXC card
and many other Zauruses!

cain2pang

  • Newbie
  • *
  • Posts: 24
    • View Profile
Need cross compile tutorials.
« Reply #2 on: September 19, 2019, 01:21:19 am »
Quote from: Varti
Hi, you should ask for help to our Zaurus kernel expert, greguu. Why would you want to compile it yourself btw, is there any feature or module in the current kernel which you need and is missing?

Varti
em.... Just wanna try. I'm free recently, have a lot time to try something.
Sharp Zaurus C3100 (Borzoi) running Arch Linux ARM.
GPD MicroPC running Manjaro XFCE.

greguu

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
    • http://github.com/greguu
Need cross compile tutorials.
« Reply #3 on: September 24, 2019, 01:43:47 am »
Quote from: cain2pang
Quote from: Varti
Hi, you should ask for help to our Zaurus kernel expert, greguu. Why would you want to compile it yourself btw, is there any feature or module in the current kernel which you need and is missing?

Varti
em.... Just wanna try. I'm free recently, have a lot time to try something.
I switched to Void Linux for building some time ago. You can find my kernel build template here:https://github.com/greguu/voidz-packages/tree/voidz-packages-v03-(build8)/srcpkgs/linux5.0-zaurus
I would recommend to use Void Linux 64 bit musl as a build host for building voidz rootfs images and packages.
You find some instructions on how to build using xbps-src here: https://github.com/greguu/voidz-packages
You can also build the kernel under Arch Linux. For this get the ArchLinuxARM toolchain for armv5tel.https://archlinuxarm.org/builder/xtools/x-tools.tar.xz
Then get the kernel src 5.0.0 and patch it with the patches provided under my void template.
or write a pkgbuild file to apply the patches.
"Manual" cross-compile you can do with a wrapper bash/sh file like this:
Code: [Select]
export ARCH=arm export PATH='/usr/local/x-tools/arm-unknown-linux-gnueabi/bin':$PATH export CROSS_COMPILE=arm-unknown-linux-gnueabi- export STAGING_DIR=/usr/local/x-tools/arm-unknown-linux-gnueabi export CC=arm-unknown-linux-gnueabi-gcc export LD=arm-unknown-linux-gnueabi-ld export TARGET=arm export HOSTCC=gcc
make -j4 "$1"
Gemini-PDA (Stock Android) / LG Nexus 5 (Sailfish OS) / Nokia N9 (MeeGo/Harmattan)
Sharp Zaurus C3100 (Borzoi) - Void Linux (voidz) Kernel 5.0.0 - Hardware (Buffalo CF LAN, DLink 660 CF WiFi, ASIX AX88772 USB Ethernet)

cain2pang

  • Newbie
  • *
  • Posts: 24
    • View Profile
Need cross compile tutorials.
« Reply #4 on: September 24, 2019, 02:44:37 am »
Thanks greguu.

My target is to write a detailed document to help anothers to build a Linux distribution by themself, include boot loader, kernel and rootfs.

I had built the linux 5.0 kernel successfully with the config file and patch files in https://github.com/greguu/voidz-packages/tr...linux5.0-zaurus, and it works well with the ZALARM rootfs which provide by you. Many thanks.

Now I'm trying to build the kexecboot, here are the steps I'm working on:

1. build kexecboot
2. make a initramfs with the kexecboot in step one and kexec.
3. build the linux kernel zImage with the initramfs in step two.

Are the steps correct?
« Last Edit: September 24, 2019, 02:50:05 am by cain2pang »
Sharp Zaurus C3100 (Borzoi) running Arch Linux ARM.
GPD MicroPC running Manjaro XFCE.

cain2pang

  • Newbie
  • *
  • Posts: 24
    • View Profile
Need cross compile tutorials.
« Reply #5 on: September 26, 2019, 12:00:50 am »
Quote from: greguu
Quote from: cain2pang
Quote from: Varti
Hi, you should ask for help to our Zaurus kernel expert, greguu. Why would you want to compile it yourself btw, is there any feature or module in the current kernel which you need and is missing?

Varti
em.... Just wanna try. I'm free recently, have a lot time to try something.
I switched to Void Linux for building some time ago. You can find my kernel build template here:https://github.com/greguu/voidz-packages/tree/voidz-packages-v03-(build8)/srcpkgs/linux5.0-zaurus
I would recommend to use Void Linux 64 bit musl as a build host for building voidz rootfs images and packages.
You find some instructions on how to build using xbps-src here: https://github.com/greguu/voidz-packages
You can also build the kernel under Arch Linux. For this get the ArchLinuxARM toolchain for armv5tel.https://archlinuxarm.org/builder/xtools/x-tools.tar.xz
Then get the kernel src 5.0.0 and patch it with the patches provided under my void template.
or write a pkgbuild file to apply the patches.
"Manual" cross-compile you can do with a wrapper bash/sh file like this:
Code: [Select]
export ARCH=arm export PATH='/usr/local/x-tools/arm-unknown-linux-gnueabi/bin':$PATH export CROSS_COMPILE=arm-unknown-linux-gnueabi- export STAGING_DIR=/usr/local/x-tools/arm-unknown-linux-gnueabi export CC=arm-unknown-linux-gnueabi-gcc export LD=arm-unknown-linux-gnueabi-ld export TARGET=arm export HOSTCC=gcc
make -j4 "$1"

Hi greguu

I want to build Kexecboot with linux 5.0, but I don't know how to start, the wiki in https://github.com/kexecboot/kexecboot/wiki is too old and I don't want to use OpenEmbedded.
Can you give me some tutorials how to start the work?

Thanks.
Sharp Zaurus C3100 (Borzoi) running Arch Linux ARM.
GPD MicroPC running Manjaro XFCE.

greguu

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
    • http://github.com/greguu
Need cross compile tutorials.
« Reply #6 on: September 26, 2019, 02:42:15 am »
Quote from: cain2pang
Hi greguu

I want to build Kexecboot with linux 5.0, but I don't know how to start, the wiki in https://github.com/kexecboot/kexecboot/wiki is too old and I don't want to use OpenEmbedded.
Can you give me some tutorials how to start the work?

Thanks.

Hi cain2pang,
I am not sure you will get a 5.0.0 kernel kexecboot to work without taking out some features from the kernel config.
 The last version I build was using 4.14 kernel.After that version the kexec kernel got too large to fit in the Zaurus kernel partition.  
This is the latest kexecboot kernel. https://github.com/greguu/voidz-packages-ol...execboot.tar.xz
I need to check my build server and get the .config file and patches for the kexecboot kernel. Its the same source as https://github.com/greguu/linux-4.14.18-c3x00 but does need a different .config and initramfs.cpio containing kexecboot.

Do you want to rebuild kexecboot as well or just the kernel ?
Cheers!
« Last Edit: September 26, 2019, 03:31:54 am by Varti »
Gemini-PDA (Stock Android) / LG Nexus 5 (Sailfish OS) / Nokia N9 (MeeGo/Harmattan)
Sharp Zaurus C3100 (Borzoi) - Void Linux (voidz) Kernel 5.0.0 - Hardware (Buffalo CF LAN, DLink 660 CF WiFi, ASIX AX88772 USB Ethernet)

greguu

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
    • http://github.com/greguu
Need cross compile tutorials.
« Reply #7 on: September 26, 2019, 03:07:19 am »
Quote from: greguu
Hi cain2pang,
I am not sure you will get a 5.0.0 kernel kexecboot to work without taking out some features from the kernel config.
 The last version I build was using 4.14 kernel.After that version the kexec kernel got too large to fit in the Zaurus kernel partition.  
This is the latest kexecboot kernel. https://github.com/greguu/voidz-packages-ol...execboot.tar.xz
I need to check my build server and get the .config file and patches for the kexecboot kernel. Its the same source as https://github.com/greguu/linux-4.14.18-c3x00 but does need a different .config and initramfs.cpio containing kexecboot.

Do you want to rebuild kexecboot as well or just the kernel ?
Cheers!


Attached the 4.14.18 kernel .config for void linux kexecboot and the initramfs. This should help you get going.
Source is same as https://github.com/greguu/linux-4.14.18-c3x00
« Last Edit: September 26, 2019, 03:32:32 am by Varti »
Gemini-PDA (Stock Android) / LG Nexus 5 (Sailfish OS) / Nokia N9 (MeeGo/Harmattan)
Sharp Zaurus C3100 (Borzoi) - Void Linux (voidz) Kernel 5.0.0 - Hardware (Buffalo CF LAN, DLink 660 CF WiFi, ASIX AX88772 USB Ethernet)

cain2pang

  • Newbie
  • *
  • Posts: 24
    • View Profile
Need cross compile tutorials.
« Reply #8 on: September 26, 2019, 03:21:43 am »
Quote from: greguu
Hi cain2pang,
I am not sure you will get a 5.0.0 kernel kexecboot to work without taking out some features from the kernel config.
 The last version I build was using 4.14 kernel.After that version the kexec kernel got too large to fit in the Zaurus kernel partition.  
This is the latest kexecboot kernel. https://github.com/greguu/voidz-packages-ol...execboot.tar.xz
I need to check my build server and get the .config file and patches for the kexecboot kernel. Its the same source as https://github.com/greguu/linux-4.14.18-c3x00 but does need a different .config and initramfs.cpio containing kexecboot.

Do you want to rebuild kexecboot as well or just the kernel ?
Cheers!

Thanks greguu, I had built the kexecboot, my problems is how to make a image with the kexecboot.
I noticed the CONFIG_INITRAMFS_SOURCE="initramfs.cpio.xz" in you config file, I will try to make a initramfs.cpio.xz file and then the kernel image.
I will have a 7 days holiday from October 1st, hope I can go through the building of kernel and kexecboot, and make them boot on my c3100 device.
If everything is OK, I will organize these steps to write a tutorial document.
Thanks again for all your help, greguu.
« Last Edit: September 26, 2019, 03:27:51 am by cain2pang »
Sharp Zaurus C3100 (Borzoi) running Arch Linux ARM.
GPD MicroPC running Manjaro XFCE.

greguu

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
    • http://github.com/greguu
Need cross compile tutorials.
« Reply #9 on: September 26, 2019, 04:17:48 am »
Quote from: cain2pang
Quote from: greguu
Hi cain2pang,
I am not sure you will get a 5.0.0 kernel kexecboot to work without taking out some features from the kernel config.
 The last version I build was using 4.14 kernel.After that version the kexec kernel got too large to fit in the Zaurus kernel partition.  
This is the latest kexecboot kernel. https://github.com/greguu/voidz-packages-ol...execboot.tar.xz
I need to check my build server and get the .config file and patches for the kexecboot kernel. Its the same source as https://github.com/greguu/linux-4.14.18-c3x00 but does need a different .config and initramfs.cpio containing kexecboot.

Do you want to rebuild kexecboot as well or just the kernel ?
Cheers!

Thanks greguu, I had built the kexecboot, my problems is how to make a image with the kexecboot.
I noticed the CONFIG_INITRAMFS_SOURCE="initramfs.cpio.xz" in you config file, I will try to make a initramfs.cpio.xz file and then the kernel image.
I will have a 7 days holiday from October 1st, hope I can go through the building of kernel and kexecboot, and make them boot on my c3100 device.
If everything is OK, I will organize these steps to write a tutorial document.
Thanks again for all your help, greguu.
You can build your own initramfs.cpio.xz like this example:

Code: [Select]
cd cpio/
find . | cpio -o -H newc | xz --check=crc32 --lzma2=dict=512KB > ../initramfs.cpio.xz
Gemini-PDA (Stock Android) / LG Nexus 5 (Sailfish OS) / Nokia N9 (MeeGo/Harmattan)
Sharp Zaurus C3100 (Borzoi) - Void Linux (voidz) Kernel 5.0.0 - Hardware (Buffalo CF LAN, DLink 660 CF WiFi, ASIX AX88772 USB Ethernet)

greguu

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
    • http://github.com/greguu
Need cross compile tutorials.
« Reply #10 on: September 26, 2019, 04:25:14 am »
Quote from: cain2pang
If everything is OK, I will organize these steps to write a tutorial document.
Please share your success with our community.
« Last Edit: September 26, 2019, 04:25:38 am by greguu »
Gemini-PDA (Stock Android) / LG Nexus 5 (Sailfish OS) / Nokia N9 (MeeGo/Harmattan)
Sharp Zaurus C3100 (Borzoi) - Void Linux (voidz) Kernel 5.0.0 - Hardware (Buffalo CF LAN, DLink 660 CF WiFi, ASIX AX88772 USB Ethernet)

cain2pang

  • Newbie
  • *
  • Posts: 24
    • View Profile
Need cross compile tutorials.
« Reply #11 on: September 26, 2019, 05:11:44 am »
Quote from: greguu
Quote from: cain2pang
If everything is OK, I will organize these steps to write a tutorial document.
Please share your success with our community.

OK, this is the reason why I do these things.
Sharp Zaurus C3100 (Borzoi) running Arch Linux ARM.
GPD MicroPC running Manjaro XFCE.

greguu

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
    • http://github.com/greguu
Need cross compile tutorials.
« Reply #12 on: September 27, 2019, 04:47:49 am »
Quote from: cain2pang
Quote from: greguu
Quote from: cain2pang
If everything is OK, I will organize these steps to write a tutorial document.
Please share your success with our community.  

OK, this is the reason why I do these things.  
No worries, nice to see someone working on Zaurus. Happy to help anytime
Gemini-PDA (Stock Android) / LG Nexus 5 (Sailfish OS) / Nokia N9 (MeeGo/Harmattan)
Sharp Zaurus C3100 (Borzoi) - Void Linux (voidz) Kernel 5.0.0 - Hardware (Buffalo CF LAN, DLink 660 CF WiFi, ASIX AX88772 USB Ethernet)

cain2pang

  • Newbie
  • *
  • Posts: 24
    • View Profile
Need cross compile tutorials.
« Reply #13 on: February 27, 2020, 09:05:18 pm »
Quote from: greguu
No worries, nice to see someone working on Zaurus. Happy to help anytime

I'm sorry I haven't logged into the forum for such a long time.
I had tried to compile kexecboot many times, using static compilation method, and the size is still around 500kb after strip.
I noticed that the size of kexecboot in the file you gave is about 90KB.

The toolchain I use is the latest version of https://archlinuxarm.org/builder/xtools/x-tools.tar.xz.
When I use readelf to check the information of the files I found that the alignment values of .text section in my compiled file and your compiled file are 16 and 4 respectively.
Do you use a different custom ld script, or is there something wrong with my approach?

Thanks.
Sharp Zaurus C3100 (Borzoi) running Arch Linux ARM.
GPD MicroPC running Manjaro XFCE.

cain2pang

  • Newbie
  • *
  • Posts: 24
    • View Profile
Need cross compile tutorials.
« Reply #14 on: February 28, 2020, 12:24:08 am »
I think I find the key, I build kexec, kexecboot with klibc, and the size is correct now.
Sharp Zaurus C3100 (Borzoi) running Arch Linux ARM.
GPD MicroPC running Manjaro XFCE.