Can I edit build_dir after compilation?

I download the source code of openwrt using git clone, then I run make menuconfig and choose my router then I run make.

After the compilation, a build_dir folder appear which contain netfilter that has .c files about networking like iptables, nat, filter …etc.

My question is: I want to edit the .c files in build_dir then to install the .bin on the router. So, Can I edit these files and how I to install the newest editing on the router? Should I recompile again ?

1 Like

Yes, I' am using a Linux environment, but build_dir after after compilation, and I want to edit some files in it.
So, how can edit these files ? Should I recompile again or what ?

search the document provided for 'quilt'

1 Like

I see it.

Can you tell me which patches responsible for creation of build_dir folder?

can you us what you are doing, where and why? (practical evidence and samples preferrably)

what you have tried? references you have found and read?

everything you need is documented online... suggest you spend more time reading/practicing/building basic skills instead of asking

1 Like

I want to reach a .c file that responsible for nating, routing, filtering ..etc, then I want to edit some codes in these files.

I told you in the other thread. .C file for packet sniffer(socket) - #8 by omran11

The files in build dir are deleted and created again every time you compile a new firmware.

If you want to make modifications to these files you must create a patch following these instructions

and then compile the firmware again.

So that the build system will delete the files in build_dir, redownload the source, apply the patches from OpenWrt, apply the new patch with your changes, and then compile a new kernel.

And after it has done you must upgrade the firmware on your device with the firmware you have generated now.

1 Like

Thank you brother, I understand the solution of my problem.
But, can you tell or do you know the path of patches responsible for creation of build_dir after compile?

You started with the following:

You was told multiple times to edit the firewall config.
But for some reason you insist on modifying the source code.

Perhaps you don't realize that you can build an image with custom files and use uci-defaults:
First boot / scripts / config files / best solution to have a configuration at first boot - #2 by vgaetera

However, the latter posts indicate that your actual intention may not be that harmless:

I hope you don't plan to distribute an image with hidden modifications. :slight_smile:

2 Likes

I am not sure I understand the question.

kernel patches you created with

will go in /openwrt/target/linux/x86/patches-5.4 (if your target is x86 and kernel version is 5.4) if they were created with

quilt new platform/010-main_code_fix.patch

and the ones you create with quilt new generic/010-main_code_fix.patch will go in a subfolder of /openwrt/target/linux/generic, I don't know exactly but you can find it easily.

The patches in /openwrt/target/linux/generic are applied to all devices built by OpenWrt, the patches in /openwrt/target/linux/x86/patches-5.4 are applied to only that target, so in this example only to x86