Skip to content

Instantly share code, notes, and snippets.

View TG9541's full-sized avatar

Thomas TG9541

View GitHub Profile
@TG9541
TG9541 / UbuntuServerLXD.md
Last active February 22, 2024 05:21
Ubuntu Server an an Futro S720 with LXD and Docker - setup notes

LXD on Futro S720, basic installation

The following notes assume a Futro S720 "thin client" with a dual core AMD GX-217GA SOC, 2GiB DDR3 RAM and the standard "2GB" MSATA SDD. There is no way to install Ubuntu 22.04 Server on the 2GB SDD (the attempt to install "Ubuntu Server minimal" resulted in a crash), I connected a 5V SATA power supply cable to pins 1 and 7 of the "2xUSB" header and installed a HDD. The 10 pin 2xUSB header, next to MSATA, has the following pinout: 1/2: 5V, 7/8: Gnd, 9:(key), 10: 3.3V.

What we have is:

  • Ubuntu Server 22.04.3 on a 4GB thumb drive
  • Normal installation on HDD
  • Disk partitioning:
    • 2GB MSATA disk partitioned as
  • /boot (auto size)
@TG9541
TG9541 / ModbusRaspberryPi.md
Last active June 8, 2023 10:25
Modbus on the Raspberry Pi

Modbus with Raspberry Pi

I'd like to use a simple Pi Zero which has but one USB interface. That's why my preference is connecting a RS485 transceiver to the GPIO header. Here is a useful picture from stackexcange (that also indicates that it's advisable to use a 3.3V compatible transceiver): Tx:GPIO14, RX:GPIO15, Transmit:GPIO23

Kontron provides a good introduction to configuring the Linux kernel for using RS485 on the Raspberri Pi, especially regarding disabling kernel console output in the kernel configuration level. The docs link to the official RasPi UART configuration docs, which refers to the BCM2835 peripherals documentation.

On most RasPis only UART0 can be used which is of the PL011 type (basically a 16550). The

@TG9541
TG9541 / GoogleScholarBookmarklet.txt
Created November 20, 2022 19:28
A bookmarklet for Google Scholar
Looks up selected text, or else opens a dialog box
Create bookmark with the below text as the URL:
javascript:T='Scholar';S='https://scholar.google.com/scholar?hl=en&as_sdt=0%2C5&btnG=&q=';Q=document.getSelection().toString().replace(/[\.\%22,;%E2%80%9D%E2%80%9C\?]/g,%22%22);if(!Q){void(Q=prompt('Search%20'+T,'-'));if(Q){if(Q=='-'){location.href='http://scholar.google.com';}else{location.href=S+escape(Q);}}}else{void(window.open(S+escape(Q),T))}
@TG9541
TG9541 / Fujitsu_s740_power.md
Last active December 10, 2023 17:11
Apply "powertop tunables" to Fujitsu Futro S740

S740 Power Settings

The S740 is based on a J4105 6th gen. Intel Core SoC ("Gemini Lake") with 10W TDP. The box runs just fine with Ubuntu 22.04 Server as an always-on box.

In order to reduce power consumption the following service applies "tunables" recommended by Intel PowerTop after while starting the system.

I followed this systemd service howto.

Manual Install

@TG9541
TG9541 / forth2020-stm8-modbus.md
Created June 25, 2022 06:00
Forth2020 User-Group 2022 #24 Talk: A Modular MODBUS Server with STM8 eForth

The talk in the Forth2020 User-Group Zoom meeting 2022 #24 about using STM8 eForth for MODBUS nodes is here on YouTube.

If you wish to replicate the demo you should clone the STM8 eForth MODBUS code on GitHub and follow the instructions there. The code below should be placed in the root folder of this cloned repository with the indicated names.

If you have questions, please either join the Forth2020 group or open a GitHub Issue in the stm8ef-modbus repository.

This the base code with the MODBUS protocol handler loaded first (save as base):

\ STM8EF-MODBUS base protocol code
 
@TG9541
TG9541 / C0135-Counter-Inputs.md
Last active May 12, 2022 19:21
Using the C0135 Relay Board Counter Inputs

Two Pulse Inputs for the C0135 "4 Relay MODBUS Board"

A friend needs a C0135 based MODBUS Node with two pulse counter inputs.

The requirements are modest:

  • provide reliabe pulse counting on two inputs
  • at a maximum frequency of about 200Hz
  • where the duty cycle isn't well known (but likely not always 50%)
  • without jamming the MODBUS server
@TG9541
TG9541 / R-on-RaspPi-Zero-W.md
Last active January 17, 2024 10:23
Using R on a Raspberry Pi Zero W

Using R on a Raspberry Pi Zero W

Using R on an embedded device might sound like a wacky thing to do but for "small scale data analytics" and for learning to analyze real-world data (e.g. using JAGS or STAN) it's a good match.

Yes, compared to a PC it's relatively slow - but consider this:

  • it runs on small power budget (maybe 0.5W when idling)
  • it has a hardware watchdog which makes it more likely that it can run for many months unattended
  • Raspbian-lite is based on Debian and it comes with all kinds of well tested tools and applications
@TG9541
TG9541 / vim-and-nvim.md
Last active September 22, 2022 04:59
VIM and NeoVIM installation notes

VIM and NeoVIM installation notes

In the context of Using R on a Raspberry Pi Zero W the following notes list the steps that were used to install vim and nvim from scratch on a Raspberry Pi Zero W. The steps should also work for PCs with a recent Debian or Ubuntu version.

I'm aware that nvim implements many features not available in vim but since nvim was designed to be coexist with vim - it can even use the same .vimrc - so why not make a common installation so that starting any of them for editing a config file works as expected.

The default .vimrv location can be used, which is ~/.vimrc (general notes on configuring vim can be found in idiomatic-vimrc).

The following ~/.vimrc settings contain the minimal vim-plug configuration for both vim and nvim:

@TG9541
TG9541 / relay8.fs
Last active May 17, 2021 19:07
modbus_relay8 board reduced duty cycle experiment with STM8 eForth (https://github.com/TG9541/stm8ef)
\ Modbus_Relay X8 V1.2 - experiment with reduced relay solenoid current
\ use STM8S Low density device, e.g. STM8S103F3P6
\res MCU: STM8S103
\res export PB_IDR PD_IDR
\res export PC_ODR PC_DDR PC_CR1
\res export PE_ODR PE_DDR PE_CR1
\res export TIM1_CR1 TIM1_IER TIM1_SR1
\res export TIM1_ARRH TIM1_CCMR3 TIM1_CCR3H
@TG9541
TG9541 / 1-Wire-Advanced.md
Created March 3, 2021 21:01
1-Wire with STM8 eForth: using CamelForth "onewire.f"

The first 1-wire low level sketch was nice - but since Brad J. Rodriguez has implemented high level code, e.g. the 0F0h "ROM Search" algorithm, for CamelForth it's maybe a better idea to re-use it!

The "onewire" source archive contains the CamelForth source file "onewire.f", MSP430 assembler code and some documentation. The assembler code implements the primitives OWRESET (reset the bus) and OWSLOT (write and read a bit).

Unlike the MSP430 files the low-level code doesn't need to be compiled into the kernel, and the configuration doesn't need to be fixed.

Here are the primitives in STM8 eForth (the words gpio.d and gpio.i carry the GPIO configuration into the code):

\ STM8 eForth "1-Wire" communication primitives