Avoid message loops with FHEM2FHEM

Multiple instances of the open source server for house automation FHEM running on different machines can communicate using the FHEM2FHEM¹ module. Unfortunately one runs into big trouble when trying to use the module bidirectionally. FHEM2FHEM reads events from a remote FHEM instance. When using declarations like the following on both sides this results in an event loop because instance1 reads an event from instance2 and generates a new event on instance1. This event then gets read by instance2 again and so on…

define instance2 FHEM2FHEM instance2:7072 LOG:.*

fhem.cfg on instance1

define instance1 FHEM2FHEM instance1:7072 LOG:.*

fhem.cfg on instance2

Eventually this results in an event loop consuming all available CPU power and freezing FHEM.

One could simply prevent this situation by not forwarding all events by using a regular expression filtering the events instead of using LOG:.* . This also means one has to know which event gets received best by which instance. For example for simple radio temperature sensors this is hard to tell. Also one might want to have all sensor data available on all instances. This can be achieved by preventing FHEM from processing events, that got received from a remote instance a second time.

My modified version of 93_FHEM2FHEM.pm does exactly this, when a remote event gets read an additional flag (DISABLEEVENT) is being set. When the event afterwards gets processed a second time it gets discarded and the flag gets removed, so that usual message handling for the device can continue. This might not be the most sophisticated solution for the problem, but at least it prevents FHEM from freezing.

To prevent FHEM from freezing in the bidirectional setup, download the modified version of 93_FHEM2FHEM.pm (4328 downloads ) and replace the original file in the folder /opt/fhem/FHEM for both instances. Then edit the file fhem.cfg for both instances and add the attribute avoidMsgLoop to the FHEM2FHEM device, like in the following example. To get useful states for some devices, like CUL_TCM97001 sensors one still has to add the addStateEvent attribute.² Without this, for example plots would not work properly.

define instance1 FHEM2FHEM instance1:7072 LOG:.*
attr instance1 avoidMsgLoop 1
attr instance1 addStateEvent 1

With this modification it should be possible to set up a “cluster” of FHEM instances that can operate independent from each other but have the same data available. Thus the failure of one instance has less impact and the range of most radio devices can be extended transparently.

For completeness and in case someone wants to include this or an improved variant into FHEM the diff is available from here: 93_FHEM2FHEM-avoidMSgLoop.patch (4296 downloads )

Update (08/11/2021): This approach is outdated. Better use the new loopThreshold³ parameter from now on.

Jürgen

References:
1. fhem.de
2. forum.fhem.de
3. forum.fhem.de

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Modular Linux kernel for the Gemini PDA with FOTA5 fixes

Recently the fixes in Planet Computers over the air update found their way into the Gemini Linux kernel sources. Thus the Linux kernel binaries I have shared before are a bit outdated now. So I have decided to build another kernel from the newer kernel sources with the following configuration changes with respect to the previous version:

•Enabled CONFIG_TOUCHSCREEN_MTK_SSL_SSD20XX (touchscreen driver for newer Gemini revisions)
•Added aeon_ssd2092_fhd_dsi_solomon to CONFIG_CUSTOM_KERNEL_LCM (use the touchscreen driver)
•Enabled CONFIG_USER_NS (for lxc and snapd)
•Enabled CONFIG_OVERLAY_FS (for lxc and snapd)
•Enabled CONFIG_SQUASHFS (for lxc and snapd)
•Enabled CONFIG_SQUASHFS_XATTR (for lxc and snapd)
•Enabled CONFIG_SQUASHFS_ZLIB (for lxc and snapd)
•Enabled CONFIG_SQUASHFS_XZ (for lxc and snapd)
•Enabled CONFIG_SQUASHFS_LZO (for lxc and snapd)
•Enabled CONFIG_SQUASHFS_LZ4 (for lxc and snapd)
•Enabled CONFIG_CRYPTO_LZ4HC (for lxc and snapd)

The changes and dependencies result in this kernel configuration: gemini-3.18.41+-config.gz (4710 downloads )

For the build, again the updated kernel source the from https://github.com/gemian/gemini-linux-kernel-3.18 has been used.

Again the kernel modules for the iptables MIRROR target (will not be usable with the default iptables version on the Gemini) and frandom have been added.

Those who do not want to go through the build themselves can download my prebuild kernel from here:

Kernel Image: modules_firmware-gemini-3.18.41+.tar.gz (3588 downloads )
Modules: linux_boot-gemini-3.18.41+.img (334 downloads )

