How to configure unknown usb device as ethernet on Linux host? - linux

When my USB device was connected, I got the following:
$ dmesg | tail
[ 79.612133] usb 2-2: new full-speed USB device number 3 using ohci-pci
[ 79.937340] usb 2-2: New USB device found, idVendor=238b, idProduct=0a21
[ 79.937343] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 79.937344] usb 2-2: Product: DMR Radio
[ 79.937346] usb 2-2: Manufacturer: Hytera Communications
[ 80.282770] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[ 80.286007] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[ 80.399206] usbcore: registered new interface driver cdc_ether
[ 80.404402] usbcore: registered new interface driver rndis_host
[ 80.421516] usbcore: registered new interface driver rndis_wlan
There is no message like "cdc_subset 1-4.4.2:1.1: usb0: register 'cdc_subset' at usb-0000:00:02.1-4.4.2, Linux Device".
So there is no ethernet named as usb0.
$ uname -a
Linux VB1804 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
It is shown as unknown device.
$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 238b:0a21
Bus 002 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
$ lsmod | grep usbnet
usbnet 45056 3 rndis_host,cdc_ether,rndis_wlan
mii 16384 1 usbnet
I got the same on physical Linux.
And,
$ usb-devices
--------- other usb devices ----
T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 3 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=ff(vend.) Sub=fe Prot=fe MxPS= 8 #Cfgs= 1
P: Vendor=238b ProdID=0a21 Rev=00.00
S: Manufacturer=Hytera Communications
S: Product=DMR Radio
C: #Ifs= 3 Cfg#= 1 Atr=c0 MxPwr=4mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=02 Prot=ff Driver=(none)
I: If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=(none)
I: If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)

