Compiling Directly From Terminal - Szybet/InkWatchy GitHub Wiki

This method is less supported. Instructions managed and written by Saiyaken-PHOENIX.

NOTE: This method is written for native Linux systems and experienced Linux users. This may or may not work directly with WSL.

NOTE: If you previously had Docker Desktop installed, prune all the config files of both it and Docker completely. Make sure Docker Desktop is NOT your default Docker application, as it will change itself to the default if installed and not set the default back on removal. Docker Desktop leftovers WILL screw things up.


1. Prerequisites

You will need to have Git, Docker, and the buildx Docker plugin properly installed. They are commonly found as distribution packages under the names git, docker and docker-buildx.

Once installed, make sure the Docker daemon is running. Most people (systemd users...) may run this command to start it:

sudo systemctl start docker.service

If you have a different init system/service manager that you don't know how to start the daemon through, you may also run the daemon directly in a shell:

sudo dockerd

NOTE: Podman works as a drop-in replacement for Docker, make sure you have both podman and podman-docker installed before attempting to compile. This is tested and confirmed to be working as of July 2024.

NOTE: Another possible necessary prerequisite, depending on your user profile permissions (or if you're using Podman instead of Docker), is also having the PlatformIO udev rules installed. If uploading to your Watchy isn't working, follow the instructions at the link.

Find a directory you would like to store the project in and run the following command to download and enter the InkWatchy project directory:

git clone https://github.com/Szybet/InkWatchy.git && cd InkWatchy

2. Setting up the build image and container

Now that we're in the project root, run the following command to create the build image:

docker buildx build resources/tools/other/compile/ --tag InkWatchy/main

With the image created, run the following command to launch a container shell:

docker run --privileged \
--mount type=bind,source=/dev/,target=/dev/,consistency=consistent \
--mount type=bind,source=$(pwd)/.platformio/,target=/root/.platformio/,consistency=consistent \
--mount type=bind,source=$(pwd)/.esp-idf/espressif/,target=/root/.espressif/,consistency=consistent \
--mount type=bind,source=$(pwd)/,target=/workspaces/InkWatchy/,consistency=consistent \
-it InkWatchy/main /bin/bash  

This should put you in an interactive shell. You should see something along the lines of root@[identifier]:~# as a prompt. You will need to be in this shell to complete the rest of the steps.

NOTE: You may type exit at any time to leave the container. When re-entering the container, go to the InkWatchy project directory and run the above command again.


3. PlatformIO configuration

We need PlatformIO installed in the container to build the project and interface with our Watchy. Run the following command to download and execute the PlatformIO automated installer:

curl -fsSL -o /tmp/ipio.py https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py && python3 /tmp/ipio.py

We also need to match the model/version of your Watchy to the corresponding build environment:

Watchy Model Command
Watchy 1 export ENVNAME=Watchy_1
Watchy 1.5 export ENVNAME=Watchy_1_5
Watchy 2 export ENVNAME=Watchy_2
Watchy 3 export ENVNAME=Watchy_3
Yatchy export ENVNAME=Yatchy

Find your Watchy model in the table and run the corresponding command. The ENVNAME variable will be used in the remaining steps to let PlatformIO know what board to build for.

NOTE: If you leave the container shell, you will have to set this variable again upon coming back.


4. Compiling InkWatchy for the first time

Enter the project workspace via the following command:

cd /workspaces/InkWatchy

And run the following command:

PLATFORMIO_ENV_NAME=$ENVNAME ./resources/tools/other/tasks/taskerCompile.sh

You should find yourself at a menu labelled "Compile options". Select the option labelled First build and select the OK button to continue. This will take a while, maybe grab some coffee.


5. Uploading the firmware to your Watchy

Plug your Watchy into your computer via USB. Make sure the connection between your Watchy and computer is stable. Do not disconnect the Watchy before the flashing process is complete; an interrupted flash may render the Watchy useless.

NOTE: A version 3 Watchy can only accept new firmware in "bootloader mode". Hold the top two buttons for 5 seconds, then release the one on the left before releasing the other. See more information here.

Once you're ready to upload the firmware, run the following command:

pio run -t upload -e $ENVNAME

After the upload completes, the InkWatchy firmware will be present on your Watchy. To exit bootloader mode, once again hold the two top buttons for 5 seconds, then release the one on the right before releasing the other.

NOTE: Ports USB 2.0 or older typically work best. If your Watchy is not connecting, you may want to try a different cable; many cables only support charging without data transfer.

After the upload completes, the firmware will be present on your Watchy.


6. Uploading filesystem resources

Filesystem resources (images, books, e.t.c.) are uploaded separately. Options to generate and flash filesystem resources are available though the resource options menu, which can be opened by running the following command:

PLATFORMIO_ENV_NAME=$ENVNAME ./resources/tools/other/tasks/taskerResources.sh

The first build already generates the resources for you, so you can go ahead and select Flash filesystem and then the OK button to flash them.

If you modify the resources, you will have to regenerate and flash them again before they update on your Watchy. To regenerate resources after modifying them, run the command again and select Generate resources instead (and then select the OK button of course). Then go back to flash them.


7. Rebuilding & re-uploading

After configuring the code to your liking, you can rebuild and re-upload the firmware via the following two commands:

pio run -e $ENVNAME

pio run -t upload -e $ENVNAME