Cross Compiling & Big Projects



  • Forgive me if this is all really, really elementary. We're developing a few big projects where the Omega will be a bridge between ethernet and a handful of fast SPI chips. Python almost certainly won't be fast enough to keep up with everything, so it looks like cross-compilation from C is required.

    I'm not a linux ninja, but can get around reasonably well with a search window on my second monitor:

    Here's a list of rabbit holes I've been down over the past week:

    1. On a Windows 10 workhorse machine, I installed Hyper-V and spun up a new Ubuntu 18.04 LTS image. Then tried working through all these steps: https://docs.onion.io/omega2-docs/cross-compiling.html I gave up after being error'd for more missing files and libraries than I can remember.

    2. Disabled Hyper-V. Installed Docker Desktop for Windows 10. Tried working through these steps, including make menuconfig and selecting the proper processor, etc.:

    https://docs.onion.io/omega2-docs/cross-compiling.html

    https://onion.io/2bt-cross-compiling-c-programs-part-1/
    https://onion.io/2bt-cross-compiling-programs/

    Make -J6 fails, again, missing files and libraries.

    1. Disabled Hyper-V. Somewhere in these forums someone shared a .vbox virtual disk image, 6 GB, hosted on Microsoft One Drive, a year or two ago. I downloaded it and spun it up. Make menuconfig showed that only the Omega 2 was selected, so I added the 2+. Make quits after a couple hours with errors.

    2. Discovered this thread from July 2019:

    http://community.onion.io/topic/3666/plans-to-update-the-onion-omega2-source-docker-container

    Which mentions this new brand-new Docker image openwrt-18.06 b228:

    https://hub.docker.com/r/onion/omega2-source/tags

    So I started from scratch just now:

    Microsoft Windows [Version 10.0.18362.356]
    (c) 2019 Microsoft Corporation. All rights reserved.

    C:\Users\ThinkStation>docker pull onion/omega2-source:latest
    latest: Pulling from onion/omega2-source
    Digest: sha256:6bf05eb531ece478c1f22e3e7a9a522466e2a48f781c06a52df01afec2f10904
    Status: Image is up to date for onion/omega2-source:latest
    docker.io/onion/omega2-source:latest

    C:\Users\ThinkStation>docker run -it onion/omega2-source

    root@ea7a8942a075:~/source# git pull

    remote: Enumerating objects: 68, done.
    remote: Counting objects: 100% (68/68), done.
    remote: Total 97 (delta 68), reused 68 (delta 68), pack-reused 29
    Unpacking objects: 100% (97/97), done.
    From https://github.com/OnionIoT/source
    ddd04310cb..52a1594fbb openwrt-18.06 -> origin/openwrt-18.06

    • [new branch] openwrt-18.06-dev -> origin/openwrt-18.06-dev
      Updating ddd04310cb..52a1594fbb
      Fast-forward
      .config.O2 | 67 +-
      .config.O2-minimum | 15 -
      .config.O2Dash | 6051 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      CHANGELOG.md | 30 +
      build_info.json | 2 +-
      files/etc/config/dhcp | 9 +-
      files/etc/config/network | 17 +-
      files/etc/uci-defaults/12_onion_version | 2 +-
      package/kernel/linux/modules/video.mk | 511 ++++-
      target/linux/ramips/base-files/etc/board.d/01_leds | 1 +
      target/linux/ramips/base-files/etc/board.d/02_network | 6 +-
      target/linux/ramips/base-files/etc/diag.sh | 1 +
      target/linux/ramips/base-files/lib/ramips.sh | 3 +
      target/linux/ramips/base-files/lib/upgrade/platform.sh | 1 +
      target/linux/ramips/dts/OMEGA2DASH.dts | 37 +
      target/linux/ramips/image/mt76x8.mk | 8 +
      target/linux/ramips/mt76x8/config-4.14 | 79 +
      17 files changed, 6792 insertions(+), 48 deletions(-)
      create mode 100644 .config.O2Dash
      create mode 100644 target/linux/ramips/dts/OMEGA2DASH.dts
      root@ea7a8942a075:~/source#

    Ran Make Menuconfig. Everything seems correct, including the addition of libugpio for the cross-compile example. So I exit without saving the configuration.

    Your configuration changes were NOT saved.

    root@ea7a8942a075:~/source# make -j6

    WARNING: Makefile 'package/feeds/onion/transmission-console-app/Makefile' has a dependency on 'Onion-Console', which does not exist
    WARNING: Makefile 'package/feeds/onion/transmission-console-app/Makefile' has a dependency on 'transmission-daemon', which does not exist
    WARNING: Makefile 'package/feeds/onion/zeromq/Makefile' has a build dependency on 'libuuid', which does not exist
    Checking 'rsync'... ok.
    time: target/linux/prereq#0.14#0.00#0.26
    WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!
    make[1] world
    make[2] tools/compile
    make[2] package/cleanup
    make[3] -C tools/flock compile
    make[3] -C tools/sed compile
    ...
    This of course fails after two hours:

    make[3] -C feeds/packages/net/vsftpd compile
    make[3] -C feeds/packages/net/vsftpd compile
    make -r world: build failed. Please re-run make with -j1 V=s to see what's going on
    /root/source/include/toplevel.mk:216: recipe for target 'world' failed
    make: *** [world] Error 1

    root@16fae4e217a9:~/source# make -j7 V=s
    WARNING: Makefile 'package/feeds/onion/transmission-console-app/Makefile' has a dependency on 'Onion-Console', which does not exist
    WARNING: Makefile 'package/feeds/onion/transmission-console-app/Makefile' has a dependency on 'transmission-daemon', which does not exist
    WARNING: Makefile 'package/feeds/onion/zeromq/Makefile' has a build dependency on 'libuuid', which does not exist
    make[1]: Entering directory '/root/source'
    make[2]: Entering directory '/root/source'
    make[2]: Entering directory '/root/source'
    make[3]: Entering directory '/root/source/target/linux'
    make[4]: Entering directory '/root/source/target/linux/ramips'
    ...

    Then hundreds and hundreds of pages of compiler output, which I won't even include here, but it fails again after two hours with this text:

    make[3]: Leaving directory '/root/source/package/firmware/linux-firmware'
    time: package/firmware/linux-firmware/compile#5.49#5.02#813.85
    make[2]: Leaving directory '/root/source'
    package/Makefile:103: recipe for target '/root/source/staging_dir/target-mipsel_24kc_musl/stamp/.package_compile' failed
    make[1]: *** [/root/source/staging_dir/target-mipsel_24kc_musl/stamp/.package_compile] Error 2
    make[1]: Leaving directory '/root/source'
    Build failed - please re-run with -j1 to see the real error message
    /root/source/include/toplevel.mk:216: recipe for target 'world' failed
    make: *** [world] Error 1
    root@16fae4e217a9:~/source#

    Finally, my questions:

    I'm comfortable using Microchip's IDE tools, where there's a file browser on the left part of the window, I can see and easily open tons of different source files, etc.

    How do I get something similar set up for Omega? I don't mind using nano, etc for simple python scrips but it's too restrictive for big projects. Something like Eclipse or Atom would be amazing. I can even dual boot this machine if it's useful - VirtualBox, Hyper V, etc don't seem to like giant dual screen machines and I can't work in a single 1024 x 768 window.

    Is there a way to set up an IDE that... sorry for bad phrasing... points to my docker system, assuming I can get the docker image to compile properly in the first place?

    Google search for 'IDE with Docker compiler' seems to get out in the weeds really, really quickly.

    Thanks for reading. I really, really want this platform to work for us in several upcoming products. But I've never had to fight so hard just to get a silly 'hello world' to run.



  • Hi,

    I probably read half of all text you pasted above, however I understand from your question you would like to interact with docker containers from the IDE. Being that the case, have you considered using the Visual Code Docker extension?

    Don't know exactly if it will suit your needs, but the integration seems quite neat. Also, not quite sure what you meant with docker compiler.

    Good luck.



  • @orlando-mendez Thanks that looks like a useful tool. I still can't get the docker image to compile without errors.



  • @peanut I don't see errors, I see warnings then you assumed it would fail so you terminated it. Which warning did you assume would cause the build to fail?

    Personallly I find it more efficient to run Ubuntu 18 as my build environment, I find docker to slow things down considerably. I develop my code on Netbeans 11.2, test on Ubuntu, I can debug the main code then rsync sends it over to my Omega test device.



  • Here's the end of the trace which I started yesterday, plain make no -j6:

    make[3] -C feeds/packages/utils/kmod compile
    make[3] -C feeds/packages/libs/libid3tag compile
    make[3] -C feeds/packages/libs/libgcrypt compile
    make[3] -C feeds/packages/libs/libidn2 compile
    make[3] -C feeds/packages/libs/gnutls compile
    make[3] -C feeds/packages/libs/libvorbis compile
    make[3] -C feeds/packages/libs/libvorbisidec compile
    make[3] -C feeds/packages/utils/mariadb host-compile
    make[3] -C feeds/packages/net/nginx compile
    make -r world: build failed. Please re-run make with -j1 V=s to see what's going on
    /root/source/include/toplevel.mk:216: recipe for target 'world' failed
    make: *** [world] Error 1
    root@7f1783d8454f:~/source#

    When I run with -j1 V=s, I get hundreds and hundreds of pages of output, scrolling past so quickly it's impossible to parse. This morning I'll make this big machine dual boot and see what happens.



  • @peanut the linux console is scrollable so you can look back the output, or you can pipe it to file so you can later review the output by viewing the file:

    make -j 9 > /tmp/makeoutput.txt

    To speed up make you can remove from the build all those packages that you don't need. For example, I don't use sound so I don't make any of those packages, I also don't use python so I remove those. If you run make menuconfig you see there are many packages set to "m", if you don't use them just deactivate them so they don't get built. It takes a little time to do this but once you have trimmed things down it can save lot of build time.



  • @crispyoz

    I set up this machine to dual boot with a fresh copy of Ubuntu 18.0.4 installed. It took some time and a few false turns, but I'm able to compile my own 'hello world' file now:

    file hello
    hello: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /lib/ld-, with debug_info, not stripped

    Next I'll work on rsync, etc, to automatically move the final build to my Omega 2+.

    Thanks for the suggestion of running outside a virtual machine.



Looks like your connection to Community was lost, please wait while we try to reconnect.