Search code examples
openwrt

how can I change a software of openwrt and rebuild it in Bin file


... $make menuconfig select some package ... $make ...

there are many bin files in the bin folder.:

My question is , I want to change some software source code of openwrt and rebuild again.

I have try to edit some source code of build_dir. But want I rebuild openwrt My code with be refresh with the newest code of svn.

Does any one how to do that?


Solution

  • Writing your code and synchronizing it:

    1) Clone the official linino repository from Arduino on your machine using git (install it using sudo apt-get install git):

    git clone https://github.com/linino/linino_distro.git
    

    2) Do your own changes in the relevant code files, Makefiles or whatever that you need to change.

    3) Whenever you want to synchronize your work with the latest changes from the remote master branch in the linino repository, you need to first fetch the changes, meaning retrieving them without yet merging them, then in a 2nd time merge them and then resolve conflicts if any:

    Preliminary: if you created a local branch with your own changes make sur you get back to the master branch, you need to check out the master: git checkout master a) fetching the latest changes:

    git fetch master
    

    b) Merging them with your changes on your local repository (normally called origin):

    git merge origin/master
    

    Note: alternatively you can do it in one command:

    git pull
    

    It essentially does a fetch and a merge at the same time but it's important to understand the process using fetch first. From experience it can be confusing for beginners, plus it can cause automerge if not explicitely specified otherwise, causing more work to undo them.

    4) Now you're ready to resolve conflicts if any, for that you can use:

    git mergetool
    

    This will allow you to resolve conflicts using a graphical tool such as tkdiff (2 way merge tool), or meld (3 way merge tool, diff your changes, the changes from the remote master, and the original file).

    Compiling your code:

    5) Open a terminal in your linino buildroot directory, make sure you get to update the config if you added any new packages, then recompile the image i.e.

    cd ~/myLininoBuildRoot/trunk
    make menuconfig
    #now select your new package, that you added in trunk/package
    # Make sure you save the configuration before exiting
    make
    

    Note: Alternatively you can recompile packages one by one. Instead of doing a simple make do:

    Preliminary step: Make sure to have compiled the linino toolchain that allows you to compile packages separately: cd trunk/ make tools/install make toolchain/install make target/compile

    Then compile your package:

    make package/myPackage
    

    Or Alternatively, you can be more specific by selecting the any target from your package Makefile say for instance install or compile or build targets:

    make package/myPackage/install
    make package/myPackage/compile
    make package/myPackage/build
    

    Finally, recompile the index target common to all packages that will allow you to have an bin directory trunk/bin/yourArchitecture/packages that contains an up to date index of packages including your freshly compiled one:

    make package/index
    

    More info at: http://wiki.openwrt.org/doc/howto/build.a.package

    Checking that everything is alright:

    Now go have a look at trunk/bin/yourArchitecture/packages/Packages, do a grep to make sure it is listed in Packages (the actual packages index file) and is up to date:

    grep Packages | myPackage