FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
+3 votes
1,193 views 27 comments
by anonymous
Hi, everyone

I have installed Python 3.7 on a TRB140 using 'opkg install python3-light'. The installation completed succesfully. When I run 'python3' or execute a python-script then the following error appears:

Error relocating /usr/lib/libpython3.7.so.1.0: getrandom: symbol not found

I have no working resolution. Can anybody help?

Regards, Mike
by anonymous
firmware version V7.01 seems to have fixed this issue by updating the base openwrt to 21.02

please check

Regards

      heiterkiter
by anonymous
Yes, the latest firmware V7.02 is openwrt 21.02 based and Python is working. Thanks!

Regards
by anonymous
Newest firmware did not fix this issue

1 Answer

0 votes
by anonymous
Hi,

Could you please check if other opkg packages work normally and are installed correctly?

Check if you have the latest firmware version? Try resetting the router to default factory settings?

If you're able to install others and use them and only a little part of packages return with errors like that - I'm afraid there's nothing we can do, as this is a third-party package and it's not included in our base functionality.

Your best bet would be waiting for a newer firmware version as it should include a little newer OpenWRT update.

EB.
by anonymous
Hi,

other packages work properly. Latest firmware already installed. Factory default settings set as well. The issue occurs again. It seems that the linking of the libraries is not correct. I did not find any working resolution yet.

Regards, Mike
by anonymous
Hi again,

I tested a Python 2 installation with opkg and it works well. Unfortunately Python 3 doesn't resulting in the mentioned error. What is the difference between both? Since they are available for installation using opkg I assume they should run without issues. Does anybody know how to resolve the relocation issue?

Regards, Mike
by anonymous
If you are interested, I have built a libgetrandom.so using the SDK. To use it:

LD_PRELOAD=./libgetrandom.so python3 ...

Regards,
by anonymous
unfortunately this even occurs in the newest firmware RUT9_R_00.07.00 on my RUT955.
as far as i remember this is not an issue with the RUTX_R_00.07.00. running on my RUTX11. python3 runs like a charm

@flebourse is it possible to build a complete firmware for the RUT955 from the sdk with the fix included?
@teltonika maybe a fix?

Best,
by anonymous
Stock python3 fails on the RUTX11 version 00.07.00 with getrandom: symbol not found.

You can build a complete firmware to solve this issue, either via a libgetrandom / LD_PRELOAD supplementary package , or by patching musl. The latter is more intrusive but won't require the use of LD_PRELOAD.
by anonymous

ah! you are right. 

it doesnt work on a rutx11 7.0 either. I remembered it wrong. it was a rutx12 with an older firmware. i tried this two months ago and there python3 was running fine.

in another forum i found out what the issue seems to be: 

"So what happened here is that the getrandom symbol has been moved into /lib/libc.musl-x86_64.so.1 which /usr/lib/libpython3.6m.so.1.0 depends on. You are getting this because you have a newer version of libpython3.6 that no longer implements this symbol and expects libc.musl to implement it, but the version of libc.musl does not have it implemented. Solution is to simply upgrade libc.musl to latest version and the symbol is implemented there. "

I have set up a machine with ubuntu 20.04 and compiled a firmware for the 955 already which is running on the device. 

Would you be so kind and point me in the right direction on how to patch the problem? 

thank you for your time

heiterkiter

 

by anonymous

Add the following 902-add-getrandom-syscall.patch file to toolchain/musl/patches and make:

--- a/src/linux/getrandom.c     1970-01-01 01:00:00.000000000 +0100                                                                                
+++ b/src/linux/getrandom.c     2021-07-31 16:15:13.747358550 +0200                                                                                
@@ -0,0 +1,7 @@
+#include <sys/types.h>                                                                                                                           
+#include "syscall.h"                                                                                                                              
+                                                                                                                                                  
+ssize_t getrandom(void *buf, size_t buflen, unsigned flags)                                                                                       
+{                                                                                                                                                 
+       return syscall(SYS_getrandom, buf, buflen, flags);                                                                                         
+}

Regards,

by anonymous
thx a lot,flebourse, that helped it.

i tried it yesterday but got stuck with another problem. now it can not download any packages because the feed url within the build firmware does not exist :/ looks like i need to learn a lot more :)

but python3 works :)

Best,
by anonymous

@flebrouse could you share how you built the libgetrandom.so library to use with LD_PRELOAD?

I have the build toolchain set up and am able to build a patched firmware, but for now would prefer the "less intrusive" solution of just copying a single library file to a stock firmware. Unfortunately I don't see libgetrandom within the firmware build tree, so I guess you pulled the source in elsewhere?

by anonymous
I'll send you the file by PM.
by anonymous
@flebourse

would you be o kind and also share the libgetrandom.so library with me. i am on the road with a rutx11 and i have a hard time compiling firmware here.

thx

heiterkiter
by anonymous
Sent by PM.

Regards,
by anonymous
@flebouse

Sir could you please share with me this library .so file? Is that compiled for mdm9x07 target? I have a TRB140 device
by anonymous
Sent via PM.

Regards,
by anonymous
@flebourse

I would also appreciate if you could send me the libgetrandom.so library. I'm getting the same error on a TRB140 with 00.07.00.1.

Best regards
by anonymous
@flebourse

Would you be so kind to send me the libgetrandom.so via PM? Thank you very much in advance, getting the same error on a TRB142 with the latest firmware.
by anonymous

libgetrandom.so is here and the source code is here.

by anonymous
Upgrading to the latest TRB140 firmware fixed the problem (while whipping out all my site-packages python folder contents)
by anonymous

@flebourse

Using the patch I cannot build the firmware as per this error message:

Any instructions on how to fix that? You've mentioned a method with an LD_PRELOAD a few comments ago, can you elaborate on that?

by anonymous
1 - looks like you have a SDK version already containing a getrandom.c file, so the patch is not required. Which version do you use ? What is the content of the original file ?

2) extract the source in the base directory and make menuconfig to enable it, copy libgetrandom.so to the target device and use it as LD_PRELOAD=./libgetrandom.so python3 ...
by anonymous
I'm using the latest SDK available from Teltonika, so TRB1_R_00.07.01.2

I cannot find the file in the SDK, do I have to check for it during runtime on the target device?

Regarding 2): With base directory you mean the base directory of the sdk or the target device? Sorry for asking these possibly trivial questions but I'm new to building firmwares with the SDK.
by anonymous
Just checked, getrandom.c is in build_dir/toolchain-mips_24kc_gcc-8.4.0_musl/musl-1.1.24/src/linux. It is downloaded so it appears only after a make. The 902-xxx pacth is redondant, don't use it in this version (and delete it if it is present).

2) the folder where it resides, for me rutos-ath79-trb2-gpl
by anonymous
Thank you very much so far. I did not find any options to enable it in the menuconfig menu, can you hint me in the right direction one last time?
by anonymous
It is in the Libraries sub-menu, but you shouldn't need it as getrandom() is included in the musl library in this version.