We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Missing target_dir for cross compiling using OpenWRT 22.03



  • Re: ⭐️ Beta OpenWRT 22.03 firmware available! Your feedback is needed ⭐

    Hello.
    I need to cross compile C++ sources using the new firmware based on openwrt 22.03. I downloaded new image builder, sdk and toolchain from http://downloads.onioniot.com/releases/22.03.5/targets/ramips/mt76x8/. I am able to build a new working custom firmware and i compiled sdk but I am unable to compile my sources due to missing target_dir. The include directories in openwrt-sdk-22.03.5-ramips-mt76x8_gcc-11.2.0_musl.Linux-x86_64/staging_dir/target-mipsel_24kc_musl are empty.

    Did I miss a needed step?

    Regards

    Alberto



  • @Alberto-Brosich Hi Alberto, can you post more details on how you are trying to compile your code. Command line? The base directory of your OpenWrt build system. The output of your make.



  • I'm using Eclipse CDT as IDE. The projects are configured as cross compiling projects, that permits to specify the path and the prefix of the toolchain (g++ compiler and other tools).
    But for compiling and linking I have also to specify the includes search path (-I option) and the libraries search path (-L option) and set the environment variable STAGING_DIR, where I have, for the 18.06 version, both toolchain directory and target_dir.
    I read the openwrt wiki page for cross compiling (https://openwrt.org/docs/guide-developer/toolchain/crosscompile). They cited the staging_dir:
    "If compilation aborts due to missing header files or shared objects, you might need to override CFLAGS and LDFLAGS to point to the staging_dir/target-architecture_uClibc-libcver/usr/include and .../usr/lib directories". This staging_dir is present in the sdk I downloaded, but, as I said, doesn't contain any include file.

    Regards



  • @Alberto-Brosich You need to build the firmware, this creates the staging directory.

    Check out this FAQ I wrote for setting up NetBeans, this gives you the correct paths to set up once you have built the firmware.The paths will be the same for Eclipse.

    https://community.onion.io/topic/4131/setup-netbeans-11-for-c-c-development-cross-compilation?_=1720556879460



  • I built the firmware using the openwrt-imagebuilder-wrapper (https://github.com/OnionIoT/openwrt-imagebuilder-wrapper) and it works but doesn't populate "target-mipsel_24kc_musl" directory inside staging_dir (it contains just an empty "image" directory).

    I'm also trying to build the firmware using openwrt-imagebuilder-22.03.5-ramips-mt76x8.Linux-x86_64 from http://downloads.onioniot.com/releases/22.03.5/targets/ramips/mt76x8/, with the following command line:

    make -C ${HOME}/src/openwrt-imagebuilder-22.03.5-ramips-mt76x8.Linux-x86_64/ image PROFILE=onion_omega2p PACKAGES='onion-repo-keys omega2-base omega2-base-files omega2-base-passwd omega2-ctrl i2c-tools bash boost boost-atomic boost-chrono boost-date_time boost-filesystem boost-log boost-program_options boost-regex boost-system boost-thread boost-timer coreutils-sleep curl ethtool ip-tiny kmod-wireguard logrotate nginx objdump omega2-script openssh-sftp-server poco-all spawn-fcgi spi-tools sqlite3-cli tcpdump wireguard-tools wpa-cli'
    

    I got the following errors:

    Collected errors:
     * opkg_install_cmd: Cannot install package onion-repo-keys.
     * opkg_install_cmd: Cannot install package omega2-base.
     * opkg_install_cmd: Cannot install package omega2-base-files.
     * opkg_install_cmd: Cannot install package omega2-base-passwd.
     * opkg_install_cmd: Cannot install package omega2-ctrl.
    ...
    

    Ok, correct, there are missing lines for onioniot packages repository in the repository.conf file .

    I tried to use repository.conf file from openwrt-imagebuilder-wrapper, that contains these lines but I got other errors:

    Collected errors:
     * opkg_conf_parse_file: Duplicate src declaration (openwrt_core https://downloads.openwrt.org/releases/22.03.5/targets/ramips/mt76x8/packages). Skipping.
    
    Installing packages...
    Unknown package 'libc'.
    Collected errors:
     * opkg_conf_parse_file: Duplicate src declaration (openwrt_core https://downloads.openwrt.org/releases/22.03.5/targets/ramips/mt76x8/packages). Skipping.
     * pkg_hash_check_unresolved: cannot find dependency libgcc for libc
     * pkg_hash_fetch_best_installation_candidate: Packages for libc found, but incompatible with the architectures configured
     * opkg_install_cmd: Cannot install package libc.
    

    The message "Packages for libc found, but incompatible with the architectures configured" says that I missed a required step?

    Any clue?

    Regards



  • @Alberto-Brosich I don't use the image wrapper so I can't spend time trying to diagnose the issue with it, but I will say that the errors seem to suggest there are some issues with your paths. I take the more standard approach for building the firmware, which uses the OpenWrt official method of building the firmware. Here's the steps:

    git clone https://git.openwrt.org/openwrt/openwrt.git openwrt22
    cd openwrt22
    scripts/feeds update -a
    scripts/feeds install -a
    git checkout openwrt-22.03
    make menuconfig
    Target System (MediaTek Ralink MIPS)
    Subtarget (MT76x8 based boards)
    Target Profile (Onion Omega2+)

    make -j $(($(nproc)+1))

    You can change the git repository to the Onion version is you wish.



  • Ok, it works!

    Many thanks!

    Just another question. Can I use version 23.05? Is it stable for onion omega2?

    Regards



  • @Alberto-Brosich I use 23.05 exclusively these days on Omega2+, Omega2 Pro and Omega2S+. Personally I didn't find the jump from 22 to 23 much of an issue. There were a couple of things I had to fix and right now I have an issue with the frame buffer on the Dash, but other than that no issues.



  • Thank you.

    I have another problem, sorry!
    My software uses oniondebug, onioni2c and onionspi libraries. I cannot find it in the onion repository (https://github.com/OnionIoT/OpenWRT-Packages.git). Are they missing in version 22 or 23? Are there another alternatives libraries?

    Regards



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