Probably a very newbie question:
I have a Zynq 7100, zc706 board. I am playing around with the ARM Processing System with Xilinx's PetaLinux distro. What would happen if I added a device to the device tree, say and EEPROM on the I2C bus, but in reality I never physically attached the EEPROM to the bus. I then try to use the I2C Linux driver to read and write to the address in the device tree where the EEPROM is. Will the attempt to open the file just fail? If that is the case what is the point of the device tree, just to tell the kernel to look for the devices/include the driver and build a certain way?
if((file = open(I2C_ADAPTER, O_RDWR)) < 0) {
printf("Failed to open the bus\n");
return -1;
}
buf[0] = addr;
buf[1] = reg_addr;
buf[2] = 0x10;
if(write(file, buf, 3) != 3) {
printf("Failed to write to bus %s.\n\n", strerror(errno));
}
else {
printf("Successful write\n");
printf(buf);
printf("\n\n");
}
if(read(file, buf, 3) != 3) {
printf("Failed to read from the i2c bus.\n %s\n\n", strerror(errno));
}
else {
printf("Successful read\n");
printf("Buf = [%02X,%02X,%02X]\n", buf[0], buf[1], buf[2]);
printf("\n\n");
}
Let's say I feed the code an I2C bus address (addr) of 0x5d and write to the base register reg_addr is 0x00, which is where my EEPROM is in the device tree. How does the system know the device location if I were to connect an EEPROM?