Image Builder with Custom Files won't boot

I've been working on developing a custom image for my WG3526 router. I used the menuconfig while I was starting out, and got it tweaked with all the custom packages I wanted. If I include any custom files in the files/ folder, it builds and installs no problem.

However, I recently decided I wanted to use the imagebuilder because I have an IPK package I wanted to install by default. Everything works great when using the image builder. The problem I'm facing is I cannot include custom files in the image builder.
When I compile firmware with just additional packages it loads onto the router just fine. I've tried to compile the same image but with some replaced files (namely the config/network file), and it compiles just fine but when I flash it onto the router, it gets stuck with the IP of 169.254.145.88 and subnet mask 255.255.0.0 with no router ip.
I've tried putting custom files in different folders, I even tried just adding a custom file and not even replacing an existing one. It's still the same thing of the router not booting on.

I've done a lot of searching online and cannot find anyone with this same problem.
I'm doing everything it says in this guide: https://openwrt.org/docs/guide-user/additional-software/imagebuilder#files_variable

The command I'm running inside my image builder folder is: make FILES="files/" I've also tried it with make FILES=files/ just in case it shouldn't have quotes. But every time, it compiles just fine but it will not boot on the router. However when I do just make it boots just fine on the router. So there seems to be a specific problem with the custom files being added in.

Currently the only custom file I'm testing with is /etc/config/network.

Any thoughts?

1 Like

Most likely your custom config conflicts with the board/UCI-init scripts.
Consider to perform customization this way:

2 Likes

Reading into that looks like it'll be a solution to my problem.

I'm having a bit of a struggle on how to edit an existing file though. So in the case of the config/network file, how would I go about editing the wan interface name from wan to wan0?

So far I see how you can add to the file just using cat << EOF >> ... but I'm having a hard time finding how to actually edit a specific section.

So I built the following script and put it in the files/etc/uci-defaults and named the file 99_network
The file contains the following:

cat << EOF > /etc/config/network

config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option packet_steering '1'
	option ula_prefix 'fd8f:c7ec:adb3::/48'

config interface 'lan'
	option type 'bridge'
	option ifname 'lan1 lan2 lan3 lan4'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'
	option ip6assign '60'

config interface 'wan'
	option ifname 'wan0'
	option proto 'dhcp'

EOF

Even with just that addition, I'm still having the problem with the router not booting up. If you notice, I even put the 99_xxx which was recommended to make sure it was run last.

Any ideas?

  • what is the file format of your script?
  • show the full directory structure of files please
( find ./files ) #or equivalent print screen of expanded structure etc.
1 Like

Here's the structure:

./files
./files/etc
./files/etc/uci-defaults
./files/etc/uci-defaults/99_network

@vgaetera That was a typo which I edited in my post.

1 Like

Can you post the default network config?

1 Like

you should really use 'EOF' here otherwise it's likely encoding/format issue...


config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option packet_steering '1'
	option ula_prefix 'fd6f:6fa0:f809::/48'

config interface 'lan'
	option type 'bridge'
	option ifname 'lan1 lan2 lan3 lan4'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'
	option ip6assign '60'

config interface 'wan'
	option ifname 'wan'
	option proto 'dhcp'

config interface 'wan6'
	option ifname 'wan'
	option proto 'dhcpv6'

Only thing I've changed is I removed the wan6 interface, and changed the ifname of the wan interface.

@wulfy23 It's an O as in Oscar. I'm not sure why it's showing up like a zero on the webpage.

EDIT: I just realized you meant to put it in single quotes :roll_eyes:. I'll rebuild and try that.

1 Like

don't rebuid... test it manually on the router first...

Then it can be simpler:

cat << EOF_cat > files/etc/uci-defaults/99_custom
uci -q batch << EOF
delete network.wan6
commit network
EOF
EOF_cat

Quotes should not matter in your case as you have no variables/commands to expand/substitute.

1 Like

I ran the updated code with the cat << 'EOF' > ... on the firmware image which doesn't have the updated files and it went through just fine. I then restarted the router and it restarted perfectly. However, when I build the image with that command in the 99_network it will not boot.

@vgaetera If I'm understanding fully, you're saying to replace my script, and put your script into the 99_network file?

2 Likes

For sake of testing I removed all the contents of the 99_network file and rebuilt the image. The .bin file was the exact same size as my previous .bin file which had the contents in the 99_network file.
Even with a completely blank file, the router still won't power on.

I also created a blank file named network1 and pushed it to /etc/config, however that also causes the router to not power on. Any thoughts on that?

does this make any difference;

sed -i 's/\r//' /etc/config/*

I don't know how UCI is handling text files. I never thought about so it might be irrelevant. But I start my scripts always with:

#!/bin/sh
set -f

And it might be irrelevant but I'm setting executeable bit for the files I place into uci-defaults also.

@WilliamCellTech, this might be a bug if you are building a snapshot.
You can check if the issue persists when building a stable release.
Or try building from sources.

@pwned, these scripts are sourced, thus they don't need shebang or executable bit.

2 Likes

That was the problem! I switched to the stable build and now am able to build with the custom files no problem.
Thanks for the help!

1 Like