PAC1934 Energy Metering Using Linux Appendix

Last modified by Microchip on 2023/11/09 09:00

Issue 1 – Not Being Able Connect scp to the SOM1-EK Successfully

This issue could be caused by network settings preventing the virtual machine from communicating with the SOM1-EK. Try doing the following to double-check.

  • From the virtual machine, try to ping the IP address of the SOM1-EK (192.168.1.5):

$ ping 192.168.1.5

  • From SOM1-EK, ping the IP of Ubuntu, 192.168.1.10:

$ ping 192.168.1.10

  • Double-check the Network Adapter settings in VirtualBox. Refer to Step 2.1.1 and 2.1.5 for additional details.

Back to Top

Issue 2 – Host Key Verification Failed When Trying to Use scp

You may encounter the error shown in Figure 1 when trying to use scp.

Error Example

Figure 1

To get around this, try executing the following command before using scp again in Step 5:

$ sudo rm -rf /home/<user>/.ssh/known_hosts

Back to Top

Issue 3 – Bad File Descriptor When Trying to Run the C Demo Application

When you try to run the C application demo, the following error appears:
read /sys/bus/iio/devices/iio:device1/in_voltage0_mean_raw: Bad file descriptor

This error is likely due to the PAC193x driver not initializing to the iio:device1 node.

  • On the SOM1-EK, run the following command:

# ls /sys/bus/iio/devices/

  • Find the correct iio:deviceN directory by locating the name file inside the directories of /sys/bus/iio/devices/.
  • Use the following command to check each iio:deviceN directory. The file should contain microchip,pac1934. Replace N with the number corresponding to the available directory.

# cat iio:deviceN/name

# cat iio:deviceN/name

Figure 2

  • Modify the C source code, ~/project/pac1934-linux/src/c/pac193x/pac193x_sysfs.c, at line 41 with the actual device node path. Refer to the following example. You may use your preferred text editor.
40: /* PAC193x IIO Device Node */
41: #define DEV_PAC193X /sys/bus/iio/devices/iio:device1
  • Save and start from Step 5.1 – Build C Sample Application.

Back to Top

Issue 4 – ERROR ioctl() X Mode When Trying to Run the C Demo Application

It is likely that spidev did not initialize to the spidev1.0 node as defined in the C source code.

  • In the SOM1-EK, run the following command and take note of the returned results.

# ls /dev | grep spidev

  • Modify the C source code, ~/project/pac1934-linux/src/c/spi/spi.c, at line 42 with the actual device node path. Refer to the following example. You may use your preferred text editor.
42: #define DEV_SPI /dev/spidev1.1    /* SPI Device Node */
43: #define SPI_MSG_SIZE 1            /* Message Size for SPI */
  • Save and start from Step 5.1 – Build C Sample Application

Back to Top

Issue 5 – dmesg Does Not Show pac193x

Nothing happens when running the following command:

# dmesg | grep pac193x

  • Use the following command to check I2C devices:

# i2cdetect 1

  • You should see UU or 10 on I2C address 0x10 if the PAC1934 Click board™ can be probed by I2C. Refer to Figure 3 for an example.
UU or 10 on I2C address 0x10

Figure 3

  • If the PAC1934 is not found, try re-seating the PAC1934 Click board from the mikroBUS™ Interface. Make sure to double-check that Jumper J22 is also connected properly, as this connects 3.3V to the mikroBUS™ 1 interface.
  • Try running the command again after doing the steps above.

Back to Top

Issue 6 – Device or Resource is Busy, or the C Demo Showed Gibberish Display in OLED Click.

When you try to switch between running the C demo and Python demo, in C, the OLED Click shows gibberish on the display and in Python, a Device or Resource is Busy error appears.

  • Ensure that the C demo or the Python demo application was killed and not running in the background. Use Ctrl + C to kill or end the demo.
  • If Ctrl + Z (suspend) was used, use the command fg to see the suspended C demo or Python demo code and bring it to foreground. Then, use Ctrl + C to gracefully end the demo.

Back to Top

Buildroot Errors

Generally, when the Buildroot make command returns an error, a prior error can help us understand the underlying cause of the issue.

Issue 1 – “Error 2” Returned With Seemingly Missing rootfs.ext4

“Error 2” Returned With Seemingly Missing rootfs.ext4

Figure 4

  • Make sure that the custom script mentioned in Step 3.3.4 is entered in the custom script to run AFTER creating the filesystem images field, not on custom script to run BEFORE creating filesystem images.
  • To double-check, navigate to my_external_tree before running make menuconfig and navigating to System Configuration. Refer to Step 3.3.4 for additional details.

Back to Top

Issue 2 – Unable to Resolve Host Address

Unable to Resolve Host Address

Figure 5

  • Make sure that the virtual machine is connected to the Internet by checking the network status on the upper right-hand corner of Ubuntu.
  • Make sure that your Internet connection is working properly. If yes, then go to the virtual machine and turn off then turn on the network interface used to connect to the Internet.

Back to Top

Back to Lab Start