WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Which is better for RPi development: Native on Pi or Cross Compile?  (Read 7049 times)

Offline andyj

  • Hero Member
  • *****
  • Posts: 973
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

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 831
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #1 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.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7172
    • My Community Forum
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #2 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.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline andyj

  • Hero Member
  • *****
  • Posts: 973
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #3 on: January 16, 2015, 11:28:01 AM »
Do you think the ODROID-C1 would be a good dev platform? Any known issues?

Andy

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7172
    • My Community Forum
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #4 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.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline eno

  • Jr. Member
  • **
  • Posts: 54
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #5 on: January 17, 2015, 07:55:02 AM »
Does piCore run on the Odroid ?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 831
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #6 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


Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7172
    • My Community Forum
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #7 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
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline andyj

  • Hero Member
  • *****
  • Posts: 973
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #8 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?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 831
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #9 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


Offline andyj

  • Hero Member
  • *****
  • Posts: 973
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #10 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.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 831
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #11 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.
« Last Edit: January 18, 2015, 07:45:32 PM by Paul_123 »

Offline andyj

  • Hero Member
  • *****
  • Posts: 973
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #12 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?

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7172
    • My Community Forum
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #13 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
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline andyj

  • Hero Member
  • *****
  • Posts: 973
Re: Which is better for RPi development: Native on Pi or Cross Compile?
« Reply #14 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.