-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4ffc5cb
Showing
13 changed files
with
430 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[target.thumbv7em-none-eabihf] | ||
rustflags = [ | ||
"-C", "link-arg=-Tlink.x", | ||
] | ||
|
||
[build] | ||
target = "thumbv7em-none-eabihf" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/target | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"rust-analyzer.cargo.target": "thumbv7em-none-eabihf", | ||
"rust-analyzer.checkOnSave.allTargets": false, | ||
"editor.formatOnSave": true, | ||
"files.watcherExclude": { | ||
"**/.git/objects/**": true, | ||
"**/.git/subtree-cache/**": true, | ||
"**/target/**": true | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[package] | ||
name = "{{project-name}}" | ||
version = "0.1.0" | ||
authors = ["{{authors}}"] | ||
edition = "2021" | ||
resolver = "2" | ||
|
||
[dependencies] | ||
cortex-m = "^0.7" | ||
{% if rtic == "Yes" %}cortex-m-rtic = "^1" | ||
systick-monotonic = "^1"{% else %}cortex-m-rt = "^0.7"{% endif %} | ||
{% if rtt == "Yes" %}panic-rtt-target = { version = "0.1", features = ["cortex-m"] } | ||
rtt-target = { version = "^0.3", features = ["cortex-m"] }{% else %}panic-halt = "0.2"{% endif %} | ||
{% if board == "IskraJS" %}stm32f4xx-hal = {version = "0.13.1", default-features = false, features = ["rt", "stm32f405"]} | ||
r0 = "^1"{% else %}stm32f4xx-hal = {version = "0.13.1", default-features = false, features = ["rt", "stm32f411"]}{% endif %} | ||
|
||
[profile.release] | ||
codegen-units = 1 | ||
debug = true | ||
debug-assertions = true | ||
# lto = true | ||
opt-level = "s" | ||
|
||
# do not optimize proc-macro crates = faster builds from scratch | ||
[profile.dev.build-override] | ||
codegen-units = 8 | ||
debug = false | ||
debug-assertions = false | ||
opt-level = 0 | ||
overflow-checks = false | ||
|
||
[profile.release.build-override] | ||
codegen-units = 8 | ||
debug = false | ||
debug-assertions = false | ||
opt-level = 0 | ||
overflow-checks = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[default.probe] | ||
protocol = "Swd" | ||
|
||
[default.flashing] | ||
enabled = true | ||
restore_unwritten_bytes = false | ||
|
||
[default.reset] | ||
enabled = true | ||
halt_afterwards = false | ||
|
||
[default.rtt] | ||
enabled = true | ||
|
||
[default.general] | ||
{% if board == "IskraJS" %}chip = "STM32F405RGTx"{% else %}chip = "STM32F411CEUx"{% endif %} | ||
log_level = "WARN" | ||
|
||
[default.gdb] | ||
enabled = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use std::{env, error::Error, fs, path::PathBuf}; | ||
|
||
fn main() -> Result<(), Box<dyn Error>> { | ||
let out_dir = PathBuf::from(env::var("OUT_DIR")?); | ||
|
||
fs::copy("memory.x", out_dir.join("memory.x"))?; | ||
|
||
println!("cargo:rustc-link-search={}", out_dir.display()); | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
println!("cargo:rerun-if-changed=memory.x"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[template] | ||
cargo_generate_version = ">=0.10.0" | ||
ignore = [ | ||
".git", | ||
"readme.md", | ||
"readme_ru.md", | ||
] | ||
description1 = "Rust blink template for Iskra JS or Iskra JS Mini boards" | ||
|
||
[placeholders] | ||
board = { type = "string", prompt = "Select board", choices = ["IskraJS", "IskraJS Mini"], default = "IskraJS" } | ||
rtic = { type = "string", prompt = "Use RTIC framework?", choices = ["Yes", "No"], default = "No" } | ||
rtt = { type = "string", prompt = "Use RTT (require debug)?", choices = ["Yes", "No"], default = "No" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cargo objcopy --release -- -O binary ./target/iskrajs.bin | ||
uf2conv ./target/iskrajs.bin --base 0x08008000 --family 0x57755a57 --output ./target/iskrajs.uf2 | ||
cp ./target/iskrajs.uf2 /media/roman/IskraJSBOOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{% if board == "IskraJS" %}MEMORY | ||
{ | ||
/* NOTE K = KiBi = 1024 bytes */ | ||
FLASH (rx) : ORIGIN = 0x08000000 + 32K, LENGTH = 1024K - 32K | ||
CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K | ||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K | ||
} | ||
|
||
/* This is where the call stack will be allocated. */ | ||
/* The stack is of the full descending type. */ | ||
/* NOTE Do NOT modify `_stack_start` unless you know what you are doing */ | ||
_stack_start = ORIGIN(RAM) + LENGTH(RAM); | ||
|
||
/* Advanced users can place the stack inthe CCMRAM */ | ||
/* which is smaller but faster. */ | ||
/* _stack_start = ORIGIN(CCMRAM) + LENGTH(CCMRAM); */ | ||
|
||
/* # Sections */ | ||
SECTIONS | ||
{ | ||
_siccmram = LOADADDR(.ccmram); | ||
|
||
/* CCM-RAM section | ||
* | ||
* IMPORTANT NOTE! | ||
* If initialized variables will be placed in this section, | ||
* the startup code needs to be modified to copy the init-values. | ||
*/ | ||
.ccmram ORIGIN(CCMRAM) : | ||
{ | ||
. = ALIGN(4); | ||
_ccmram_start = .; /* create a global symbol at ccmram start */ | ||
*(.ccmram) | ||
*(.ccmram*) | ||
|
||
. = ALIGN(4); | ||
_ccmram_end = .; /* create a global symbol at ccmram end */ | ||
} >CCMRAM AT> FLASH | ||
} | ||
INSERT AFTER .rodata{% else %}MEMORY | ||
{ | ||
/* NOTE K = KiBi = 1024 bytes */ | ||
FLASH (rx) : ORIGIN = 0x08000000 + 32K, LENGTH = 512K - 32K | ||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K | ||
} | ||
|
||
/* This is where the call stack will be allocated. */ | ||
/* The stack is of the full descending type. */ | ||
/* NOTE Do NOT modify `_stack_start` unless you know what you are doing */ | ||
_stack_start = ORIGIN(RAM) + LENGTH(RAM);{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Rust template for Iskra JS or Iskra JS Mini boards | ||
|
||
## Prerequisites | ||
|
||
### Install Rustup and Rust | ||
|
||
If you don't have `rustup` installed yet, follow the instructions on the [rustup.rs](https://rustup.rs) site | ||
|
||
### Install Rust plugins | ||
```sh | ||
rustup default stable | ||
rustup target add thumbv7em-none-eabihf | ||
rustup component add llvm-tools-preview | ||
``` | ||
|
||
### Install VS Code and plugins | ||
|
||
If you don't have `VS Code` installed yet, follow the instructions on the [code.visualstudio.com](https://code.visualstudio.com) site | ||
|
||
Install plugins: | ||
```sh | ||
code --install-extension matklad.rust-analyzer | ||
code --install-extension bungcip.better-toml | ||
code --install-extension marus25.cortex-debug | ||
``` | ||
|
||
### Install Cargo Sub-Commands and tools | ||
|
||
```sh | ||
cargo install cargo-generate cargo-binutils probe-run cargo-embed uf2conv | ||
``` | ||
|
||
## Generate the project | ||
|
||
```sh | ||
cargo generate gh:amperka/iskrajs-rust-template | ||
``` | ||
|
||
## Build | ||
|
||
In the root of the generated project. | ||
|
||
```sh | ||
cargo build --release | ||
``` | ||
|
||
## Flash | ||
|
||
In the root of the generated project. | ||
|
||
To build and flash using uf2 bootloader, use: | ||
```sh | ||
# for Windows or MacOS | ||
cargo objcopy --release -- -O binary ./target/iskrajs.bin | ||
uf2conv ./target/iskrajs.bin --base 0x08008000 --family 0x57755a57 --output iskrajs.uf2 | ||
# copy iskrajs.uf2 file to IskraJSBOOT or IskraJSMini disk | ||
|
||
# for Linux | ||
sh ./load.sh | ||
``` | ||
|
||
To build and flash using debugger, use: | ||
```sh | ||
cargo embed --release | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Шаблон Rust для плат Iskra JS или Iskra JS Mini | ||
|
||
## Требования | ||
|
||
### Установите Rustup и Rust | ||
|
||
Если у вас еще не установлен `rustup`, следуйте инструкциям на сайте [rustup.rs](https://rustup.rs). | ||
|
||
### Установите плагины Rust | ||
```sh | ||
rustup default stable | ||
rustup target add thumbv7em-none-eabihf | ||
rustup component add llvm-tools-preview | ||
``` | ||
|
||
### Установите VS Code и плагины | ||
|
||
Если у вас еще не установлен VS Code, следуйте инструкциям на сайте [code.visualstudio.com](https://code.visualstudio.com). | ||
|
||
Установите плагины: | ||
```sh | ||
code --install-extension matklad.rust-analyzer | ||
code --install-extension bungcip.better-toml | ||
code --install-extension marus25.cortex-debug | ||
``` | ||
|
||
### Установите подкоманды и инструменты Cargo | ||
|
||
```sh | ||
cargo install cargo-generate cargo-binutils probe-run cargo-embed uf2conv | ||
``` | ||
|
||
## Создайте проект | ||
|
||
```sh | ||
cargo generate gh:amperka/iskrajs-rust-template | ||
``` | ||
|
||
## Скомпелируйте | ||
|
||
Выполните в корне сгенерированного проекта. | ||
|
||
```sh | ||
cargo build --release | ||
``` | ||
|
||
## Загрузите на плату | ||
|
||
Выполните в корне сгенерированного проекта. | ||
|
||
Для сборки и прошивки с использованием загрузчика uf2 используйте: | ||
```sh | ||
# для Windows или MacOS | ||
cargo objcopy --release -- -O binary ./target/iskrajs.bin | ||
uf2conv ./target/iskrajs.bin --base 0x08008000 --family 0x57755a57 --output iskrajs.uf2 | ||
# скопируйте файл iskrajs.uf2 на диск IskraJSBOOT или IskraJSMini | ||
|
||
# для Linux | ||
sh ./load.sh | ||
``` | ||
|
||
Для сборки и прошивки с помощью отладчика используйте: | ||
```sh | ||
cargo embed --release | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
edition = "2021" | ||
max_width = 120 |
Oops, something went wrong.