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

Problem: OpenWRT lora_gateway-5.0.1 compile as DEBUG enable



  • Hi All,

    I am new on openWRT. I have an Omega2+ based custom board which is openwrt 18.06 custom compilation loaded. I enabled libloragw-utils and related libs on make menuconfig.

    I would like to enable DEBUG messages on "/home/ahmet/OpenWRT/openwrt_19/openwrt/build_dir/target-mipsel_24kc_musl/lora_gateway-5.0.1/libloragw/src/loragw_reg.c" like below part as making DEBUG_REG=1 in config.h and library.cfg

    a part from loragw_reg.c

    #if DEBUG_REG == 1
        #define DEBUG_MSG(str)              fprintf(stderr, str)
        #define DEBUG_PRINTF(fmt, args...)  fprintf(stderr,"%s:%d: "fmt, __FUNCTION__, __LINE__, args)
        #define CHECK_NULL(a)               if(a==NULL){fprintf(stderr,"%s:%d: ERROR: NULL POINTER AS ARGUMENT\n", __FUNCTION__, __LINE__);return LGW_REG_ERROR;}
    #else
        #define DEBUG_MSG(str)
        #define DEBUG_PRINTF(fmt, args...)
        #define CHECK_NULL(a)               if(a==NULL){return LGW_REG_ERROR;}
    #endif
    

    library.cfg ;

    ### Debug options ###
    # Set the DEBUG_* to 1 to activate debug mode in individual modules.
    # Warning: that makes the module *very verbose*, do not use for production
    
    DEBUG_AUX= 1
    DEBUG_SPI= 1
    DEBUG_REG= 1
    DEBUG_HAL= 1
    DEBUG_LBT= 1
    DEBUG_GPS= 1
    

    I am working on "openwrt/build_dir/target-mipsel_24kc_musl/lora_gateway-5.0.1" while compiling.
    after running make, I see the messages below:

    -- Build with debug AUX: OFF
    -- Build with debug SPI: OFF
    -- Build with debug REG: OFF
    -- Build with debug HAL: OFF
    -- Build with debug GPIO: OFF
    -- Build with debug LBT: OFF
    -- Build with debug GPS: OFF
    -- Build with SPI_DEV_PATH: /dev/spidev0.1
    -- Build with SPI_SPEED: 8000000
    -- Configuring done
    -- Generating done

    even I made all debug parameters 1, I see same message as OFF. and I cannot change SPI_DEV_PATH also...

    Is there anyone who know about this issue?

    Thanks in advance...


  • administrators

    @optech I'm assuming you're using the build system to compile this package?

    When building packages, the build system will default to downloading the source code, unzipping it, and compiling it. I'm not 100% sure if modifying the unzipped source code in build_dir will result in these changes being compiled.

    I suggest taking a look at this guide for working on local application source code: https://openwrt.org/docs/guide-developer/packages#working_on_local_application_source



  • @Lazar-Demin I understand it. but situation makes me complicated because of I am new on OpenWRT. Let me explain the issue:

    • I need to work on "openwrt/build_dir/target-mipsel_24kc_musl/lora_gateway-5.0.1" sources...
    • For example, I change "loragw_spi.native.c" module on "openwrt/build_dir/target-mipsel_24kc_musl/lora_gateway-5.0.1/libloragw/src"
      **local make on "openwrt/build_dir/target-mipsel_24kc_musl/lora_gateway-5.0.1" compile the all sources in this directory but I cannot see the changes which i made on sources as output...
      **main make after "make menuconfig", compiles whole openwrt as expected well but it takes too long time as you know. For whole OS compile, I can see outputs of the changes which i made in sources ("loragw_spi.native.c") at "openwrt/build_dir/target-mipsel_24kc_musl/lora_gateway-5.0.1/libloragw/src".
      *configuration file changes like "library.crg" doesnt effect even whole OS compile.. It always compile debug off. (Probably the cause of the issue which you mentioned for build system )

    I spend so many time for it, and i am continue to solve this, but i couldnt until now. I tried a method which is in the link that you send, but I couldnt succeed.

    I am just trying to compile "utils_spi_stress" in "libloragw-utils" without compiling whole openwrt. How do you do such a kind of partial package compiling when you need?



  • @optech For me the easiest solution is to fork the package then add the forked package to the feeds. Since you're going to have to release the source to your package anyway, you may as well set up the repository.

    I personally prefer to use NetBeans for my coding so working with the repository is seamless.


  • administrators

    @optech what @crispyoz is also a valid method. That's what you'll eventually need to do to consistently build your package.

    What I was suggesting is quicker for early development and debugging.

    Here is a more in-depth explanation of how to build a package with local application source code:

    1. In the build system (assuming ~/source), run make menuconfig and make sure your package is selected for compilation
    2. Download the source code for your package somewhere to your computer, let's say ~/lora_gateway/
    3. Make your changes to the source code in the ~/lora_gateway/ directory
    4. Go back to the build system at ~/source
    5. Following the openwrt guide on working for local application source code, you will then run:
      • make package/awesome_app/clean V=s
      • make package/awesome_app/prepare USE_SOURCE_DIR=~/src/awesome_src V=s
      • make package/awesome_app/clean V=s
      • (But replace awesome_app with the name of your package, and ~/src/awesome_src with the ~/lora_gateway directory from step 2)
    6. Compile just your package by running make package/awesome_app/compile but replace awesome_app with the name of your package. (More info on building a single package here)


  • @Lazar-Demin and @crispyoz Firstly, thank you all for trying to help me.i am really stuck at this point šŸ™‚

    • I copied "openwrt/build_dir/target-mipsel_24kc_musl/lora_gateway-5.0.1" directory to "~/OpenWRT/lora_gateway-5.0.1" path. this directory includes sources.
    • When I try to execute "make ~/OpenWRT/lora_gateway-5.0.1/clean V=s", i got an error like "make: *** No rule to make target '/home/ahmet/OpenWRT/lora_gateway-5.0.1/clean'."

    Another two comments:
    *When I execute "make clean" in "~/OpenWRT/lora_gateway-5.0.1", it completes the job but do not delete the binaries in "~/OpenWRT/lora_gateway-5.0.1/bin"
    *it is same for compile, it compiles but I guess to the original path...

    Could you advice me something at this point?

    I probably making a basic issue wrong šŸ™‚



  • @optech Are you using OpenWrt 18 or 19, your initial message states you are using 18.06 but the directory you refer to is 19. I'll try to duplicate your issue but I want to be sure I am using the correct source pool.



  • @crispyoz probably you can reproduce the problem for both 18 or 19.

    Firstly 18.06 was loaded in my system but I was editing 19.07 lora_gateway-5.0.1 sources to load 18.06 system šŸ™‚ But now i switched to 19.07 completely.



  • @optech try this:

    make menuconfig
    Check "Enable package source tree override" in the "Advanced configuration options (for developers)" menu
    exit and save

    make package/feeds/packages/lora-gateway-hal/clean V=s
    make package/feeds/packages/lora-gateway-hal/prepare USE_SOURCE_DIR=~/lora_gateway-5.0.1 V=s
    make package/feeds/packages/lora-gateway-hal/compile V=s



  • @optech I should mention that if all you want to do is turn on the debug options you can just tweak the patch file because this overrides the library.cfg settings. To do this just edit package/feeds/packages/net/lora-gateway-hal/patches/0001-add-cmake-support.patch

    Line 126 has the debug options you are looking for, just change the OFF to ON for the required options, then clean and make build again and you'll see the debug options you set are turned on.

    SPI_DEV_PATH is set in package/feeds/packages/net/lora-gateway-hal/patches/0002-add-preprocessing-for-SPI_DEV_PATH-and-SPI_SPEED.patch



  • @crispyoz I tried your advices as you commented.

    • I done --> "Check "Enable package source tree override" in the "Advanced configuration options (for developers)" " step

    • "make package/feeds/packages/lora-gateway-hal/clean V=s" is ok.

    • "make package/feeds/packages/lora-gateway-hal/prepare USE_SOURCE_DIR=~/lora_gateway-5.0.1 V=s" delete "lora_gateway-5.0.1" folder from main path, then creates a symbolic link to "~/lora_gateway-5.0.1".

    • "make package/feeds/packages/lora-gateway-hal/compile V=s" compiles well but the result is same as before, no output as my changes in source codes or header/configuration files.

    This operation just changes the path of "lora_gateway-5.0.1"... šŸ˜•

    If I execute a "make package/feeds/packages/lora-gateway-hal/clean V=s", it deletes the symbolic link. So, if I compile again, it download the "lora_gateway-5.0.1" folder again to the original path, then compile the original code... šŸ˜–



  • @crispyoz I tried the edit the patch file also. I made :

    +option(DEBUG_SPI "Active debug mode in SPI module" ON)
    +option(DEBUG_REG "Active debug mode in REG module" ON)
    

    But when i load the executable file (util_spi_stress) to omega2s+ as getting from "lora_gateway-5.0.1/bin", i can not see any debug output.

    But this time i see changes in config.h:

    #define DEBUG_AUX 0
    #define DEBUG_SPI 1
    #define DEBUG_REG 1
    #define DEBUG_HAL 0
    #define DEBUG_GPS 0
    #define DEBUG_GPIO 0
    #define DEBUG_LBT 0
    

    Do you think it is correct path for compiled executable? --> "lora_gateway-5.0.1/bin" ???

    By the way, I wanna edit sources also to solve a communication problem as looking debug outputs...



  • @optech if you look at the code it doesn't log much at all, regardless of the debug settings.

    clean does remove the symlink. This is basically a hack so it's always going to be a pain. This is why my original suggestion was to fork the source and set up your own package so you have control of the code.



  • This post is deleted!


  • @crispyoz How can i set up a separate package ? When I copy and compile separately at different location, it compiles but no changes at output (changes for source codes and configs)? I mean not for just debug outputs, i cant get results for source code changes too.. Could you tried something at your side to reproduce the problem with a small source code change(like console print text change)?



  • @crispyoz I cloned "https://github.com/Lora-net/lora_gateway.git" repository and I made cross compile settings. Then I can see the results what i did šŸ™‚ Thank you for your help @crispyoz and @Lazar-Demin



  • @optech Congratulations.
    This was my original advice, because the other methods are really workarounds/hacks/shortcuts. In my experience shortcuts rarely are that.



  • @crispyoz Yes it is. I remember. Thank you šŸ™‚



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