NuttX RTOS is now Apache TLP

My favorite NuttX RTOS [1] that is “Tiny Unix on MCU” has graduated to Apache Top-Level-Project [2], congratulations! :-)

Apache NuttX [1] is a real-time operating system (RTOS) that emphasizes standards compliance and small footprint, usable in all but the tightest micro-controller environments. It runs on 8-bit, 16-bit, 32-bit, and 64-bit microcontrollers across RISC-V, ARM, MIPS, ESP32, AVR, x86, and other architectures with a high degree of standards compliance. NuttX is used to power the Fitbit fitness tracker, as well as satellites, IoT devices, bluetooth headphones, drones, and more.

What I like most in NuttX is the development team / community.. and scalability starting upwards from 8-bit CPU’s. One day I wish porting NuttX to my 8-bit Atari and 16-bit Amiga and Atari ST and push new life to these amazing machines :-)

[1] https://nuttx.apache.org
[2] https://news.apache.org/foundation/entry/the-apache-software-foundation-announces-apache-nuttx-as-a-top-level-project

FreeBSD + Zephyr RTOS + ESP32

FreeBSD can natively emulate Linux ELF binaries. You can now bootstrap Linux espressif xtensa toolchain for ESP32 on FreeBSD under The Zephyr Project with west espressif install :-)
https://github.com/espressif/esp-idf/pull/7226#event-5064755416

ZEPHYR RTOS ROX!

If you never heard about Free-and-Open-Source ZEPHYR RTOS [1] (Apache 2.0 licensed) then it will make your day as the best platform out there for your new embedded electronics design :-) It works on anything.. even on Open-Source-Hardware RISC-V CPU [2] :-)

[1] https://zephyrproject.org/
[2] https://riscv.org/

Make PDF small with GS

With this trick you can make your PDF smaller even 10x with no noticable picture quality loss :-)

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dBATCH  -dQUIET -dDownsampleColorImages=true -dColorImageResolution=200 -dColorImageDownsampleType=/Bicubic -sOutputFile=output.pdf input.pdf

Xilinx USB JTAG Platform Cable Vivado Linux

If you work with Xilnx Vivado Design Suite [1] for FPGA development using USB JTAG interface such as Xilinx USB Platform Cable [2] or its cheaper clone from WaveShare [3], everything seems to be connected properly, but it cannot find the Target for programming, you probably need to perform drivers setup manually [4]. Error message looks like this:

ERROR: [Labtoolstcl 44-494] There is no active target available for server at localhost.
Targets(s) ", jsn3" may be locked by another hw_server.

Error message may indicate that another instance of hw_server is running in the background but that is not the case. Check your drivers first [4]. Some hints:

  • Run as root and be careful as this will modify your OS.
  • Install script location is Vivado/2020.2/data/xicom/cable_drivers/lin64/install_script/install_drivers.
  • Platform Cable USB interface is pcusb.
  • Make sure UDEV rules are installed in /etc/udev/rules.d/ (i.e. 52-xilinx-pcusb.rules file).
  • After drivers are set up remember to restart UDEV with service udev restart command and re-attach your USB JTAG cable.

[1] https://www.xilinx.com/products/design-tools/vivado.html
[2] https://www.xilinx.com/products/boards-and-kits/hw-usb-ii-g.html
[3] https://www.waveshare.com/platform-cable-usb.htm
[4] https://www.xilinx.com/support/answers/54381.html

Why Linux Sux?

Imagine you have a disk full of your precious data that you want to mount to a new Ubuntu Linux system and add user to match the existing home directory.

# adduser user
Adding user `user' ...
Adding new group `user' (1000) ...
Adding new user `user' (1000) with group `user' ...
Creating home directory `/home/user' ...
Stopped: Couldn't create home directory `/home/user': File exists.

Removing directory `/home/user' ...
Removing user `user' ...
Removing group `user' ...
groupdel: group 'user' does not exist
adduser: `groupdel user' returned error code 6. Exiting.

