Skip to content

Instantly share code, notes, and snippets.

@odudex
Last active January 29, 2024 16:44
Show Gist options
  • Save odudex/c279fbad4f80ffd8778ea8c6942c405b to your computer and use it in GitHub Desktop.
Save odudex/c279fbad4f80ffd8778ea8c6942c405b to your computer and use it in GitHub Desktop.
Developing Krux on Windows

Motivation

Linux and Ubuntu are ideal for Krux development, but if you have a computer that lacks Linux support, with no drivers available for peripherals like the webcam (the webcam is integral to many Krux workflows), you can consider developing for Krux on Windows.

Development Environment Preparation

We will use the combo Window WSL(2), running Ubuntu and VS Code for simulation, code edition and compiling. To edit Krux source code, when preparation is finished, you’ll be able to open Ubuntu, navigate to Krux project and run: code . This will open VS Code on Windows, which will be editing the project inside Ubuntu.

Install WSL and VS Code and clone Krux

Open PowerShell and type the command:

wsl --install

Download VS Code and install it on Windows, making sure it is checked to be added to PATH on “additional tasks”.

Reboot the computer.

Open VS Code and install the “Remote Development” extension from Microsoft, then close it.

Run “Ubuntu” application on Windows. When prompted in the terminal, create a Linux username and password.

On Ubuntu terminal, update the system:

sudo apt update
sudo apt upgrade

Install ssl requirements:

sudo apt-get install wget ca-certificates

Clone Krux:

git clone --recurse-submodules https://github.com/selfcustody/krux

Run the Simulator

(update) Webcam won't work in WSL :/

On Ubuntu terminal, install poetry

curl -sSL https://install.python-poetry.org | python3 -

restart Ubuntu (exit command and run it again)

Test poetry:

poetry --version

Install other dependencies:

sudo apt install libgl1 zbar-tools

Reboot Ubuntu again to smooth out recent package installations.

Enter krux dir:

cd krux/

(Optional) Checkout to a develop branch:

git checkout integrated_changes

Install project’s dependencies using poetry:

poetry install --extras simulator

Enter simulator folder:

cd simulator

Run the Simulator:

poetry run python simulator.py --device maixpy_amigo_tft

Build From Source

Install Docker

Prepare:

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Install:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Test:

sudo docker run hello-world

Add user to docker group:

sudo usermod -aG docker $USER

Log in to the new docker group

newgrp docker

Build Krux

Enter Krux main directory and build Krux:

./krux build maixpy_amigo_tft

This takes a looong time, and you may need to retry if it fails due to an internet connection instability. Subsequent builds will be much faster, as it will build only Krux binaries, not the whole tool-chain.

Flash a Device

Windows WSL2 don’t have access to serial ports, so the best is to copy the binary to a Windows folder and run Ktool natively from there.

Edit the Source Code

On Ubuntu terminal, enter in Krux main directory and run VS Code:

code .

It will open VS Code on Windows, but will live edit the project inside Ubuntu

@tadeubas
Copy link

Na instalação do poetry vc sugere curl -sSL https://install.python-poetry.org | python3 -, pq não fazer pelo pyhton mesmo?
python3 -m pip install poetry

@tadeubas
Copy link

tadeubas commented Jan 27, 2024

(EDITADO)
O Docker, pq não linkar para seguir esse tutorial deles?

https://docs.docker.com/engine/install/ubuntu/

@tadeubas
Copy link

A parte do simulador, basta mudar pra vc fazer a instalação no Windows mesmo pq no WSL não vai funcionar a câmera

@odudex
Copy link
Author

odudex commented Jan 29, 2024

Os métodos usados para instalação do poetry e docker foram os que funcionaram pra mim. Em ambos os comandos acima constam como opção nos respectivos sites oficiais.
Infelizmente WSL não suporta nem câmera para o simulador nem serial para gravar. Talvez por hora rodar poetry nativamente no Windows, e compilar e gravar através do Vagrant ainda seja a melhor opção.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment