Alpine Linux run/compile problem

Applications, development tools, FPGA, C, WEB
kasaudio
Posts: 37
Joined: Sun Mar 11, 2018 6:03 pm

Alpine Linux run/compile problem

Post by kasaudio » Wed Mar 18, 2020 2:50 am

Hello RP community/team and Pavel Demin

Starting from here

viewtopic.php?f=14&t=24535

I decided to open a new topic to keep things transparent.

I have to detect ultrasonic pulse reflection time in liquid medium from bottom to surface and back. Quite a simple task, but requires at least 2 MHz sample rate, which is out of scope for Cypress Psoc 5LP which I'm familiar with and intended to use for this project at the beginning.

Short pulse of around 200V is generated on the transducer and then received as 100mV reflection. Visible with the RP oscilloscope app. There are some other things involved via i2c slave. Bluetooth is the preffered communication between measurement device and graphically rich Android application, wi-fi is acceptable also.

The official C example "acquire_trigger_software.c" with fpga_0.94.bin covers basic requirements. I2c part also works OK. The official linux system suffers from possible sd card corruption caused by intermittent power off. Starting custom program at RP power on also presents a challenge at some degree. I would like my RP behave just like ordinary MCU.

Pavel Demin suggested me to look at his project based on Alpine Linux. This solves the upper two problems. At this point I hope I somehow did my first homework - read the intro docs and some other things also.

I git the https://github.com/pavel-demin/red-pitaya-notes

"adc-recorder-trigger" covers the task, but requires to do all the fpga stuff from .tcl to .bin file. This seems quite steep for me at the moment. I grew up with MS Windows, Linux is my weak topic for now. Migration from Arduino to Cypress was quite similar in this aspect. I would like to avoid Vivado stuff for now if possible and build my C code around pre-made fpga configuration.

From my aspect it would be nice if I could compile/run the official C examples with fpga_0.94.bit on the Alpine Linux.

Copying the executable of the official "digital_led_blink", fpga image and running the program:

rp-f05fc9:/media/mmcblk0p1/CExamples# cat fpga.bit > /dev/xdevcfg
rp-f05fc9:/media/mmcblk0p1/CExamples# ./digital_led_blink
-ash: ./digital_led_blink: not found

Compiling digital_led_blink.c also fails... :

