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 ?
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 ?
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.
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?
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