Skip to content

Commit a06a8e8

Browse files
committed
First pass skeleton BIOS.
Based on the Neotron-XXX-BIOS template, the latest Cortex-M Quickstart, and the RP2040 examples.
0 parents  commit a06a8e8

File tree

14 files changed

+593
-0
lines changed

14 files changed

+593
-0
lines changed

.cargo/config.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[target.thumbv6m-none-eabi]
2+
rustflags = [
3+
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
4+
# See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
5+
"-C", "link-arg=--nmagic",
6+
7+
# LLD (shipped with the Rust toolchain) is used as the default linker
8+
"-C", "link-arg=-Tlink.x",
9+
]
10+
11+
[build]
12+
target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+

.github/workflows/format.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Format
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
check:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v1
12+
- name: Add Tool
13+
run: rustup component add rustfmt
14+
- name: Check Format
15+
run: cargo fmt -- --check

.github/workflows/rust.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v1
13+
with:
14+
submodules: true
15+
- name: Add Target
16+
run: rustup target add thumbv6m-none-eabi
17+
- name: Build
18+
run: cargo build --verbose
19+
- name: Build Release
20+
run: cargo build --release --verbose

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
**/*.rs.bk
2+
.#*
3+
.gdb_history
4+
Cargo.lock
5+
target/
6+
7+
# editor files
8+
.vscode/*
9+
!.vscode/*.md
10+
!.vscode/*.svd
11+
!.vscode/launch.json
12+
!.vscode/tasks.json
13+
!.vscode/extensions.json

.vscode/README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# VS Code Configuration
2+
3+
Example configurations for debugging programs in-editor with VS Code.
4+
This directory contains configurations for two platforms:
5+
6+
- `LM3S6965EVB` on QEMU
7+
- `STM32F303x` via OpenOCD
8+
9+
## Required Extensions
10+
11+
If you have the `code` command in your path, you can run the following commands to install the necessary extensions.
12+
13+
```sh
14+
code --install-extension rust-lang.rust
15+
code --install-extension marus25.cortex-debug
16+
```
17+
18+
Otherwise, you can use the Extensions view to search for and install them, or go directly to their marketplace pages and click the "Install" button.
19+
20+
- [Rust Language Server (RLS)](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust)
21+
- [Cortex-Debug](https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug)
22+
23+
## Use
24+
25+
The quickstart comes with two debug configurations.
26+
Both are configured to build the project, using the default settings from `.cargo/config`, prior to starting a debug session.
27+
28+
1. QEMU: Starts a debug session using an emulation of the `LM3S6965EVB` mcu.
29+
- This works on a fresh `cargo generate` without modification of any of the settings described above.
30+
- Semihosting output will be written to the Output view `Adapter Output`.
31+
- `ITM` logging does not work with QEMU emulation.
32+
33+
2. OpenOCD: Starts a debug session for a `STM32F3DISCOVERY` board (or any `STM32F303x` running at 8MHz).
34+
- Follow the instructions above for configuring the build with `.cargo/config` and the `memory.x` linker script.
35+
- `ITM` output will be written to the Output view `SWO: ITM [port: 0, type: console]` output.
36+
37+
### Git
38+
39+
Files in the `.vscode/` directory are `.gitignore`d by default because many files that may end up in the `.vscode/` directory should not be committed and shared.
40+
If you would like to save this debug configuration to your repository and share it with your team, you'll need to explicitly `git add` the files to your repository.
41+
42+
```sh
43+
git add -f .vscode/launch.json
44+
git add -f .vscode/tasks.json
45+
git add -f .vscode/*.svd
46+
```
47+
48+
## Customizing for other targets
49+
50+
For full documentation, see the [Cortex-Debug][cortex-debug] repository.
51+
52+
### Device
53+
54+
Some configurations use this to automatically find the SVD file.
55+
Replace this with the part number for your device.
56+
57+
```json
58+
"device": "STM32F303VCT6",
59+
```
60+
61+
### OpenOCD Config Files
62+
63+
The `configFiles` property specifies a list of files to pass to OpenOCD.
64+
65+
```json
66+
"configFiles": [
67+
"interface/stlink-v2-1.cfg",
68+
"target/stm32f3x.cfg"
69+
],
70+
```
71+
72+
See the [OpenOCD config docs][openocd-config] for more information and the [OpenOCD repository for available configuration files][openocd-repo].
73+
74+
### SVD
75+
76+
The SVD file is a standard way of describing all registers and peripherals of an ARM Cortex-M mCU.
77+
Cortex-Debug needs this file to display the current register values for the peripherals on the device.
78+
79+
You can probably find the SVD for your device on the vendor's website.
80+
81+
82+
For example, the STM32F3DISCOVERY board uses an mcu from the `STM32F303x` line of processors.
83+
All the SVD files for the STM32F3 series are available on [ST's Website][stm32f3].
84+
Download the [stm32f3 SVD pack][stm32f3-svd], and copy the `STM32F303.svd` file into `.vscode/`.
85+
This line of the config tells the Cortex-Debug plug in where to find the file.
86+
87+
```json
88+
"svdFile": "${workspaceRoot}/.vscode/STM32F303.svd",
89+
```
90+
91+
For other processors, simply copy the correct `*.svd` file into the project and update the config accordingly.
92+
93+
### CPU Frequency
94+
95+
If your device is running at a frequency other than 8MHz, you'll need to modify this line of `launch.json` for the `ITM` output to work correctly.
96+
97+
```json
98+
"cpuFrequency": 8000000,
99+
```
100+
101+
### Other GDB Servers
102+
103+
For information on setting up GDB servers other than OpenOCD, see the [Cortex-Debug repository][cortex-debug].
104+
105+
[cortex-debug]: https://github.com/Marus/cortex-debug
106+
[stm32f3]: https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus/stm32-mainstream-mcus/stm32f3-series.html#resource
107+
[stm32f3-svd]: https://www.st.com/resource/en/svd/stm32f3_svd.zip
108+
[openocd-config]: http://openocd.org/doc/html/Config-File-Guidelines.html
109+
[openocd-repo]: https://sourceforge.net/p/openocd/code/ci/master/tree/tcl/

.vscode/extensions.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3+
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4+
5+
// List of extensions which should be recommended for users of this workspace.
6+
"recommendations": [
7+
"rust-lang.rust",
8+
"marus25.cortex-debug",
9+
],
10+
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
11+
"unwantedRecommendations": [
12+
13+
]
14+
}

.vscode/launch.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
/*
3+
* Requires the Rust Language Server (RLS) and Cortex-Debug extensions
4+
* https://marketplace.visualstudio.com/items?itemName=rust-lang.rust
5+
* https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug
6+
*/
7+
"version": "0.2.0",
8+
"configurations": [
9+
{
10+
"type": "cortex-debug",
11+
"request": "launch",
12+
"name": "Debug (QEMU)",
13+
"servertype": "qemu",
14+
"cwd": "${workspaceRoot}",
15+
"preLaunchTask": "Cargo Build (debug)",
16+
"runToMain": true,
17+
"executable": "./target/thumbv7m-none-eabi/debug/neotron-pico-bios",
18+
/* Run `cargo build --example hello` and uncomment this line to run semi-hosting example */
19+
//"executable": "./target/thumbv7m-none-eabi/debug/examples/hello",
20+
"cpu": "cortex-m3",
21+
"machine": "lm3s6965evb",
22+
},
23+
{
24+
/* Configuration for the STM32F303 Discovery board */
25+
"type": "cortex-debug",
26+
"request": "launch",
27+
"name": "Debug (OpenOCD)",
28+
"servertype": "openocd",
29+
"cwd": "${workspaceRoot}",
30+
"preLaunchTask": "Cargo Build (debug)",
31+
"runToMain": true,
32+
"executable": "./target/thumbv7em-none-eabihf/debug/neotron-pico-bios",
33+
/* Run `cargo build --example itm` and uncomment this line to run itm example */
34+
// "executable": "./target/thumbv7em-none-eabihf/debug/examples/itm",
35+
"device": "STM32F303VCT6",
36+
"configFiles": [
37+
"interface/stlink-v2-1.cfg",
38+
"target/stm32f3x.cfg"
39+
],
40+
"svdFile": "${workspaceRoot}/.vscode/STM32F303.svd",
41+
"swoConfig": {
42+
"enabled": true,
43+
"cpuFrequency": 8000000,
44+
"swoFrequency": 2000000,
45+
"source": "probe",
46+
"decoders": [
47+
{ "type": "console", "label": "ITM", "port": 0 }
48+
]
49+
}
50+
}
51+
]
52+
}

