diff --git a/README.md b/README.md index 25b73a2..f645ff6 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 diff --git a/docs/windows_build.md b/docs/windows_build.md index c5c1dad..e939f78 100644 --- a/docs/windows_build.md +++ b/docs/windows_build.md @@ -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) @@ -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! +``` \ No newline at end of file