OESF Portables Forum

Model Specific Forums => Sharp Zaurus => Zaurus - Arch Linux ARM support => Topic started by: cain2pang on September 18, 2019, 12:07:00 am

Title: Need cross compile tutorials.
Post by: cain2pang 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
Title: Need cross compile tutorials.
Post by: Varti 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
Title: Need cross compile tutorials.
Post by: cain2pang 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.
Title: Need cross compile tutorials.
Post by: greguu 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 (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"
Title: Need cross compile tutorials.
Post by: cain2pang 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 (https://github.com/greguu/voidz-packages/tree/voidz-packages-v03-(build8)/srcpkgs/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?
Title: Need cross compile tutorials.
Post by: cain2pang 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 (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 (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.
Title: Need cross compile tutorials.
Post by: greguu 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 (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 (https://github.com/greguu/voidz-packages-old/releases/download/build-005/zImage-4.14.18-kexecboot.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 (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!
Title: Need cross compile tutorials.
Post by: greguu 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 (https://github.com/greguu/voidz-packages-old/releases/download/build-005/zImage-4.14.18-kexecboot.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 (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 (https://github.com/greguu/linux-4.14.18-c3x00)
Title: Need cross compile tutorials.
Post by: cain2pang 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 (https://github.com/greguu/voidz-packages-old/releases/download/build-005/zImage-4.14.18-kexecboot.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 (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.
Title: Need cross compile tutorials.
Post by: greguu 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 (https://github.com/greguu/voidz-packages-old/releases/download/build-005/zImage-4.14.18-kexecboot.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 (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
Title: Need cross compile tutorials.
Post by: greguu 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.
Title: Need cross compile tutorials.
Post by: cain2pang 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.
Title: Need cross compile tutorials.
Post by: greguu 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
Title: Need cross compile tutorials.
Post by: cain2pang 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 (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.
Title: Need cross compile tutorials.
Post by: cain2pang 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.
Title: Need cross compile tutorials.
Post by: Varti on February 28, 2020, 04:04:43 am
Quote from: cain2pang
I think I find the key, I build kexec, kexecboot with klibc, and the size is correct now.
That's nice, have you also tried to boot it on the Z?

Varti
Title: Need cross compile tutorials.
Post by: cain2pang on February 28, 2020, 09:33:54 pm
Quote from: Varti
Quote from: cain2pang
I think I find the key, I build kexec, kexecboot with klibc, and the size is correct now.
That's nice, have you also tried to boot it on the Z?

Varti

I had tried but something works wrong, I'm still working on that.
Title: Need cross compile tutorials.
Post by: cain2pang on March 03, 2020, 07:09:17 am
Quote from: greguu
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 (https://github.com/greguu/linux-4.14.18-c3x00)

Sorry, seems the config file is missed, can you reupload it?
Title: Need cross compile tutorials.
Post by: Varti on March 03, 2020, 07:16:41 am
Quote from: cain2pang
Quote from: greguu
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 (https://github.com/greguu/linux-4.14.18-c3x00)

Sorry, seems the config file is missed, can you reupload it?
Do you mean the kexecboot.tar.gz attached to that post? I have successfully downloaded it, and I have seen it contains a .config and a initramfs.cpio.xz archive. Is the .config file the one you are searching for?

Varti
Title: Need cross compile tutorials.
Post by: cain2pang on March 03, 2020, 09:52:59 am
Quote from: Varti
Do you mean the kexecboot.tar.gz attached to that post? I have successfully downloaded it, and I have seen it contains a .config and a initramfs.cpio.xz archive. Is the .config file the one you are searching for?

Varti

Sorry, my mistake, I ignored the hidden file.
Title: Need cross compile tutorials.
Post by: greguu on March 17, 2020, 03:23:39 am
Quote from: cain2pang
I think I find the key, I build kexec, kexecboot with klibc, and the size is correct now.

Yes that is the way, use klibc or glibc and make sure to "strip" the binary, too.  I have not tried musl for kexecboot, but should also work