Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: andyj on January 16, 2015, 09:41:12 AM

Title: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: andyj on January 16, 2015, 09:41:12 AM
I've been using TinyCore for a while but I'm just now starting to work on the Raspberry Pi. I have a few things I'd like to get going on the Pi: libnfc / nfcutils and a USB display. They've been done on other distros so I'm sure it's possible. My question is: From everyone's experience, is it better to set up a build environment on the Pi and build there natively or cross compile on a bigger faster multi-core box? Is setting up a native build environment about the same as PC hardware?

Any and all tales of success and woe are welcome.

Thanks,

Andy
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: Paul_123 on January 16, 2015, 10:15:33 AM
I've been using TinyCore for a while but I'm just now starting to work on the Raspberry Pi. I have a few things I'd like to get going on the Pi: libnfc / nfcutils and a USB display. They've been done on other distros so I'm sure it's possible. My question is: From everyone's experience, is it better to set up a build environment on the Pi and build there natively or cross compile on a bigger faster multi-core box? Is setting up a native build environment about the same as PC hardware?

Any and all tales of success and woe are welcome.

Thanks,

Andy

When building stuff for the piCore environment, I build it on a piCore box, to ensure the libraries and the dev headers are all the same version.   I've had the most problems with the multimedia libraries.....as there is seems to be compatability issues when mixing versions.

If you don't have to link with alot of external libraries, then building anywhere should work fine.    I have a CC setup on my x86 box, and the binaries work just fine on Raspbian and tinycore boxes.
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: bmarkus on January 16, 2015, 10:31:10 AM
I'm crosscompiling only the kernel. All others are built native. While you can crosscompile simple programs with no or just few dependencies, in case of complex apps very soon cross complation fails for one or other reason and you are wasting much more time resolving the issue than waiting for native build finished. Even if it takes a day, you don't have to deal with.

What you can do is to have a fast ARM board and run piCore. ARM code is binary backward compatible, it works for examle on BeagleBone Black where compilation is nearly 3 times faster and still it has a single CPU. You can buy now cheap quad-core SBC's for the same price as Raspberry Pi. In fact, you can buy only faster boards than RPi today. BTW, Raspbian is also built on fast ARM board.
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: andyj on January 16, 2015, 11:28:01 AM
Do you think the ODROID-C1 would be a good dev platform? Any known issues?

Andy
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: bmarkus on January 16, 2015, 11:33:32 AM
Do you think the ODROID-C1 would be a good dev platform? Any known issues?

Andy

C1 looks OK.
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: eno on January 17, 2015, 07:55:02 AM
Does piCore run on the Odroid ?
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: Paul_123 on January 17, 2015, 08:15:23 AM
not yet,  the BBB was just released as an alpha.    But look here http://forum.tinycorelinux.net/index.php/topic,17895.0.html

Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: bmarkus on January 18, 2015, 04:43:00 AM
I've been using TinyCore for a while but I'm just now starting to work on the Raspberry Pi. I have a few things I'd like to get going on the Pi: libnfc / nfcutils and a USB display.

libnfc.tcz / nfcutils.tcz added to piCore 6.x repo
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: andyj on January 18, 2015, 07:08:09 AM
Thanks for libnfc. It will be good to have "native" support for NFC. I finished making those extensions last night myself. I added the one program in nfcutils (lsnfc) to the libnfc extension, rather than have a second extension with only one file in it. I'm moving on to rpusbdisp, which to make a long story short requires something like patching the kernel sources to make the module. Where can I get a tarball of the compiled kernel source without having to make it myself? I understand that would take a really long time.

Also above someone said that piCore wouldn't run on an ODROID. Why would that be?
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: Paul_123 on January 18, 2015, 10:44:11 AM
Thanks for libnfc. It will be good to have "native" support for NFC. I finished making those extensions last night myself. I added the one program in nfcutils (lsnfc) to the libnfc extension, rather than have a second extension with only one file in it. I'm moving on to rpusbdisp, which to make a long story short requires something like patching the kernel sources to make the module. Where can I get a tarball of the compiled kernel source without having to make it myself? I understand that would take a really long time.

Also above someone said that piCore wouldn't run on an ODROID. Why would that be?

