FTDI device on Voxel/Entware firmware

Для чайников и не только
Selcal
Сообщения: 7
Зарегистрирован: 27 дек 2020, 17:39

Сообщение Selcal » 27 дек 2020, 17:48

Hello all,
Sorry I don't speak Russian, I hope I can make my way with English and a Google Translation. Thanks for the community!

I have basic Linux knowledge, but recently ran into something that is way beyond what I can deal with.
I have changed the firmware on my Netgear R9000 router to Voxel firmware, with Entware on an ext4 partition. (voxel-firmware.com, Cortex-a15-3x)

This works really well. I love the Entware additions.
Now I like to add a device: USB-serial adapter, to connect to my P1 port on electricity meter. It works out-of-the-box on my rPi, but is not recognized by the router. I have ftdilib1 Entware package installed but I think this contains not the driver?

I can see it with lsusb:

Код: Выделить всё

Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC


But there is nothing else... I've installed ser2net package, which I'd like to use. But there is no /dev/ttyUSBx or similar, and ser2net cannot connect to the device. I think the driver / ko is missing?
Is there an easy way of adding this? This lower level device and kernal stuff is quite new to me. If you think it will be too hard to help with or make work, just let me know no problem.

But if there can be a solution I'd be great for me :).

Thanks all!

===

Всем привет,
Извините, я не говорю по-русски, я надеюсь, что смогу справиться с английским и переводом Google. Спасибо сообществу!

У меня есть базовые знания Linux, но недавно я столкнулся с чем-то, что выходит за рамки того, с чем я могу справиться.
Я изменил прошивку на моем маршрутизаторе Netgear R9000 на прошивку Voxel с Entware на разделе ext4. (voxel-firmware.com)

Это действительно хорошо работает. Мне нравятся дополнения Entware.
Теперь мне нравится добавлять устройство USB-serial для подключения к моему порту P1 на счетчике электроэнергии. Он работает на моем rPi "из коробки", но не распознается маршрутизатором. У меня установлен пакет ftdilib1, но я думаю, что он не содержит драйвера?

Я могу увидеть это с помощью lsusb:

[code] Шина 001 Устройство 004: ID 0403: 6001 Future Technology Devices International, Ltd FT232 Последовательный порт (UART) IC [/ code]

Но больше ничего ... Я установил пакет ser2net, которым хочу воспользоваться. Но нет / dev / ttyUSBx или аналогичного, и ser2net не может подключиться к устройству. Думаю драйвер / ко отсутствует?
Есть простой способ добавить это? Это устройство нижнего уровня и ядро ​​для меня совершенно внове. Если вы думаете, что вам будет слишком сложно помочь или поработать, просто дайте мне знать без проблем.

Но если есть решение, я бы отлично подошел :).

Спасибо всем!

Аватара пользователя
Zyxmon
Администратор
Сообщения: 1912
Зарегистрирован: 09 авг 2015, 15:33

Сообщение Zyxmon » 27 дек 2020, 18:24

Entware does not have ko modules in repo. To compile ko kernel module one needs kernel sources, device kernel configuration and a toolchain.
Just take Voxel firmware, Voxel toolchain and try to compile kernel module. Entware has only userspace binaries, because it can be used on different devices with the same architecture.

Voxel
Сообщения: 161
Зарегистрирован: 29 фев 2016, 13:34

Сообщение Voxel » 27 дек 2020, 20:30

Zyxmon писал(а):Источник цитаты Entware does not have ko modules in repo. To compile ko kernel module one needs kernel sources, device kernel configuration and a toolchain.
Just take Voxel firmware, Voxel toolchain and try to compile kernel module. Entware has only userspace binaries, because it can be used on different devices with the same architecture.


Zyxmon: Thank you for your reply. But I am afraid it would be a bit problematic for users to compile my version.

What kernel modules are needed (*.ko)? What to enable in kernel menu config? I have of course pre-built project for R9000 (as well as for other routers I support). So not so difficult for me to create related kernel modules to help (I hope so).

I am sorry but I know nothing re: FTDI and what is needed else.

Thank you,
Voxel.

Selcal
Сообщения: 7
Зарегистрирован: 27 дек 2020, 17:39

Сообщение Selcal » 27 дек 2020, 23:59

Thank you both for thinking along with me, I realize this is a specific use case and I am asking a lot for minimal community gain. I hope to learn also, of course, but I picked something difficult to start :).

From what I have found, the modules needed are usbserial.ko and ftdi_sio.ko, present normally in 2.6.32 at least.
Some background and discussions are here https://stackoverflow.com/questions/212 ... -linux-arm

