Tiny Core Linux

Tiny Core Extensions => TCE Corepure64 => Topic started by: GNUser on November 28, 2021, 10:25:06 AM

Title: [Solved] is there support for Ralink RT5370 chipset in TCL?
Post by: GNUser on November 28, 2021, 10:25:06 AM
I'm considering getting this device for my wireless router, which is powered by TCL11 x86_64:
https://www.amazon.ca/gp/product/B01KWQAQ00

The device uses the Ralink RT5370 chipset, which apparently on GNU/Linux is supported by the rt2800usb driver (per https://wiki.debian.org/rt2800usb).

wireless-KERNEL.tcz provides rt2800usb.ko.gz but firmware-ralinkwifi.tcz does not seem to contain any relevant firmware. I've seen situations where a relevant kernel module exists but it can't do what it needs to do unless the appropriate firmware is also present on the system.

My question is simple: Is the device I'm considering, which uses the Ralink RT5370 chipset, supported on TCL11 x86_64?
Title: Re: is there support for Ralink RT5370 chipset in TCL?
Post by: GNUser on November 28, 2021, 10:40:25 AM
This table says that the rt2800usb kernel module requires non-free firmware:
https://en.wikipedia.org/wiki/Comparison_of_open-source_wireless_drivers

Does the firmware need to be loaded by the user, or does stock kernel itself already contain the firmware? I guess it's also possible that the device itself contains the needed firmware. Please pardon my ignorance.
Title: Re: is there support for Ralink RT5370 chipset in TCL?
Post by: curaga on November 29, 2021, 12:14:20 AM
The kernel doesn't contain firmware, and most devices don't contain it to save money. So it's in most cases external.

Unless someone with such a device chimes in, here's how you can check:
- look up the usb id
- in the 2800usb sources, there will be a mapping from the id to required firmware

You can probably get it to work, but may require downloading firmware or customizing the kernel. Atheros wireless cards are a bit more expensive, but they tend to have good support.
Title: Re: is there support for Ralink RT5370 chipset in TCL?
Post by: GNUser on November 29, 2021, 06:41:19 AM
The kernel doesn't contain firmware, and most devices don't contain it to save money. So it's in most cases external.
Thank you, curaga. Good to know. When the firmware is free (as in freedom), is it contained in the kernel module then? Because in my experience, free software-friendly peripherals almost never require downloading any firmware.

I did a bit more research. Someone mentioned here (https://www.elinux.org/RPi_USB_Wi-Fi_Adapters) that the firmware for the RT5370 chipset is rt2870.bin. So it seems that if I load wireless-KERNEL.tcz (which contains the driver, rt2800usb.ko.gz) and firmware-ralinkwifi.tcz (which contains the firmware, rt2870.bin) this thing should work. (It's frustrating how none of the numbers match--RT5370, rt2800usb, rt2870. Oh, well. It seems very few things in life are as simple as one would expect.) I'll order this thing and will add a reply once I've had a chance to test it out.

P.S. I much prefer Atheros chipsets because they do not require anything proprietary to work. However, USB wireless adapters with Atheros chipsets support only 7-8 clients when used in AP mode (I know this from years of living with this limitation). Supposedly, USB wireless adapters with the RT5370 chipset are able to handle 20+ clients in AP mode.
Title: Re: is there support for Ralink RT5370 chipset in TCL?
Post by: Rich on November 29, 2021, 07:30:44 AM
Hi GNUser
... the firmware for the RT5370 chipset is rt2870.bin. ...
I don't remember where, but I stumbled across a similar statement.

... - look up the usb id ...
According to this:
https://wireless.wiki.kernel.org/en/users/drivers/rt2800usb/devices
the usb id is  0x148f:0x5370.

Since I had them handy, I checked this Kconfig in the TC10 kernel sources:
kernel64/linux-4.19.10/drivers/net/wireless/ralink/rt2x00/Kconfig

It listed this option:
Code: [Select]
config RT2800USB_RT53XX
       bool "rt2800usb - Include support for rt53xx devices (EXPERIMENTAL)"
       ---help---
         This adds support for rt53xx wireless chipset family to the
         rt2800usb driver.
         Supported chips: RT5370

Then checking the kernel config for  TCL11 x86_64  here:
http://tinycorelinux.net/11.x/x86_64/release/src/kernel/config-5.4.3-tinycore64

it shows:
Code: [Select]
# CONFIG_RT2800USB_RT53XX is not setwhich means support for RT5370 is not enabled for that kernel.
Title: Re: is there support for Ralink RT5370 chipset in TCL?
Post by: GNUser on November 29, 2021, 08:09:28 AM
Rich, you are always so helpful. Thank you. You saved me a headache.
I will recompile the kernel while I wait for this device to arrive, with that config option enabled.
Title: Re: is there support for Ralink RT5370 chipset in TCL?
Post by: GNUser on November 29, 2021, 08:14:08 AM
I found this nearby, which seems similar to what I need:
Code: [Select]
CONFIG_RT2800USB_RT33XX=y
so I'm going to go with this:
Code: [Select]
CONFIG_RT2800USB_RT53XX=y

Title: Re: is there support for Ralink RT5370 chipset in TCL?
Post by: curaga on November 29, 2021, 09:55:56 AM
Thank you, curaga. Good to know. When the firmware is free (as in freedom), is it contained in the kernel module then? Because in my experience, free software-friendly peripherals almost never require downloading any firmware.
It rarely is included in the sources, since when it's external, it's easier to update it. The peripherals you mention most likely have it internally.
Title: Re: is there support for Ralink RT5370 chipset in TCL?
Post by: Rich on November 29, 2021, 10:05:45 AM
Hi GNUser
Yes, that is the correct setting.

In case you are not aware, kernel config files are not intended to be edited directly. Options can interact. Use the command:
Code: [Select]
make menuconfigto make changes.
Title: Re: is there support for Ralink RT5370 chipset in TCL?
Post by: GNUser on November 29, 2021, 10:22:53 AM
Thanks, Rich. I know. But things are so hard to find in the menu with all the nesting.

Do you have any tricks on how to find things in the kernel configuration menu (for example, where to find the checkbox that corresponds to CONFIG_RT2800USB_RT53XX)?
Title: Re: is there support for Ralink RT5370 chipset in TCL?
Post by: Rich on November 29, 2021, 10:35:18 AM
Hi GNUser
Simple. Once the  menuconfig  menu is up, press  /  to call up the (case insensitive) search dialog. Then enter:
Code: [Select]
rt53xxYou should see 2 items come up, the PCI and the USB versions. Enter  2  to select the second one (USB) and
it will take you to the correct menu section.
Title: Re: is there support for Ralink RT5370 chipset in TCL?
Post by: GNUser on November 29, 2021, 11:36:47 AM
NICE! What a killer trick!

Thank you both so much for all your help and for helping me become a better user/hacker :)

Thread may definitely be marked as solved!
Title: Re: [Solved] is there support for Ralink RT5370 chipset in TCL?
Post by: Rich on November 29, 2021, 12:11:38 PM
Hi GNUser
... Thread may definitely be marked as solved!
As you wish.  :)
Title: Re: [Solved] is there support for Ralink RT5370 chipset in TCL?
Post by: GNUser on December 02, 2021, 04:51:06 PM
Just a quick follow-up. Loading the two relevant extensions (wireless-KERNEL.tcz and firmware-ralink.tcz) and using custom kernel (compiled with CONFIG_RT2800USB_RT53XX=y) did not do the trick. It turns out that the  rt2800usb  kernel module supplied with  wireless-KERNEL.tcz  does not support the device. I discovered this because this command did not return anything:
Code: [Select]
$ modinfo rt2800usb | grep 5370
When the kernel module supports this chipset, this is what you should see:
Code: [Select]
$ modinfo rt2800usb | grep 5370
alias:          usb:v148Fp5370d*dc*dsc*dp*ic*isc*ip*in*