Because it requires bootcode and kernel for the Odroid.   I feel like tinkering, so I'm going to grab an Odroid-C1 and give it a shot.   I have a Wandboard-Quad, but I use that for a media server, and don't want to take it down to play.

The kernel source for piCore comes from the Raspberry Pi Github.   https://github.com/raspberrypi/linux   Grab the config from a working piCore in /proc/config.gz

Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: andyj on January 18, 2015, 06:42:46 PM
I was hoping for the linux directory tree where the kernel was already made. I'm trying to build a module against it and the files it needs like the "generated" directory aren't there.
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: Paul_123 on January 18, 2015, 07:43:51 PM
I was hoping for the linux directory tree where the kernel was already made. I'm trying to build a module against it and the files it needs like the "generated" directory aren't there.

It's best to build it completely on your dev system.  the piCore kernels are compiled on a cross compiler, and odds that everything on your local machine is exactly the same is unlikely.  I've had mixed results compiling single modules on different computers.   Just build it from the git.   It doesn't take that long to build.....even on a pi.
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: andyj on January 19, 2015, 12:47:09 AM
Will the config take care of the cross compile, or will I need to do some magic to my shell environment or command line?
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: bmarkus on January 19, 2015, 12:57:50 AM
Will the config take care of the cross compile, or will I need to do some magic to my shell environment or command line?

Read http://elinux.org/Raspberry_Pi_Kernel_Compilation
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: andyj on January 22, 2015, 07:00:37 AM
Now that 6.0 is released, might a compiled kernel tarball be forthcoming? I'm trying to compile natively on the RPi but I have a few questions. I did these (make expects bash):

git clone -b rpi-3.12.y https://github.com/raspberrypi/linux
tce-load -i compile-essentials.tcz linux-3.12.y_api_headers.tcz bash.tcz
sudo ln -s $(which bash) /bin/bash
bash
cd to linux source directory
zcat /proc/config.gz > .config
make oldconfig (just a check I suppose since I wasn't prompted for any config choices)
make help
This step lists ALOT of options. The defaults are vmlinux modules zImage xipImage dtbs. Three kernel images? Should I go with the default, one of the "packaging" options, or what?

I looked at the cross compile link, which I had already found, but I decided to go with http://xathrya.web.id/blog/2013/08/30/building-cross-compiler-for-raspberry-pi-using-crosstool-ng/ instead since I have both Slackware and I have used crosstool-ng in the past. I built crosstool but I haven't tried it yet. I may have a compiler race later.

Also, I tested libnfc.tcz. libnfc and the kernel modules pn533 and nfs are mutually exclusive, so libnfc will only work if the kernel modules are NOT loaded. So please remove the nfc-KERNEL.tcz dependency. Without the modules it works fine. Thanks.

Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: andyj on January 22, 2015, 07:22:59 AM
I spoke too soon. The native compile died because it's looking for bc for kernel./timeconst.h
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: andyj on January 23, 2015, 05:05:15 AM
I got both the native and cross compilers to work. Both kernels boot, but both complain that it can't find /lib/modules/3.12.36-piCore during boot and so USB doesn't work. The directory is actually  /lib/modules/3.12.36-piCore+ in 6.0.gz. CONFIG_LOCALVERSION from /proc/config.gz is "-piCore" and not "-piCore+". How did this happen, and how do I get my kernels to boot properly?
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: andyj on January 23, 2015, 09:43:00 AM
Adding a symlink from 3.12.36-piCore to 3.12.36-piCore+ in /lib/modules and rebuilding 6.0.gz fixed the boot issue, but that's obviously a kludge. BTW, I did finally get the USB display working. It would be helpful if I could get dual-head working (I don't want xinerama), but that might be asking a lot of a RPI.
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: Paul_123 on January 23, 2015, 04:07:29 PM
I forget the link, but the level config automatically adds the "+" when you modify it.   It's a pain, so if you build the kernel, you need to replace the modules in the initrd as well
Title: Re: Which is better for RPi development: Native on Pi or Cross Compile?
Post by: bmarkus on January 25, 2015, 01:47:35 AM
Also, I tested libnfc.tcz. libnfc and the kernel modules pn533 and nfs are mutually exclusive, so libnfc will only work if the kernel modules are NOT loaded. So please remove the nfc-KERNEL.tcz dependency. Without the modules it works fine. Thanks.

nfc-KERNEL.tcz  removed