Now you can say your all precious data goodbye. No questions asked. Core Linux utility adduser just found your existing data and erased them without even asking. The years is 2021 (30 years since Linux was created).

This is why for over 15 years I am only working with BSD Operating Systems [1] [2] [3] [4]. Its Open-Source with long-term maintenance and self-compatibility in mind.  BSD license is even more liberal than GPL for your products [5]. You should try BSD too :-)

[1] https://www.freebsd.org/
[2] https://www.openbsd.org/
[3] https://netbsd.org/
[4] https://www.dragonflybsd.org/
[5] https://en.wikipedia.org/wiki/List_of_products_based_on_FreeBSD

Synaptics TouchPad on Panasonic CF-MX4

This wulf7 [1] is a really nice guy that helped me run full featured Synaptics TouchPad with FreeBSD on Panasonic Toughbook CF-MX4 [2][3]. Now it works for moused and libinput with all multitouch gestures like two or three finger scroll, scale, etc! The problem was in detection mechanism as device is connected over multiplexer with both PS/2 and SMBus but multitouch works only over SMBus. Although fix requires change and rebuild of FreeBSD Kernel I hope it gets quickly to the upstream [4]. I had a chance to exercise building whole FreeBSD distribution into the USB memstick image, so I could test driver fix on a target computer without even touching its hard drive contents :-)

/* psm has a special support for GenMouse + SynTouchpad combination */
if (active_ports_count >= 2) {
    for (port = 0; port < KBDC_AUX_MUX_NUM_PORTS; port++) {

That 2 above had to be changed into 1 in /usr/src/sys/dev/atkbdc/psm.c. Nice? That’s what I call a one-bit-fix :-)

In addition, when you work with Synaptics Touchpad in Xorg and you want to use its all features like tap-to-click, natural (swapped) two finger scroll, two and three finger gestures, don’t use moused,xmodmap, or xinput as this will produce inconsistent behavior in applications based on different toolkits (i.e. GTK will scroll up while Qt will scroll down etc), instead use the new way of input based on libinput and modify MatchIsTouchpad section of /usr/local/share/X11/xorg.conf.d/40-libinput.conf like:

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event5"
        Option "NaturalScrolling" "on"
        Option "Tapping" "on"
        Option "ClickMethod" "clickfinger"
        Driver "libinput"
EndSection

[1] https://github.com/wulf7/iichid
[2] https://github.com/wulf7/iichid/issues/51
[3] https://github.com/wulf7/iichid/issues/53
[4] https://reviews.freebsd.org/D28502

Disable Comments in WordPress

You can disable comments for existing posts using Bulk Edit, but this is not possible for existing media files. You can do both with a single SQL command :

UPDATE wp_your_table_with_posts SET comment_status = 'closed';

You can disable comments for all new posts either by hand as administrator unchecking Settings / Discussion / Allow people to submit comments on new posts, or using SQL command:

UPDATE wp_your_table_with_options SET option_value = NULL WHERE option_name = 'default_comment_status';

LimeSuite on FreeBSD

I have ported LimeSuite [1] to FreeBSD [2]. You can now work with LimeSDR [3] / LimeSDR-Mini [4] and others on my favourite OS. Please visit MyriadRF [5] for various radio inspirations. Have fun! :-)

[1] https://github.com/myriadrf/LimeSuite
[2] https://www.freebsd.org/
[3] https://limemicro.com/products/boards/limesdr/
[4] https://limemicro.com/products/boards/limesdr-mini/
[5] https://myriadrf.org/

Mounting external ZFS volume

