WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: piCore 8.0 and TL-WN722N wifi dongle  (Read 6772 times)

Offline eggze

  • Newbie
  • *
  • Posts: 7
piCore 8.0 and TL-WN722N wifi dongle
« on: October 16, 2016, 08:03:34 AM »
Hi,

I've installed piCore 8.0 on SD card for usage on RPi B with TL-WN722N wifi dongle. I've installed following extensions: wifi.tcz, firmware.tcz, firmware-atheros.tcz. But according to dmesg kernel still cannot load its firmware:
Code: [Select]
[    3.622826] usb 1-1.3: new high-speed USB device number 4 using dwc_otg
[    3.744166] usb 1-1.3: New USB device found, idVendor=0cf3, idProduct=9271
[    3.744207] usb 1-1.3: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[    3.744225] usb 1-1.3: Product: USB2.0 WLAN
[    3.744242] usb 1-1.3: Manufacturer: ATHEROS
[    3.744257] usb 1-1.3: SerialNumber: 12345
[   46.036543] usb 1-1.3: ath9k_htc: Firmware ath9k_htc/htc_9271-1.4.0.fw requested
[   46.036748] usb 1-1.3: Direct firmware load for ath9k_htc/htc_9271-1.4.0.fw failed with error -2
[   46.036795] usb 1-1.3: ath9k_htc: Firmware htc_9271.fw requested
[   46.036945] usb 1-1.3: Direct firmware load for htc_9271.fw failed with error -2
[   46.036975] usb 1-1.3: no suitable firmware found!
[   46.036994] usb 1-1.3: ath9k_htc: Failed to get firmware htc_9271.fw
[   46.037755] usb 1-1.3: ath9k_htc: USB layer deinitialized

TL-WN722N uses Atheros AR9271 chip (see https://wikidevi.com/wiki/TP-LINK_TL-WN722N). And as stated here http://wiki.tinycorelinux.net/wiki:list_of_supported_wifi_devices, it should be supported by TinyCoreLinux. I have suspicion that firmware.tcz or firmware-atheros.tcz is not updated accordingly and cannot work with the newest kernel which uses different names of firmware file (see https://wireless.wiki.kernel.org/en/users/Drivers/ath9k_htc#firmware).

Unfortunately I don't know what should I do to fix this as I'm pretty new to TCL and piCore. Any ideas?

In the meantime I'll study the CoreBook and hopefully I'll understand more how to troubleshoot and fix it…
Thank you.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11040
Re: piCore 8.0 and TL-WN722N wifi dongle
« Reply #1 on: October 16, 2016, 12:30:58 PM »
You can create a personal firmware extension easily.

cd /tmp
mkdir -p dst/usr/local/lib/firmware/ath9k_htc
# download htc_9271-1.4.0.fw into that directory
mksquashfs dst myfirmware.tcz

Then copy this new extension to your tce/optional directory, and add to onboot.lst.
The only barriers that can stop you are the ones you create yourself.

Offline eggze

  • Newbie
  • *
  • Posts: 7
Re: piCore 8.0 and TL-WN722N wifi dongle
« Reply #2 on: October 16, 2016, 04:50:02 PM »
You can create a personal firmware extension easily.

Thanks, I did almost exactly what you wrote. My assumption was that /lib/firmware/ar9271.fw is basically htc_9271-1.4.0.fw which I could use (according to what I found here https://wireless.wiki.kernel.org/en/users/Drivers/ath9k_htc#firmware).

So I created extension which took ar9271.fw and gradually copied it into four various paths but only last path works somehow:
- /usr/local/lib/firmware/atk9k_htc/htc_9271.fw
- /usr/local/lib/firmware/htc_9271.fw
- /lib/firmware/atk9k_htc/htc_9271.fw
- /lib/firmware/htc_9271.fw

Works somehow means that I was wrong about usage of ar9271.fw because dmesg gives me this now:
Code: [Select]
[    3.622911] usb 1-1.3: new high-speed USB device number 4 using dwc_otg
[    3.744100] usb 1-1.3: New USB device found, idVendor=0cf3, idProduct=9271
[    3.744136] usb 1-1.3: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[    3.744156] usb 1-1.3: Product: USB2.0 WLAN
[    3.744172] usb 1-1.3: Manufacturer: ATHEROS
[    3.744187] usb 1-1.3: SerialNumber: 12345
[   41.862184] usb 1-1.3: ath9k_htc: Firmware ath9k_htc/htc_9271-1.4.0.fw requested
[   41.862416] usb 1-1.3: Direct firmware load for ath9k_htc/htc_9271-1.4.0.fw failed with error -2
[   41.862463] usb 1-1.3: ath9k_htc: Firmware htc_9271.fw requested
[   41.926651] usbcore: registered new interface driver ath9k_htc
[   42.147378] usb 1-1.3: ath9k_htc: Transferred FW: htc_9271.fw, size: 51312
[   42.423120] ath9k_htc 1-1.3:1.0: ath9k_htc: HTC initialized with 33 credits
[   42.424317] ath: phy0: Mac Chip Rev 0x00.0 is not supported by this driver
[   42.424351] ath: phy0: Unable to initialize hardware; initialization status: -95
[   42.424413] ath: phy0: Unable to initialize hardware; initialization status: -95
[   42.424544] ath9k_htc: Failed to initialize the device
[   42.426361] usb 1-1.3: ath9k_htc: USB layer deinitialized

It seems I really need the exact version of the firmware… So I found this https://github.com/qca/open-ath9k-htc-firmware. It looks like correct source code. But I'm not able to compile it. I've installed all things like make, automake, cmake, gcc. I also created shell script for sha256sum (http://stackoverflow.com/a/7956146) which is used by the Makefile and it's not available in busybox. But now I've got stuck on following message:
Code: [Select]

checking compiler gcc -Os -pipe ... no
checking compiler cc -Os -pipe ... no
configure: error: could not find a working compiler, see config.log for details
make: *** [Makefile:147: /home/tc/open-ath9k-htc-firmware/toolchain/build/gmp-6.1.1/.built] Error 1

So I think cross-compilation would be better but I don't have any experience with it :-( Any other idea?

Btw. why this firmware isn't part of piCore's extensions? Is it possible to add it there so it's available the official way?

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: piCore 8.0 and TL-WN722N wifi dongle
« Reply #3 on: October 16, 2016, 05:02:13 PM »
Install  compiletc.tcz .
Download a copy and keep it handy: Core book ;)

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1238
Re: piCore 8.0 and TL-WN722N wifi dongle
« Reply #4 on: October 16, 2016, 09:31:54 PM »
i have the same adapter, I took the firmware file from raspbian image.

You want htc_9271.fw

Offline eggze

  • Newbie
  • *
  • Posts: 7
Re: piCore 8.0 and TL-WN722N wifi dongle
« Reply #5 on: October 27, 2016, 01:55:32 PM »
Thank you very much curaga and Paul_123, it works!

Offline VMat

  • Newbie
  • *
  • Posts: 14
Re: piCore 8.0 and TL-WN722N wifi dongle
« Reply #6 on: June 17, 2017, 04:21:18 PM »
Thank you very much curaga and Paul_123, it works!

Hi,

I'm having the same trouble, tried to follow the steps here, but it's still not working. Can you tell me where you got htc_9271.fw from? I got one from Raspbian Jessie (2015-11-21). If you can tell me the file size it may be useful for a comparison too.

I'll try to put together some more info to post here tonight.

Thank you,

VMat

Offline VMat

  • Newbie
  • *
  • Posts: 14
Re: piCore 8.0 and TL-WN722N wifi dongle
« Reply #7 on: June 17, 2017, 09:03:13 PM »
So...

I have piCorePlayer 3.20 running here. Not sure if the solution applies to piCorePlayer (I hope you don't mind me posting here, as the symptoms are very similar). And the same adapter, TL-WN722N.

Error messages (this is now, with the "custom" firmware applied - same as before):

Code: [Select]
tc@piCorePlayer:~$ dmesg | grep -i error
[   17.858679] usb 1-1.2.5: Direct firmware load for ath9k_htc/htc_9271-1.4.0.fw failed with error -2
[   17.858884] usb 1-1.2.5: Direct firmware load for htc_9271.fw failed with error -2

As I said, I copied htc_9271.fw from a Raspbian image (late 2015). Copied it to /tmp/dst/usr/local/lib/firmware/ath9k_htc/, and on another try, to /tmp/dst/usr/local/lib/firmware/.

Created myfirmware.tcz as suggested. It is there:

Code: [Select]
tc@piCorePlayer:~$ ls -l /mnt/mmcblk0p2/tce/optional/my*
-rw-rw-r--    1 tc       staff        32768 Jun 16 23:54 /mnt/mmcblk0p2/tce/optional/myfirmware.tcz
tc@piCorePlayer:~$ cat /mnt/mmcblk0p2/tce/onboot.lst
pcp.tcz
slimserver.tcz
firmware-atheros.tcz
firmware-brcmwifi.tcz
firmware-rpi3-wireless.tcz
firmware-ralinkwifi.tcz
firmware-rtlwifi.tcz
wifi.tcz
squashfs-tools.tcz
myfirmware.tcz

And the fw file is where I expected (is this the right place?):

Code: [Select]
tc@piCorePlayer:~$ ls -l /lib/firmware/htc*
-rw-r--r--    1 root     root         51272 Jun 15 23:08 /lib/firmware/htc_9271.fw

Output from lsusb:
Code: [Select]
tc@piCorePlayer:~$ sudo lsusb
Bus 001 Device 007: ID 0781:5571 SanDisk Corp. Cruzer Fit
Bus 001 Device 006: ID 0cf3:9271 Atheros Communications, Inc. AR9271 802.11n
Bus 001 Device 005: ID 08bb:2902 Texas Instruments PCM2902 Audio Codec
Bus 001 Device 004: ID 1a40:0201 Terminus Technology Inc. FE 2.1 7-port Hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

And this is from pCP diag page, I don't know what is the command to get this:
Code: [Select]
Module                  Size  Used by    Not tainted
ath9k_htc              61269  0
mac80211              655416  1 ath9k_htc
ath9k_common           29430  1 ath9k_htc
ath9k_hw              451961  2 ath9k_htc,ath9k_common
ath                    23073  3 ath9k_htc,ath9k_common,ath9k_hw
cfg80211              543027  4 ath9k_htc,mac80211,ath9k_common,ath
rfkill                 20851  1 cfg80211
fixed                   3285  0

Also, I had a different adapter installed with a Realtek chipset, not sure if this can mess up the TP-Link installation. I replaced it with the TP-Link before booting and getting all the data pasted above.

Any help is appreciated. Again, if this is the wrong place, my apologies - please let me know. This thread is really the closest one I found to my issue, so I thought I should ask.

Thank you,

VMat
« Last Edit: June 17, 2017, 09:10:59 PM by VMat »

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1238
Re: piCore 8.0 and TL-WN722N wifi dongle
« Reply #8 on: June 18, 2017, 09:11:45 AM »
Put the file in /lib/firmware/ath9k_htc/htc_9271.fw

Offline VMat

  • Newbie
  • *
  • Posts: 14
Re: piCore 8.0 and TL-WN722N wifi dongle
« Reply #9 on: June 18, 2017, 02:32:09 PM »
Hey Paul,

I did try that before. I tried it again now:

Code: [Select]
tc@piCorePlayer:~$ ls -l /lib/firmware/htc*
-rw-r--r--    1 root     root         51272 Jun 15 23:08 /lib/firmware/htc_9271.fw
tc@piCorePlayer:~$ cd /tmp
tc@piCorePlayer:/tmp$ mkdir -p dst/usr/local/lib/firmware/ath9k_htc
tc@piCorePlayer:/tmp$ cp /lib/firmware/htc* dst/usr/local/lib/firmware/ath9k_htc/
tc@piCorePlayer:/tmp$ mksquashfs dst myfirmware.tcz
Parallel mksquashfs: Using 4 processors
Creating 4.0 filesystem on myfirmware.tcz, block size 131072.
[===================================================================|] 1/1 100%

Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
        compressed data, compressed metadata, compressed fragments, no xattrs
        duplicates are removed
Filesystem size 28.41 Kbytes (0.03 Mbytes)
        56.11% of uncompressed filesystem size (50.64 Kbytes)
Inode table size 98 bytes (0.10 Kbytes)
        43.36% of uncompressed inode table size (226 bytes)
Directory table size 106 bytes (0.10 Kbytes)
        65.84% of uncompressed directory table size (161 bytes)
Number of duplicate files found 0
Number of inodes 7
Number of files 1
Number of fragments 1
Number of symbolic links  0
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 6
Number of ids (unique uids + gids) 2
Number of uids 1
        tc (1001)
Number of gids 1
        staff (50)
tc@piCorePlayer:/tmp$ ls -l my*
-rw-r--r--    1 tc       staff        32768 Jun 18 10:06 myfirmware.tcz
tc@piCorePlayer:/tmp$ cp my* /mnt/mmcblk0p2/tce/optional/
cp: overwrite '/mnt/mmcblk0p2/tce/optional/myfirmware.tcz'? y
tc@piCorePlayer:/tmp$ ls -l /mnt/mmcblk0p2/tce/optional/myfirmware.tcz
-rw-r--r--    1 tc       staff        32768 Jun 18 10:07 /mnt/mmcblk0p2/tce/optional/myfirmware.tcz
tc@piCorePlayer:/tmp$ sudo filetool.sh -b
Backing up files to /mnt/mmcblk0p2/tce/mydata.tgz|
Done.
tc@piCorePlayer:/tmp$

After rebooting:

Code: [Select]
tc@piCorePlayer:~$ dmesg | grep -i error
[   17.917250] usb 1-1.2.2: Direct firmware load for ath9k_htc/htc_9271-1.4.0.fw failed with error -2
[   17.917379] usb 1-1.2.2: Direct firmware load for htc_9271.fw failed with error -2
tc@piCorePlayer:~$ ls -l /lib/firmware/ath*
lrwxrwxrwx    1 root     root            52 Dec 31  1969 /lib/firmware/ath3k-1.fw -> /tmp/tcloop/firmware-atheros/lib/firmware/ath3k-1.fw

/lib/firmware/ath6k:
total 0
drwxr-xr-x    2 root     root           120 Dec 31  1969 AR6002/
drwxr-xr-x    5 root     root           100 Dec 31  1969 AR6003/
drwxr-xr-x    3 root     root            60 Dec 31  1969 AR6003.1/
drwxr-xr-x    4 root     root            80 Dec 31  1969 AR6004/
tc@piCorePlayer:~$ find /lib/firmware -name 'htc*' -print
tc@piCorePlayer:~$tc@piCorePlayer:~$ sudo mount | grep firmware
/mnt/mmcblk0p2/tce/optional/firmware-atheros.tcz on /tmp/tcloop/firmware-atheros type squashfs (ro,relatime)
/mnt/mmcblk0p2/tce/optional/firmware-brcmwifi.tcz on /tmp/tcloop/firmware-brcmwifi type squashfs (ro,relatime)
/mnt/mmcblk0p2/tce/optional/firmware-rpi3-wireless.tcz on /tmp/tcloop/firmware-rpi3-wireless type squashfs (ro,relatime)
/mnt/mmcblk0p2/tce/optional/firmware-ralinkwifi.tcz on /tmp/tcloop/firmware-ralinkwifi type squashfs (ro,relatime)
/mnt/mmcblk0p2/tce/optional/firmware-rtlwifi.tcz on /tmp/tcloop/firmware-rtlwifi type squashfs (ro,relatime)
/mnt/mmcblk0p2/tce/optional/myfirmware.tcz on /tmp/tcloop/myfirmware type squashfs (ro,relatime)

So myfirmware is mounted, but there's no ath9k* under /lib/firmware. If I got this right, there should be a link from /lib/firmware/ath9k_htc to /tmp/tcloop/myfirmware/usr/local/lib/firmware/ath9k_htc, correct? Should I make the link manually?

I must be missing something...   :(

VMat
« Last Edit: June 18, 2017, 02:40:24 PM by VMat »

Offline VMat

  • Newbie
  • *
  • Posts: 14
Re: piCore 8.0 and TL-WN722N wifi dongle
« Reply #10 on: June 18, 2017, 07:29:05 PM »
What I managed to do now is:

  • Flash another card with the pCP image, to start from scratch since I've been tinkering too much with the other one and that may have messed up something.
  • Expand the filesystem, enable wi-fi.
  • Re-pack that myfirmware.tcz with the htc_9271.fw from raspbian image, put it in optional directory and add it to onboot.lst. It was mounted in /tmp/tcloop/... after a reboot.


Still no luck, so I tried to force the files into the firmware directory (I have a copy of htc_9271.fw in ~tc directory):

Code: [Select]
tc@piCorePlayer:~$ cd /lib/firmware
tc@piCorePlayer:/lib/firmware$ sudo mkdir ath9k_htc
tc@piCorePlayer:/lib/firmware$ cd ath9k_htc
tc@piCorePlayer:/lib/firmware/ath9k_htc$ sudo cp ~/htc_9271.fw ./
tc@piCorePlayer:/lib/firmware/ath9k_htc$ sudo cp htc_9271.fw htc_9271-1.4.0.fw
tc@piCorePlayer:/lib/firmware/ath9k_htc$ ls -la
total 104
drwxr-xr-x    2 root     root            80 Jun 18 14:55 ./
drwxr-xr-x    7 root     root           580 Jun 18 14:54 ../
-rw-r--r--    1 root     root         51272 Jun 18 14:55 htc_9271-1.4.0.fw
-rw-r--r--    1 root     root         51272 Jun 18 14:54 htc_9271.fw
tc@piCorePlayer:/lib/firmware/ath9k_htc$ sudo filetool.sh -b
Backing up files to /mnt/mmcblk0p2/tce/mydata.tgz|
Done.
tc@piCorePlayer:~$ tail -1 /opt/.filetool.lst
lib/firmware/ath9k_htc
tc@piCorePlayer:~$ sudo reboot

After the reboot, same error in dmesg - however, if I remove the wi-fi adapter and plug it back in, I get this:

Code: [Select]
tc@piCorePlayer:~$ dmesg | grep htc
[   15.656509] usb 1-1.2.2: ath9k_htc: Firmware ath9k_htc/htc_9271-1.4.0.fw requested
[   15.656672] usb 1-1.2.2: Direct firmware load for ath9k_htc/htc_9271-1.4.0.fw failed with error -2
[   15.656697] usb 1-1.2.2: ath9k_htc: Firmware htc_9271.fw requested
[   15.656835] usb 1-1.2.2: Direct firmware load for htc_9271.fw failed with error -2
[   15.656860] usb 1-1.2.2: ath9k_htc: Failed to get firmware htc_9271.fw
[   15.658060] usb 1-1.2.2: ath9k_htc: USB layer deinitialized
[   15.658520] usbcore: registered new interface driver ath9k_htc
[  182.542154] usb 1-1.2.2: ath9k_htc: Firmware ath9k_htc/htc_9271-1.4.0.fw requested                           ############# <--- HERE
[  182.838709] usb 1-1.2.2: ath9k_htc: Transferred FW: ath9k_htc/htc_9271-1.4.0.fw, size: 51272
[  183.084200] ath9k_htc 1-1.2.2:1.0: ath9k_htc: HTC initialized with 33 credits
tc@piCorePlayer:~$ iwconfig
eth0      no wireless extensions.

lo        no wireless extensions.

wlan0     IEEE 802.11  ESSID:off/any                                   ############# <--- AND HERE
          Mode:Managed  Access Point: Not-Associated   Tx-Power=0 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off

So it seems what I'm missing is how to make the files appear in /lib/firmware before the wi-fi stack is initialized at boot time.

Any thoughts?

Thanks again,

VMat

Offline VMat

  • Newbie
  • *
  • Posts: 14
Re: piCore 8.0 and TL-WN722N wifi dongle
« Reply #11 on: June 18, 2017, 09:29:50 PM »
So it seems what I'm missing is how to make the files appear in /lib/firmware before the wi-fi stack is initialized at boot time.

Or how to make sure the OS looks for the fw under /temp/tcloop/myfirmware/, which apparently is not happening.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1238
Re: piCore 8.0 and TL-WN722N wifi dongle
« Reply #12 on: June 18, 2017, 11:03:43 PM »
I'm not sure what you are doing wrong creating your extension....I made one, and tested it with my TL-WN722N

The system wants the file to be /lib/firmware/htc_9721.fw   (Yes this file is a symlink to the loop mount of the extension, but don't worry about that)

Assuming you already have wifi setup, do the following.

Code: [Select]
tc@piTouch:~$ wget https://dl.dropbox.com/s/b99b09guu0qyd59/firmware-htc_9721.tcz
Connecting to dl.dropbox.com (162.125.17.6:443)
Connecting to dl.dropboxusercontent.com (162.125.6.6:443)
firmware-htc_9721.tc 100% |****************************************************************************************************| 32768   0:00:00 ETA
tc@piTouch:~$  wget https://dl.dropbox.com/s/fsnufqu833nkkfq/firmware-htc_9721.tcz.md5.txt
Connecting to dl.dropbox.com (162.125.17.133:443)
Connecting to dl.dropboxusercontent.com (162.125.18.7:443)
firmware-htc_9721.tc 100% |****************************************************************************************************|    56   0:00:00 ETA
tc@piTouch:~$ md5sum -c firmware-htc_9721.tcz.md5.txt
firmware-htc_9721.tcz: OK
tc@piTouch:~$ mv firmware-htc_9721.tcz* /mnt/mmcblk0p2/tce/optional/
tc@piTouch:~$ echo "firmware-htc_9721.tcz" >> /mnt/mmcblk0p2/tce/onboot.lst
tc@piTouch:~$

Also, Make sure you remove your extension from the system.

Offline VMat

  • Newbie
  • *
  • Posts: 14
Re: piCore 8.0 and TL-WN722N wifi dongle
« Reply #13 on: June 19, 2017, 01:09:01 AM »
It works now!! Thank you SO much!    :D

VMat