> For the complete documentation index, see [llms.txt](https://tk233.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tk233.gitbook.io/notes/risc-v-soc/getting-started-with-zephyr/getting-started-with-zephyr-on-risc-v-ubuntu.md).

# Getting Started with Zephyr on RISC-V - Ubuntu

Using a12.mill

## Installation

Create a conda virtual environment.

```bash
conda create -yp ./.conda-env/ python=3.10
conda activate ./.conda-env/
```

Install system dependencies.

on a12.mill, cmake version is too low, so we need to install a newer one in conda environment.

```bash
conda install anaconda::cmake
```

additionally, we need these

```bash
conda install conda-forge::ninja
```

Install west, the build tool for zephyr.

```bash
pip install west
```

Create a new project.

```bash
west init ./getting-started/
cd ./getting-started/
west update
```

Export a [Zephyr CMake package](https://docs.zephyrproject.org/latest/build/zephyr_cmake_package.html#cmake-pkg). This allows CMake to automatically load boilerplate code required for building Zephyr applications.

```
west zephyr-export
```

Install Python dependencies.

```bash
pip install -r ./zephyr/scripts/requirements.txt
```

Install Zephyr SDK

```bash
cd ./zephyr/
west sdk install
```

Build blinky

```bash
west build -p always -b sparkfun_red_v_things_plus samples/basic/blinky
```

build for spike

```bash
west build -p always -b qemu_riscv64 samples/hello_world
```

on windows

<https://github.com/ninja-build/ninja/releases>

<https://www.segger.com/downloads/jlink/>

<https://7-zip.org/download.html>

```bash
pacman -S dtc
```

The workflow roughly follows the official tutorial.

{% embed url="<https://docs.zephyrproject.org/latest/develop/getting_started/index.html>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://tk233.gitbook.io/notes/risc-v-soc/getting-started-with-zephyr/getting-started-with-zephyr-on-risc-v-ubuntu.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