The solution was to compile the ralink kernel modules and rebuild  wireless-KERNEL.tcz  extension with the new modules.

Here are the steps I took in case it ever helps anyone:

Code: [Select]
1. Download linux-5.4.3-patched.txz and config-5.4.3-tinycore64 from here:
       http://tinycorelinux.net/11.x/x86_64/release/src/kernel/
2. In the config file, change the "# CONFIG_RT2800USB_RT53XX not set" line to this:
       CONFIG_RT2800USB_RT53XX=y
3. Extract the .txz archive so that ~/Downloads now contains linux-5.4.3 directory
4. Follow these steps:
$ tce-load -i compiletc perl5 bash ncursesw-dev bc glibc_apps elfutils-dev
$ cd ~/Downloads/linux-5.4.3
$ cp ../config-5.4.3-tinycore64 ./.config
$ make oldconfig
$ make bzImage # this compiles the kernel image, but go ahead and skip this step bc all we need are some modules
$ make M=drivers/net/wireless/ralink/rt2x00 modules # this creates the kernel modules you need
The payload will the the files ~/Downloads/linux-5.4.3/drivers/net/wireless/ralink/rt2x00/rt*.ko
Now you have to unsquashfs the  wireless-KERNEL.tcz  extension, replace all the *.ko.gz files in  its  /usr/local/lib/modules/5.4.3-tinycore64/kernel/drivers/net/wireless/ralink/rt2x00  directory with the rt*.ko files that you just compiled, then recreate the extension with mksquashfs.