I add the idVendor and idProduct to the white list of structure array prodocts[] in file rndis_host.c.
static const struct usb_device_id products [] = {
{ /* DMR Radio*/
USB_DEVICE_AND_INTERFACE_INFO(0x238b, 0x0a21,
USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
.driver_info = (unsigned long) &rndis_info,
}, {
And, It works.

Related

Diolan DLN-2 SPI controller on x86_64 platform

I am attempting to utilize the DLN-2 in an x86_64 Linux environment (kernel version 4.18) to provide SPI and I2C bus controllers to the userspace, in a similar manner you would using an ARM platform with DTS/DTB file modifications. I am having trouble identifying the proper method to attach a SPI slave device or mount the device to userspace with the spidev driver.
The kernel modules are loading successfully and the SPI bus is mounted as a spi_master. I am certain the chip itself is working because the I2C (/dev/i2c-#) and GPIO (/dev/gpiochip#) interfaces can be successfully manipulated. For reference, here is a list of all references in the Linux system tree for "dln":
# find /sys -name *dln*
/sys/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0/dln2-i2c.1.auto
/sys/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0/dln2-spi.2.auto
/sys/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0/dln2-gpio.0.auto
/sys/fs/selinux/booleans/minidlna_read_generic_user_content
/sys/bus/platform/devices/dln2-i2c.1.auto
/sys/bus/platform/devices/dln2-spi.2.auto
/sys/bus/platform/devices/dln2-gpio.0.auto
/sys/bus/platform/drivers/dln2-gpio
/sys/bus/platform/drivers/dln2-gpio/dln2-gpio.0.auto
/sys/bus/platform/drivers/dln2-adc
/sys/bus/platform/drivers/dln2-spi
/sys/bus/platform/drivers/dln2-spi/dln2-spi.2.auto
/sys/bus/platform/drivers/dln2-i2c
/sys/bus/platform/drivers/dln2-i2c/dln2-i2c.1.auto
/sys/bus/usb/drivers/dln2
/sys/module/i2c_dln2
/sys/module/i2c_dln2/drivers/platform:dln2-i2c
/sys/module/industrialio_triggered_buffer/holders/dln2_adc
/sys/module/spi_dln2
/sys/module/spi_dln2/drivers/platform:dln2-spi
/sys/module/industrialio/holders/dln2_adc
/sys/module/dln2_adc
/sys/module/dln2_adc/drivers/platform:dln2-adc
/sys/module/gpio_dln2
/sys/module/gpio_dln2/drivers/platform:dln2-gpio
/sys/module/dln2
/sys/module/dln2/holders/i2c_dln2
/sys/module/dln2/holders/spi_dln2
/sys/module/dln2/holders/dln2_adc
/sys/module/dln2/holders/gpio_dln2
/sys/module/dln2/drivers/usb:dln2
Here is the matching portion of the boot log:
[ 1.578110] usb 1-2: new full-speed USB device number 2 using xhci_hcd
[ 1.705306] usb 1-2: New USB device found, idVendor=a257, idProduct=2013, bcdDevice= 1.00
[ 1.705310] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1.705312] usb 1-2: Product: Diolan DLN2
[ 1.705314] usb 1-2: Manufacturer: Diolan
[ 10.485997] dln2 1-2:1.0: Diolan DLN2 serial 33632920
[ 10.486182] usbcore: registered new interface driver dln2
And the relevant portion of the usb device tree:
Bus 001 Device 002: ID a257:2013
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 255 Vendor Specific Class
bDeviceSubClass 255 Vendor Specific Subclass
bDeviceProtocol 255 Vendor Specific Protocol
bMaxPacketSize0 64
idVendor 0xa257
idProduct 0x2013
bcdDevice 1.00
iManufacturer 1 Diolan
iProduct 2 Diolan DLN2
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0020
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status: 0x0000
(Bus Powered)
At this point, I am assuming that an ACPI patch is the correct method. however, the device does not appear in the ACPI device tree, or I am not searching with the correct string. I am assuming it will be similar to the following, which I pulled from a kernel patch (https://lore.kernel.org/patchwork/patch/527210/) that appears to have since been removed from the current kernel.
DefinitionBlock ("dln2.aml", "SSDT", 1, "INTEL", "CpuDptf", 3)
{
Device (DLN0)
{
Name (_ADR, Zero)
Name (_HID, "DLN2000")
Device (TP40) {
Name (_HID, "SPT0001")
Name (_DDN, "SPI4-CS0")
Name (_CRS, ResourceTemplate () {
SpiSerialBus (
1, // Chip select
PolarityLow, // Chip select is active low
FourWireMode, // Full duplex
8, // Bits per word is 8 (byte)
ControllerInitiated, // Don't care
1000000, // 1 MHz
ClockPolarityLow, // SPI mode 0
ClockPhaseFirst, // SPI mode 0
"\\DLN0.SPI0", // SPI host controller
0 // Must be 0
)
})
}
}
}
I have also tried udev rules, but my knowledge of udev is slim so they are likely incorrect. None of these appeared to have done the trick:
DEVPATH=="/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0/dln2-spi.2.auto/spi_master/spi0", DRIVER="spidev"
DEVPATH=="/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0/dln2-spi.2.auto/spi_master/spi0", KERNEL="spi-SPT0001:02", SUBSYSTEM="spi", DRIVER="spidev", ATTRS{driver_override}==""
DEVPATH=="/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0/dln2-spi.2.auto/spi_master/spi0/spi-SPT0001:02", KERNEL="spidev2.0", SUBSYSTEM="spidev", DRIVER=""
Okay, now I'm able to answer to the question.
First of all, assume that DSDT on the host machine, i.e. USB host controller excerpt, looks like this (some names maybe different, some methods may or may not be provided, just interesting us part):
Device (XHC)
{
Name (_ADR, 0x00110000)
...
Device (RHUB)
{
Name (_ADR, Zero)
// GPLD: Generate Port Location Data (PLD)
Method (GPLD, 1, Serialized) {
Name (PCKG, Package () {
Buffer (0x10) {}
})
// REV: Revision 0x02 for ACPI 5.0
CreateField (DerefOf (Index (PCKG, Zero)), Zero, 0x07, REV)
Store (0x02, REV)
// VISI: Port visibility to user per port
CreateField (DerefOf (Index (PCKG, Zero)), 0x40, One, VISI)
Store (Arg0, VISI)
Return (PCKG)
}
Device (HS01) { Name (_ADR, 1) }
Device (HS02) { Name (_ADR, 2) }
Device (SS01) { Name (_ADR, 3) }
Device (SS02) { Name (_ADR, 4) }
...
}
}
Important thing above is that port devices (HS01, SS01, etc) does not have _UPC() or _PLD() methods. If they are, you will need to override complete DSDT or upgrade it and ACPI SSDT overlays won't work.
Assume that Diolan device is connected to HS02 USB port. In this case we have to provide the following ACPI excerpt, either in DSDT or as SSDT overlay (Note, method GPLD(), if not present, should be copied from above excerpt):
External (\_SB.PCI0.XHC.RHUB.HS02, DeviceObj)
External (\_SB.PCI0.XHC.RHUB.GPLD, MethodObj)
/*
* We set the port to hard wired state to get the connected device
* enumerated properly. See more details here:
* https://learn.microsoft.com/en-us/windows-hardware/drivers/bringup/other-acpi-namespace-objects#acpi-namespace-hierarchy-and-_adr-for-embedded-usb-devices
*/
Scope (\_SB.PCI0.XHC.RHUB.HS02)
{
Name (_UPC, Package ()
{
0xFF,
0xFF,
Zero,
Zero,
})
Method (_PLD, 0, NotSerialized)
{
Return (GPLD (Zero))
}
Device (GPIO)
{
Name (_ADR, Zero)
Name (_STA, 0x0F)
}
Device (I2C)
{
Name (_ADR, One)
Name (_STA, 0x0F)
}
Device (SPI)
{
Name (_ADR, 0x02)
Name (_STA, 0x0F)
}
}
Note, this example now is a part of meta-acpi project.
After loading these tables we will get everything enumerated like:
$ grep -H HS02 /sys/bus/acpi/devices/device\:*/path
/sys/bus/acpi/devices/device:09/path:\_SB_.PCI0.XHC.RHUB.HS02
/sys/bus/acpi/devices/device:0e/path:\_SB_.PCI0.XHC.RHUB.HS02.GPIO
/sys/bus/acpi/devices/device:0f/path:\_SB_.PCI0.XHC.RHUB.HS02.I2C_
/sys/bus/acpi/devices/device:10/path:\_SB_.PCI0.XHC.RHUB.HS02.SPI_
$ ls -l /sys/bus/platform/devices/dln2-*/firmware_node
lrwxrwxrwx 1 root root 0 Jan 1 00:04 /sys/bus/platform/devices/dln2-gpio.2.auto/firmware_node -> ../../../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:07/device:08/device:09/device:0e
lrwxrwxrwx 1 root root 0 Jan 1 00:04 /sys/bus/platform/devices/dln2-i2c.3.auto/firmware_node -> ../../../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:07/device:08/device:09/device:0f
lrwxrwxrwx 1 root root 0 Jan 1 00:04 /sys/bus/platform/devices/dln2-spi.4.auto/firmware_node -> ../../../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:07/device:08/device:09/device:10
This gets us the device object we can attach our slave devices to. So, more detailed this part has been answered in the following SO posts:
adding i2c client devices on x86_64
Building a i2c device controller
spidev Linux driver on Intel Atom board
Note, there are two patches to make it possible in Linux.
One is a599a0fb629a ("Add ACPI support for USB interface devices") and one is pending e3fadb35bc1b ("Allow to be enumerated via ACPI"). Both will be in v5.7-rc1.

OpenCV how to select which camera to connect to?

I am writing an OpenCV 3.4 app on Ubuntu 16.04.
However, I am running into a problem where no matter what deviceId I set on my VideoCapture() function, I always get the built in webcam stream. However I need to get the stream from my usb camera. Btw my usb camera is a Logitech c920, and my computer is a ThinkPad P51 (not sure if that would matter)
Here is my code:
#include <opencv2/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/aruco.hpp>
#include <iostream>
int main(int, char**){
cv::Mat inputImage;
std::vector<int> markerIds;
std::vector<std::vector<cv::Point2f> > markerCorners, rejectedCandidates;
cv::aruco::DetectorParameters parameters;
cv::VideoCapture inputVideo(1); // I have tried 0, 1, 2...20 all the same stream
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_4X4_50);
while (inputVideo.grab()){
cv::Mat image, imageCopy;
inputVideo.retrieve(image);
image.copyTo(imageCopy);
std::vector<int> ids;
std::vector<std::vector<cv::Point2f> > corners;
cv::aruco::detectMarkers(image, dictionary, corners, ids);
if (ids.size() > 0) cv::aruco::drawDetectedMarkers(imageCopy, corners, ids);
cv::imshow("out", imageCopy);
if(cv::waitKey(30) >= 0) break;
}
}
Thanks!
EDIT:
This is the result I get with ls -lR /dev/v4l:
/dev/v4l:
total 0
drwxr-xr-x 2 root root 80 Feb 23 10:53 by-id
drwxr-xr-x 2 root root 80 Feb 23 10:53 by-path
/dev/v4l/by-id:
total 0
lrwxrwxrwx 1 root root 12 Feb 23 10:53 usb-046d_HD_Pro_Webcam_C920_25CCF0FF-video-index0 -> ../../video1
lrwxrwxrwx 1 root root 12 Feb 23 2019 usb-8SSC20F27019L1GZ83C07ZY_Integrated_Camera-video-index0 -> ../../video0
/dev/v4l/by-path:
total 0
lrwxrwxrwx 1 root root 12 Feb 23 10:53 pci-0000:00:14.0-usb-0:6:1.0-video-index0 -> ../../video1
lrwxrwxrwx 1 root root 12 Feb 23 2019 pci-0000:00:14.0-usb-0:8:1.0-video-index0 -> ../../video0
And this is what I get with lsusb:
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 138a:0097 Validity Sensors, Inc.
Bus 001 Device 004: ID 04ca:7066 Lite-On Technology Corp.
Bus 001 Device 008: ID 046d:082d Logitech, Inc. HD Pro Webcam C920
Bus 001 Device 003: ID 046d:c539 Logitech, Inc.
Bus 001 Device 002: ID 04d9:0169 Holtek Semiconductor, Inc.
Bus 001 Device 006: ID 8087:0a2b Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Not sure how to match them?

Managing interrupts from custom hardware

I am working on a driver for a custom piece of hardware (Xilinx FPGA based) and am having difficulty picking up the interrupt it is sending. The old system ran uCOS-II and just registered the interrupt ID 94. When I register that interrupt in Linux, it never triggers even though I know the hardware is sending the signal.
Is there something besides calling register_irqthat I need to do?
Is there a way for me to see all interrupt signals sent to the CPU even if nothing has registered for them?
/proc/interrupts:
CPU0 CPU1
16: 0 0 GIC-0 43 Level ttc_clockevent
17: 9383808 10190941 GIC-0 29 Edge twd
20: 68 0 GIC-0 82 Level xuartps
21: 0 0 GIC-0 45 Level f8003000.ps7-dma
22: 0 0 GIC-0 46 Level f8003000.ps7-dma
23: 0 0 GIC-0 47 Level f8003000.ps7-dma
24: 0 0 GIC-0 48 Level f8003000.ps7-dma
25: 0 0 GIC-0 49 Level f8003000.ps7-dma
26: 0 0 GIC-0 72 Level f8003000.ps7-dma
27: 0 0 GIC-0 73 Level f8003000.ps7-dma
28: 0 0 GIC-0 74 Level f8003000.ps7-dma
29: 0 0 GIC-0 75 Level f8003000.ps7-dma
33: 33759 0 GIC-0 54 Level eth0
35: 16184 0 GIC-0 56 Level mmc0
36: 0 0 GIC-0 57 Level cdns-i2c
37: 15117 0 GIC-0 58 Level e0006000.spi
38: 9 0 GIC-0 81 Level e0007000.spi
39: 204 0 GIC-0 40 Level f8007000.devcfg
40: 43 0 GIC-0 39 Level f8007100.xadc
41: 0 0 GIC-0 89 Edge 7c400000.dma
42: 0 0 GIC-0 88 Edge 7c420000.dma
94: 0 0 zynq-gpio 48 Level my_int_handle
IPI1: 0 0 Timer broadcast interrupts
IPI2: 25906 23777 Rescheduling interrupts
IPI3: 37 17 Function call interrupts
IPI4: 0 0 CPU stop interrupts
IPI5: 0 0 IRQ work interrupts
IPI6: 0 0 completion interrupts
Err: 0
Boot Log:
EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
* Will now restart
þeboot: Restarting system
U-Boot 2015.07-03600-g7bcb6ed (Dec 22 2015 - 12:24:30 +0200)
Model: Zynq PicoZed SDR2 Board
I2C: ready
DRAM: ECC disabled 1 GiB
MMC: zynq_sdhci: 0
Invalid bus 0 (err=-1)
*** Warning - spi_flash_probe() failed, using default environment
In: serial
Out: serial
Err: serial
Model: Zynq PicoZed SDR2 Board
Net: Gem.e000b000
Hit any key to stop autoboot: 0
Device: zynq_sdhci
Manufacturer ID: 3
OEM: 5344
Name: SS08G
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 7.4 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
reading uEnv.txt
679 bytes read in 10 ms (65.4 KiB/s)
Loaded environment from uEnv.txt
Importing environment from SD ...
Running uenvcmd ...
Setting clocks
Copying Linux from SD to RAM...
reading uImage
3946384 bytes read in 380 ms (9.9 MiB/s)
reading devicetree.dtb
8768 bytes read in 46 ms (185.5 KiB/s)
reading uramdisk.image.gz
** Unable to read file uramdisk.image.gz **
## Booting kernel from Legacy Image at 03000000 ...
Image Name: Linux-4.9.0
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3946320 Bytes = 3.8 MiB
Load Address: 00008000
Entry Point: 00008000
Verifying Checksum ... OK
## Flattened Device Tree blob at 02a00000
Booting using the fdt blob at 0x2a00000
Loading Kernel Image ... OK
Loading Device Tree to 1fffa000, end 1ffff23f ... OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0x0
Linux version 4.9.0 (root#analog) (gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-12ubuntu1) ) #2 SMP PREEMPT Tue Feb 27 22:37:50 UTC 2018
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
OF: fdt:Machine model: ags,FMC
bootconsole [earlycon0] enabled
cma: Reserved 128 MiB at 0x38000000
Memory policy: Data cache writealloc
percpu: Embedded 13 pages/cpu #ef7d5000 s23744 r8192 d21312 u53248
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 260608
Kernel command line: console=ttyPS0,115200 root=/dev/mmcblk0p2 rw earlyprintk rootfstype=ext4 rootwait
PID hash table entries: 4096 (order: 2, 16384 bytes)
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Memory: 900532K/1048576K available (5249K kernel code, 231K rwdata, 1696K rodata, 260K init, 154K bss, 16972K reserved, 131072K cma-reserved, 131072K highmem)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
vmalloc : 0xf0800000 - 0xff800000 ( 240 MB)
lowmem : 0xc0000000 - 0xf0000000 ( 768 MB)
pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
.text : 0xc0008000 - 0xc0528a24 (5251 kB)
.init : 0xc0701000 - 0xc0742000 ( 260 kB)
.data : 0xc0742000 - 0xc077bd80 ( 232 kB)
.bss : 0xc077bd80 - 0xc07a27b4 ( 155 kB)
Preemptible hierarchical RCU implementation.
Build-time adjustment of leaf fanout to 32.
RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=2
NR_IRQS:16 nr_irqs:16 16
efuse mapped to f0802000
slcr mapped to f0804000
L2C: platform modifies aux control register: 0x72360000 -> 0x72760000
L2C: DT/platform modifies aux control register: 0x72360000 -> 0x72760000
L2C-310 erratum 769419 enabled
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 ID prefetch enabled, offset 1 lines
L2C-310 dynamic clock gating enabled, standby mode enabled
L2C-310 cache controller enabled, 8 ways, 512 kB
L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x76760001
zynq_clock_init: clkc starts at f0804100
Zynq clock init
clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 537538477 ns
sched_clock: 16 bits at 54kHz, resolution 18432ns, wraps every 603975816ns
timer #0 at f080c000, irq=16
Console: colour dummy device 80x30
Calibrating delay loop... 1332.01 BogoMIPS (lpj=6660096)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x82c0 - 0x8318
CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
Brought up 2 CPUs
SMP: Total of 2 processors activated (2664.03 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 4 bytes.
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
media: Linux media interface: v0.10
Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti#linux.it>
PTP clock support registered
EDAC MC: Ver: 3.0.0
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource ttc_clocksource
NET: Registered protocol family 2
TCP established hash table entries: 8192 (order: 3, 32768 bytes)
TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
UDP hash table entries: 512 (order: 2, 16384 bytes)
UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
NET: Registered protocol family 1
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
futex hash table entries: 512 (order: 3, 32768 bytes)
workingset: timestamp_bits=30 max_order=18 bucket_order=0
jitterentropy: Initialization failed with host not compliant with requirements: 2
bounce: pool size: 64 pages
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
dma-pl330 f8003000.ps7-dma: Loaded driver for PL330 DMAC-241330
dma-pl330 f8003000.ps7-dma: DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
e0001000.uart: ttyPS0 at MMIO 0xe0001000 (irq = 20, base_baud = 6249999) is a xuartps
àconsole [ttyPS0] enabled
console [ttyPS0] enabled
bootconsole [earlycon0] disabled
bootconsole [earlycon0] disabled
xdevcfg f8007000.devcfg: ioremap 0xf8007000 to f0871000
[drm] Initialized
brd: module loaded
loop: module loaded
spidev spi32766.0: buggy DT: spidev listed directly in DT
------------[ cut here ]------------
WARNING: CPU: 1 PID: 1 at drivers/spi/spidev.c:757 spidev_probe+0x178/0x1b4
Modules linked in:
CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.9.0 #2
Hardware name: Xilinx Zynq Platform
[<c0015f30>] (unwind_backtrace) from [<c0012914>] (show_stack+0x10/0x14)
[<c0012914>] (show_stack) from [<c01e60b8>] (dump_stack+0x84/0xa4)
[<c01e60b8>] (dump_stack) from [<c0023e48>] (__warn+0xd4/0x100)
[<c0023e48>] (__warn) from [<c0023e94>] (warn_slowpath_null+0x20/0x28)
[<c0023e94>] (warn_slowpath_null) from [<c02f2d44>] (spidev_probe+0x178/0x1b4)
[<c02f2d44>] (spidev_probe) from [<c02f0dfc>] (spi_drv_probe+0x7c/0xa8)
[<c02f0dfc>] (spi_drv_probe) from [<c0299b94>] (driver_probe_device+0x1f0/0x2a8)
[<c0299b94>] (driver_probe_device) from [<c0298184>] (bus_for_each_drv+0x44/0x8c)
[<c0298184>] (bus_for_each_drv) from [<c029991c>] (__device_attach+0x9c/0x100)
[<c029991c>] (__device_attach) from [<c029900c>] (bus_probe_device+0x84/0x8c)
[<c029900c>] (bus_probe_device) from [<c0297578>] (device_add+0x380/0x528)
[<c0297578>] (device_add) from [<c02f0c54>] (spi_add_device+0x8c/0x130)
[<c02f0c54>] (spi_add_device) from [<c02f25bc>] (spi_register_master+0x438/0x778)
[<c02f25bc>] (spi_register_master) from [<c02f5250>] (cdns_spi_probe+0x2bc/0x384)
[<c02f5250>] (cdns_spi_probe) from [<c029b15c>] (platform_drv_probe+0x50/0xb0)
[<c029b15c>] (platform_drv_probe) from [<c0299b94>] (driver_probe_device+0x1f0/0x2a8)
[<c0299b94>] (driver_probe_device) from [<c0299cf8>] (__driver_attach+0xac/0xb0)
[<c0299cf8>] (__driver_attach) from [<c0298220>] (bus_for_each_dev+0x54/0x88)
[<c0298220>] (bus_for_each_dev) from [<c02991f0>] (bus_add_driver+0xe8/0x1f4)
[<c02991f0>] (bus_add_driver) from [<c029a4f4>] (driver_register+0x78/0xf4)
[<c029a4f4>] (driver_register) from [<c00097ac>] (do_one_initcall+0x3c/0x16c)
[<c00097ac>] (do_one_initcall) from [<c0701d80>] (kernel_init_freeable+0x11c/0x1e8)
[<c0701d80>] (kernel_init_freeable) from [<c05233a8>] (kernel_init+0x8/0xfc)
[<c05233a8>] (kernel_init) from [<c000f938>] (ret_from_fork+0x14/0x3c)
---[ end trace dd90ee247f61645e ]---
spidev spi32765.0: buggy DT: spidev listed directly in DT
------------[ cut here ]------------
WARNING: CPU: 1 PID: 1 at drivers/spi/spidev.c:757 spidev_probe+0x178/0x1b4
Modules linked in:
CPU: 1 PID: 1 Comm: swapper/0 Tainted: G W 4.9.0 #2
Hardware name: Xilinx Zynq Platform
[<c0015f30>] (unwind_backtrace) from [<c0012914>] (show_stack+0x10/0x14)
[<c0012914>] (show_stack) from [<c01e60b8>] (dump_stack+0x84/0xa4)
[<c01e60b8>] (dump_stack) from [<c0023e48>] (__warn+0xd4/0x100)
[<c0023e48>] (__warn) from [<c0023e94>] (warn_slowpath_null+0x20/0x28)
[<c0023e94>] (warn_slowpath_null) from [<c02f2d44>] (spidev_probe+0x178/0x1b4)
[<c02f2d44>] (spidev_probe) from [<c02f0dfc>] (spi_drv_probe+0x7c/0xa8)
[<c02f0dfc>] (spi_drv_probe) from [<c0299b94>] (driver_probe_device+0x1f0/0x2a8)
[<c0299b94>] (driver_probe_device) from [<c0298184>] (bus_for_each_drv+0x44/0x8c)
[<c0298184>] (bus_for_each_drv) from [<c029991c>] (__device_attach+0x9c/0x100)
[<c029991c>] (__device_attach) from [<c029900c>] (bus_probe_device+0x84/0x8c)
[<c029900c>] (bus_probe_device) from [<c0297578>] (device_add+0x380/0x528)
[<c0297578>] (device_add) from [<c02f0c54>] (spi_add_device+0x8c/0x130)
[<c02f0c54>] (spi_add_device) from [<c02f25bc>] (spi_register_master+0x438/0x778)
[<c02f25bc>] (spi_register_master) from [<c02f5250>] (cdns_spi_probe+0x2bc/0x384)
[<c02f5250>] (cdns_spi_probe) from [<c029b15c>] (platform_drv_probe+0x50/0xb0)
[<c029b15c>] (platform_drv_probe) from [<c0299b94>] (driver_probe_device+0x1f0/0x2a8)
[<c0299b94>] (driver_probe_device) from [<c0299cf8>] (__driver_attach+0xac/0xb0)
[<c0299cf8>] (__driver_attach) from [<c0298220>] (bus_for_each_dev+0x54/0x88)
[<c0298220>] (bus_for_each_dev) from [<c02991f0>] (bus_add_driver+0xe8/0x1f4)
[<c02991f0>] (bus_add_driver) from [<c029a4f4>] (driver_register+0x78/0xf4)
[<c029a4f4>] (driver_register) from [<c00097ac>] (do_one_initcall+0x3c/0x16c)
[<c00097ac>] (do_one_initcall) from [<c0701d80>] (kernel_init_freeable+0x11c/0x1e8)
[<c0701d80>] (kernel_init_freeable) from [<c05233a8>] (kernel_init+0x8/0xfc)
[<c05233a8>] (kernel_init) from [<c000f938>] (ret_from_fork+0x14/0x3c)
---[ end trace dd90ee247f61645f ]---
spidev spi32765.1: buggy DT: spidev listed directly in DT
------------[ cut here ]------------
WARNING: CPU: 1 PID: 1 at drivers/spi/spidev.c:757 spidev_probe+0x178/0x1b4
Modules linked in:
CPU: 1 PID: 1 Comm: swapper/0 Tainted: G W 4.9.0 #2
Hardware name: Xilinx Zynq Platform
[<c0015f30>] (unwind_backtrace) from [<c0012914>] (show_stack+0x10/0x14)
[<c0012914>] (show_stack) from [<c01e60b8>] (dump_stack+0x84/0xa4)
[<c01e60b8>] (dump_stack) from [<c0023e48>] (__warn+0xd4/0x100)
[<c0023e48>] (__warn) from [<c0023e94>] (warn_slowpath_null+0x20/0x28)
[<c0023e94>] (warn_slowpath_null) from [<c02f2d44>] (spidev_probe+0x178/0x1b4)
[<c02f2d44>] (spidev_probe) from [<c02f0dfc>] (spi_drv_probe+0x7c/0xa8)
[<c02f0dfc>] (spi_drv_probe) from [<c0299b94>] (driver_probe_device+0x1f0/0x2a8)
[<c0299b94>] (driver_probe_device) from [<c0298184>] (bus_for_each_drv+0x44/0x8c)
[<c0298184>] (bus_for_each_drv) from [<c029991c>] (__device_attach+0x9c/0x100)
[<c029991c>] (__device_attach) from [<c029900c>] (bus_probe_device+0x84/0x8c)
[<c029900c>] (bus_probe_device) from [<c0297578>] (device_add+0x380/0x528)
[<c0297578>] (device_add) from [<c02f0c54>] (spi_add_device+0x8c/0x130)
[<c02f0c54>] (spi_add_device) from [<c02f25bc>] (spi_register_master+0x438/0x778)
[<c02f25bc>] (spi_register_master) from [<c02f5250>] (cdns_spi_probe+0x2bc/0x384)
[<c02f5250>] (cdns_spi_probe) from [<c029b15c>] (platform_drv_probe+0x50/0xb0)
[<c029b15c>] (platform_drv_probe) from [<c0299b94>] (driver_probe_device+0x1f0/0x2a8)
[<c0299b94>] (driver_probe_device) from [<c0299cf8>] (__driver_attach+0xac/0xb0)
[<c0299cf8>] (__driver_attach) from [<c0298220>] (bus_for_each_dev+0x54/0x88)
[<c0298220>] (bus_for_each_dev) from [<c02991f0>] (bus_add_driver+0xe8/0x1f4)
[<c02991f0>] (bus_add_driver) from [<c029a4f4>] (driver_register+0x78/0xf4)
[<c029a4f4>] (driver_register) from [<c00097ac>] (do_one_initcall+0x3c/0x16c)
[<c00097ac>] (do_one_initcall) from [<c0701d80>] (kernel_init_freeable+0x11c/0x1e8)
[<c0701d80>] (kernel_init_freeable) from [<c05233a8>] (kernel_init+0x8/0xfc)
[<c05233a8>] (kernel_init) from [<c000f938>] (ret_from_fork+0x14/0x3c)
---[ end trace dd90ee247f616460 ]---
spidev spi32765.2: buggy DT: spidev listed directly in DT
------------[ cut here ]------------
WARNING: CPU: 1 PID: 1 at drivers/spi/spidev.c:757 spidev_probe+0x178/0x1b4
Modules linked in:
CPU: 1 PID: 1 Comm: swapper/0 Tainted: G W 4.9.0 #2
Hardware name: Xilinx Zynq Platform
[<c0015f30>] (unwind_backtrace) from [<c0012914>] (show_stack+0x10/0x14)
[<c0012914>] (show_stack) from [<c01e60b8>] (dump_stack+0x84/0xa4)
[<c01e60b8>] (dump_stack) from [<c0023e48>] (__warn+0xd4/0x100)
[<c0023e48>] (__warn) from [<c0023e94>] (warn_slowpath_null+0x20/0x28)
[<c0023e94>] (warn_slowpath_null) from [<c02f2d44>] (spidev_probe+0x178/0x1b4)
[<c02f2d44>] (spidev_probe) from [<c02f0dfc>] (spi_drv_probe+0x7c/0xa8)
[<c02f0dfc>] (spi_drv_probe) from [<c0299b94>] (driver_probe_device+0x1f0/0x2a8)
[<c0299b94>] (driver_probe_device) from [<c0298184>] (bus_for_each_drv+0x44/0x8c)
[<c0298184>] (bus_for_each_drv) from [<c029991c>] (__device_attach+0x9c/0x100)
[<c029991c>] (__device_attach) from [<c029900c>] (bus_probe_device+0x84/0x8c)
[<c029900c>] (bus_probe_device) from [<c0297578>] (device_add+0x380/0x528)
[<c0297578>] (device_add) from [<c02f0c54>] (spi_add_device+0x8c/0x130)
[<c02f0c54>] (spi_add_device) from [<c02f25bc>] (spi_register_master+0x438/0x778)
[<c02f25bc>] (spi_register_master) from [<c02f5250>] (cdns_spi_probe+0x2bc/0x384)
[<c02f5250>] (cdns_spi_probe) from [<c029b15c>] (platform_drv_probe+0x50/0xb0)
[<c029b15c>] (platform_drv_probe) from [<c0299b94>] (driver_probe_device+0x1f0/0x2a8)
[<c0299b94>] (driver_probe_device) from [<c0299cf8>] (__driver_attach+0xac/0xb0)
[<c0299cf8>] (__driver_attach) from [<c0298220>] (bus_for_each_dev+0x54/0x88)
[<c0298220>] (bus_for_each_dev) from [<c02991f0>] (bus_add_driver+0xe8/0x1f4)
[<c02991f0>] (bus_add_driver) from [<c029a4f4>] (driver_register+0x78/0xf4)
[<c029a4f4>] (driver_register) from [<c00097ac>] (do_one_initcall+0x3c/0x16c)
[<c00097ac>] (do_one_initcall) from [<c0701d80>] (kernel_init_freeable+0x11c/0x1e8)
[<c0701d80>] (kernel_init_freeable) from [<c05233a8>] (kernel_init+0x8/0xfc)
[<c05233a8>] (kernel_init) from [<c000f938>] (ret_from_fork+0x14/0x3c)
---[ end trace dd90ee247f616461 ]---
MACsec IEEE 802.1AE
libphy: Fixed MDIO Bus: probed
libphy: mdio_driver_register: xgmiitorgmii
tun: Universal TUN/TAP device driver, 1.6
tun: (C) 1999-2004 Max Krasnyansky <maxk#qualcomm.com>
libphy: XEMACPS mii bus: probed
[Firmware Warn]: /amba#0/eth#e000b000/phy#0: Whitelisted compatible string. Please remove
xemacps e000b000.eth: pdev->id -1, baseaddr 0xe000b000, irq 33
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
usbcore: registered new interface driver usb-storage
usbcore: registered new interface driver usbserial
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial support registered for generic
usbcore: registered new interface driver ftdi_sio
usbserial: USB Serial support registered for FTDI USB Serial Device
mousedev: PS/2 mouse device common for all mice
i2c /dev entries driver
cdns-i2c e0004000.i2c: 400 kHz mmio e0004000 irq 36
usbcore: registered new interface driver uvcvideo
USB Video Class driver (1.1.1)
gspca_main: v2.14.0 registered
Xilinx Zynq CpuIdle Driver started
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
ledtrig-cpu: registered to indicate activity on CPUs
hidraw: raw HID events driver (C) Jiri Kosina
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
cf_axi_adc 79020000.cf-ad9361-lpc: could not find spi node
OF: /fpga-axi#0/cf-ad9361-dds-core-lpc#79024000: could not find phandle
ERROR: could not get clock /fpga-axi#0/cf-ad9361-dds-core-lpc#79024000:sampl_clk(0)
cf_axi_dds: probe of 79024000.cf-ad9361-dds-core-lpc failed with error -2
NET: Registered protocol family 17
zynq_pm_remap_ocm: no compatible node found for 'xlnx,zynq-ocmc-1.0'
zynq_pm_suspend_init: Unable to map OCM.
Registering SWP/SWPB emulation handler
hctosys: unable to open rtc device (rtc0)
ALSA device list:
No soundcards found.
Waiting for root device /dev/mmcblk0p2...
mmc0: new high speed SDHC card at address aaaa
mmcblk0: mmc0:aaaa SS08G 7.40 GiB
mmcblk0: p1 p2 p3
EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext4 filesystem) on device 179:2.
devtmpfs: mounted
Freeing unused kernel memory: 260K (c0701000 - c0742000)
This architecture does not have kernel memory protection.
random: fast init done
Mount failed for selinuxfs on /sys/fs/selinux: No such file or directory
init: hwclock main process (799) terminated with status 1
Adding 511996k swap on /swapfile. Priority:-1 extents:1 across:511996k SS
* Setting up X socket directories... [ OK ]
Setting default sampling frequency to 2.1 MSPS
/etc/rcS.d/S99default-sdr: line 3: /sys/bus/iio/devices/iio:device1/in_voltage_sampling_frequency: No such file or directory
Loading default filter
/etc/rcS.d/S99default-sdr: line 7: /sys/bus/iio/devices/iio:device1/filter_fir_config: No such file or directory
* STARTDISTCC is set to false in /etc/default/distcc
* /usr/bin/distccd not starting
* Starting NTP server ntpd [ OK ]
* Starting web server apache2 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
*
* Starting IIO Daemon iiod [ OK ]
Last login: Thu Jan 1 21:40:23 UTC 1970 from 169.254.212.36 on pts/1
Welcome to Linaro 14.04 (GNU/Linux 4.9.0 armv7l)
Which driver are you using, your custom driver or Xilinx GPIO?
As I understand you hardcoded Linux IRQ number 94 in register irq?
94: 0 0 zynq-gpio 48 Level my_int_handle
I would say that you have to declare your GPIO node as interrupt controller in the device tree with appropiate interrupt property, because driver uses that information for interrupt:
gpio->irq = platform_get_irq(pdev, 0);
I'm not sure of the exact IRQ number mapping.
Device tree node for GPIO controller on Zynq looks like this:
gpio#e000a000 {
#gpio-cells = <2>;
#interrupt-cells = <2>;
compatible = "xlnx,zynq-gpio-1.0";
clocks = <&&clkc 42>;
gpio-controller;
interrupt-controller;
interrupt-parent = <&&intc>;
interrupts = <0 20 4>;
interrupt-controller;
#interrupt-cells = <2>;
reg = <0xe000a000 0x1000>;
};
If you use hardcoded Linux IRQ number instead of device tree, you can try to find it with probe_irq_on/off();

FTDI D2XX FT_DEVICE_LIST_INFO_NODE structure is all zeros

I am trying to get a Matlab MEX to run in Linux. It uses FTDI's D2XX library v1.3.6 (Documentation).
FT_CreateDeviceInfoList(&ftdi_count) gives me an ftdi_count of 1, so the FTDI chip is detected.
However, when iterating through the device list from FT_GetDeviceInfoList(device_list, &ftdi_count), my FT_DEVICE_LIST_INFO_NODE structure is all zeros, so obviously the code cannot find the device with the description it is looking for:
(gdb) p *p_device
$3 = {Flags = 1, Type = 3, ID = 0, LocId = 0, SerialNumber = '\000' <repeats 15 times>,
Description = '\000' <repeats 63 times>, ftHandle = 0x0}
My first guess was that udev wasn't set up. But the problem persists with
SUBSYSTEM=="usb", ATTR{idVendor}=="0403", ATTR{idProduct}="6014", MODE="0666"
lsusb -v has access to the values:
Bus 001 Device 012: ID 0403:6014 Future Technology Devices International, Ltd FT232H Single HS USB-UART/FIFO IC
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0403 Future Technology Devices International, Ltd
idProduct 0x6014 FT232H Single HS USB-UART/FIFO IC
bcdDevice 9.00
iManufacturer 1 FTDI
iProduct 2 [company that provided me with their] Kit v3
iSerial 3 FT266WVA
bNumConfigurations 1
[...]
What can I do to make the FTDI functions work?
The problem is that Linux automatically loads the VCP driver (ftdi_sio).
In the Question How can I get Linux device with FTDI D2XX driver API, Akira shows a udev script to from A blog unload that driver. I modified it to work with my FT232H chip, which has only one port:
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6014", RUN+="/bin/sh -c 'echo -n $kernel:1.0 > /sys/bus/usb/drivers/ftdi_sio/unbind;'"

STM32F0-Discovery: no tty

I am currently trying to send data to my STM32F0308 board via USART.
The data is supposed to be sent by a Python script using PySerial.
However, when I plug in the board, I cannot find the corresponding /dev/ttyXXXX.
The board is branched and I can flash code on it (STLink via USB), but there is no port visible.
dmesg shows that the computer is aware of the board:
[10364.101554] usb 1-3: USB disconnect, device number 10
[10368.044231] usb 1-3: new full-speed USB device number 12 using xhci_hcd
[10368.173948] usb 1-3: New USB device found, idVendor=0483, idProduct=3748
[10368.173956] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[10368.173959] usb 1-3: Product: STM32 STLink
[10368.173962] usb 1-3: Manufacturer: STMicroelectronics
[10368.173965] usb 1-3: SerialNumber: VÿnIxRT68\xffffffc2\xffffff87
Here is the output of lsusb:
Bus 001 Device 012: ID 0483:3748 STMicroelectronics ST-LINK/V2
Here's the output of ls /dev/tty*:
tty tty12 tty17 tty21 tty26 tty30 tty35 tty4 tty44 tty49 tty53 tty58 tty62 ttyprintk ttyS12 ttyS17 ttyS21 ttyS26 ttyS30 ttyS7
tty0 tty13 tty18 tty22 tty27 tty31 tty36 tty40 tty45 tty5 tty54 tty59 tty63 ttyS0 ttyS13 ttyS18 ttyS22 ttyS27 ttyS31 ttyS8
tty1 tty14 tty19 tty23 tty28 tty32 tty37 tty41 tty46 tty50 tty55 tty6 tty7 ttyS1 ttyS14 ttyS19 ttyS23 ttyS28 ttyS4 ttyS9
tty10 tty15 tty2 tty24 tty29 tty33 tty38 tty42 tty47 tty51 tty56 tty60 tty8 ttyS10 ttyS15 ttyS2 ttyS24 ttyS29 ttyS5
tty11 tty16 tty20 tty25 tty3 tty34 tty39 tty43 tty48 tty52 tty57 tty61 tty9 ttyS11 ttyS16 ttyS20 ttyS25 ttyS3 ttyS6
And here is my the function to initialize the serial port:
#function to initialize the serial port
def init_serial():
global ser #must be declared in each function
#set serial: port, baudrate, timeout (port does not hang)
ser = serial.Serial(port="/dev/ttyS3", baudrate=9600, timeout=5)
if ser.isOpen():
ser.close()
#open the serial port
ser.open()
#print: port is open or closed
if ser.isOpen():
print("Port open: " + ser.portstr)
else:
print("Port not open: We have a problem!")
#function ends here
I am using Ubuntu 15.04, but it also did not work on another computer using Debian.
According to ST, the STM32F0x0 line supports USB.
Edit:
As requested, the output of lsusb -v:
Bus 001 Device 003: ID 0483:3748 STMicroelectronics ST-LINK/V2
Couldn't open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0483 STMicroelectronics
idProduct 0x3748 ST-LINK/V2
bcdDevice 1.00
iManufacturer 1
iProduct 2
iSerial 3
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 39
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 4
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
The device gets discovered and it's a ST-Link debug interface.
The STM32F0308-Discovery does not have a USB UART interface and the ST-Link does not include UART functionality as far as I can see. What you are trying to do appears to be impossible without extra hardware. You would have to get one of those USB UART interfaces with separate connectors and wire it up to the USART pins exposed on the headers.

Resources