The backup version with a microcontroler is done :
@sonel can you review it?
I try it now!
I try to add the debug flag on my config.txt
dmesg
: give me absolutely nothingdtc -I fs /proc/device-tree
: nothingsudo vcdbg log msg
: I got a little bit more information :@Nicolas with kernel 4.4 they changed the format of the overlay.
You need to change:
dtc -@ -I dts -O dtb -o sc16is750-spi-overlay.dtb sc16is750-spi-overlay.dts
sudo cp sc16is750-spi-overlay.dtb /boot/overlays/
to:
dtc -@ -I dts -O dtb -o sc16is750-spi.dtbo sc16is750-spi-overlay.dts
sudo cp sc16is750-spi.dtbo /boot/overlays/
Notice no -overlay and the new extension.
This post talks about this topic.
This is what I get in sudo vcdbg log msg
:
001413.849: Loaded overlay 'sc16is762-spi'
001413.867: dtparam: clkrate=32000000
001414.110: dtdebug: Found override clkrate
001414.148: dtdebug: override clkrate: cell target clock-frequency @ offset 0 (size 4)
001414.723: dtparam: irqpin=25
001414.971: dtdebug: Found override irqpin
001415.007: dtdebug: override irqpin: cell target interrupts @ offset 0 (size 4)
001415.382: dtdebug: override irqpin: cell
But I still canāt see the /dev/ttySC0 and SC1 devices being shown.
I got some warning during the overlay compilation :
Warning (reg_format): "reg" property in /fragment@0/__overlay__/sc16is750@0 has invalid length (4 bytes) (#address-cells == 2, #size-cells == 0)
Warning (reg_format): "reg" property in /fragment@1/__overlay__/sc16is750_clock@10 has invalid length (4 bytes) (#address-cells == 1, #size-cells == 1)
Warning (avoid_default_addr_size): Relying on default #address-cells value for /fragment@0/__overlay__/sc16is750@0
Warning (avoid_default_addr_size): Relying on default #size-cells value for /fragment@1/__overlay__/sc16is750_clock@10
I use wour new tricks so I got something better :
dmesg
: give me absolutely nothing
dtc -I fs /proc/device-tree
:
spidev@0 {
reg = <0x0>;
compatible = "spidev";
spi-max-frequency = <0x7a120>;
status = "disabled";
#address-cells = <0x1>;
phandle = <0x2a>;
#size-cells = <0x0>;
};
spidev@1 {
reg = <0x1>;
compatible = "spidev";
spi-max-frequency = <0x7a120>;
status = "disabled";
#address-cells = <0x1>;
phandle = <0x2b>;
#size-cells = <0x0>;
};
sc16is750@0 {
reg = <0x0>;
interrupts = <0x19 0x2>;
#gpio-cells = <0x2>;
compatible = "nxp,sc16is750";
clocks = <0x37>;
spi-max-frequency = <0x3d0900>;
phandle = <0x38>;
gpio-controller;
linux,phandle = <0x38>;
interrupt-parent = <0xa>;
};
sc16is750_pins {
phandle = <0x39>;
brcm,function = <0x0>;
brcm,pins = <0x19>;
linux,phandle = <0x39>;
};
sc16is750_clock@10 {
reg = <0xa>;
#clock-cells = <0x0>;
clock-output-name = "sc16is750";
compatible = "fixed-clock";
clock-frequency = <0xe10000>;
phandle = <0x37>;
linux,phandle = <0x37>;
};
sudo vcdbg log msg
:
001700.336: Loaded overlay 'sc16is750-spi'
001700.354: dtparam: clkrate=14745600
001700.596: dtdebug: Found override clkrate
001700.634: dtdebug: override clkrate: cell target clock-frequency @ offset 0 (size 4)
001701.207: dtparam: irqpin=25
001701.453: dtdebug: Found override irqpin
001701.488: dtdebug: override irqpin: cell target interrupts @ offset 0 (size 4)
001701.859: dtdebug: override irqpin: cell target brcm,pins @ offset 0 (size 4)
001702.596: dtdebug: Found fragment 0 (offset 36)
001707.013: dtdebug: merge_fragment(/soc/spi@7e204000,/fragment@0/__overlay__)
001707.038: dtdebug: +prop(#address_cells)
001708.856: dtdebug: +prop(#size-cells)
001710.232: dtdebug: +prop(status)
001713.081: dtdebug: merge_fragment(/soc/spi@7e204000/spidev@0,/fragment@0/__overlay__/spidev@0)
001713.107: dtdebug: +prop(status)
001714.536: dtdebug: merge_fragment() end
001716.129: dtdebug: merge_fragment(/soc/spi@7e204000/spidev@1,/fragment@0/__overlay__/spidev@1)
001716.153: dtdebug: +prop(status)
001717.575: dtdebug: merge_fragment() end
001720.622: dtdebug: merge_fragment(/soc/spi@7e204000/sc16is750@0,/fragment@0/__overlay__/sc16is750@0)
001720.649: dtdebug: +prop(compatible)
001721.970: dtdebug: +prop(reg)
001723.351: dtdebug: +prop(clocks)
001724.757: dtdebug: +prop(interrupt-parent)
001726.109: dtdebug: +prop(interrupts)
001727.541: dtdebug: +prop(gpio-controller)
001729.010: dtdebug: +prop(#gpio-cells)
001730.495: dtdebug: +prop(spi-max-frequency)
001732.041: dtdebug: +prop(linux,phandle)
001733.816: dtdebug: +prop(phandle)
001735.325: dtdebug: merge_fragment() end
001735.366: dtdebug: merge_fragment() end
001735.480: dtdebug: Found fragment 1 (offset 424)
001744.533: dtdebug: merge_fragment(/clocks,/fragment@1/__overlay__)
001744.560: dtdebug: +prop(#address-cells)
001745.466: dtdebug: +prop(#size_cells)
001746.758: dtdebug: +prop(status)
001752.182: dtdebug: merge_fragment(/clocks/sc16is750_clock@10,/fragment@1/__overlay__/sc16is750_clock@10)
001752.210: dtdebug: +prop(compatible)
001753.125: dtdebug: +prop(reg)
001754.101: dtdebug: +prop(#clock-cells)
001755.126: dtdebug: +prop(clock-output-name)
001756.440: dtdebug: +prop(clock-frequency)
001757.554: dtdebug: +prop(linux,phandle)
001758.880: dtdebug: +prop(phandle)
001759.945: dtdebug: merge_fragment() end
001759.983: dtdebug: merge_fragment() end
001760.074: dtdebug: Found fragment 2 (offset 688)
001763.086: dtdebug: merge_fragment(/soc/gpio@7e200000,/fragment@2/__overlay__)
001766.158: dtdebug: merge_fragment(/soc/gpio@7e200000/sc16is750_pins,/fragment@2/__overlay__/sc16is750_pins)
001766.184: dtdebug: +prop(brcm,pins)
001767.832: dtdebug: +prop(brcm,function)
001769.484: dtdebug: +prop(linux,phandle)
001771.396: dtdebug: +prop(phandle)
001773.042: dtdebug: merge_fragment() end
001773.074: dtdebug: merge_fragment() end
001776.737: dtdebug: /aliases:serial0=uart0
001779.777: dtdebug: /aliases:serial1=uart1
The strange thing is that we donāt have any message in dmesg
! Just to be sure I try to add a simple debug message on the initialisation function :
static int __init sc16is7xx_init(void)
{
printk("I AM ALIFE");
I have compiled this version with success rmmod the running one and insmod the new compiled version. So If I look on dmesg I donāt have anythingā¦
Whatās wrong with this driver why he donāt do anything!
I will open a topic on the raspberry pi forumā¦
There was a suggestion is a thread to add \n in the printk.
Also I had a look at the code of the driver and I think we need to change something in the Kconfig (/driver/tty/serial/) to enable the SPI support. I think right now the driver is compiled only with i2c support. Weāll need to change the default y
from the I2C to the SPI section (line 1202 in Kconfig).
Then we need to recompile the driver and recopy it in the modules directory. Iāll see if I have time to do that today.
Nice! the \n do the job!
Now Iām ready to debug! I think you right about the kconfig, I try to print something on I2C and SPI code part but nothing on dmesg. I think none off the 2 option are selected, thatās why catch some warning during the driver compilation.
I try to add default y for spi mode on the Kconfig file but no change at allā¦ I probably fail on my Kconfig modification, I just discover it!
Just to be sure I choose to cheet by adding the good define directly into the c source code ad then I catch a sc16is7xx: Unknown symbol __devm_regmap_init_spi (err 0)
on dmesg, this option appear on the Kconfig.
We have to deal with it, rest how to do it!
I was just about to write about the same thing. Iāve also added a #define in the c code after unsuccessful attempts to change the Config and Iām getting the same error in dmesg.
Iāve added in the c code a few more printk in the __init function to see when the UART is registered and then when the spi init is successful. Earlier the UART message was printed but nothing else. When I added the #define I started to get the unknown symbol error.
By the look of it is a dynamic binding that is not working. I donāt know exactly why not, it might be that the regmap-spi module is not loaded. If you run
modinfo sc16is7xx
you will see that the module is dependent on the regmap-spi.
Earlier when it was loading the i2c part I noticed regmap-i2c being listed in lsmod
. But for some reasons regmap-spi doesnāt seem to do the same thing.
I try to catch your difference but nothing modinfo sc16is7xx
donāt give me any depends!
I probably have something differentā¦
Do you have unsed function Warning during the driver build?
/home/poppy/spi/sc16is7xx.c:1085:12: warning: āsc16is7xx_probeā defined but not used [-Wunused-function]
static int sc16is7xx_probe(struct device *dev,
^
/home/poppy/spi/sc16is7xx.c:1214:12: warning: āsc16is7xx_removeā defined but not used [-Wunused-function]
static int sc16is7xx_remove(struct device *dev)
^
/home/poppy/spi/sc16is7xx.c:1250:29: warning: āregcfgā defined but not used [-Wunused-variable]
static struct regmap_config regcfg = {
The difference is that I have been used the code that is in the 4.4 kernel. I donāt see those warnings when compiling.
I also understand why the Kconfig changes did not work: what we need is to have a Kconfig file next to the Makefile in the same directory with the source because the Kconfig from linux/drivers/ā¦ is not taken into account (the make works in the current directory). So just a trim down version of the Kconfig only with the SC16IS part would be enough.
This is what I get when I run modinfo sc16is7xx
:
pi@raspberrypi:~/Documents/sc16is7xx_test/module $ modinfo sc16is7xx
filename: /lib/modules/4.4.7-v7+/kernel/drivers/sc16is7xx.ko
description: SC16IS7XX serial driver
author: Jon Ringle <jringle@gridpoint.com>
license: GPL
alias: spi:sc16is7xx
srcversion: 5D4F14B07B2A09D838936CD
alias: of:N*T*Cnxp,sc16is762*
alias: of:N*T*Cnxp,sc16is760*
alias: of:N*T*Cnxp,sc16is752*
alias: of:N*T*Cnxp,sc16is750*
alias: of:N*T*Cnxp,sc16is741*
alias: of:N*T*Cnxp,sc16is740*
alias: spi:sc16is762
alias: spi:sc16is760
alias: spi:sc16is752
alias: spi:sc16is750
alias: spi:sc16is741
alias: spi:sc16is740
alias: spi:sc16is74x
depends: regmap-spi
vermagic: 4.4.7-v7+ SMP mod_unload modversions ARMv7
Yes, managed something:
I manually run:
sudo modprobe -v regmap-spi
checked with lsmod that regmap-spi is listed
then
sudo modprobe -v sc16is7xx
this time no error. And when running ls /dev
pi@raspberrypi:~/Documents/sc16is7xx_test/module $ ls /dev/*SC*
/dev/ttySC0 /dev/ttySC1
So practically the whole trick is to include:
regmap-spi (apparently there is no difference between _ and - for modules!) in /etc/modules just before sc16is7xx.
Then everything loads nicely and the ports are shown in /dev.
Now to dampen your enthusiasm I moved to the next stage in testing: the actual serial interface.
So I shorted the pins 3 and 4 (TXA and RXA) and did this in python:
>>> import serial
>>> ser = serial.Serial('/dev/ttySC0', 1000000, timeout=0.5)
>>> ser.write('some text')
9
>>> ser.read(9)
''
In principle I should read back what I wrote earlier (itās a loopback) but as you can see I cannot get anything back.
One good think is that setting the speed to 1000000 seems to be fine.
But then I tried this and I am less optimistic:
>>> ser = serial.Serial('/dev/ttySC0', 347623422423, timeout=0.5)
>>> ser
Serial<id=0x76a34830, open=True>(port='/dev/ttySC0', baudrate=347623422423L, bytesize=8, parity='N', stopbits=1, timeout=0.5, xonxoff=False, rtscts=False, dsrdtr=False)
ā¦ the battle continues.
With the 4.4 kernel version of the driver I keep my warning!
This is like my compilation donāt use any Kconfig so he donāt have I2C or SPI enabled!
Here is my modinfo with native Kconfig file in my directory and in /lib/modules/4.4.7-v7+/build :
poppy@compile:~/spi $ modinfo sc16is7xx
filename: /lib/modules/4.4.7-v7+/kernel/drivers/sc16is7xx.ko
description: SC16IS7XX serial driver
author: Jon Ringle <jringle@gridpoint.com>
license: GPL
srcversion: 790237DC7065AC22A736748
alias: of:N*T*Cnxp,sc16is762*
alias: of:N*T*Cnxp,sc16is760*
alias: of:N*T*Cnxp,sc16is752*
alias: of:N*T*Cnxp,sc16is750*
alias: of:N*T*Cnxp,sc16is741*
alias: of:N*T*Cnxp,sc16is740*
depends:
vermagic: 4.4.7-v7+ SMP mod_unload modversions ARMv7
To understand why regmap-spi is missing during modprob you could generate modules.dep
poppy@compile:~/spi $ sudo depmod /lib/modules/4.4.7-v7+/kernel/drivers/sc16is7xx.ko
poppy@compile:~/spi $ cat /lib/modules/4.4.7-v7+/modules.dep
kernel/drivers/sc16is7xx.ko:
There is absolutely no dependances for meā¦
Put a #define at the beginning of the c source and the warnings should go away. I will make the Kconfig later.
Have you tried running sudo modprobe as mentioned above? Or even better just add regmap-spi in the /etc/modules just before sc16is7xx and reboot.
Also have you run sudo depmod to update the dependencies? Maybe thatās the reason you donāt see it.
I try running all your modprobe, move the Kconfig on source folder source it from the kernel one I donāt have any dependancesā¦
If I manually add the #define CONFIG_SERIAL_SC16IS7XX_SPI
I donāt have any warning but I canāt see anyone of my debug message on the SPI code part!
I add regmap-spi on /etc/modules and reboot and I see both of them on lsmod but no change on modinfoā¦
Something wrong during my compilation!
Just to be sure I try to remove all#ifdef CONFIG_SERIAL_SC16IS7XX_SPI
of the C source code and now I have ttysc0!
If I write #define CONFIG_SERIAL_SC16IS7XX_SPI
it donesnāt work!
How do you pass the CONFIG_SERIAL_SC16IS7XX_SPI option?
With this Hack I can transmit things using your python code, everything is ok on the osciloscope!
But no reception!
Here is a topic about Rx fail : https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=112048
ITāS WORKING! TX and RX!
The /IRQ pin was not routed on the sparkfun breakout boardā¦
So your problem is probably the /IRQā¦
God this was exhaustingā¦ Next step: put the 241 and check with the Dynamixel.
Iās sorry I have seen the fact that the IRQ pin is not connected on the spark fun board in another post (post 5) but I forgot youāre using one of those.
I still have to debug my one to see why the RX doesnāt work.
One other thing weāll have to think about is a simpler way of distributing the driver. We cannot expect people to recompile their kernelā¦
Mine works too now. The IRQ needs the 10k pullup. I removed that when I connected to pin 25. But I put it back and now I can read too.
Iāll try the 241 next and a servo with pypot.