If you need to perform a data recovery from an external ZFS [zfs] volume you may find those hinds helpful:

  1. Attach encrypted partition where ZFS pool resides with:
    geli attach /dev/your_device_partition
  2. Import ZFS pool at given mountpoint (/mnt/zfs):
    zpool import -af -R /mnt/zfs
  3. Modify mount point location for a given dataset that may have mountpoint set to none what marks it as no mount (note this mountpoint will append to parent mount point location):
    zfs set mountpoint=ROOT zroot/ROOT/default
  4. Mount and mount all pool datasets:
    zfs mount -a
    zfs umount -a
  5. Mount/umount given dataset:
    zfs mount zroot/ROOT/default
  6. You can verify if your ZFS pool is active with:
    zpool status
  7. You can see what ZFS datasets are available with mount points with:
    zfs list

[zfs] https://www.freebsd.org/doc/handbook/zfs.html

ZFS on SSD CAM/CRC errors

If you encounter lots of CAM/CRC errors when using encrypted ZFS on some SSD drives on FreeBSD, that is caused by TRIM. You need to disable it in boot loader prompt or add below line to /boot/loader.conf:

vfs.zfs.trim.enabled=0

netsh winsock reset

If you encounter any strange network related behavior on a windows based pc, especially after windows update, use this to resolve most of the problems and save some time, remember to reboot pc afterwards ;-)

netsh winsock reset

macOS Virtual Audio SoundFlower Loopback

SoundFlower [1] is amazing Free and Open-Source extension to macOS BSD that allows you to create Virtual Audio Device in order to Route and Record Applications Audio. This is especially important for activities like Online Streaming and Presentation/Lectures Recording.

If you need more advanced Audio Routing with a nice GUI and lots of options try Loopback [2] from RogueAmoeba [3].

Thank you for this amazing fork and keeping it Open-Source! :-)

[1] https://github.com/mattingalls/Soundflower
[2] https://rogueamoeba.com
[3] https://rogueamoeba.com/loopback

GRUB Remember Last Boot Choice

If you want GRUB to remember your last choice add:

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
to /etc/default/grub and run sudo update-grub to apply new configuration.

Blender Player Python

If you encounter a problem with running Python [python] scripts on a “bare” Blender Player [blender], make sure that both PYTHONHOME and PYTHONPATH are set correctly to match your needs. You can also use native Blender python with a simple shell script:

#!/bin/sh
export PYTHONHOME="/path/to/blender/python/"
export PYTHONPATH=$PYTHONHOME"/bin"
/path/to/your/blenderplayer $@

[python] https://www.python.org/
[blender] https://www.blender.org/

Apple macOS 10.13 High Sierra Fail

Guys at Apple are either stoned or really working hard to make macOS as bad as Windows. macOS High Sierra (10.13) was probably designed by people that were really “high”. They removed TELNET utility that is second most valuable network testing utility after PING. Except for noticeable performance degradation glitches during video modeswitch and other failures macOS really gets close to Windows in its poor design decisions and obvious quality degradation for professional applications.. now I will hardly consider buying another overpriced MacMookPro..

fastboot too old problem

If you want to perform stock factory flashing of a Nexus device and you encounter “fastboot too old” error message, that means you need to update your local fastboot application to a newer version. One additional word would make this interesting error message self-explanatory..

Added GOBI2000 support to FreeBSD U3G

I have added support for Panasonic ToughBook CF-F9 U3G GOBI2000 to FreeBSD U3G kernel module [1]. I have added firmware for Panasonic CF-F9 and HP EliteBook 2740p along with gobi_loader updates [2] that are required for 3G modems to work.

At first U3G module will create /dev/cuaU0 interface for QDL firmware load, then after successful firmware load device will reload itself to a modem mode and U3G module will provide additional /dev/cuaU0.* nodes for operations (/dev/cuaU0.2 is the AT command intarface).