The ftdi site (https://www.ftdichip.com/Support/Docume ... _Linux.pdf) only says for Linux the modules are already in the kernel (/lib/modules/2.6.11-1.14_FC3/kernel/drivers/usb/serial/)... So for me personally not enough to work on.

Selcal
Сообщения: 7
Зарегистрирован: 27 дек 2020, 17:39

Сообщение Selcal » 28 дек 2020, 00:21

In some places I see usbcore.ko mentioned as well...

Voxel
Сообщения: 161
Зарегистрирован: 29 фев 2016, 13:34

Сообщение Voxel » 28 дек 2020, 14:00

OK, I see.

Try to load these kernel modules to your R9000 (from archive):

http://voxel-firmware.com/Downloads/ftdi-drv.zip

at least the following in working on my R9000:

Код: Выделить всё

insmod usbserial.ko
insmod ftdi_sio.ko


and:

Код: Выделить всё

root@R9000:/tmp/mnt/sda1/tmp$ lsmod | grep usbserial
usbserial              20394  1 ftdi_sio
root@pR9000:/tmp/mnt/sda1/tmp$ lsmod | grep ftdi_sio
ftdi_sio               28064  0
usbserial              20394  1 ftdi_sio


usbcore is already included into firmware.

Good luck,
Voxel.

Selcal
Сообщения: 7
Зарегистрирован: 27 дек 2020, 17:39

Сообщение Selcal » 28 дек 2020, 16:31

Thanks Voxel! Appreciate your help.
I've so far loaded the modules succesfully, not yet managed to have it connect to the device:

Код: Выделить всё

insmod /mnt/optware/usbserial.ko
insmod /mnt/optware/ftdi_sio.ko vendor=0x0403 product=0x6001
cat /proc/tty/driver/usbserial

usbserinfo:1.0 driver:2.0


Would expect now to see the device in usbserial. I'll go retrace my steps, so far still I consider good progress. But the kids are getting impatient so I have to go play outside first :). I'll continue soon!

Selcal
Сообщения: 7
Зарегистрирован: 27 дек 2020, 17:39

Сообщение Selcal » 29 дек 2020, 13:26

[Edit] Spoke too soon! After posting, I thought about the output, and realised the wrong driver had been loaded.
The key here was to unload the incorrect module. It should be cleaner to not have the module attach in the first place, is there an easy way to do this?

Anyway, with the compiled modules, I had to load them using the insmod above, and then inform the ftdi_sio module of the hardware/vendor id:

Код: Выделить всё

echo 0403 6001 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id


But the lsusb -t output became:

Код: Выделить всё

$ /opt/bin/lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M
    |__ Port 2: Dev 6, If 0, Class=Vendor Specific Class, Driver=KC NetUSB General Driver, 12M


The KC NetUSB is not the module we want for this device.
So I dug around for them:

Код: Выделить всё

$ lsmod | grep NetUSB
NetUSB                162570  0
GPL_NetUSB              3527  1 NetUSB
$ rmmod NetUSB
$ rmmod GPL_NetUSB


Now, the result is as required:

Код: Выделить всё

$ /opt/bin/lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M
    |__ Port 2: Dev 6, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 12M


And without further issues:

Код: Выделить всё

$ ls -al /dev/ttyUSB*
crw-r--r--    1 root     root     188,   0 Dec 29 12:23 /dev/ttyUSB0


The ser2net package can now be configured to read /dev/ttyUSB0 and all is well!

Question on my mind remains, is the (GPL_)NetUSB required for something else? Is seems somewhat extreme to just unload it. Perhaps just stop it from loading for this device?

Selcal
Сообщения: 7
Зарегистрирован: 27 дек 2020, 17:39

Сообщение Selcal » 29 дек 2020, 15:36

Updated with success story in post above! Just two minor questions remaining but functional already :so_happy:

Thanks very much!!

Voxel
Сообщения: 161
Зарегистрирован: 29 фев 2016, 13:34

Сообщение Voxel » 29 дек 2020, 16:09

Selcal писал(а):Источник цитаты Question on my mind remains, is the (GPL_)NetUSB required for something else? Is seems somewhat extreme to just unload it. Perhaps just stop it from loading for this device?

Both: (GPL_NetUSB.ko and NetUSB.ko) are part of pre-built modules from NG/DNI GPL. They are used for their outdated (2012) and strange "ReadySHARE Printer" system with specific old program/driver to be installed on PC. I was never able to get it working as I'd expect. And these modules often spoil other USB devices. For example I have to "rmmod" them when using USB LTE modem (R7500/R7800/ORBI RBR/RBS). So if you are not using this "ReadySHARE Printer"...

OK, good it is working now for you.
Voxel.


Вернуться в «Linux - все вопросы тут»

Кто сейчас на конференции

Всего 4 посетителя :: 1 зарегистрированный, 0 скрытых и 3 гостя (основано на активности пользователей за последние 5 минут)
Больше всего посетителей (162) здесь было 16 ноя 2019, 18:33

Сейчас этот форум просматривают: CommonCrawl [Bot] и 3 гостя