.vscode/tasks.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
/*
8+
* This is the default cargo build task,
9+
* but we need to provide a label for it,
10+
* so we can invoke it from the debug launcher.
11+
*/
12+
"label": "Cargo Build (debug)",
13+
"type": "process",
14+
"command": "cargo",
15+
"args": ["build"],
16+
"problemMatcher": [
17+
"$rustc"
18+
],
19+
"group": {
20+
"kind": "build",
21+
"isDefault": true
22+
}
23+
},
24+
{
25+
"label": "Cargo Build (release)",
26+
"type": "process",
27+
"command": "cargo",
28+
"args": ["build", "--release"],
29+
"problemMatcher": [
30+
"$rustc"
31+
],
32+
"group": "build"
33+
},
34+
{
35+
"label": "Cargo Build Examples (debug)",
36+
"type": "process",
37+
"command": "cargo",
38+
"args": ["build","--examples"],
39+
"problemMatcher": [
40+
"$rustc"
41+
],
42+
"group": "build"
43+
},
44+
{
45+
"label": "Cargo Build Examples (release)",
46+
"type": "process",
47+
"command": "cargo",
48+
"args": ["build","--examples", "--release"],
49+
"problemMatcher": [
50+
"$rustc"
51+
],
52+
"group": "build"
53+
},
54+
{
55+
"label": "Cargo Clean",
56+
"type": "process",
57+
"command": "cargo",
58+
"args": ["clean"],
59+
"problemMatcher": [],
60+
"group": "build"
61+
},
62+
]
63+
}

