Table of Contents

OpenWRT 17.01.x with MESHdesk packages

Follow these instructions to build the MESHdesk firmware on devices capable of running OpenWRT version 17.01.x

Minimum Hardware Requirements

Steps In Adding New Hardware

The Very First Time (Draft)

These steps you have to do ONCE ONLY

  1. Build OpenWRT with MESHdesk firmware (MESHdesk disabled).
  2. Flash your device.
  3. Prepare the wan_network file for specific device.
  4. Prepare meshdesk config file for specific device.
  5. Prepare captive_config.json file for specific device.

Afterwards (Final)

  1. Build OpenWRT with MESHdesk firmware containing the device specific files for
    1. wan_network
    2. captive_config.json
    3. meshdesk
  2. Flash your device with the final built of firmware.

Fetching the MESHdesk package

#Do this in the working directory e.g. cd 17.01.7
git clone git://git.code.sf.net/p/radiusdesk/openwrt-meshdesk openwrt-meshdesk
  1. zzz-MESHdesk - This is the MESHdesk package which will be build by the SDK.
  2. files - This is the override structure containing files to override during the build process.
  3. luci-app-meshdesk - This is the Luci application used to enable central control.

Copying the three components

#cd to the working directory
cp -R ./openwrt-meshdesk/zzz-MESHdesk ./openwrt/package 
#cd to the working directory
cp -R ./openwrt-meshdesk/files ./openwrt 
#cd to the working directory
cp -R ./openwrt-meshdesk/luci-app-meshdesk ./openwrt/feeds/luci/applications

Updating the available packages

#cd to the working directory
cd ./openwrt
scripts/feeds update -i
#Install the package to make it visible 
scripts/feeds install luci-app-meshdesk
  • These instructions are for the 17.01.x branch.
  • Each branch has a unique set of small tweaks in its instructions.
  • If you are using a different branch please refer to that branch's page

Select Packages To Include With Firmware

Package Location Comment
zzz-MESHdesk Base system
kmod-batman-adv Kernel Modules → Network Support Keep the default options
lua-mosquitto Languages → Lua
libiwinfo-lua Languages → Lua
luasocket Languages → Lua
libuci-lua Libraries
luci Luci → Collections
luci-app-meshdesk Luci → Applications Luci App to enable and disable central management
luci-theme-material Luci → Themes Modern theme that is easy to customize
luci-lib-httpclient Luci → Libraries
luci-lib-json Luci → Libraries
luci-lib-jsonc Luci → Libraries
coova-chilli Network → Captive Portals Select OpenSSL as SSL Library Do not include to save space eg on OM2P
curl Network → File Transfer
relayd Network → Routing and Redirection
batctl Network
mosquitto-client-ssl Network Note the CLIENT package
wpad IEEE 802.1x Auth/Supplicant (built-in full) Network Use default wpad-mini to save space eg on OM2P

Although the OM2P has 16M FLASH there is a 7M fail-safe partition which complicates things a bit. To keep things small I included the mesh parts (Batman) but excluded coova-chilli and the full version of wpad in the firmware I created

Initial File Preparation

wan_network

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 ula_prefix 'fd15:97e0:cb63::/48'
 
config interface 'lan'
	option type 'bridge'
	option ifname 'eth0'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'
	option ip6assign '60'
 
config interface 'wan'
	option ifname 'eth1'
	option proto 'dhcp'
 
config interface 'wan6'
	option ifname 'eth1'
	option proto 'dhcpv6'
wan_network
config interface 'loopback'
    option proto 'static'
    option ipaddr '127.0.0.1'
    option netmask '255.0.0.0'
    option ifname 'lo'
 
config interface 'lan'
    option ifname 'eth0'
    option type 'bridge'
    option proto 'dhcp'
 
config interface 'client_0'
    option proto 'dhcp'
 
config interface 'client_1'
    option proto 'dhcp'
  • There is a growing list of existing sample wan_network files under the /openwrt/package/zzz-MESHdesk/files/MESHdesk/configs folder.
  • They have a convention of network_<firmware_id> e.g. network_xiaomi_4a_100
  • Simply copy that file over openwrt/package/zzz-MESHdesk/files/MESHdesk/configs/wan_network
  • Those files will have a matching existing hardware section in the openwrt/package/zzz-MESHdesk/files/MESHdesk/meshdesk file

meshdesk

Tweaks For Our Hardware

