Re: BBB tnc-black i2c question


Basil Gunn
 

On Wed, 24 Sep 2014 11:19:58 -0700
Basil Gunn <basil@...> wrote:


I purchased a tnc-black for my BBB and have it working with a serial
port interface. I've been unsuccessful in using the RPi programs to
get the i2c interface to work on the BBB.

I now have my BeagleBone Black & TNC-Black working with the i2c bus.
Below is a description of what I did to get it working with the AX.25
stack.


The first time you configure a tnc-black you must give a symbolic link
between a valid serial port on the black that matches the Pi software
'pitnc_setparam' program.
This program opens the UART like this:


fd = OpenCOMPort("/dev/ttyAMA0", 19200);


so you must make a link like this:
Use which every UART number you configured on the TNC-Black /dev/ttyOx
That's a capital oh not a zero for ttyO2


ln -s /dev/ttyO2 /dev/ttyAMA0


My optargs entry in /boot/uboot/uEnv.txt looks like this:
optargs=capemgr.enable_partno=BB-UART1,BB-UART2,BB-I2C1


Once you set the uboot environment, set the i2c device
number with your serial device. The line below sets i2cdevice number to
4 using the serial device.


pitnc_setparams 0 0 7 4


--> POWER CYCLE, a soft reset (shutdown -r now) didn't do it for me
and was part of my problem, use 'shutdown -h now' & pull the power plug.


After a power cycle the symlink to /dev/ttwAMA0 will disappear, you
shouldn't need it. Note that all i2c device numbers are not alike, 0,
1, 2 & 3 are invalid. Also device number 10 didn't work for me but
that may have been because I didn't do a hard reset after making i2c
config changes.


Test 1:
Make sure you see BB-I2C1 somewhere
in file: /sys/devices/bone_capemgr.9/slots


Note the linux kernel enumerates the i2c bus and may be in a different
order than the physical addresses. ie. BB-I2C1 is addressed with
/dev/i2c-2


cat /sys/devices/bone_capemgr.9/slots
0: 54:PF---
1: 55:PF---
2: 56:PF---
3: 57:PF---
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-L Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART1
8: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART2
9: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-I2C1


Test 2: Make sure you can detect the i2c device, i2cdetect -r 2
specifies the i2c bus number. This command should only take a second,
if it takes a while then the i2c device has not been configured
properly.


# i2cdetect -r 2
WARNING! This program can confuse your I2C bus, cause data loss and
worse! I will probe file /dev/i2c-2 using read byte commands.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- 04 -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --


Test 3:
Make sure you can read the i2c device parameters with the I2C bus.
pitnc_getparams <i2c_bus_number> <i2c_device_number>


# pitnc_getparams 2 4


01 TXDelay - Zero means use ADC 30
02 Persistance 32
03 Slottime (in 10 mS) 2
04 TXTail 0
05 Full Duplex - Not used 0
06 Our Channel (Hex) 00
07 I2C Address (0 = async) Hex 04
ADC Value 29
8 1 1e 20 2 0 0 0 4 1d 2c c0 sum 0




Test 4:
Bind the device to the protocol
i2c bus 2, i2c device 4, ax25 port 1, ip_address
The ax25 port name/number can be found in /etc/ax25/axports


# i2ckiss 2 4 1 44.142.1.1
i2ckiss Version 0.1.0
slave device is: /dev/pts/2
Resetting TNC...
AX.25 port 1 bound to device ax0


/Basil n7nix

Join RaspberryPi-4-HamRadio@groups.io to automatically receive all group messages.