Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: add building on WSL and VSCode integration #162

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ these steps:
* Obtain a checkout of the RebbleOS source code. Ensure that you have also checked out the submodules required to build the resource tree: `git submodule update --init --recursive`
* Create a `localconfig.mk` if your cross-compiler is in an unusual location. For instance, if you have the SDK installed in `/home/me`, add the following line to your `localconfig.mk`: `PEBBLE_TOOLCHAIN_PATH=/home/me/Pebble/SDK/pebble-sdk-4.5-linux64/arm-cs-tools/bin`. For more information on `localconfig.mk` variables, consult the `Makefile`.
* Build the firmware: `make`
* If you wish to run the firmware in `qemu`, copy the resources necessary into `Resources/`. Take a look at [Utilities/mk_resources.sh](Utilities/mk_resources.sh) for more information on that.
* To run the firmware in `qemu`, try `make snowy_qemu`.

[Building on Debian Stretch](docs/debian_build.md)

Expand All @@ -84,7 +82,15 @@ currently out of scope for this document.

> You need the `snowy_fpga.bin` and `chalk_fpga.bin` files to compile on their respective firmwares. They can be found on the `#firmware` channel in the [Rebble Discord](http://discord.gg/aRUAYFN).

### Code structure
### Debugging

* If you wish to run the firmware in `qemu`, copy the resources necessary into `Resources/`. Take a look at [Utilities/mk_resources.sh](Utilities/mk_resources.sh) for more information on that.
* To run the firmware in `qemu`, try `make snowy_qemu`.

You may want to set breakpoints and step through the code. First load `qemu` with `make snowy_qemu QEMUFLAGS=-S`, which will also pause the emulation. In a separate console, and run `make snowy_gdb` and type `c` to continue.

If you're using Visual Studio Code and Windows Subsystem for Linux (WSL2), see [Debugging on VS Code](docs/windows_build.md).
## Code structure

_(This section is, admittedly, somewhat aspirational. Do not be surprised
if code within RebbleOS does not necessarily conform to this structure
Expand Down
110 changes: 71 additions & 39 deletions docs/windows_build.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,76 @@
# Building on Windows

So unfortunately there is no known way (yet), to fully work on Windows while working for Pebble. This document will guide you through the setup of a Ubuntu VM, the Pebble and Rebble development environment and finally look at some ways to move most of the development back to Windows.
## Windows Subsystem for Linux

## Setting up a virtual machine
First set up WSL2 and get RebbleOS building on it, for which you can use the [Building on Debian](docs/debian_build.md) steps.

### Visual Studio Code integration

To automate the process of building and debugging with VS Code on WSL2, you can use these template `tasks.json` and `launch.json`:

```json
{
// tasks.json

"version": "2.0.0",
"tasks": [
{
"label": "Build RebbleOS",
"type": "shell",
"command": "make ${input:buildTargets}",
"group": "build",
"problemMatcher": "$gcc",
},
],
"inputs": [
{
"id": "buildTargets",
"type": "pickString",
"description": "Selects the build target from the list",
"options": [
"snowy",
"snowy_qemu",
"snowy_qemu QEMUFLAGS=-S",
"snowy_gdb",
"tintin"
]
}
]
}
```

```json
{
// launch.json

"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "attach",
"name": "Attach to gdbserver",
"executable": "${workspaceFolder}/build/snowy/tintin_fw.elf",
"target": "localhost:63770",
"remote": true,
"cwd": "${workspaceRoot}",
"gdbpath": "/usr/bin/arm-none-eabi-gdb",
"autorun": [
// "any other gdb commands to initiate your environment, if it is needed"
]
}
]
}
```

To build and step through RebbleOS, you need to:

1. Set a breakpoint somewhere in the code, selecting the line and pressing `F9`.
1. Invoke the build task with `CTRL+Shift+B` and select `make snowy_qemu QEMUFLAGS=-S`. The output from `qemu` will be displayed in the console.
1. Press `F5` to attach VSCode to `gdb`. The emulation will continue and stop at the breakpoint you set.


## Linux VM
### Setting up a virtual machine

- Install [VirtualBox](http://www.virtualbox.org/)
- Download the Ubuntu's ISO from [their website](https://www.ubuntu.com/download/desktop)
Expand Down Expand Up @@ -57,40 +125,4 @@ Then you can start the emulator on the virtual machine by running `make snowy_qe

```batch
C:\msys\bin\arm-none-eabi-gdb.exe -ex "target remote localhost:63770" -ex "sym build/snowy/tintin_fw.elf"
```

### Integrating into VSCode

For building you can use this `tasks.json`:

```json
{
"version": "2.0.0",
"tasks": [
{
"label": "Build all",
"type": "shell",
"command": "C:\\msys\\bin\\make.exe",
"args": [ ],
"options": {
"env": {
"PATH": "C:\\msys\\bin"
}
},
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$gcc",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared"
}
}
]
}
```

Unfortunately integrating remote debugging is still a problem, if you happen to solve it, please make a PR describing the solution!
```