Build Home Router with OpenWrt – Setup Wireless

11 minute read

Wireless Setup

By default, the encryption method for wireless was set to None, apply below patch if to setup encryption and default password for this new router:

diff --git a/target/linux/brcm2708/base-files/etc/board.d/03_wireless b/target/linux/brcm2708/base-files/etc/board.d/03_wireless
new file mode 100755
index 0000000..0407834
--- /dev/null
+++ b/target/linux/brcm2708/base-files/etc/board.d/03_wireless
@@ -0,0 +1,23 @@
+#!/bin/sh
+# Copyright (C) 2014-2016 OpenWrt.org
+# Copyright (C) 2017 LEDE project
+
+[ ! -e /etc/config/wireless ] && exit 0
+
+. /lib/functions.sh
+. /lib/functions/system.sh
+
+board=$(board_name)
+
+case "$board" in
+raspberrypi,3-model-b)
+       uci set wireless.radio0.disabled=0
+       uci set wireless.default_radio0.encryption='psk2+ccmp'
+       uci set wireless.default_radio0.key='12345678'
+       uci commit wireless
+       ;;
+esac
+
+board_config_flush
+
+exit 0

After system boot, wireless was set like this:

root@OpenWrt:/# cat etc/config/wireless

config wifi-device 'radio0'
	option type 'mac80211'
	option channel '11'
	option hwmode '11g'
	option path 'platform/soc/3f300000.mmc/mmc_host/mmc1/mmc1:0001/mmc1:0001:1'
	option htmode 'HT20'
	option disabled '0'

config wifi-iface 'default_radio0'
	option device 'radio0'
	option network 'lan'
	option mode 'ap'
	option ssid 'OpenWrt'
	option encryption 'psk2+ccmp'
	option key '12345678'