Instructions for flashing the image can be found on: support.planetcom.co.uk. Make sure to use a proper scatter file, in example the one that has been used for the initial flashing. Using the Download only mode of the flash tool is sufficient. Uncheck all partitions but boot (or boot1 or boot2, depending on your boot order). For the boot partition respectively the boot1 or boot2 partition select the downloaded kernel image.

Alternatively you can flash the kernel using dd:

dd if=linux_boot-gemini-3.18.41+.img of=/dev/block/disk/by-partlabel/boot

If Linux is not your primary operating system on the Gemini use boot1 or boot2 instead, depending on your partition layout.

After flashing, copy the modules archive onto your Gemini and extract it in your root directory:

cd /
tar -xzf /path_to/modules_firmware-gemini-3.18.41+.tar.gz

After rebooting the device, it should behave somewhat more stable than it did before.

Regards
Jürgen

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Using the auto power on feature with the NVIDIA Jetson TX2 development kit

There has been a discussion about enabling the auto power on feature of the Jetson TX2 development kit on devtalk.nvidia.com. The solutions discussed there involved using a additional micro controller or soldering directly on the quite expensive board which is not desired by quite some users. This article will show a fairly simple and quite safe method to use the auto power on feature without additional circuitry or soldering directly on the board.

According to the Developer Kit Carrier Board Specification the auto power on feature can be enabled by shorting the CHARGR_PRSNT pin (pin 1) of the charge Charge Control Receptacle (J27) to ground (pin 5). This is fairly hard to achieve without having the appropriate connector or soldering the board itself. Since the pins 2-4 also are input pins it is safe to short all these pins (1-4)  to ground. This can easily be achieved by using a small piece of a copper plated circuit board matching the receptacles dimensions.

The piece of circuit board has to be cut and grinded to proper dimensions. A board of approximately 6mm x 8mm x1 mm size is fine. Afterwards the copper plating has to be grinded off in the area that can get contact with any other pin than the five mentioned pins. It is advisable to check this with a Multimeter while moving the board left and right in the receptable before attaching power. If you damage your board due to this procedure, you are the only one responsible. The resulting board is being shown below.

The circuit board.

The completed circuit board.

This board turned out to be a bit to thin to ensure contact, thus a bit of soldering tin has been applied to the copper plating to ensure the contact between the pins. The tiny board can now be inserted into the Charge Control Receptacle

Jetson TX2 with auto-power-on

Jetson TX2 Development board with applied board for auto-power-on

With the crafted piece of circuit board inserted into the Charge Control Receptacle the Jetson TX2 now boots directly after applying power. This has been tested with two different development boardw. For the older board (Revision B04, SATA port facing up) it worked, but it did not work for the newer (Revision C02, SATA port facing to the side) one. So your mileage might vary.

Jürgen

References:
1 NVIDIA development forums
2 JetsonTX1 TX2 Developer Kit Carrier Board Specification p. 31
3 how-to-find-carrier-board-version

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Another improved modular Linux kernel for the Gemini PDA

The time has come for another modular linux kernel for the Gemini PDA. The linux kernel binaries I have shared before were lacking proper USB pendrive support. Whenever a drive got connected it froze and the device begun behaving strange, in example it has been impossible to open applications afterwards. Furthermore, in the meanwhile the Geminis keyboard ghosting issue got fixed in the updated kernel sources. Thus I have decided to build another kernel with the following changes:

•Enabled modules for more USB devices
•Enabled FB_UDL and DRM_UDL (for displaylink devices)
•Disabled SCSI_MQ_DEFAULT (for getting USB pendrives working again)

The changes and dependencies result in this kernel configuration: gemini-3.18.41+-config.gz (4102 downloads )

For the build, again the updated kernel source the from https://github.com/gemian/gemini-linux-kernel-3.18 has been used.

Again the kernel modules for the iptables MIRROR target (will not be usable with the default iptables version on the Gemini) and frandom have been added.

Those who do not want to go through the build themselves can download my prebuild kernel from here:

Kernel Image: modules_firmware-gemini-3.18.41+.tar.gz (3427 downloads )
Modules: linux_boot-gemini-3.18.41+.img (451 downloads )

Instructions for flashing the image can be found on: support.planetcom.co.uk. Make sure to use a proper scatter file, in example the one that has been used for the initial flashing. Using the Download only mode of the flash tool is sufficient. Uncheck all partitions but linux_boot (or boot if you boot into linux as default). For the linux_boot respectively the boot partition select the downloaded kernel image. With newer scatter files the boot partition names have changed to boot, boot1 and boot2. Select the appropriate  one for your Gemini.

