# MT7697 interface wifi on mangoh red WP7603 not working

**URL:** <https://mangoh.discourse.group/t/mt7697-interface-wifi-on-mangoh-red-wp7603-not-working/1679>\
**Category:** mangOH Red\
**Created:** [July 6, 2018, 3:37pm UTC](https://mangoh.discourse.group/t/mt7697-interface-wifi-on-mangoh-red-wp7603-not-working/1679 "2018-07-06T15:37:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![leoniloris](https://avatars.discourse-cdn.com/v4/letter/l/d07c76/32.png) [@leoniloris](https://mangoh.discourse.group/u/leoniloris)\
**Post date:** [July 6, 2018, 3:37pm UTC](https://mangoh.discourse.group/t/mt7697-interface-wifi-on-mangoh-red-wp7603-not-working/1679/1 "2018-07-06T15:37:56Z")

</div>

# My current arranging:

- I’m able to build and flash the correct firmware for MT7697 (after some modifications from the [wiki tutorial](https://github.com/mangOH/mangOH/wiki/mangOH-Red-mt7697-wifi) in order to make it work)
- I’m able to connect and get an IP using the console usb as interface for the MT7697.
- I flashed the necessary kernel modules for the MT7697 as well as the scripts for setting the interface up.

# My problem:

- I’m no able to see the interface `wlan1` which is supposed to interface the MT7697 (not the TI) and when I try to set the interface up with `ifup wlan1`I receive the following:  
`Setup MT7697 UART`  
`Device: WP76`  
`Enable power control`  
`Initialized Linux WiFi modules`  
`Initialized MT7697 WiFi core`  
`Failed to init MT7697 WiFi core`  
which is due to `ifconfig -a | grep wlan$2` not finding any interface.

# Logs:

- lsmod:

```auto
mt7697wifi_core 70999 0 - Live 0xbf175000 (O)
mac80211 437300 0 - Live 0xbf0e6000
cfg80211 476220 2 mt7697wifi_core,mac80211, Live 0xbf045000
spisvc 1069 0 - Live 0xbf043000 (O)
mt7697serial 8110 1 mt7697wifi_core, Live 0xbf03d000 (O)
mt7697q 19703 1 mt7697wifi_core, Live 0xbf033000 (O)
mangoh_red_dv5 8148 0 - Live 0xbf02d000 (O)
ltc294x 5575 0 - Live 0xbf028000 (O)
led 1935 0 - Live 0xbf024000 (O)
cp2130 20478 1 mt7697q, Live 0xbf01b000 (O)
bq24296 10836 0 - Live 0xbf014000 (O)
bmp280_i2c 2631 0 - Live 0xbf010000 (O)
bmp280 9493 1 bmp280_i2c, Live 0xbf009000 (O)
bmi160_i2c 1396 0 - Live 0xbf005000 (O)
bmi160 5472 1 bmi160_i2c, Live 0xbf000000 (O)

```

- dmseg:  
[log](https://pastebin.com/zdw973Z5)

- Log Console from MT7697:

```auto
[T: 2845 M: common C: info F: swi_wifi_event_hndlr L: 287]: ==> CONNECTED

[T: 2846 M: common C: info F: swi_wifi_event_hndlr L: 288]: MAC
70 3A CB 02 D4 7B 00
[T: 2928 M: common C: info F: swi_wifi_event_hndlr L: 293]: ==> PORT SECURE

[T: 2929 M: common C: info F: swi_wifi_event_hndlr L: 310]: Port Secure!

[T: 2929 M: common C: info F: swi_wifi_event_hndlr L: 311]: MAC
70 3A CB 02 D4 7B 00
[T: 2929 M: common C: info F: swi_wifi_event_hndlr L: 318]: channel(0)
[T: 2929 M: common C: info F: swi_wifi_event_hndlr L: 322]: <-- CONNECT IND len(24) result(0)
[T: 2929 M: common C: info F: wifi_station_port_secure_event_handler L: 130]: wifi connected
[T: 3928 M: common C: info F: ip_ready_callback L: 75]: ************************
[T: 3928 M: common C: info F: ip_ready_callback L: 76]: DHCP got IP:192.168.86.73
[T: 3928 M: common C: info F: ip_ready_callback L: 77]: ************************

```

---

<div class="post-metadata">

**Author:** ![leoniloris](https://avatars.discourse-cdn.com/v4/letter/l/d07c76/32.png) [@leoniloris](https://mangoh.discourse.group/u/leoniloris)\
**Post date:** [July 8, 2018, 3:56am UTC](https://mangoh.discourse.group/t/mt7697-interface-wifi-on-mangoh-red-wp7603-not-working/1679/2 "2018-07-08T03:56:16Z")

</div>

Was anyone able to get the modules working on the wp76xx?  
Can someone help with this issue?

---

<div class="post-metadata">

**Author:** ![leoniloris](https://avatars.discourse-cdn.com/v4/letter/l/d07c76/32.png) [@leoniloris](https://mangoh.discourse.group/u/leoniloris)\
**Post date:** [July 10, 2018, 3:21pm UTC](https://mangoh.discourse.group/t/mt7697-interface-wifi-on-mangoh-red-wp7603-not-working/1679/3 "2018-07-10T15:21:10Z")

</div>

I have seen that when we reset the mt7697 using the control switch 8 we can set the `wlan1` up.

But when we just power the mangoh board on and try to do a `ifup wlan1` it does not work because  
either the mt7697 uart do not respond back or the wp7603 uart do not write properly.  
We can check in dmesg that the last comand sent from the wifi driver is:

`mt7697core mt7697core: mt7697_wr_cfg_req(): <-- GET CONFIG len(4)`

Thus, not receiving any response from the wp7697. But if we:

- turn the 8th switch to the off position
- issue `modprobe mac80211`
- Issue `rmmod mt7697wifi_core`
- Turn the switch (8) on
- issue `insmod /legato/systems/current/modules/mt7697wifi_core.ko hw_itf=uart itf_idx_start=1`

It successfully adds the interface.  
dmesg:

```auto
[774.142704] [<c0033650>] (process_one_work) from [<c00342fc>] (worker_thread+0x2e0/0x3bc) [12/6546]
[774.142726] [<c00342fc>] (worker_thread) from [<c0037bd0>] (kthread+0xc8/0xd4)
[774.142748] [<c0037bd0>] (kthread) from [<c000e798>] (ret_from_fork+0x14/0x3c)
[774.142761] ---[end trace 210d62f45caefc62]---
[774.142779] mt7697serial mt7697serial: mt7697_uart_open(): open serial device '/dev/ttyHS0'
[774.190977] mt7697core mt7697core: mt7697_wr_cfg_req(): <-- GET CONFIG len(4)
[774.206029] mt7697core mt7697core: mt7697_proc_get_cfg(): --> GET CONFIG RSP
[774.206065] mt7697core mt7697core: mt7697_proc_get_cfg(): operation mode(1)
[774.206079] mt7697core mt7697core: mt7697_proc_get_cfg(): STA ssid len(0)
[774.206092] mt7697core mt7697core: mt7697_proc_get_cfg(): STA passphrase len(0)
[774.206106] mt7697core mt7697core: mt7697_wr_get_listen_interval_req(): <-- GET LISTEN INTERVAL len(4)
[774.206149] mt7697core mt7697core: mt7697_wr_get_wireless_mode_req(): <-- GET WIRELESS MODE port(0) len(8
leoni@leoni-ubuntu:/projs/iot/mangOH/linux_kernel_modules/mt7697wifi/scripts$ │)
[774.206180] mt7697core mt7697core: mt7697_wr_mac_addr_req(): <-- GET MAC ADDRESS port(0) len(8)
[774.219357] mt7697core mt7697core: mt7697_proc_get_listen_interval(): --> GET LISTEN INTERVAL RSP
[774.219382] mt7697core mt7697core: mt7697_proc_get_listen_interval(): listen interval(1)
[774.231628] mt7697core mt7697core: mt7697_proc_get_wireless_mode(): --> GET WIRELESS MODE RSP
[774.231654] mt7697core mt7697core: mt7697_proc_get_wireless_mode(): wireless mode(9)
[774.231675] mt7697core mt7697core: mt7697_proc_mac_addr(): --> GET MAC ADDRESS RSP
[774.231691] mt7697core MAC address 00000000: 00 0c 43 76 87 22
[774.231708] mt7697core mt7697core: mt7697_interface_add(): interface('wlan1') type(2)
[774.231747] mt7697core mt7697core: mt7697_interface_add(): register('wlan1') type(2)
[774.233465] mt7697core mt7697core: mt7697_interface_add(): added('wlan1') type(2)
[774.239925] mt7697core mt7697core: mt7697_proc_mac_addr(): name/type('wlan1'/2) netdev(0xcb813000), cfg($
mtwifi 100% 2555 314.1KB/s 00:00 │xcd3d8480)

```

Can someone give some light on this iffy issue?

---

<div class="post-metadata">

**Author:** ![lotam](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lotam](https://mangoh.discourse.group/u/lotam)\
**Post date:** [July 11, 2018, 1:27am UTC](https://mangoh.discourse.group/t/mt7697-interface-wifi-on-mangoh-red-wp7603-not-working/1679/4 "2018-07-11T01:27:34Z")

</div>

Any chance relate to issue mentioned below?  
[https://github.com/mangOH/mangOH/issues/9](https://github.com/mangOH/mangOH/issues/9)

---

<div class="post-metadata">

**Author:** ![leoniloris](https://avatars.discourse-cdn.com/v4/letter/l/d07c76/32.png) [@leoniloris](https://mangoh.discourse.group/u/leoniloris)\
**Post date:** [July 11, 2018, 2:25pm UTC](https://mangoh.discourse.group/t/mt7697-interface-wifi-on-mangoh-red-wp7603-not-working/1679/5 "2018-07-11T14:25:45Z")

</div>

Thanks for answering, but it seems not related to the above issue.  
Watching the bytes that goes out of the mt7697 kernel module and reaches the mt7697 firmware, I could notice something:

- When manually reset the mt7697 chip and successfully adds a `wlan1` interface  
\*\* the mt7697 should receive 4 bytes requesting a mac address, and it does receive 4 bytes (4, 0, 2, 2)

- When I just boot the mangoh board and it does not add successfully a `wlan1` interface  
\*\* the WP7603 send 4bytes (4, 0, 2, 2), whereas the mt7697 receive 3 (4, 0, 2) bytes and then receive again 1 byte (the last 2), but can not interpret the command.

Following the firmware of the mt7697, the 3+1 bytes received is a normal behavior, since it will remain stuck in the `swi_uart_recv()` while loop. but not interpreting it is not a normal behavior.

---

<div class="post-metadata">

**Author:** ![leoniloris](https://avatars.discourse-cdn.com/v4/letter/l/d07c76/32.png) [@leoniloris](https://mangoh.discourse.group/u/leoniloris)\
**Post date:** [July 11, 2018, 7:36pm UTC](https://mangoh.discourse.group/t/mt7697-interface-wifi-on-mangoh-red-wp7603-not-working/1679/6 "2018-07-11T19:36:17Z")

</div>

I created a function to flush the receiver inside mt7697 as soon as it starts the receiver task. It’s adding the interface now.

The problem is different now.  
For connecting to a network i’m trying the following:

- wifi client start  
it returns `ERROR: le_wifiClient_Start returns ERROR.`
- also tried to connect manually:  
– add an entry in `wpa_supplicant.conf`,  
– use wpa\_cli to connect (it finds my network and says `OK` when I issue `enable_network 0`),  
– issuing `/sbin/udhcpc -i wlan1 -s /usr/share/udhcpc/default.script` for getting a IP (since there’s no dhclient )  
  
  
The program stays forever printing:

```auto
root@swi-mdm9x28:~# /sbin/udhcpc -i wlan1 -s /usr/share/udhcpc/default.script
udhcpc (v1.24.1) started
Sending discover...
Sending discover...
Sending discover...

```

How could I get a valid IP?
