essenemari
Posts: 1
Joined: Sat Oct 23, 2021 8:53 pm

>>bcm2835_init: gpio mmap failed: Cannot allocate memory << on EasyIoT framework

Sat Oct 23, 2021 9:35 pm

Hi All,

I am facing issue on RPi4 with EasyIoT Server framework where GPIO are used. First of all - this issue concerns RPi4 only (Rpi 2, 3 works well). EasyIoT Server framework is under https://creativecommons.org/licenses/by-nc/3.0/ license and source code is NOT open. The EasyIoT project is dead - no response from community nor author (developer of EasyIoT). This is painful for me - in my opinion, this soft is awesome. I am using it for home automation for around 5 years. Currently, I wanted to migrate from RPi2 to RPi4 due to 1Gb eth.

Problem:
GPIO part cannot start with error:

Code: Select all

bcm2835_init: gpio mmap failed: Cannot allocate memory
As far as I know, there are a differences between RPi4 and previous RPi versions https://groups.google.com/g/bcm2835/c/BwZXVsDRtwI or on this forum viewtopic.php?f=28&t=265324&p=1612920&h ... 2#p1612920.

Tried to recreate the libbcm2835.so with the latest bcm2835 library from link above plus this: stackoverflow.com/questions/23639895/in ... spberry-pi no success.

I don't understand the problem at all and the worst thing is that I do not know if the issue is possible to fix without access to EasyIoT source code.

Would be someone so kind and try to help me understand if there is chance to have it fixed or find workaround without framework source code? Do you have ideas about any potential fix?

I am worry that framework calls some libraries used in previous Raspberry Pi or there are some values in the code (i.e. memory addressing) that are not relevant to Rpi4 anymore.

Thanks for any help, advices or just hints.

Full error when trying to turn on the GPIO module in EasyIoT Server. Of course it works like a charm in RPi2 and RPI3, but not on RPi4 as below:

Code: Select all

root@raspberrypi4b:/home/easyiot# sudo mono EasyIoT.exe
2021-10-13T21:34:56.7967960+02:00       INFO    System                          System started
13-10-2021-21-34-58  Web service started
13-10-2021-21-34-58  Listening on port(s):81, 1301
bcm2835_init: gpio mmap failed: Cannot allocate memory
2021-10-13T21:34:58.3089140+02:00       DEBUG   MySensors                               MySensors Connect
bcm2835_init: gpio mmap failed: Cannot allocate memory
2021-10-13T21:34:58.3118200+02:00       DEBUG   MySensors                               Check wires.
13-10-2021-21-35-28 [192.168.0.195]  user:[admin]  authentication success: authentication success
2021-10-13T21:35:32.5830730+02:00       INFO    EasyIoTWebinterface     EasyIoTConfig   Module  List    /Api/EasyIoT/Config/Module/List//?_=1634153730465
2021-10-13T21:35:32.6891380+02:00       INFO    EasyIoTWebinterface     EasyIoTConfig   Group   List    /Api/EasyIoT/Config/Group/List/?_=1634153730466
2021-10-13T21:35:38.5743990+02:00       INFO    EasyIoTWebinterface     EasyIoTConfig   Webinterface    IsAdmin /Api/EasyIoT/Config/Webinterface/IsAdmin//?_=1634153730467
2021-10-13T21:35:42.2736650+02:00       INFO    EasyIoTWebinterface     EasyIoTConfig   Group   List    /Api/EasyIoT/Config/Group/List/?_=1634153730468
2021-10-13T21:35:50.3078570+02:00       INFO    EasyIoTWebinterface     EasyIoTConfig   Driver  RPiGPIO /Api/EasyIoT/Config/Driver/RPiGPIO/GetIsEnabled//?_=1634153730469
2021-10-13T21:35:51.7302120+02:00       INFO    EasyIoTWebinterface     EasyIoTConfig   Driver  RPiGPIO /Api/EasyIoT/Config/Driver/RPiGPIO/SetIsEnabled/1//
Stacktrace:

at <unknown> <0xffffffff>
at (wrapper managed-to-native) RPiGPIODriver.GPIOInterface.bcm2835_gpio_write (uint,bool) <0x0003b>
at RPiGPIODriver.GPIOInterface.Write (uint,bool) [0x00000] in <2797eccd101941e5b27b8a9977290402>:0
at RPiGPIODriver.RPiGPIO.writePin (RPiGPIODriver.GpioPin,string) [0x00022] in <2797eccd101941e5b27b8a9977290402>:0
at RPiGPIODriver.RPiGPIO.write (string,string) [0x0008f] in <2797eccd101941e5b27b8a9977290402>:0
at RPiGPIODriver.RPiGPIO.connect () [0x00117] in <2797eccd101941e5b27b8a9977290402>:0
at RPiGPIODriver.RPiGPIO.SetIsEnabled (string) [0x0000d] in <2797eccd101941e5b27b8a9977290402>:0
at (wrapper runtime-invoke) <Module>.runtime_invoke_object__this___object (object,intptr,intptr,intptr) [0x00050] in <2797eccd101941e5b27b8a9977290402>:0
at <unknown> <0xffffffff>
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) <0x00043>
at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x00044] in <d0e12f672b88444ab4b6d9b2ecf20142>:0
at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in <d0e12f672b88444ab4b6d9b2ecf20142>:0
at EasyIoT.Service.Handler.Config.ProcessRequest (WebGateway.WebServiceGatewayContex) [0x03280] in <cfabd3496a6841abb7f37d89020559aa>:0
at EasyIoT.EasyIoTService.httpService_ServiceRequestProcess (WebGateway.WebServiceGatewayContex) [0x0009b] in <cfabd3496a6841abb7f37d89020559aa>:0
at WebGateway.WebService.httpgw_ProcessRequest (object) [0x0003a] in <5ff314d9d4864b029c1f02fb1261afdb>:0
at WebGateway.WebGateway.worker (System.Net.HttpListenerContext) [0x00261] in <5ff314d9d4864b029c1f02fb1261afdb>:0
at WebGateway.WebGateway.ListenerCallback (System.IAsyncResult) [0x00032] in <5ff314d9d4864b029c1f02fb1261afdb>:0
at System.Net.ListenerAsyncResult.InvokeCallback (object) [0x0001e] in <a9a08e39ba304bd0a84c49bd158dfc02>:0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00019] in <d0e12f672b88444ab4b6d9b2ecf20142>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00096] in <d0e12f672b88444ab4b6d9b2ecf20142>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <d0e12f672b88444ab4b6d9b2ecf20142>:0
at (wrapper runtime-invoke) <Module>.runtime_invoke_bool (object,intptr,intptr,intptr) [0x0001e] in <d0e12f672b88444ab4b6d9b2ecf20142>:0
/proc/self/maps:
00010000-003d7000 r-xp 00000000 b3:02 31352      /usr/bin/mono-sgen
003e6000-003ea000 r--p 003c6000 b3:02 31352      /usr/bin/mono-sgen
003ea000-003ee000 rw-p 003ca000 b3:02 31352      /usr/bin/mono-sgen
003ee000-00474000 rw-p 00000000 00:00 0
0119a000-017a7000 rw-p 00000000 00:00 0          [heap]
ae100000-af900000 rw-s fe000000 00:05 4          /dev/mem
af900000-afa00000 rw-p 00000000 00:00 0
afb00000-afc00000 rw-p 00000000 00:00 0
b0ce8000-b0e00000 r--p 00000000 b3:02 387866     /usr/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll
b0e00000-b0f00000 rw-p 00000000 00:00 0
b1000000-b1123000 rw-p 00000000 00:00 0
b1123000-b1200000 ---p 00000000 00:00 0
b1200000-b12ff000 rw-p 00000000 00:00 0
b12ff000-b1300000 ---p 00000000 00:00 0
b13fa000-b1700000 r--p 00000000 b3:02 388406     /usr/lib/mono/gac/System.Web/4.0.0.0__b03f5f7f11d50a3a/System.Web.dll
b1700000-b1800000 rw-p 00000000 00:00 0
b1900000-b1a00000 rw-p 00000000 00:00 0
b1b00000-b1c00000 rw-p 00000000 00:00 0
b1d00000-b1e00000 rw-p 00000000 00:00 0
b1efa000-b1efb000 ---p 00000000 00:00 0
b1efb000-b1ffb000 rwxp 00000000 00:00 0
b1ffb000-b1ffc000 ---p 00000000 00:00 0
b1ffc000-b20fc000 rwxp 00000000 00:00 0
b20fc000-b20fd000 ---p 00000000 00:00 0
b20fd000-b21fd000 rwxp 00000000 00:00 0
Memory around native instruction pointer (0xb64ce5b4):
0xb64ce5a4  02 20 8f e0 00 00 d2 e5 01 20 a0 e1 00 00 50 e3  . ....... ....P.
0xb64ce5b4  00 10 83 05 1e ff 2f 01 0c 00 9f e5 03 10 a0 e1  ....../.........
0xb64ce5c4  00 00 8f e0 84 f7 ff ea f4 a6 00 00 98 1f 00 00  ................
0xb64ce5d4  28 20 9f e5 00 30 a0 e1 02 20 8f e0 00 00 d2 e5  ( ...0... ......

Native stacktrace:

Pkilling 0xb379e440 from 0xb27ff440
Pkilling 0xb22fd440 from 0xb27ff440
Pkilling 0xb673f440 from 0xb27ff440
Pkilling 0xb24ff440 from 0xb27ff440
Pkilling 0xb1ffa440 from 0xb27ff440
Pkilling 0xb6f35240 from 0xb27ff440
Pkilling 0xb21fc440 from 0xb27ff440
Pkilling 0xb34ff440 from 0xb27ff440
Pkilling 0xb2aff440 from 0xb27ff440
Pkilling 0xb23fe440 from 0xb27ff440
Pkilling 0xb2df0440 from 0xb27ff440
Pkilling 0xb31ff440 from 0xb27ff440
Pkilling 0xb20fb440 from 0xb27ff440
Entering thread summarizer pause from 0xb27ff440
Finished thread summarizer pause from 0xb27ff440.

Waiting for dumping threads to resume


Debug info from gdb:

[New LWP 1072]
[New LWP 1073]
[New LWP 1075]
[New LWP 1076]
[New LWP 1077]
[New LWP 1078]
[New LWP 1079]
[New LWP 1080]
[New LWP 1087]
[New LWP 1088]
[New LWP 1089]
[New LWP 1090]
[New LWP 1091]
[New LWP 1092]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
0xb33f5978 in ?? ()
Id   Target Id                                      Frame
* 1    Thread 0xb6f35240 (LWP 1071) "mono"            0xb33f5978 in ?? ()
2    Thread 0xb5fff440 (LWP 1072) "SGen worker"     futex_wait_cancelable (private=0, expected=0, futex_word=0x3f8c58) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
3    Thread 0xb673f440 (LWP 1073) "Finalizer"       0xb6e1a088 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=1, futex_word=0x3f0ee0) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
4    Thread 0xb379e440 (LWP 1075) "mono"            futex_reltimed_wait_cancelable (private=0, reltime=0xb379d1b0, expected=0, futex_word=0x3f0d1c) at ../sysdeps/unix/sysv/linux/futex-internal.h:142
5    Thread 0xb34ff440 (LWP 1076) "mono"            futex_reltimed_wait_cancelable (private=0, reltime=0xb34fe638, expected=0, futex_word=0x4733c0) at ../sysdeps/unix/sysv/linux/futex-internal.h:142
6    Thread 0xb31ff440 (LWP 1077) "Thread Pool I/O" __GI___poll (timeout=-1, nfds=5, fds=0x1599d70) at ../sysdeps/unix/sysv/linux/poll.c:29
7    Thread 0xb2df0440 (LWP 1078) "mono"            futex_reltimed_wait_cancelable (private=0, reltime=0xb2defc60, expected=0, futex_word=0x4733c0) at ../sysdeps/unix/sysv/linux/futex-internal.h:142
8    Thread 0xb2aff440 (LWP 1079) "Thread Pool Wor" futex_wait_cancelable (private=0, expected=0, futex_word=0x3f0d1c) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
9    Thread 0xb27ff440 (LWP 1080) "Thread Pool Wor" __waitpid (options=0, stat_loc=0xb27fcfa8, pid=1097) at ../sysdeps/unix/sysv/linux/waitpid.c:30
10   Thread 0xb24ff440 (LWP 1087) "Thread Pool Wor" futex_abstimed_wait_cancelable (private=0, abstime=0xb24fed8c, expected=1, futex_word=0x3f1448) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
11   Thread 0xb23fe440 (LWP 1088) "Thread Pool Wor" futex_abstimed_wait_cancelable (private=0, abstime=0xb23fdd8c, expected=1, futex_word=0x3f1448) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
12   Thread 0xb22fd440 (LWP 1089) "Thread Pool Wor" futex_reltimed_wait_cancelable (private=0, reltime=0xb22fc370, expected=0, futex_word=0x4733c0) at ../sysdeps/unix/sysv/linux/futex-internal.h:142
13   Thread 0xb21fc440 (LWP 1090) "Timer-Scheduler" futex_reltimed_wait_cancelable (private=0, reltime=0xb21fb2e8, expected=0, futex_word=0x119b0f0) at ../sysdeps/unix/sysv/linux/futex-internal.h:142
14   Thread 0xb20fb440 (LWP 1091) "Thread Pool Wor" futex_abstimed_wait_cancelable (private=0, abstime=0xb20fad8c, expected=1, futex_word=0x3f1448) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
15   Thread 0xb1ffa440 (LWP 1092) "Thread Pool Wor" futex_abstimed_wait_cancelable (private=0, abstime=0xb1ff9d8c, expected=1, futex_word=0x3f1448) at ../sysdeps/unix/sysv/linux/futex-internal.h:205

