My question is: I would like to know if there is a way to enable a debug on telethon library as initially I thought it was Telegram related but now it seems more like arch (os/python..?) related:
Facts:
-armv6 (raspberyy pi1, busterOS, python3): telethon client authenticates (with .start()) and disconnects after 3-5 minutes(!). Need to resend request/receive auth sms and it stays connected for another 3-5 minutes after which asks again for phone number
-armv7(raspberry pi4, busterOS, python3): telethon client authenticates (with .start()) and STAYS authenticated, as it should
Python version(Python 3.7.3), telethon package (Telethon1.23.0) are STRICTLY the same, only the architecture is a generation different between the two devices.
(What worth noticing (probably) is that when using armv6 (and having another session opened also on a phone), when the disauthenthication happens on armv6 the phone app gets logged out of telegram also, like a "disconnect ALL sessions" request is taking place all of a sudden)
I found why I had the disauthentication. The difference between the two devices was not the arch generation but the kernel NAME, not the version.
The device that triggered the disauthentication had a kernel name like 4.16.30CUSTOM while the "good" device had it like 4.16.30-v7lCUSTOM.
I recompiled the "broken" device's kernel using a custom name like 4.16.30-vxCUSTOM (using a dash -) and now everything is working.
Later edit: the default_system_version is split from the Kernel name (aka system.release) in telegrambaseclient.py file:
default_system_version = re.sub(r'-.+','',system.release)
Telethon gets disauthenticated on armv6 (but not armv7)