# Introduction

Our "own firmware" (called spielzeug) is not really a custom firmware. This is just a custom runtime built on top of the original LEGO SPIKE v2 firmware, which needs to be installed to use it and will stay installed.

### Installation

#### Installing the CLI

To manage the hub, you need to install the CLI tool "tigerente". To do this, use your python package manager of choice and install "tigerente".

##### PIP

```bash
pip install tigerente
```

##### PIPX

```bash
pipx install tigerente
```

##### UV/UVX

```
uv tool add tigerente
```

#### Installing the firmware

To install the current version of the firmware, ensure the newest LEGO firmware is installed and plug the hub into your computer using USB.

Then, run the following command:

```bash
tigerente fw-flash
```

This will flash spielzeug on your device and connect to it.

#### Updating your hub

You can always update the firmware using the command above, but for convenience, you can use the following one in order to update the firmware over bluetooth:

```bash
tigerente fw-update
```

#### Renaming your hub

When you install the firmware for the first time, a random name will be assigned to the hub. To assign your own name, run:

```bash
tigerente rename <NEW_NAME>
```

### Uploading a program

First create a directory where your program will live in. In this tutorial we will call it `src`. Inside this directory, create a file called `__init__.py`.  
The `__init__.py` needs to define an async function called `loop`. This is the main entrypoint of your program.

```python
# src/__init__.py

async def loop():
    ...
```

For this tutorial, we will write a program that will make the power LED light up in green for five seconds and in red for another five. That would look something like this:

```python
# src/__init__.py

import asyncio
import hub
import color


async def loop():
    hub.light.color(hub.light.POWER, color.GREEN)
    await asyncio.sleep(5)
    hub.light.color(hub.light.POWER, color.RED)
    await asyncio.sleep(5)

```

Great!  
Now, we can upload this program by running the following command:

```bash
tigerente sync src
```

You should now see the program running on the hub. If it was too fast and you want to start the program again, run:

```bash
tigerente start
```

This command will start the program that was uploaded most recently.

You have successfully written your first program using spielzeug, great!

### Uninstalling

To uninstall the firmware and go back to the official one from lego, use the following command:

```bash
tigerente fw-update -v restore-original
```

In case this does not work, you can always use the `fw-flash` command in the same way, just like with updates as explained above.