Cargo.toml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[package]
2+
authors = ["Jonathan 'theJPster' Pallant <[email protected]>"]
3+
edition = "2018"
4+
readme = "README.md"
5+
license = "GPLv3"
6+
name = "neotron-pico-bios"
7+
version = "0.1.0"
8+
9+
[dependencies]
10+
# Useful Cortex-M specific functions (e.g. SysTick)
11+
cortex-m = "0.7.3"
12+
# The Raspberry Pi Pico HAL
13+
pico = { git = "https://github.com/rp-rs/rp-hal.git" }
14+
# Cortex-M run-time (or start-up) code
15+
cortex-m-rt = "0.6.14"
16+
# The BIOS API we export to the OS
17+
neotron-common-bios = { git = "https://github.com/Neotron-Compute/Neotron-Common-BIOS.git" }
18+
# For time keeping/handling
19+
embedded-time = "0.12"
20+
# For the RP2040 bootloader
21+
rp2040-boot2 = "0.1"
22+
# For panic handling (todo remove this)
23+
panic-halt = "0.2"
24+
# For hardware abstraction traits
25+
embedded-hal ="0.2"
26+
27+
[[bin]]
28+
name = "neotron-pico-bios"
29+
test = false
30+
bench = false
31+
32+
[profile.release]
33+
# better optimizations
34+
codegen-units = 1
35+
# symbols are nice and they don't increase the size on Flash
36+
debug = true
37+
# better optimizations
38+
lto = true

0 commit comments

Comments
 (0)