OpenWrt Forum Archive

Topic: Build OpenWRT with custom configuration

The content of this topic has been archived on 6 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Good day folks!

I have quite of a dilemma in creating custom configuration when compiling or generating a custom image for OpenWrt. What I want to do is customize the default '/etc/config/wireless' file during the building process, and from the docs, this is done by adding the custom wireless config to 'files/etc/config/wireless', no problems there, it works.

Here's the problem, when I create the wireless config, say with the following in it:

config wifi-device  radio0
    option type     mac80211
    option channel  11
    option macaddr    [b]00:11:22:33:44:55[/b]
    option hwmode    11ng
    option htmode    HT20

config wifi-iface
    option device   radio0
    option network  wifi
    option mode     ap
    option ssid     'MySSID'
    option encryption none

then compile/build/generate the image, and flash it to a router whose MAC address is 00:00:00:00:00:11 (i.e its different from the mac addr in the config file) things get messy, after flashing, and checking on the '/etc/config/wireless' file, this is what it would have:

config wifi-device  radio0
    option type     mac80211
    option channel  11
    option macaddr    [b]00:11:22:33:44:55[/b]
    option hwmode    11ng
    option htmode    HT20

config wifi-iface
    option device   radio0
    option network  wifi
    option mode     ap
    option ssid     'MySSID'
    option encryption none

config wifi-device  radio1
    option type     mac80211
    option channel  11
    option macaddr    [b]00:00:00:00:00:11[/b]
    option hwmode    11ng
    option htmode    HT20
    # REMOVE THIS LINE TO ENABLE WIFI:
        option disabled 0

config wifi-iface
    option device   [b]radio1[/b]
    option network  lan
    option mode     ap
    option ssid     'OpenWrt'
    option encryption none

If you notice, what happens is that, the installation appends the correct and default configuration for wireless. And this messes up the configuration, which would need me to ssh the router and manually edit the config (or thru LuCI) w/c is time consuming.

My ultimate goal is to set the ssid (to my own, say 'MySSID') and have the wireless enabled directly after flashing. Is there any other way to set the default template for the generation of the wireless config? (I was thinking that there was a template in the source code, that the compiler would consult).

Thanks!

I ran into the same problem a year ago:
You can leave "macaddr" away from the included config, and use "phy".

Read here. There is first my approach to "change mac in wireless config on first boot", and then jow's advice:
https://forum.openwrt.org/viewtopic.php … 24#p185424

phy as option is documented here: http://wiki.openwrt.org/doc/uci/wireless#wifi.devices

phy string no/yes (autodetected)
Specifies the radio phy associated to this section, it is usually autodetected and should not be changed. By default openwrt uses macaddr to identify the radio (more precise) but you can use phy instead, to be more hardware independent.
:!: This option is only used for type mac80211 and madwifi (trunk)

macaddr MAC address yes/no (autodetected)
Specifies the radio adapter associated to this section, it is not used to change the device mac but to identify the underlying interface. The value is autodetected at first boot or when you use phy parameter. If you want a hardware independent config (to restore the config on many routers) you should use phy parameter instead of macaddr.
:!: This option is only used for type mac80211 and madwifi (trunk)

(Last edited by hnyman on 28 Jan 2014, 11:36)

Thanks! I failed to read that part of the documentation.

The discussion might have continued from here.