[OpenWrt-Devel] Setting uci defaults in trunk

micke.prag at telldus.se micke.prag at telldus.se
Fri Feb 26 11:56:06 EST 2016

2016-02-26 17:20 skrev Felix Fietkau:

> On 2016-02-26 15:54, micke.prag at telldus.sewrote:
>> 2016-02-26 15:35 skrev Felix Fietkau:
>>> On 2016-02-26 15:27, micke.prag at telldus.sewrote:
>>>> Hi I have a board config for a device that I am about to commit to
>>>> OpenWRT. I am rebasing my work against trunk but some things have
>>>> changed since I made the config. My code was written against 
>>>> r46120
>>>> but somethings doesn't work on r48800. My question is how I should
>>>> update my code to "proper OpenWRT standard"? First, network. The
>>>> board has only one network port (it is not a router). This should
>>>> be configured using DHCP. The board also has Wifi and should be
>>>> configured as a client but disabled as default. In -r46120 I put
>>>> this in /etc/uci-defaults/02_network: ucidef_set_interface_raw
>>>> "lan" "eth0" "dhcp" ucidef_set_interface_raw "wlan" "wlan0" "dhcp"
>>>> uci batch <<EOF set network.lan.hostname='TellStick-ZNet-Lite' set
>>>> wireless.radio0.disabled=0 set
>>>> wireless. at wifi-iface[0].network='wlan' set
>>>> wireless. at wifi-iface[0].mode='sta' set
>>>> wireless. at wifi-iface[0].encryption=psk2 EOF uci commit wireless In
>>>> r48800 this file seems to have been replaced by
>>>> /etc/board.d/02_network instead. Unfortunately "raw" uci commands
>>>> does not work since its generating /etc/board.json instead? Am I
>>>> correct? If I do this then "dhcp" is ignored and the interface is
>>>> set to static anyway: ucidef_set_interface_lan "eth0" "dhcp" How 
>>>> to
>>>> convert the wireless and the hostname I have no idea? Next is led.
>>>> I had this in /etc/uci-defaults/02_network: ucidef_set_led_netdev
>>>> "lan_act" "LANACT" "tellstick:green:lan" "eth0"
>>>> ucidef_set_led_netdev "lan_link" "LANLINK" "tellstick:orange:lan"
>>>> "eth0" uci set system.led_lan_act.mode='tx rx' uci set
>>>> system.led_lan_link.mode='link' The first two lines work in r48800
>>>> but how do I convert the last two lines? How do I set the mode?
>>> To change the defaults, you shouldn't just modify the existing
>>> files. You can simply create a new file in /etc/uci-defaults which
>>> runs your uci batch command as usual. It will run after 
>>> /etc/board.d
>>> has been processed and the default config has been generated, so 
>>> you
>>> should be able to override any parameter you want.
>> The file /etc/uci-defaults/02_network was (re)moved in r47534. Is it
>> really the right way to go to reintroduce this file again? My thougs
>> was that this should be implemented in /etc/board.json instead, 
>> maybe I
>> was wrong? Please note that my goal is to have the board config sent
>> upstream, not only for my local build.
> Ah, ok. I misread your intentions because of the kinds of changes you
> were proposing. Some of the things you mentioned don't make sense as
> board specific defaults in my opinion:
> - We don't change the default host name for specific boards.

The hostname is used in DHCP requests. Since this is not a router the 
user will see this device in his/her router. Finding out the local ip 
address of the board helps a lot when there is a hostname tied to the 
ip-address. Since this is not a router but I "client" in the network I 
cannot see the harm in setting a default hostname (that can be changed 
by the user anyway).

> - We don't enable wireless by default or change its mode

Default mode is to act as an access point in OpenWRT. This is fine 
because most boards supported by OpenWRT is routers.
But, for this product this mode make no sense. If the user wants to 
enable wifi he/she needs to switch the mode to a client anyway. Why not 
have the default configuration as close to how the product is intended 
to be used as possible?

I strongly believe the default configuration should be as close as 
possible to how the product was designed to be used. When we put up 
build instructions for building OpenWRT for this board then a default 
build should be as close as possible to the stock firmware delivered 
with the product.
For me its not user friendly to have instructions like this:
1) Clone git
2) Configure OpenWRT and select board to XXX
3) Build and flash
4) Change setting X to y
5..67) Change 62 more settings.

I rather skip step 4 to 67 above and let the user configure the board 
only when the default behavior is not that the user wants.

> - Interfaces using dhcp are usually considered 'wan' instead of 
> 'lan',
> LAN should have a predictable IP address.
> If you believe that that any of the above changes are necessary, 
> please
> provide compelling reasons for it. Otherwise we'd prefer to keep 
> device
> configurations more consistent with each other.

That is fine. I have switched the interface to wan and it is now 
working as expected.

> As for the LED stuff: I'd suggest extending the API to make it 
> possible
> to pass the mode to ucidef_set_led_netdev so that it ends up in
> board.json and can be used by /bin/config_generate.

Already solved in r48806 ;)

> Anything else?
> - Felix
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list