Bootup message

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.90 (fdbai@fdbai-desktop) (gcc version 7.4.0 (OpenWrt GCC 7.4.0 r8985-ddc9fd5)) #0 SMP Sun Jan 6 07:33:11 2019
[    0.000000] CPU: ARMv7 Processor [410fd034] revision 4 (ARMv7), cr=10c5383d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Raspberry Pi 3 Model B Rev 1.2
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] cma: Reserved 16 MiB at 0x3a400000
[    0.000000] random: get_random_bytes called from start_kernel+0x84/0x35c with crng_init=0
[    0.000000] percpu: Embedded 16 pages/cpu @b9c35000 s33932 r8192 d23412 u65536
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 240792
[    0.000000] Kernel command line: 8250.nr_uarts=1 bcm2708_fb.fbwidth=640 bcm2708_fb.fbheight=480 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  dwc_otg.lpm_enable=0 console=ttyS0,115200 kgdboc=ttyS0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=squashfs,ext4 rootwait
[    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Memory: 937856K/970752K available (4651K kernel code, 148K rwdata, 1212K rodata, 1024K init, 351K bss, 16512K reserved, 16384K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xbb800000 - 0xff800000   (1088 MB)
[    0.000000]     lowmem  : 0x80000000 - 0xbb400000   ( 948 MB)
[    0.000000]     modules : 0x7f000000 - 0x80000000   (  16 MB)
[    0.000000]       .text : 0x80008000 - 0x8058ac64   (5644 kB)
[    0.000000]       .init : 0x80700000 - 0x80800000   (1024 kB)
[    0.000000]       .data : 0x80800000 - 0x80825380   ( 149 kB)
[    0.000000]        .bss : 0x8082a150 - 0x80881dc8   ( 352 kB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] Hierarchical RCU implementation.
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] arch_timer: cp15 timer(s) running at 19.20MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x46d987e47, max_idle_ns: 440795202767 ns
[    0.000007] sched_clock: 56 bits at 19MHz, resolution 52ns, wraps every 4398046511078ns
[    0.000020] Switching to timer-based delay loop, resolution 52ns
[    0.000220] Console: colour dummy device 80x30
[    0.000677] console [tty1] enabled
[    0.000711] Calibrating delay loop (skipped), value calculated using timer frequency.. 38.40 BogoMIPS (lpj=192000)
[    0.000747] pid_max: default: 32768 minimum: 301
[    0.000878] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000907] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.001439] CPU: Testing write buffer coherency: ok
[    0.001784] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.002096] Setting up static identity map for 0x100000 - 0x100060
[    0.002211] Hierarchical SRCU implementation.
[    0.002720] smp: Bringing up secondary CPUs ...
[    0.003305] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[    0.003918] CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
[    0.004506] CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
[    0.004584] smp: Brought up 1 node, 4 CPUs
[    0.004648] SMP: Total of 4 processors activated (153.60 BogoMIPS).
[    0.004666] CPU: All CPU(s) started in HYP mode.
[    0.004681] CPU: Virtualization extensions available.
[    0.013688] VFP support v0.3: implementor 41 architecture 3 part 40 variant 3 rev 4
[    0.013902] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.013941] futex hash table entries: 1024 (order: 4, 65536 bytes)
[    0.014578] pinctrl core: initialized pinctrl subsystem
[    0.015244] NET: Registered protocol family 16
[    0.017480] DMA: preallocated 1024 KiB pool for atomic coherent allocations
[    0.020838] cpuidle: using governor ladder
[    0.020876] cpuidle: using governor menu
[    0.021327] Serial: AMBA PL011 UART driver
[    0.022722] bcm2835-mbox 3f00b880.mailbox: mailbox enabled
[    0.023119] uart-pl011 3f201000.serial: could not find pctldev for node /soc/gpio@7e200000/uart0_pins, deferring probe
[    0.047341] bcm2835-dma 3f007000.dma: DMA legacy API manager at bb813000, dmachans=0x1
[    0.049044] SCSI subsystem initialized
[    0.049238] usbcore: registered new interface driver usbfs
[    0.049296] usbcore: registered new interface driver hub
[    0.049362] usbcore: registered new device driver usb
[    0.050032] raspberrypi-firmware soc:firmware: Attached to firmware from 2018-11-23 19:36
[    0.051059] clocksource: Switched to clocksource arch_sys_counter
[    0.055501] NET: Registered protocol family 2
[    0.056050] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
[    0.056175] TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
[    0.056375] TCP: Hash tables configured (established 8192 bind 8192)
[    0.056506] UDP hash table entries: 512 (order: 2, 16384 bytes)
[    0.056565] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
[    0.056750] NET: Registered protocol family 1
[    0.057870] Crashlog allocated RAM at address 0x3f00000
[    0.058034] workingset: timestamp_bits=30 max_order=18 bucket_order=0
[    0.061770] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.063194] io scheduler noop registered
[    0.063215] io scheduler deadline registered
[    0.063329] io scheduler cfq registered (default)
[    0.065900] BCM2708FB: allocated DMA memory fa510000
[    0.065944] BCM2708FB: allocated DMA channel 0 @ bb813000
[    0.075612] Console: switching to colour frame buffer device 80x30
[    0.084742] Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled
[    0.088501] vc-mem: phys_addr:0x00000000 mem_base=0x3ec00000 mem_size:0x40000000(1024 MiB)
[    0.094677] vc-sm: Videocore shared memory driver
[    0.104376] brd: module loaded
[    0.110949] loop: module loaded
[    0.114289] libphy: Fixed MDIO Bus: probed
[    0.117257] usbcore: registered new interface driver lan78xx
[    0.120195] usbcore: registered new interface driver smsc95xx
[    0.123019] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[    0.153662] dwc_otg 3f980000.usb: base=0xf0980000
[    0.356519] Core Release: 2.80a
[    0.359173] Setting default values for core params
[    0.361860] Finished setting default values for core params
[    0.564720] Using Buffer DMA mode
[    0.567316] Periodic Transfer Interrupt Enhancement - disabled
[    0.569986] Multiprocessor Interrupt Enhancement - disabled
[    0.572648] OTG VER PARAM: 0, OTG VER FLAG: 0
[    0.575246] Dedicated Tx FIFOs mode
[    0.578090] WARN::dwc_otg_hcd_init:1046: FIQ DMA bounce buffers: virt = 0xba504000 dma = 0xfa504000 len=9024
[    0.583561] FIQ FSM acceleration enabled for :
[    0.583561] Non-periodic Split Transactions
[    0.583561] Periodic Split Transactions
[    0.583561] High-Speed Isochronous Endpoints
[    0.583561] Interrupt/Control Split Transaction hack enabled
[    0.597166] WARN::hcd_init_fiq:459: FIQ on core 1 at 0x80412cc8
[    0.599800] WARN::hcd_init_fiq:460: FIQ ASM at 0x80412fe4 length 36
[    0.602401] WARN::hcd_init_fiq:486: MPHI regs_base at 0xf0006000
[    0.605025] dwc_otg 3f980000.usb: DWC OTG Controller
[    0.607676] dwc_otg 3f980000.usb: new USB bus registered, assigned bus number 1
[    0.612990] dwc_otg 3f980000.usb: irq 62, io mem 0x00000000
[    0.615841] Init: Port Power? op_state=1
[    0.618605] Init: Power Port (0)
[    0.621505] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    0.624352] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    0.629915] usb usb1: Product: DWC OTG Controller
[    0.632763] usb usb1: Manufacturer: Linux 4.14.90 dwc_otg_hcd
[    0.635604] usb usb1: SerialNumber: 3f980000.usb
[    0.638783] hub 1-0:1.0: USB hub found
[    0.641572] hub 1-0:1.0: 1 port detected
[    0.644880] usbcore: registered new interface driver uas
[    0.647648] usbcore: registered new interface driver usb-storage
[    0.650304] mousedev: PS/2 mouse device common for all mice
[    0.652914] i2c /dev entries driver
[    0.655959] bcm2835-wdt 3f100000.watchdog: Broadcom BCM2835 watchdog timer
[    0.658927] bcm2835-cpufreq: min=600000 max=1200000
[    0.662024] sdhci: Secure Digital Host Controller Interface driver
[    0.664809] sdhci: Copyright(c) Pierre Ossman
[    0.667847] mmc-bcm2835 3f300000.mmc: could not get clk, deferring probe
[    0.670983] sdhost-bcm2835 3f202000.mmc: could not get clk, deferring probe
[    0.674021] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.679590] vchiq: vchiq_init_state: slot_zero = ba580000, is_master = 0
[    0.683854] [vc_sm_connected_init]: start
[    0.692533] [vc_sm_connected_init]: end - returning 0
[    0.696231] NET: Registered protocol family 10
[    0.699883] Segment Routing with IPv6
[    0.702785] NET: Registered protocol family 17
[    0.705587] 8021q: 802.1Q VLAN Support v1.8
[    0.708680] Registering SWP/SWPB emulation handler
[    0.716102] uart-pl011 3f201000.serial: cts_event_workaround enabled
[    0.718946] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
[    0.725774] console [ttyS0] disabled
[    0.728618] 3f215040.serial: ttyS0 at MMIO 0x0 (irq = 166, base_baud = 31250000) is a 16550
[    0.861154] Indeed it is in host mode hprt0 = 00021501
[    0.871905] console [ttyS0] enabled
[    0.872646] mmc-bcm2835 3f300000.mmc: mmc_debug:0 mmc_debug2:0
[    1.131081] usb 1-1: new high-speed USB device number 2 using dwc_otg
[    1.135729] mmc-bcm2835 3f300000.mmc: DMA channel allocated
[    1.154682] Indeed it is in host mode hprt0 = 00001101
[    1.182301] random: fast init done
[    1.644300] sdhost: log_buf @ ba507000 (fa507000)
[    1.671295] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
[    1.681266] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    1.688837] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
[    1.700527] hub 1-1:1.0: USB hub found
[    1.701940] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[    1.716117] hub 1-1:1.0: 5 ports detected
[    1.717645] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[    1.731987] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[    1.741584] of_cfs_init
[    1.747074] of_cfs_init: OK
[    1.773686] Waiting for root device /dev/mmcblk0p2...
[    1.775835] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
[    1.868681] mmc0: host does not support reading read-only switch, assuming write-enable
[    1.885679] mmc0: new high speed SD card at address cb7d
[    1.894538] mmcblk0: mmc0:cb7d SD01G 947 MiB
[    1.902979]  mmcblk0: p1 p2
[    1.923369] mmc1: new high speed SDIO card at address 0001
[    1.935961] EXT4-fs (mmcblk0p2): mounted filesystem without journal. Opts: (null)
[    1.949595] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
[    1.961314] Freeing unused kernel memory: 1024K
[    2.030211] init: Console is alive
[    2.036970] init: - watchdog -
[    2.061132] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[    2.071118] Under-voltage detected! (0x00050005)
[    2.162625] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    2.175401] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    2.191325] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[    2.194615] init: - preinit -
[    2.201464] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    2.224205] smsc95xx v1.0.6
[    2.224221] random: procd: uninitialized urandom read (4 bytes read)
[    2.334782] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-3f980000.usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:c3:53:cc
[    2.431084] usb 1-1.5: new full-speed USB device number 4 using dwc_otg
[    2.587287] usb 1-1.5: New USB device found, idVendor=0a5c, idProduct=21ec
[    2.597836] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    2.612185] usb 1-1.5: Product: BCM20702A0
[    2.619746] usb 1-1.5: Manufacturer: Broadcom Corp
[    2.627953] usb 1-1.5: SerialNumber: 00198600164E
[    6.373880] mount_root: mounting /dev/root
[    6.381810] EXT4-fs (mmcblk0p2): warning: mounting unchecked fs, running e2fsck is recommended
[    6.403679] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[    6.448330] urandom-seed: Seed file not found (/etc/urandom.seed)
[    6.477408] procd: - early -
[    6.483785] procd: - watchdog -
[    7.102253] procd: - watchdog -
[    7.108701] procd: - ubus -
[    7.121435] random: ubusd: uninitialized urandom read (4 bytes read)
[    7.165602] random: ubusd: uninitialized urandom read (4 bytes read)
[    7.175178] random: ubusd: uninitialized urandom read (4 bytes read)
[    7.185039] procd: - init -
Please press Enter to activate this console.
[    7.294354] kmodloader: loading kernel modules from /etc/modules.d/*
[    7.320648] ip6_tables: (C) 2000-2006 Netfilter Core Team
[    7.336175] hidraw: raw HID events driver (C) Jiri Kosina
[    7.348384] bcm2835_alsa bcm2835_alsa: card created with 8 channels
[    7.370762] Loading modules backported from Linux version v4.19.7-0-g61c68f2a2af0
[    7.383736] Backport generated by backports.git v4.19.7-1-0-g148b072d
[    7.394786] ip_tables: (C) 2000-2006 Netfilter Core Team
[    7.407738] nf_conntrack version 0.5.0 (15360 buckets, 61440 max)
[    7.433443] usbcore: registered new interface driver usbhid
[    7.442045] usbhid: USB HID core driver
[    7.454681] xt_time: kernel timezone is -0000
[    7.475162] PPP generic driver version 2.4.2
[    7.483192] NET: Registered protocol family 24
[    7.499635] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[    7.532541] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.raspberrypi,3-model-b.txt failed with error -2
[    7.550413] brcmfmac mmc1:0001:1: Falling back to user helper
[    7.569666] firmware brcm!brcmfmac43430-sdio.raspberrypi,3-model-b.txt: firmware_loading_store: map pages failed
[    7.712035] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[    7.727997] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.clm_blob failed with error -2
[    7.745570] brcmfmac mmc1:0001:1: Falling back to user helper
[    7.764632] firmware brcm!brcmfmac43430-sdio.clm_blob: firmware_loading_store: map pages failed
[    7.780980] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-11), device may have limited channels available
[    7.803563] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Oct 23 2017 03:55:53 version 7.45.98.38 (r674442 CY) FWID 01-e58d219f
[    7.869009] usbcore: registered new interface driver brcmfmac
[    7.882840] kmodloader: done loading kernel modules from /etc/modules.d/*
[   12.442813] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
[   14.020416] smsc95xx 1-1.1:1.0 eth0: kevent 4 may have been dropped
[   14.030902] smsc95xx 1-1.1:1.0 eth0: kevent 4 may have been dropped
[   14.042844] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
[   14.066228] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
[   29.111132] Voltage normalised (0x00000000)
[   34.025801] random: crng init done
[   34.033167] random: 6 urandom warning(s) missed due to ratelimiting
[   35.351127] Under-voltage detected! (0x00050005)



BusyBox v1.30.0 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r8988-3d680b5
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:/#