In order for this modem to work on FreeBSD you also need to tune some configutation files:

  • /etc/devd.conf:
    attach 100 {
     match "vendor" "0x04da";  #adjust your device VID
     match "product" "0x250e"; #adjust your device PID
     action "/usr/local/sbin/gobi_loader -2000 /dev/cuaU0 /boot/firmware/gobi/";
    };
    
  • /etc/ppp/ppp.conf:
    default:
     set log Phase Chat LCP IPCP CCP tun command
     ident user-ppp VERSION
     set device /dev/cuaU0.2
     set phone *99\#
     set redial 5 10
     set speed 115200
     set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \
               \"\" AT AT-OK-AT ATH OK ATZ OK ATE1Q0 OK \
               AT+CFUN=1 OK-AT-OK \
               AT+CPIN? READY-AT+CPIN=\"YOUR_PIN_HERE\"-OK \
               AT+CGDCONT=1,\\\"ip\\\",\\\"internet\\\" OK \
               \\dATDT\\T TIMEOUT 40 CONNECT"
     set timeout 20
     enable dns
     set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.255 0.0.0.0
     add default HISADDR
    

You now should be able to use your 3G modem connection with ppp -ddial, after you add your local user to the dialer group with pw groupmod dialer -m your_user_name. Remember to have U3G compiled in. Enjoy the Internets! :-)

[1] https://github.com/freebsd/freebsd/pull/115
[2] https://github.com/cederom/gobi_loader

Python Matplotlib macOS backend

Matplotlib is a nice Matlab-like environment for Python. If you encounter a backend related problem while using Matplotlib [1] on a Python Virtualenv [2], then you need to explicitly select one (i.e. backend : Qt5Agg) in a ~/.config/matplotlib/matplotlibrc (or directly in a matplotlib file located in current working directory) configuration file. Then remember to use modern interpreter and meet dependencies requirements. Example below:

$ mkdir ~/.matplotlib
$ echo "backend : Qt5Agg" >> ~/.config/matplotlib/matplotlibrc
$ echo "backend : Qt5Agg" >> matplotlibrc
$ python3.6 -m venv venv-mac-36
$ source venv-mac-36/bin/activate
$ which python
$ pip install matplotlib pyqt5

Now you can use Matplotlib inside created Python Virtualenv (assuming you had Python 3.6 and Qt5 [3] already installed on your system). Other backends are: TKAgg, GTKAgg, Qt4Agg, Qt5Agg, WXAgg [4].

[1] https://matplotlib.org/
[2] https://www.python.org/
[3] https://www.qt.io/
[4] https://matplotlib.org/faq/usage_faq.html

ARM mbed OS DAPLink pyOCD

It is my great honor to join Free-and-Open-Source ARM mbed [1] development team! :-)

[1] https://www.mbed.com

JTAGulator

I just did a self-assembly of JTAGulator. This simple and amazing device indeed works and shortens JTAG pinout search from days to seconds. AMAZING! I have some spare devices to sale cheap in EU, if you want one let me know! :-)

JTAGulator is an open source hardware tool, created by Joe Grand / Grand Idea Studio, that assists in identifying OCD connections from test points, vias, or component pads on a target device. All you need is a target device, bunch of tap wires / cables, USB-Mini cable, and serial terminal to operate JTAGulator.



On-chip debug (OCD) interfaces can provide chip-level control of a target device and are a primary vector used by engineers, researchers, and hackers to extract program code or data, modify memory contents, or affect device operation on-the-fly. Depending on the complexity of the target device, manually locating available OCD connections can be a difficult and time consuming task, sometimes requiring physical destruction or modification of the device.

FreeBSD PXE Network Install