rp-f05fc9:/media/mmcblk0p1/CExamples# make digital_led_blink
cc -g -std=gnu99 -Wall -Werror -I/media/mmcblk0p1/CExamples -L/media/mmcblk0p1/CExamples digital_led_blink.c -lm -lpthread -lrp -o digital_led_blink
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: warning: libm.so.6, needed by /media/mmcblk0p1/CExamples/librp.so, not found (try using -rpath or -rpath-link)
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: warning: libpthread.so.0, needed by /media/mmcblk0p1/CExamples/librp.so, not found (try using -rpath or -rpath-link)
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: warning: libc.so.6, needed by /media/mmcblk0p1/CExamples/librp.so, not found (try using -rpath or -rpath-link)
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: warning: ld-linux-armhf.so.3, needed by /media/mmcblk0p1/CExamples/librp.so, not found (try using -rpath or -rpath-link)
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `fclose@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `cos@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `floor@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `munmap@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `raise@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `asin@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `close@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `malloc@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `fread@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `__sprintf_chk@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `__errno_location@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `sysconf@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `__stack_chk_guard@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `fwrite@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `exit@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `pow@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `fseek@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `__fprintf_chk@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `strerror@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `roundf@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `__isoc99_fscanf@GLIBC_2.7'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `mmap@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `stderr@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `acos@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `fputs@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `memcpy@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `free@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `rand@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `fopen@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `__stack_chk_fail@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `sqrt@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `sin@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `log10@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `open@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `round@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `usleep@GLIBC_2.4'
/usr/lib/gcc/armv7-alpine-linux-musleabihf/8.3.0/../../../../armv7-alpine-linux-musleabihf/bin/ld: /media/mmcblk0p1/CExamples/librp.so: undefined reference to `sincos@GLIBC_2.4'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: digital_led_blink] Error 1
rp-f05fc9:/media/mmcblk0p1/CExamples#

I guess the problem is between musl libc and glibc. I read somewhere glibc should be avoided on Alpine Linux...

Any suggestions?

BR, kas

pavel
Posts: 601
Joined: Sat May 23, 2015 5:22 pm

Re: Alpine Linux run/compile problem

Post by pavel » Wed Mar 18, 2020 10:31 am

I'd suggest to rebuild librp.so from source:
https://github.com/RedPitaya/RedPitaya/tree/master/api

kasaudio
Posts: 37
Joined: Sun Mar 11, 2018 6:03 pm

Re: Alpine Linux run/compile problem

Post by kasaudio » Wed Mar 18, 2020 11:31 am

Will do/try that. Thank you for help!!

kasaudio
Posts: 37
Joined: Sun Mar 11, 2018 6:03 pm

Re: Alpine Linux run/compile problem

Post by kasaudio » Wed Mar 18, 2020 11:07 pm

Hello!

Successfuly compiled the latest RedPitaya api using make-> well, at least I got librp.so
Successfuly compiled digital_led_blink.c using make and the new librp.so
When I run the program I got "segmentation fault" which occurs as rp_Init() is called.

Before executing the digital_led_blink I loaded fpga configuration file fpga_0.94.bit from the official RedPitaya OS.

Might that be a problem -> RedPitaya ecosystem code is new, while fpga conf is older? On the latest RedPitaya git I was not able to find the new fpga_0.94.bit (only fpga_0.93.bit)

Any thougts/suggestions?

pavel
Posts: 601
Joined: Sat May 23, 2015 5:22 pm

Re: Alpine Linux run/compile problem

Post by pavel » Thu Mar 19, 2020 1:21 am

If you are using version 0.94 of FPGA configuration, then maybe the code from the release-v0.94 branch is better compatible with this version:
https://github.com/RedPitaya/RedPitaya/ ... api/rpbase

kasaudio
Posts: 37
Joined: Sun Mar 11, 2018 6:03 pm

Re: Alpine Linux run/compile problem

Post by kasaudio » Thu Mar 19, 2020 10:08 am

Thanks for help.

Will try that, but from what I've done till now, I would say that improper fpga configuration causes the system to hang.

I got the same segmentation fault even without loading the fpga image.

Wil try what you suggested...

pavel
Posts: 601
Joined: Sat May 23, 2015 5:22 pm

Re: Alpine Linux run/compile problem

Post by pavel » Thu Mar 19, 2020 2:56 pm

I've put together a zip file with the C code of the release-0.94 branch and with the fpga_0.94.bit file. I've changed the directory structure, fixed the make scripts and a minor compilation problem in common.c.

Here is a list of commands I use to test this zip file:

Code: Select all

apk add make gcc linux-headers
cd /media/mmcblk0p1/apps
rw
wget -O api-0.94.zip https://www.dropbox.com/sh/5fy49wae6xwxa8a/AAA_t0nvt9PLwDlmGBD8W3kxa/red-pitaya-ecosystem/api-0.94.zip?dl=1
unzip api-0.94.zip
cd api-0.94
make
cd examples
make
export LD_LIBRARY_PATH=/media/mmcblk0p1/apps/api-0.94/lib
cat ../fpga_0.94.bit > /dev/xdevcfg
./digital_led_blink

kasaudio
Posts: 37
Joined: Sun Mar 11, 2018 6:03 pm

Re: Alpine Linux run/compile problem

Post by kasaudio » Thu Mar 19, 2020 3:56 pm

Thank for big help. Will try asap and report. Gcc Linux headers is definitely what I missed...

kasaudio
Posts: 37
Joined: Sun Mar 11, 2018 6:03 pm

Re: Alpine Linux run/compile problem

Post by kasaudio » Thu Mar 19, 2020 5:22 pm

Tried it... IT WORKS!!!

THANK YOU!

kasaudio
Posts: 37
Joined: Sun Mar 11, 2018 6:03 pm

Re: Alpine Linux run/compile problem

Post by kasaudio » Sat Mar 21, 2020 12:12 am

I also managed to establish iic with ads1115 for some additional low speed analog stuff. Basic parts of the project now work ok. My code starts at power up.

Now only the uart for the bluetooth stuff is on the list.

Pavel, your work is awsome!

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 3 guests