Thread 15 (Thread 0xb1ffa440 (LWP 1092)):
#0  futex_abstimed_wait_cancelable (private=0, abstime=0xb1ff9d8c, expected=1, futex_word=0x3f1448) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
#1  do_futex_wait (sem=sem@entry=0x3f1448, abstime=abstime@entry=0xb1ff9d8c) at sem_waitcommon.c:115
#2  0xb6e1a5c4 in __new_sem_wait_slow (sem=0x3f1448, abstime=0xb1ff9d8c) at sem_waitcommon.c:282
#3  0x00299b14 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 14 (Thread 0xb20fb440 (LWP 1091)):
#0  futex_abstimed_wait_cancelable (private=0, abstime=0xb20fad8c, expected=1, futex_word=0x3f1448) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
#1  do_futex_wait (sem=sem@entry=0x3f1448, abstime=abstime@entry=0xb20fad8c) at sem_waitcommon.c:115
#2  0xb6e1a5c4 in __new_sem_wait_slow (sem=0x3f1448, abstime=0xb20fad8c) at sem_waitcommon.c:282
#3  0x00299b14 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 13 (Thread 0xb21fc440 (LWP 1090)):
#0  futex_reltimed_wait_cancelable (private=0, reltime=0xb21fb2e8, expected=0, futex_word=0x119b0f0) at ../sysdeps/unix/sysv/linux/futex-internal.h:142
#1  __pthread_cond_wait_common (abstime=0xb21fb364, mutex=0x2, cond=0x119b0c8) at pthread_cond_wait.c:533
#2  __pthread_cond_timedwait (cond=0x119b0c8, mutex=0x2, abstime=0xb21fb364) at pthread_cond_wait.c:667
#3  0x002fda8c in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 12 (Thread 0xb22fd440 (LWP 1089)):
#0  futex_reltimed_wait_cancelable (private=0, reltime=0xb22fc370, expected=0, futex_word=0x4733c0) at ../sysdeps/unix/sysv/linux/futex-internal.h:142
#1  __pthread_cond_wait_common (abstime=0xb22fc3ec, mutex=0x2, cond=0x473398) at pthread_cond_wait.c:533
#2  __pthread_cond_timedwait (cond=0x473398, mutex=0x2, abstime=0xb22fc3ec) at pthread_cond_wait.c:667
#3  0x002fda8c in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 11 (Thread 0xb23fe440 (LWP 1088)):
#0  futex_abstimed_wait_cancelable (private=0, abstime=0xb23fdd8c, expected=1, futex_word=0x3f1448) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
#1  do_futex_wait (sem=sem@entry=0x3f1448, abstime=abstime@entry=0xb23fdd8c) at sem_waitcommon.c:115
#2  0xb6e1a5c4 in __new_sem_wait_slow (sem=0x3f1448, abstime=0xb23fdd8c) at sem_waitcommon.c:282
#3  0x00299b14 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 10 (Thread 0xb24ff440 (LWP 1087)):
#0  futex_abstimed_wait_cancelable (private=0, abstime=0xb24fed8c, expected=1, futex_word=0x3f1448) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
#1  do_futex_wait (sem=sem@entry=0x3f1448, abstime=abstime@entry=0xb24fed8c) at sem_waitcommon.c:115
#2  0xb6e1a5c4 in __new_sem_wait_slow (sem=0x3f1448, abstime=0xb24fed8c) at sem_waitcommon.c:282
#3  0x00299b14 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 9 (Thread 0xb27ff440 (LWP 1080)):
#0  __waitpid (options=0, stat_loc=0xb27fcfa8, pid=1097) at ../sysdeps/unix/sysv/linux/waitpid.c:30
#1  __waitpid (pid=1097, stat_loc=0xb27fcfa8, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:25
#2  0x0010225c in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 8 (Thread 0xb2aff440 (LWP 1079)):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x3f0d1c) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x0, cond=0x3f0cf0) at pthread_cond_wait.c:502
#2  __pthread_cond_wait (cond=0x3f0cf0, mutex=0x0) at pthread_cond_wait.c:655
#3  0x002fdac8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 7 (Thread 0xb2df0440 (LWP 1078)):
#0  futex_reltimed_wait_cancelable (private=0, reltime=0xb2defc60, expected=0, futex_word=0x4733c0) at ../sysdeps/unix/sysv/linux/futex-internal.h:142
#1  __pthread_cond_wait_common (abstime=0xb2defcdc, mutex=0x2, cond=0x473398) at pthread_cond_wait.c:533
#2  __pthread_cond_timedwait (cond=0x473398, mutex=0x2, abstime=0xb2defcdc) at pthread_cond_wait.c:667
#3  0x002fda8c in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 6 (Thread 0xb31ff440 (LWP 1077)):
#0  __GI___poll (timeout=-1, nfds=5, fds=0x1599d70) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  __GI___poll (fds=0x1599d70, nfds=5, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:26
#2  0x002333a4 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 5 (Thread 0xb34ff440 (LWP 1076)):
#0  futex_reltimed_wait_cancelable (private=0, reltime=0xb34fe638, expected=0, futex_word=0x4733c0) at ../sysdeps/unix/sysv/linux/futex-internal.h:142
#1  __pthread_cond_wait_common (abstime=0xb34fe6b4, mutex=0x2, cond=0x473398) at pthread_cond_wait.c:533
#2  __pthread_cond_timedwait (cond=0x473398, mutex=0x2, abstime=0xb34fe6b4) at pthread_cond_wait.c:667
#3  0x002fda8c in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 4 (Thread 0xb379e440 (LWP 1075)):
#0  futex_reltimed_wait_cancelable (private=0, reltime=0xb379d1b0, expected=0, futex_word=0x3f0d1c) at ../sysdeps/unix/sysv/linux/futex-internal.h:142
#1  __pthread_cond_wait_common (abstime=0xb379d22c, mutex=0x2, cond=0x3f0cf0) at pthread_cond_wait.c:533
#2  __pthread_cond_timedwait (cond=0x3f0cf0, mutex=0x2, abstime=0xb379d22c) at pthread_cond_wait.c:667
#3  0x002fda8c in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 3 (Thread 0xb673f440 (LWP 1073)):
#0  0xb6e1a088 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=1, futex_word=0x3f0ee0) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
#1  do_futex_wait (sem=sem@entry=0x3f0ee0, abstime=0x0) at sem_waitcommon.c:115
#2  0xb6e1a1f4 in __new_sem_wait_slow (sem=0x3f0ee0, abstime=0x0) at sem_waitcommon.c:282
#3  0x00281488 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 2 (Thread 0xb5fff440 (LWP 1072)):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x3f8c58) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x0, cond=0x3f8c30) at pthread_cond_wait.c:502
#2  __pthread_cond_wait (cond=0x3f8c30, mutex=0x0) at pthread_cond_wait.c:655
#3  0x002ed600 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 1 (Thread 0xb6f35240 (LWP 1071)):
#0  0xb33f5978 in ?? ()
#1  0x012cfc20 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
[Inferior 1 (process 1071) detached]

#ERROR!
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
#ERROR!

Aborted
root@raspberrypi4b:/home/easyiot# init 6

Return to “Troubleshooting”