Sometimes you need to perform a network installation (i.e. when no USB or DVD drive is allowed to boot, but you can boot PXE). In case of FreeBSD you can use DNSMASQ to serve the DHCP that will assign the initial client address and configuration along with PXE boot image served over tFTP. At this point you will have bootloader running, so you can serve filesystem over NFS to obtain working environment and/or the installer..

  • Create a directory that will hold the target filesystem over network. In my case that was
    /usr/local/tftp/FreeBSD
  • Put OS/Installer files inside above directory
    cd /usr/local/tftp/FreeBSD
    wget http://(..)/file.iso
    7z x file.iso
  • Edit /etc/exports to export the filesystem over NFS
    /usr/local/tftp/FreeBSD -ro -alldirs -network 192.168.0.0
  • Install the dnsmasq
    pkg install dnsmasq
  • Setup the /usr/local/etc/dnsmasq.conf
    enable-tftp
    tftp-root=/usr/local/tftp/FreeBSD
    
    dhcp-range=192.168.0.50,192.168.0.60,255.255.255.0,1h
    dhcp-boot=boot/pxeboot
    dhcp-option=option:router,
    dhcp-option=option:root-path,/usr/local/tftp/FreeBSD
    
  • Restart services
    service nfsd onerestart
    service dnsmasq onerestart
  • In case you get bootloader running but troubles with NFS make sure that mountd is running. Also you can see who is using the NFS shares with
    showmount -a

PXE Boot always use initial DHCP/tFTP to fetch configuration and bootloader, so the first stage is similar and should work with other Operating Systems and Bootloaders as well, the rest is up to bootloader itself..

LibSWD-0.7 RELEASE

It is my great pleasure to inform you folks that, almost after four years, I did a new release of LibSWD-0.7 [1], a low-level embedded systems access open framework. Special thanks goes to Andrew Parlane of Carallon Ltd [2] for his much appreciated contributions! Well now I feel like I need to invent some nice small device based on ARM Cortex-M0 CPU :-)

[1] https://github.com/cederom/LibSWD
[2] http://www.carallon.com/

PIP and Python Modules inside Blender

If you want to install additional Python [1] modules inside your Blender [2] environment, you can install PIP using this recommended script [3], then use PIP to install all modules that you want. Note Blender’s Python Virtualenv location is /path_to_blender/blender_version/python/bin/python and you need to use this particular interpreter to launch the script.

[1] https://www.python.org/
[2] https://www.blender.org/
[3] https://pip.pypa.io/en/stable/installing/

MacPorts Python 3.6.0 and NumPy/SciPy import bug

Python 3.6.0 NumPy and SciPy from MacPorts crash on import bug [1].
[1] https://trac.macports.org/ticket/53453

Google Books Text-To-Speech

Google have implemented my idea to make Google Books TTS work like an audio player – it can now work in background and being controlled with bluetooth headset – so I can play, pause and rewind paragraphs of the book read by speech synthesizer just as it was music. This is soo fantastic!!

I have been proposing this solution to Amazon to implement in Kindle for Android, but for years they did not listen. I have switched to Kindle application after Amazon bricked my Kindle3 3G reader with a software update (and all other devices worldwide). Now I just wait until Google Books allow to import my Kindle library, and I will never go back to Kindle. Greedy loses twice.

OrangeADE: Orange Autonomous Device Evaluation

I have recently started the OrangeADE project [1], that is Orange Autonomous Device Evaluation, an online platform to evaluate security level of network equipment and verify against known vulnerabilities. OrangeADE is released as Open-Source under the “new” 3-Clause BSD license. Enjoy the work in progress! :-)

[1] https://github.com/CeDeROM/OrangeADE

Is Blend4Web a Blender Game Engine replacement?

You just need to see this awsome Mars Curiosity [1] simuluator [2] made by NASAJPL [3] with Blender3D [4] Blend4Web [5] HTML5 [6] WebGL [7] Free and Open-Source Software :-)

Screen Shot 2017-01-15 at 15.25.15

[1] https://www.nasa.gov/mission_pages/msl
[2] https://eyes.nasa.gov/curiosity
[3] http://www.jpl.nasa.gov
[4] https://www.blender.org
[5] https://www.blend4web.com
[6] https://www.w3.org/TR/html5
[7] https://www.khronos.org/webgl

Blender 3D and DS4 PS4 Bluetooth controller

