How to Install Tasmota on Shelly 1 from Linux

This guide will show you how to flash Tasmota firmware onto a Shelly 1 device using Linux. You will use the PlatformIO toolchain to communicate with the device, erase the existing firmware, and install the Tasmota firmware via serial communication. After flashing, you’ll configure the device to connect to your Wi-Fi and MQTT broker.

Prerequisites

  1. Linux PC
  2. Shelly 1 device
  3. USB to Serial adapter (e.g., FTDI adapter)
  4. Jumper wires to connect the Shelly 1 to the USB-to-serial adapter
  5. Tasmota binary downloaded to your local machine

Make sure that PlatformIO and Python 3 are installed on your system.

Step 1: Install PlatformIO

If you don’t already have PlatformIO installed, you can install it via Python’s package manager pip:

pip install platformio

This installs the platformio command-line interface (CLI), which will be used to flash the firmware onto the Shelly 1.

Step 2: Connect Shelly 1 to Your Linux PC

  1. Disconnect Shelly 1 from mains power to avoid electric shock.
  2. Connect the TX, RX, GND, and VCC pins of the Shelly 1 to the corresponding pins of your USB-to-serial adapter (TX->RX, RX->TX, GND->GND, VCC->3.3V).
  3. Plug the USB-to-serial adapter into your Linux PC.

Step 3: Test Communication with the Device

Before proceeding with the flashing, test whether your Linux PC can communicate with the Shelly 1 via serial.

Run the following command to check communication (replace /dev/ttyUSB0 with your actual serial device if needed):

python3 ./.platformio/packages/tool-esptoolpy/esptool.py -p /dev/ttyUSB0 flash_id

If the communication is successful, you should see information about the connected ESP8266 chip inside the Shelly 1.

Step 4: Erase the Flash Memory

Next, you need to erase the existing firmware on the device to ensure a clean installation of Tasmota. To erase the flash memory, run the following command:

python3 ./.platformio/packages/tool-esptoolpy/esptool.py -p /dev/ttyUSB0 erase_flash

This process clears the current firmware from the Shelly 1.

Step 5: Flash Tasmota Firmware

Once the flash memory is erased, you can now flash the Tasmota firmware onto the device. Replace the path ~/Downloads/tasmota.bin with the actual path to your downloaded Tasmota binary file:

python3 ./.platformio/packages/tool-esptoolpy/esptool.py -p /dev/ttyUSB0 write_flash -fm dout 0x0 ~/Downloads/tasmota.bin

This writes the Tasmota firmware onto the Shelly 1.

Step 6: Configure the Device via Serial

After flashing, you can configure the Shelly 1 via serial connection using picocom. If it’s not installed on your system, you can install it with:

sudo apt install picocom

To open a serial connection, run:

picocom --echo --omap crcrlf --baud 115200 /dev/ttyUSB0

Once connected, you will see the device’s output. You can now paste the following configuration string to set up Wi-Fi and MQTT parameters:

