Hi,
could someone give me a hint, on how to integrate des bcm Library.
Setup + ErrorI run a program in C++ on a Raspberry Pi Zero that is suposed to show bmp images on an ePaper display. The display is connected via SPI. Program and pictures are located on the sd card on the pi.
When the programm is executed via SSH with sudo, the program runs as desired. Without sudo or if the program is to be executed via cronjob, I get a segmentation fault. Cronjob is created as root with "sudo crontab -e". An entry under /etc/log/ with '*/5 * * * * root /home/marc/bcm2835-1.75/PicTest > 2>&1' also leads to seg-fault.
I was able to fix the Segfault error (at least the error message), but still the display of images fails.
What I've tried so far- Executed the instructions within "bcm2835.c" under "Running as root"
- Updated operating system on Raspi to the latest version. Bookworm V12
- libcap2 and libcap-dev installed or updated to the latest version (1:2.66-4+deb12u1)
- Adds the user to the kmem group
- reboot
- Loaded and unzipped the latest build of the library bcm2835 (here 1.75)
- Line "//#include..." in file /bcm2835/scr/bcm2835.h un-commented
- ./configure
- Make
- sudo make check
Here I got severall error messages for the test program.
gcc -g -O2 -o test test.o ./libbcm2835.a -lrt
/usr/bin/ld: ./libbcm2835.a(bcm2835.o): in function `bcm2835_has_capability':
/home/marc/bcm2835-1.75/src/bcm2835.c:140: undefined reference to `cap_get_proc'
/usr/bin/ld: /home/marc/bcm2835-1.75/src/bcm2835.c:144: undefined reference to `cap_get_flag'
/usr/bin/ld: /home/marc/bcm2835-1.75/src/bcm2835.c:146: undefined reference to `cap_free'
/usr/bin/ld: /home/marc/bcm2835-1.75/src/bcm2835.c:146: undefined reference to `cap_free'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:551: test] Error 1
make[2]: Leaving directory '/home/marc/bcm2835-1.75/src'
make[1]: *** [Makefile:851: check-am] Error 2
make[1]: Leaving directory '/home/marc/bcm2835-1.75/src'
make: *** [Makefile:369: check-recursive] Error 1xI then added the lcap in "bcm2835/makefile" and "bcm2835/src/makefile" in line "LIBS = -lrt -lcap".
"sudo make check" then ran without an error message. For my program, I also linked the -lcap when compiling. Again, there were no error messages when compiling.
The program starts without sudo, i.e. with "./myApp" also works. However, when starting via cronjob, I don't get a segmentation fault, but the bmp file is not displayed. All writing and drawing functions (letters, lines, circles, etc.) work. Only the display of images fails. The function runs without an error message, but the screen remains white.
I have almost no idea about c/c++. At most, a basic understanding through coding in e.g. Python. So I placed some debug lines along the code to see, if it fails silently while running. As far as I can tell, the program runs through. Just without showing des bmp-images.
What else I tried- Granting root rights for "/dev/gpiomem" to me as a user
```
sudo groupadd gpio
sudo usermod -a -G gpio user_name
sudo grep gpio /etc/group
sudo chown root.gpio /dev/gpiomem
sudo chmod g+rw /dev/gpiomem ```
- Assigning root rights for "/dev/mem" to me as a user as well
- compiling 2 other libraries "lg Library" and "gpiod Library", but with the same results. Drawing functions are working, but no display of images. And both Libraries are pretty slow compared to bcm2835.
Question / Request Can someone give me a hint on what I can try further.
I would be very grateful.
Of course I can post the output of the ssh session here, if i helps.
English is not my mother tongue. So I hope, what I wrote makes sense.
Thanks, Marc