ARM: Bus Error
athoik opened this issue · comments
Hi,
I am getting Bus Error on ARM (Linux osmio4k 5.5.16 #1 SMP Thu Apr 9 22:19:04 UTC 2020 armv7l GNU/Linux).
The kal binary is compiled using D_HOST_OSX.
# kal -c 90 -D
debug: Mac OS X version
debug: FPGA Master Clock Freq: 52000000
debug: decimation : 192
debug: RX Subdev Spec : A
debug: Antenna : RX2
debug: Gain : 0.000000
Found 1 device(s):
0: Generic RTL2832U OEM
Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Exact sample rate is: 270833.002142 Hz
[R82XX] PLL not locked!
kal: Calculating clock frequency offset.
Using GSM-900 channel 90 (953.0MHz)
Tuned to 953.000000MHz (reported tuner error: 0Hz)
Bus error
Here is what gdb reports:
Thread 1 "kal" received signal SIGBUS, Bus error.
0x00017ed4 in usrp_source::fill (this=0x30098, num_samples=5120, overrun_i=0x0) at ../../git/src/usrp_source.cc:261
261 c[i] = complex((ubuf[j] - 127) * 256, (ubuf[j + 1] - 127) * 256);
(gdb) p i
$1 = 0
(gdb) p c
$2 = (complex *) 0xb66a8000
(gdb) p c[0]
Cannot access memory at address 0xb66a8000
(gdb) p j
$3 = 0
(gdb) info locals
ubuf = "\177\200", '\177' <repeats 23 times>, "\200\177\200", '\177' <repeats 11 times>, "\200\200\177\200\177\177\177\177\177\177\177\177\177\200\177\200", '\177' <repeats 13 times>, "\200", '\177' <repeats 36 times>, "\200", '\177' <repeats 12 times>, "\200", '\177' <repeats 12 times>, "\200\200", '\177' <repeats 36 times>, "\200\200\177\200\177\177\177\177\177\177\177\177\200\177\200\177\177\177\177\177\177\177\177\177\200\177\177\177\200", '\177' <repeats 23 times>...
i = 0
j = 0
space = 16384
overruns = 0
c = 0xb66a8000
n_read = 32768
(gdb) bt
#0 0x00017ed4 in usrp_source::fill (this=0x30098, num_samples=5120, overrun_i=0x0) at ../../git/src/usrp_source.cc:261
#1 0x000180b0 in usrp_source::flush (this=0x30098, flush_count=10) at ../../git/src/usrp_source.cc:309
#2 0x00017170 in offset_detect (u=0x30098, hz_adjust=0, tuner_error=0) at ../../git/src/offset.cc:68
#3 0x00016fec in main (argc=3, argv=0xbefffd94) at ../../git/src/kal.cc:317
I tried to compile without defining the D_HOST_OSX.
# kal -c 90 -D
debug: FPGA Master Clock Freq: 52000000
debug: decimation : 192
debug: RX Subdev Spec : A
debug: Antenna : RX2
debug: Gain : 0.000000
shmat: Invalid argument
terminate called after throwing an instance of 'std::runtime_error'
what(): circular_buffer: shmat
Aborted
But issue with shmat appeared as described in #1
Compiling also kalibrate on mips same issue appears, like #22
root@osmega:~# kal -c 90
shmat: Invalid argument
terminate called after throwing an instance of 'std::runtime_error'
what(): circular_buffer: shmat
Aborted
root@osmega:~# uname -a
Linux osmega 4.11.0 #1 SMP Sun Feb 9 12:33:57 UTC 2020 mips GNU/Linux
root@osmega:~#
Experimenting on D_HOST_OSX without using POSIX shared memory, but only temporary mmapped file everything works fine!
So I created a patch here: athoik@0e203c2
This version used only mmap and it works great.
I was about to create a PR with above version, then I realized that /dev/shm is missing ....
root@osmega:~# ./kal -s GSM900
Found 1 device(s):
0: Generic RTL2832U OEM
Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Exact sample rate is: 270833.002142 Hz
[R82XX] PLL not locked!
kal: Scanning for GSM-900 base stations.
Bus error
root@osmega:~# mkdir /dev/shm
root@osmega:~# ./kal -s GSM900
Found 1 device(s):
0: Generic RTL2832U OEM
Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Exact sample rate is: 270833.002142 Hz
[R82XX] PLL not locked!
kal: Scanning for GSM-900 base stations.
GSM-900:
chan: 1 (935.2MHz - 21.640kHz) power: 27642.07
chan: 5 (936.0MHz - 22.428kHz) power: 51325.93
So the problem, on ARM was the missing /dev/shm directory.
The problem on MIPS was and the missing /dev/shm directory (obviously). Also we have to build without shared memory, just like we do on ARM.
A PR was created to fix issue on MIPS. #30
So if you are getting Bus Error on ARM or MIPS check if /dev/shm exists :)