#change directory to where the LEDs are
cd /sys/class/leds/
ls 
#These are the LEDs available
ath9k-phy0        om2p:blue:lan     om2p:blue:power   om2p:blue:wan     om2p:green:wifi   om2p:red:wifi     om2p:yellow:wifi
#turn it off
echo "0" > om2p\:blue\:lan/brightness
#turn it on
echo "1" > om2p\:blue\:lan/brightness
#Go through all of them and confirm which is which on the device
config hardware 'om2p'                                                        
        option morse_led '/sys/class/leds/om2p:blue:wan/brightness'      
        option internet_led '/sys/class/leds/om2p:yellow:wifi/brightness'
        option wifi_led 'om2p:blue:lan'
config settings 'settings'
	option hardware 'om2p'
	option id_if 'eth0'
	option lan_up_file '/tmp/lan_up'

Don't make the name of the hardware section more than 14characters. Longer names break things during deployment.

vi /etc/MESHdesk/reporting/report_to_server.lua 
#Look for this section
    if(ok_flag)then                                 
        internetLED('0'); -- NOTE Here we can swap thme around eg make it 0 to turn off a red LED when the internet is OK
        checkForContollerReboot('1');                   
    else                                                                             
        internetLED('1');                                                        
        checkForContollerReboot('0');                  
    end
 
#Also modify the internetLED function to look like this:
function internetLED(state)            
    local hardware  = x.get('meshdesk', 'settings', 'hardware');
    local led       = x.get('meshdesk', hardware, 'internet_led');
    if(state == '0')then                                                 
         os.execute('echo 1 > /sys/class/leds/om2p\:green\:wifi/brightness' );
    end                                             
    if(state == '1')then                                   
         os.execute('echo 0 > /sys/class/leds/om2p\:green\:wifi/brightness' );
    end                            
    os.execute('echo '..state..' > ' .. led );                   
end
config led 'wifi_led'
	option name 'wifi'
	option trigger 'netdev'
	option dev 'bat0'
	option mode 'link tx rx'
	option sysfs 'om2p:blue:lan'
Item Typical value Comment
settings → hardware om2p Must match a hw definition in the file itself
settings → id_if eth0 eg eth0, eth1 or wan - NOT eth0.1 (for those boards its just eth0)
settings → skip_radio_0 0 set to 1 when radio0 is a 5G radio and you don't want to use it for config SSID

Tweaks For Our Environment

Item Typical value Comment
internet1 → disabled 1 change it to 0 in order for the device to be centrally controlled
internet1 → dns cloud.radiusdesk.com Supply Dummy Value If Not Using DNS System
internet1 → protocol https Can be http or https
internet1 → ip 176.31.15.210 Fallback when FQDN does not resolve on FQDN not used

captive_portal.json

"wireless": [
            {
                "wifi-device": "radio1",
                "options": {
                    "channel": 1,
                    "disabled": 0,
                    "hwmode": "11g",
                    "htmode": "HT20"
                }
            },  
            {
                "wifi-iface": "two",
                "options": {
                    "device": "radio1",
                    "ifname": "two0",
                    "mode": "ap",
                    "network": "ex_two",
                    "encryption": "none",
                    "ssid": "_Replace_",
                    "key": "",
                    "hidden": false,
                    "isolate": false,
                    "auth_server": "",
                    "auth_secret": ""
                }
            },
            {
                "wifi-iface": "web_by_w",
                "options": {
                    "device": "radio1",
                    "mode": "sta",
                    "network": "web_by_w",
                    "encryption": "psk2",
                    "key": "radiusdesk",
                    "ssid": "meshdesk_config",
                    "disabled": "1"
                }
            }
        ],
{
    "interface": "lan",
    "options": {
        "ifname": "eth0",
        "type": "bridge",
        "proto": "static",
        "ipaddr": "10.50.50.50",
        "netmask": "255.255.255.0"
    }
},

The Final Built

On Device On SDK
/etc/MESHdesk/configs/wan_network openwrt/package/zzz-MESHdesk/files/MESHdesk/configs/
/etc/config/meshdesk openwrt/package/zzz-MESHdesk/files/MESHdesk/
/etc/MESHdesk/configs/captive_config.json openwrt/package/zzz-MESHdesk/files/MESHdesk/configs/
/etc/MESHdesk/reporting/report_to_server.lua openwrt/package/zzz-MESHdesk/files/MESHdesk/reporting