Alternatively you can flash the kernel using dd:

dd if=linux_boot-gemini-3.18.41+.img of=/dev/block/disk/by-partlabel/boot

If Linux is not your primary operating system on the Gemini use boot1 or boot2 instead, depending on your partition layout.

After flashing, copy the modules archive onto your Gemini and extract it in your root directory:

cd /
tar -xzf /path_to/modules_firmware-gemini-3.18.41+.tar.gz

After rebooting the device, USB pendrives and other SCSI like devices like HDDs and DVD drives/burners should work again when attached to the Geminis USB ports.

Regards
Jürgen

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Improved modular Linux kernel for the Gemini PDA

The linux kernel binary I have shared in the article Modular Linux kernel for the Gemini PDA turned out to lack some important features, like not supporting the ethernet port of the Planet Computers USB hub. Thus a second version of the kernel had to be built.

In addition to the original changes, the following changes to the kernel configuration have been performed:

•Enabled modules for more USB devices
•Disabled CONFIG_MTK_CPU_HOTPLUG_DEBUG_0 (for less pollution in dmesg)
•Disabled CONFIG_MTK_CPU_HOTPLUG_DEBUG_3 (for less pollution in dmesg)
•Enabled  CONFIG_RCU_FAST_NO_HZ (for improved energy efficiency)
•Enabled CONFIG_RCU_BOOST (for better performance)

Originally I intended to also disable CONFIG_MTK_CPU_HOTPLUG_DEBUG_2, but then the build fails with an error regarding a static struct declaration.

The changes result in this kernel configuration: gemini-3.18.41+-config.gz (4622 downloads )

For the build, the updated kernel source the from https://github.com/gemian/gemini-linux-kernel-3.18 with the fix for the Bluetooth vulnerability cve-2017-1000251 has been used.

Again the kernel modules for the iptables MIRROR target (will not be usable with the default iptables version on the Gemini) and frandom have been added.

Those who do not want to go through the build themselves can download my prebuild kernel from here:

Kernel Image: linux_boot-gemini-3.18.41+.img (464 downloads )
Modules: modules_firmware-gemini-3.18.41+.tar.gz (3240 downloads )

Downloads outdated, new version at: Another improved modular Linux kernel for the Gemini PDA

Instructions for flashing the image can be found on: support.planetcom.co.uk. Make sure to use the same scatter file that has been used for the initial flashing. Using the Download only mode of the flash tool is sufficient. Uncheck all partitions but linux_boot (or boot if you boot into linux as default). For the linux_boot respectively the boot partition select the downloaded kernel image. With newer scatter files the boot partition names have changed to boot, boot1 and boot2. Select the appropiate  one for your Gemini.

Alternatively you can flash the kernel using dd:

dd if=linux_boot-gemini-3.18.41+.img of=/dev/block/disk/by-partlabel/boot

If Linux is not your primary operating system on the Gemini use boot1 or boot2 instead, depending on your partition layout.

After flashing, copy the modules archive onto your Gemini and extract it in your root directory:

cd /
tar -xzf /path_to/modules_firmware-gemini-3.18.41+.tar.gz

After rebooting the device some more USB peripherals, including the ethernet port of the Planet Computers hub, should work.

Regards
Jürgen

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Micro SD card performance with the Gemini PDA

Recently, when writing the article Some first tests with the Gemini PDA, I have noticed the ridiculous slow micro SD card I/O performance with Android. Because of this, later on, I did some further testing with Debian installed on the Gemini. After booting the device, the micro SD card read speed looks good, but after having the device suspended (i.e. closing the lid) the speed drops to about 20 MB/sec, which is consistent with the result of the Android test. So most  probably this also has been after a suspend. To pinpoint the problem a bit more, a more extensive test setup has been carried out.

Test setup

For this performance test the common tool hdparm has been used. On Debian based systems it can be installed from a root shell:

root@gemini:/home/gemini# apt-get install hdparm

Its usage for the test is quite simple:

root@gemini:/home/gemini# hdparm -t /dev/mmcblk1 

/dev/mmcblk1:
 Timing buffered disk reads:  62 MB in  3.05 seconds =  20.34 MB/sec

To make sure that the problem is not limited to the SD card that has been tried out initially, the test has been carried out with four different cards:

