Part Number: PROCESSOR-SDK-AM335X
Hi All,
I am working on AM335x controller, and interfacing with ATECC508A Cryptographic, ATECC508A is pre loaded with algorithm,
communication supported between the two IC is i2c,
My I2C chip connected on bus-0.
From ioctl i am doing read/write and my ioctl function fail and gives "which is remote i/0 error".
i am attaching the snippest og dts,
&i2c0 {
pinctrl-names = "default";
pinctrl-0 = <&i2c0_pins>;
status = "okay";
clock-frequency = <400000>;
crypto: crypto@60{
reg = <0x60>;
};
};
and on user space i am using
/******************************************************************************************************************************/
int i2c_write(int handle, unsigned char* buf, unsigned int length)
{
int len=0;
delay_ms(10);
len = write(handle, buf, length);
//len = ioctl(handle,I2C_RDWR,(unsigned long)buf);
printf("length =%d\n",len);
if (len != length)
{
printf("i2c_write error: %s\n", strerror(errno));
return(-1);
}
return(length);
}
/******************************************************************************************************************************/
int i2c_read(int handle, unsigned char* buf_r, unsigned int length)
{
int i =0;
delay_ms(5);
/*if (read(handle, buf, length) != length)
{
printf( "2. i2c_read error: %s\n", strerror(errno));
return(-1);
}
printf("length\n = %d\n",length);
for(i =0;i<length;i++)
printf("i2c_read error: %d\n",buf[i]);
return(length);
}
/******************************************************************************************************************************/
int i2c_open( unsigned char addr)
{
int file,ret,reg,value;
file = open("/dev/i2c-0",O_RDWR);
if(file < 0)
{
printf( "i2c_open open error: %s\n", strerror(errno));
return(file);
}
if(get_i2c_register(file, addr, reg, &value)) {
printf("Unable to get register!\n");
}
else {
printf("Register %d: %d (%x)\n", reg, (int)value, (int)value);
}
ret = ioctl(file,I2C_SLAVE,addr);
if(ret< 0)
{
printf( "i2c_open ioctl error: %s\n", strerror(errno));
return ret;
}
return(file);
i request the members to please help me on this, and please let me know get the understanding.
please do the needful.
Thanks in advance
Madhusudan Sangam