Blender 3D can work with DualShock4 Playstation4 wireless controller over Bluetooth [1].

[1] http://www.blendswap.com/blends/view/78315

FreeBSD Synaptics Trackpad/Touchpad

Use advanced features of your Synaptics Trackpad on a laptop running FreeBSD [1] with:

  • set in /boot/loader.conf:
    hw.psm.synaptics_support="1"
  • set in /etc/rc.conf:
    moused_enable="YES"
  • set in /etc/X11/xorg.conf:
    Section "InputDevice"
        Identifier      "Mouse0"
        Driver          "mouse"
        Option          "Protocol"      "auto"
        Option          "Device"        "/dev/sysmouse"
        Option          "ZAxisMapping"  "4 5 6 7"
    EndSection

If you want to have “MacBook” like two-finger scrolling along with other parameters you can set in /etc/sysctl.conf:

hw.psm.synaptics.min_pressure=16
hw.psm.synaptics.max_pressure=220
hw.psm.synaptics.max_width=10

hw.psm.synaptics.vscroll_hor_area=1300
hw.psm.synaptics.vscroll_ver_area=-600
hw.psm.synaptics.vscroll_min_delta=50
hw.psm.synaptics.vscroll_div_min=100
hw.psm.synaptics.vscroll_div_max=150

hw.psm.synaptics.weight_current=3
hw.psm.synaptics.weight_previous=6
hw.psm.synaptics.weight_previous_na=20
hw.psm.synaptics.weight_len_squared=2000

hw.psm.synaptics.div_min=9
hw.psm.synaptics.div_max=17
hw.psm.synaptics.div_max_na=30
hw.psm.synaptics.div_len=100

hw.psm.synaptics.margin_top=200
hw.psm.synaptics.margin_right=200
hw.psm.synaptics.margin_bottom=200
hw.psm.synaptics.margin_left=200

hw.psm.synaptics.window_min=4
hw.psm.synaptics.window_max=10
hw.psm.synaptics.multiplicator=10000

[1] https://wiki.freebsd.org/SynapticsTouchpad

FreeBSD NTFS FUSE FSTAB

If you want to use NTFS volumes on FreeBSD [1], you need to use FUSE infrastructure andNTFS-3G [2] port. Syntax of fstab is a bit differen in this case:

/dev/ntfs_partition /mnt/ntfs_mounpoint fuse rw,locale=pl_PL.UTF8,mountprog=/usr/local/bin/ntfs-3g 0 0

Also remember to put fuse_load=”YES” in /boot/loader.conf and install the sysutils/fusefs-ntfs port. Do not use hibernated volumes.

[1] https://www.freebsd.org
[2] https://www.freshports.org/sysutils/fusefs-ntfs

FreeBSD on a Hybrid Graphics Laptop

If you happen to get a nice laptop with a powerful graphics card, such as polish HYPERBOOK SL502VR [1], it is highly probable that you will use UEFI boot mode. In that case you need to use SCFB [2] driver instead of VESA. Use the xf86-video-scfb package to get Xorg running.

Hybrid Graphics at first used MUX device that did a LCD connect to a selected video card on boot. Nowadays both cards use common Video Framebuffer [3] to draw over a screen. The simple video card (Intel in my case) is always active, while the more powerful and power consuming video card is started on-demand (nVidia in my case). This however requires a dedicated DMA BUF implementation, which is not yet available on FreeBSD, so none of the cards can see any monitor connected, resulting in “No Screens Found Error” from Xorg.

I have already reported a bug/feature request to nVidia. Also developers of FreeBSD are working on the Hybrid Graphics implementation.

[1] http://sklep.hyperbook.pl/hyperbook-sl502-vr-p651rp6g-gtx-1060-p-25965.html
[2] https://wiki.freebsd.org/Graphics/SCFB
[3] https://en.wikipedia.org/wiki/Framebuffer