Backlog ssid1 YourSSID; password1 veryStrongWiFiPassword; MqttHost 192.168.1.200; Template {"NAME":"Shelly 1","GPIO":[1,1,0,1,224,192,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":46};

Parameters in the Configuration String:

  • ssid1: Replace YourSSID with the name of your Wi-Fi network.
  • password1: Replace veryStrongWiFiPassword with your Wi-Fi password.
  • MqttHost: Set this to the IP address of your MQTT broker (e.g., 192.168.1.200).
  • Template: This defines the GPIO pin mapping for the Shelly 1.

Step 7: Verify the Device Connection

Once the Shelly 1 reboots, it should connect to your Wi-Fi and MQTT broker based on the configuration provided. You can now control it via the MQTT interface or the Tasmota web interface.


Congratulations! You have successfully flashed and configured Tasmota on your Shelly 1 device from Linux.

Tolino Shine 3 – upgrade if you have installed TWRP

If have installed TWRP and you want to upgrate to the latest firmware using the official procedure, you have to restore the original recovery.img.

  1. shutdown the device
  2. on the pc extract recovery.img from the update.zip file which contains your current firmware.

    tolino-15.3.0$ unzip update.zip recovery.img
    
  3. on the pc run the flash command and keep it waiting

    $ fastboot flash recovery recovery.img 
    < waiting for any device >
    
  4. (enter fastboot mode) keep pressed the power up button on the device while inserting the USB cable and in about 25 seconds you should see

    Sending 'recovery' (6474 KB)                       OKAY [  0.245s]
    Writing 'recovery'                                 OKAY [  0.906s]
    Finished. Total time: 1.170s
    
  5. reboot the device and now you should be able to upgrade it with the standard procedure

Tolino Shine 3 – 15.3.0 update

Good news

The adbd binary is the same of 14.1.0:

$ md5sum tolino-1*/ramdisk/sbin/adbd
1d23e203eba05102e6cb642a117b8d64  tolino-14.1.0/ramdisk/sbin/adbd
1d23e203eba05102e6cb642a117b8d64  tolino-15.3.0/ramdisk/sbin/adbd

The direct download link for the new Shine 3 firmware is https://tolinodownload-a.akamaihd.net/ereader/15.3.0/OS44/update.zip.

As a sidenote, you can find the latest Tolino updates on the Tolino website.

Everything documented is still relevant

Compile busybox (Magisk) for Android with ndk

Credits

All the credits to topjohnwu and osm0sis.

Prerequisites

I’m working on Ubuntu 21.10, so

$ apt install git google-android-ndk-installer

Instructions

Clone the repository

git clone https://github.com/topjohnwu/ndk-box-kitchen.git

Follow the instruction, as today are

git clone https://git.busybox.net/busybox/
git clone https://github.com/SELinuxProject/selinux.git jni/selinux
git clone https://android.googlesource.com/platform/external/pcre jni/pcre

Choose the supported busybox version

cd busybox
git checkout 1_34_1
cd ..

Build

/usr/lib/android-ndk/ndk-build all

Push on a device and test

adb push ./obj/local/armeabi-v7a/busybox /data/local/tmp
adb shell chmod 775 /data/local/tmp/busybox
adb shell /data/local/tmp/busybox date
Mon Nov 21 21:08:47 CET 2021

Install as you want, for example

adb shell
cd /data/local/tmp/
mkdir xbin
cd xbin
../busybox --install .
export PATH="$(pwd):$PATH"

Restore stock firmware on the Galaxy A7 (2018) using Linux

There are always good reasons to install a stock factory ROM for a phone, I can think of some of them:

  • clean factory reset before selling the device
  • install the latest firmware
  • install another official firmware (unbrand the phone)
  • downgrade the firmware
  • unbrick the device after a failed hack

Here’s what I’ve done.

Disclaimer

This is a complete reset, all the data will be lost, make a backup if you care about your data.

I am not responsible if you brick / ruin your device in any way. Basic computer skills required. Proceed with caution. I cannot be held responsible if anything goes wrong.

Device details

Model name: Galaxy A7 (2018)
Model code: SM-A750FN

Device Wikipedia page

Prerequisites

I’m working on Ubuntu 21.10, so I’ve to install these packages

$ apt install heimdall-flash lz4

Download original firmware

You can find original firmwares from various sites, in my case, I downloaded A750FNXXU5CUH2_A750FNOXM5CUH2_ITV.zip from https://www.sammobile.com/samsung/galaxy-a7-2018/firmware/#SM-A750FN. I had to create an account, so maybe there are better options.

Extract all the files from the firmware file

Explanation: the downloaded zip contains some .md5 files. They are actually .tar files, so we have to untar them (for the sake of clarity I prefer to rename them before). Each .tar contains, for the most part, .lz4 files. We have to extract the content of those files, too.

$ mkdir tmp
$ cd tmp/
$ unzip ../A750FNXXU5CUH2_A750FNOXM5CUH2_ITV.zip
$ rename 's:.md5$::' *.md5
$ for f in *.tar; do tar xf "$f" && rm "$f"; done
$ for f in *.lz4; do lz4 -d "$f" && rm -f "$f"; done

Here’s the content my folder after the extraction:

$ ls -1R
.:
A7Y18LTE_EUR_OPEN.pit
boot.img
cache.img
cm.bin
hidden.img
meta-data
modem.bin
modem_debug.bin
odm.img
omr.img
param.bin
recovery.img
sboot.bin
system.img
userdata.img
vendor.img

./meta-data:
download-list.txt
fota.zip

Boot the phone in Odin mode / Download mode

  1. shutdown the device
  2. disconnect USB cable
  3. keep pressed Volume UP and Volume DOWN
  4. connect USB cable

Start the procedure of complete firmware replacement

Test heimdall detection of the device

$ heimdall detect
Device detected

Print and store the partition table

$ heimdall download-pit --output a7.pit

(the phone will reboot and you’ll have to enter in Odin mode again. The --no-reboot argument of heimdall works, but the subsequent command will fail even if launched with --resume, so let’s reboot anyway.)

The .pit file is a binary file, but we can inspect it with the right heimdall command

$ heimdall print-pit --file a7.pit >a7.pit-decoded
$ cat a7.pit-decoded

Check if the device partition table matches the firmware’s one

$ md5sum <(heimdall print-pit --file a7.pit) <(heimdall print-pit --file A7Y18LTE_EUR_OPEN.pit)
737ea1830f953bdd7eb5297cf095592d  /dev/fd/63
737ea1830f953bdd7eb5297cf095592d  /dev/fd/62

Associate each file to the right partition to flash, as stated in the .pit file

$ for f in *; do echo -n "# $f: "; { grep -B1 "$f" a7.pit-decoded || echo "__not found__"; } | head -1; done | column -s: -t
# a7.pit                  __not found__   
# a7.pit-decoded          __not found__   
# A7Y18LTE_EUR_OPEN.pit   __not found__   
# boot.img                Partition Name   BOOT
# cache.img               Partition Name   CACHE
# cm.bin                  Partition Name   CM
# hidden.img              Partition Name   HIDDEN
# meta-data               __not found__   
# modem.bin               Partition Name   RADIO
# modem_debug.bin         Partition Name   CP_DEBUG
# odm.img                 Partition Name   ODM
# omr.img                 Partition Name   OMR
# param.bin               Partition Name   PARAM
# recovery.img            Partition Name   RECOVERY
# sboot.bin               Partition Name   BOOTLOADER
# system.img              Partition Name   SYSTEM
# userdata.img            Partition Name   USERDATA
# vendor.img              Partition Name   VENDOR

The .pit files must not be flashed, the meta-data entry in the list is a directory, so everything has a match.

With these informations we can build our flash command

$ heimdall flash --pit A7Y18LTE_EUR_OPEN.pit --BOOT boot.img --CACHE cache.img --CM cm.bin --HIDDEN hidden.img --RADIO modem.bin --CP_DEBUG modem_debug.bin --ODM odm.img --OMR omr.img --PARAM param.bin --RECOVERY recovery.img --BOOTLOADER sboot.bin --SYSTEM system.img --USERDATA userdata.img --VENDOR vendor.img

In my case it took ~3 minutes. Then the phone will reboot. The first boot will take up to ~5 minutes so don’t worry and be patient.