failure to connect with raspberry pi 4 with 'raspi'

when using raspi for a new connection i get an error that gpiod.h is not found.
i have followed all the suggections of copilot at no avail.

Answers (4)

Have you installed the required support package?

1 Comment

I have installed the support package for matlab not simulink as i dont use simulink

Sign in to comment.

is this correct that matlab-rpi is only compatible with
raspian stretch and Jessier?

2 Comments

Try
% Run this on your Raspberry Pi, NOT MATLAB
sudo apt-get update
sudo apt-get install gpiod libgpiod-dev
This will install command line tools and install header files and libraries. Then try connecting to the Raspberry Pi again.
  • 32-bit Buster OS
  • 32-bit and 64-bit Bullseye OS
  • 32-bit and 64-bit Bookworm OS
The support for Stretch was roughly R2021b. Jessie support started from R2016a (but ended before R2021b.)

Sign in to comment.

when i run
% Run this on your Raspberry Pi, NOT MATLAB
sudo apt-get update
sudo apt-get install gpiod libgpiod-dev
it looks like it is installed with the last version
when i call mypi=raspi(....)
I get
>> mypi=raspi('192.168.40.165','ran','2952');
### Updating Raspberry Pi I/O server...
### Connecting to board...
### Connected to 192.168.40.165...
### Creating server folder...
Error executing command "sudo make -C /opt/MATLAB/mw_server_v25.1.0
SERVER_DIR=/opt/MATLAB/mw_server_v25.1.0 -f Makefile_raspiPeriphs". Details:
STDERR: MW_SocketCAN.c: In function ‘int32_T MW_CAN_InitSocket(const char*,
int32_T, int32_T)’:
MW_SocketCAN.c:265:1: warning: no return statement in function returning
non-void [-Wreturn-type]
265 | }
| ^
MW_gpio.c: In function ‘int EXT_GPIO_init(unsigned int, uint8_T)’:
MW_gpio.c:34:20: error: ‘gpiod_chip_open_by_name’ was not declared in this
scope; did you mean ‘gpiod_chip_info_get_name’?
34 | gpioChip = gpiod_chip_open_by_name(GPIO_CHIP_NAME);
| ^~~~~~~~~~~~~~~~~~~~~~~
| gpiod_chip_info_get_name
MW_gpio.c:45:13: error: ‘gpiod_line_release’ was not declared in this scope;
did you mean ‘gpiod_line_request’?
45 | gpiod_line_release(existingGpioInfo->line);
| ^~~~~~~~~~~~~~~~~~
| gpiod_line_request
MW_gpio.c:50:31: error: ‘gpiod_chip_get_line’ was not declared in this scope;
did you mean ‘gpiod_chip_get_info’?
50 | struct gpiod_line *line = gpiod_chip_get_line(gpioChip, gpio);
| ^~~~~~~~~~~~~~~~~~~
| gpiod_chip_get_info
MW_gpio.c:56:15: error: ‘gpiod_line_request_output’ was not declared in this
scope; did you mean ‘gpiod_line_request_get_fd’?
56 | gpiod_line_request_output(line, "gpio_app", 0) :
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| gpiod_line_request_get_fd
MW_gpio.c:57:15: error: ‘gpiod_line_request_input’ was not declared in this
scope; did you mean ‘gpiod_line_request_get_fd’?
57 | gpiod_line_request_input(line, "gpio_app");
| ^~~~~~~~~~~~~~~~~~~~~~~~
| gpiod_line_request_get_fd
MW_gpio.c: In function ‘int EXT_GPIO_terminate(unsigned int)’:
MW_gpio.c:81:13: error: ‘gpiod_line_release’ was not declared in this scope;
did you mean ‘gpiod_line_request’?
81 | gpiod_line_release(gpioInfos[i].line);
| ^~~~~~~~~~~~~~~~~~
| gpiod_line_request
MW_gpio.c: In function ‘int EXT_GPIO_read(unsigned int, boolean_T*)’:
MW_gpio.c:122:15: error: ‘gpiod_line_get_value’ was not declared in this
scope; did you mean ‘gpiod_line_value’?
122 | int val = gpiod_line_get_value(gpioInfo->line);
| ^~~~~~~~~~~~~~~~~~~~
| gpiod_line_value
MW_gpio.c: In function ‘int EXT_GPIO_write(unsigned int, boolean_T)’:
MW_gpio.c:135:15: error: ‘gpiod_line_set_value’ was not declared in this
scope; did you mean ‘gpiod_line_value’?
135 | int ret = gpiod_line_set_value(gpioInfo->line, value);
| ^~~~~~~~~~~~~~~~~~~~
| gpiod_line_value
make: *** [Makefile_raspiPeriphs:228: MW_gpio.c.o] Error 1

1 Comment

Sounds like an libgpiod API mismatch. Start by confirming what version you have on the Raspberry Pi. Again, run the following code in SSH/terminal not MATLAB
# Shows the version provided by pkg-config (if installed)
pkg-config --modversion libgpiod || echo "pkg-config not found"
# Shows installed and candidate versions
apt-cache policy libgpiod-dev libgpiod2
# Peek at the header to see which API it exposes
grep -n "gpiod_line_request_output" /usr/include/gpiod.h || echo "v1 symbol not found"
grep -n "gpiod_line_settings_new" /usr/include/gpiod.h || echo "v2-only symbol not found"
If you see 2.x in apt-cache policy and the header lacks gpiod_line_request_output, you’re on libgpiod v2 headers. MATLAB’s server expects v1 symbols; v2 is not source-compatible with those calls. To install the v1 headers:
sudo apt-get update
# Install (or reinstall) the v1 dev and runtime packages from the current repo
# On Raspberry Pi OS Bookworm these resolve to 1.6.3
sudo apt-get install --yes --allow-downgrades libgpiod-dev libgpiod2
# (Optional) prevent an unintended upgrade to v2 later
sudo apt-mark hold libgpiod-dev libgpiod2
Then reconnect to your board with the raspi command in MATLAB.

Sign in to comment.

here is whaht I did:
ran@ran:~ $ apt-cache policy libgpiod-dev libgpiod2
libgpiod-dev:
Installed: 2.2.1-2+deb13u1
Candidate: 2.2.1-2+deb13u1
Version table:
*** 2.2.1-2+deb13u1 500
500 http://deb.debian.org/debian trixie/main arm64 Packages
100 /var/lib/dpkg/status
N: Unable to locate package libgpiod2
ran@ran:~ $ grep -n "gpiod_line_request_output" /usr/include/ gpiod.h || echo "v1 symbol not found"
grep: /usr/include/: Is a directory
grep: gpiod.h: No such file or directory
v1 symbol not found
there is
usr/include/ gpiodcxx
ran@ran:~ $ sudo apt install --yes --allow-downgrades libgpiod-dev libgpiod2
Error: Unable to locate package libgpiod2

Categories

Find more on MATLAB Support Package for Raspberry Pi Hardware in Help Center and File Exchange

Tags

Asked:

on 7 Dec 2025

Answered:

on 13 Dec 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!