Now it works. Phew!

To summarize: To use a device with the RT5370 chipset in TCL, you need 2 things:
1. Custom wireless-KERNEL.tcz extension (containing ralink kernel modules compiled with the CONFIG_RT2800USB_RT53XX=y option)
2. The firmware-ralinkwifi.tcz extension

None of this would have been possible without curaga and Rich's help. I wish I could buy you guys a beer.

EDIT: I tested things with stock kernel and with custom kernel. It worked both ways, so it turns out that custom kernel is not necessary. All we need is for the kernel module to support the device and for the firmware to be available.
Title: Re: [Solved] is there support for Ralink RT5370 chipset in TCL?
Post by: GNUser on December 02, 2021, 05:51:58 PM
curaga,

So it turns out that TCL almost supports the RT5370 chipset out of the box: It is supported by the kernel, the firmware (rt2870.bin) is provided as an extension, and the necessary kernel module (rt2800usb) is also provided as an extension. The only fly in the ointment is that the kernel module doesn't work with this chipset unless the module is compiled with the CONFIG_RT2800USB_RT53XX=y option.

In future versions of TCL, would it be possible for the rt2800usb kernel module inside wireless-KERNEL.tcz to be compiled with the CONFIG_RT2800USB_RT53XX=y option so that RT5370 is fully supported?

For folks who use a TCL box as a wireless router, this chipset is important because it supports a lot of clients when in AP mode.

refs:
https://github.com/raspberrypi/linux/issues/3010
https://raspberrypi.stackexchange.com/questions/50162/maximum-wi-fi-clients-on-pi-3-hotspot/117999#117999
Title: Re: [Solved] is there support for Ralink RT5370 chipset in TCL?
Post by: curaga on December 02, 2021, 11:47:54 PM
It'll get turned on when it's no longer marked EXPERIMENTAL.
Title: Re: [Solved] is there support for Ralink RT5370 chipset in TCL?
Post by: GNUser on December 03, 2021, 03:27:49 AM
Fair enough. Thank you.
Title: Re: [Solved] is there support for Ralink RT5370 chipset in TCL?
Post by: GNUser on December 28, 2021, 09:18:08 AM
I'm having trouble compiling the driver in TCL13 x86_64. The same procedure I followed before does not work in TCL13 for some reason:

[please see attached--the forum wouldn't let me post the commands]

Any idea how to get past this error?

P.S. Why can't Santa include RT5370 support in wireless-KERNEL.tcz? I can vouch that CONFIG_RT2800USB_RT53XX=y does not break anything and results in fully functional RT5370 in both client and AP mode. Just saying.
Title: Re: [Solved] is there support for Ralink RT5370 chipset in TCL?
Post by: Juanito on December 28, 2021, 09:33:13 AM
I'd guess you need to:

"make oldconfig" using the tinycore config
enable the functionality you need using "make menuconfig"
Title: Re: [Solved] is there support for Ralink RT5370 chipset in TCL?
Post by: GNUser on December 28, 2021, 09:39:44 AM
I had already done that. Sorry for not showing all the steps. I tried to include all the steps this time (see attached).
Title: Re: [Solved] is there support for Ralink RT5370 chipset in TCL?
Post by: GNUser on December 28, 2021, 09:54:55 AM
I got it working. Upstream (kernel developers) seems to have mixed things up just for fun. Now we need a new step before the final step:

Code: [Select]
$ make modules_prepare # the new step
$ make M=drivers/net/wireless/ralink/rt2x00 modules