•SanDisk Ultra 200GB microSDXC Speicherkarte, Class 10, U1, A1
•Samsung EVO Plus Micro SDXC 128GB, Class 10, U3
•Samsung EVO MicroSDHC 64GB, UHS-I, Grade 1, Class 10
•SanDisk Ultra microSDXC 64GB, UHS-I, Class 10

The four tested cards are being shown in the photo below.

Tested Micro SD cards

Micro SD cards tested with the Gemini, from the left Sandisk Ultra 200GB, Samsung EVO Plus 128GB, Samsung EVO 64GB, Sandisk Ultra 64GB

For each card the read speed has been measured directly after startup and after closing the lid and reopening it. To ensure not to use fake or broken SD cards, all the cards also have been tested using a laptop with Gentoo Linux and a USB 3 card reader (Transcend TS-RDF8K). These speeds then can be compared to the results with the Gemini.

Results

The following table shows the results of the test as well as the “official” speed rating of the cards.

SanDisk Ultra 200GBSamsung EVO Plus 128GBSamsung EVO 64GBSanDisk Ultra 64GB
after boot58.5 MB/s39.0 MB/s34.3 MB/s30.4 MB/s
after resume19.8 MB/s13.1 MB/s19.3 MB/s19.2 MB/s
with PC84.4 MB/s68.3 MB/s44.7 MB/s35.8 MB/s
rated speed100 MB/s100 MB/s48 MB/s30 MB/s

The measured speed of the two older 64GB cards is quite close to the rated speed, but the performance of the two 100MB/sec rated cards is far too low. Especially the results for the 128GB Samsung EVO are catastrophic. With the Gemini these cards operate at 57% respectively 69% of the speed  measured with the laptop. After suspending the Gemini the read speed of all cards drops below 20 MB/sec. The initial higher speed can only be achieved by rebooting the device. The results with the cards inserted into an external card reader attached to a laptop show that the cards generally are in a good working condition.

Conclusion

The test shows, that there is a performance issue with the Gemini PDA and micro SD cards. The higher rated cards operate far below their capabilities. For all the cards, the speed drops below 20 MB/sec after a suspend cycle. Thus, most probably there is a bug inside the Mediatek driver for the SD card reader, that prevents the cards from operating at high speed after a suspend cycle.  Also it might be possible to optimize the driver for newer cards. Hopefully these issues get resolved when the Gemini gets Android Oreo and a 4.X Linux kernel with it.

Jürgen

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Modular Linux kernel for the Gemini PDA

For the Debian Technology Preview image for the Gemini PDA a monolithic kernel has been used. In order to get as many peripherals as possible working a modular kernel is necessary. So I decided to build a custom kernel.

Since the suspend on lid close feature only works with the community kernel, the kernel source from https://github.com/gemian/gemini-linux-kernel-3.18 has been used. After cloning I have followed the instructions on https://github.com/gemian/gemini-keyboard-apps/wiki/KernelCompilation. During kernel configuration I have changed the following options:

•Enabled kernel modules
•Enabled modules for nearly all USB devices
•Enabled modules for nearly all filesystems
•Enabled modules for nearly all encryptions/hashes/compressions
•Enabled multiple options for iptables

Disabled ANDROID_PARANOID_NETWORK (for not having to add the user for every network service to the groups aid_inet_raw and aid_inet)
•Enabled CONFIG_JUMP_LABEL (for better performance)
•Enabled CONFIG_TASK_IO_ACCOUNTING (for using iotop)

This results in this kernel configuration: gemini-3.18.41+-config.gz (4517 downloads )

After building the kernel modules for the iptables MIRROR target (will not be usable with the default iptables version on the Gemini) and frandom have been added.

Those who do not want to go through this themselves can download my kernel from here:

Kernel Image: linux_boot-gemini-3.18.41+.img (510 downloads )
Modules: modules_firmware-gemini-3.18.41+.tar.gz (3032 downloads )

Downloads outdated, new version at: Improved modular Linux kernel for the Gemini PDA

Instructions for flashing the image can be found on: support.planetcom.co.uk. Make sure to use the same scatter file that has been used for the initial flashing. Using the Download only mode of the flash tool is sufficient. Uncheck all partitions but linux_boot (or boot if you boot into linux as default). For the linux_boot respectively the boot partition select the downloaded kernel image. After flashing, copy the modules archive onto your Gemini and extract it in your root directory:

cd /
tar -xzf /path_to/modules_firmware-gemini-3.18.41+.tar.gz

After rebooting the device should feel a bit smoother and many USB peripherals should work.

Regards
Jürgen

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

siteinfo

Translator