pi@raspberrypi:~/rpi_xc112 $ ./out/example_detector_distance_rpi_xc112_r2b_xr112_r2b_a111_r2c 
acc_board_init: Board data from EEPROM: HW: XC112, HW rev: R2B, Production test version: v1.103, Test log id: 768055333, Date: 2018-08-07, Test status: PASS.
00:02:06.167 [  890] (E) (driver_gpio_linux_sysfs) Could not write to gpio export: Device or resource busy
00:02:06.241 [  890] (E) (driver_gpio_linux_sysfs) Could not write to gpio export: Device or resource busy


There are two problems:

  1. Our "acc_board_*" files tries to open the GPIO 8/SPI0 CS0 as a GPIO and configure it as an output. In later linux kernel versions this fails as the kernel spi driver (spi-bcm2835.c) will request ownership of them
  2. For XC112 we also need to use the GPIO 7/SPI0 CS1 as a GPIO but the kernel driver will prevent this

Resolve by:

  1. Do not configure GPIO 8/SPI0 CS0 in the "acc_board_*" files. (Remove the #define PIN_SS_N/PIN_SPI_SS_N and the lines using them)
  2. Use an overlay to remap the GPIO to another GPIO:
    sudo dtoverlay spi0-cs cs0_pin=8 cs1_pin=4
    sudo dtparam spi=off
    sudo dtparam spi=on


    Or you can add "dtoverlay=spi0-cs,cs0_pin=8,cs1_pin=4" to "/boot/config.txt" and reboot.