Skip to content

Commit 3811669

Browse files
authored
Merge pull request esp-rs#24 from arjanmels/feature-exceptions
Feature exceptions
2 parents 3d007f4 + 986ee32 commit 3811669

29 files changed

+3398
-163
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/target
2+
procmacros/target
23
**/*.rs.bk
34
Cargo.lock
45
.vscode/.cortex-debug*

.vscode/launch.json

+49-25
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,65 @@
55
"version": "0.2.0",
66
"configurations": [
77
{
8+
// more info at: https://github.com/Marus/cortex-debug/blob/master/package.json
9+
"name": "Attach",
810
"type": "cortex-debug",
11+
"request": "attach", // attach instead of launch, because otherwise flash write is attempted, but fails
912
"cwd": "${workspaceRoot}",
10-
"executable": "target/xtensa-esp32-none-elf/debug/examples/${input:example}",
11-
"name": "debug-with-svd",
12-
"request": "launch",
13+
"executable": "target/current.elf",
1314
"servertype": "openocd",
1415
"interface": "jtag",
1516
"svdFile": "../esp32/svd/esp32.svd",
16-
// complains about not allowed,
17-
// but it does work.. https://github.com/Marus/cortex-debug/issues/111#issuecomment-504778053
18-
"serverpath": "${env:HOME}/programs/openocd-esp32/bin/openocd",
19-
// for this to work you will have to run `ln -s xtensa-esp32-elf-gdb arm-none-eabi-gdb`
20-
"toolchainPath": "${env:HOME}/programs/xtensa-esp32-elf/bin",
17+
"toolchainPrefix": "xtensa-esp32-elf",
18+
"openOCDPreConfigLaunchCommands": [
19+
"set ESP_RTOS none"
20+
],
2121
"configFiles": [
2222
"board/esp32-wrover-kit-3.3v.cfg"
2323
],
24+
"overrideAttachCommands": [
25+
"set remote hardware-watchpoint-limit 2",
26+
"mon halt",
27+
"flushregs"
28+
],
29+
"overrideRestartCommands": [
30+
"mon reset halt",
31+
"flushregs",
32+
"c",
33+
]
2434
},
25-
],
26-
"inputs": [
27-
// requires Tasks Shell Input extension
2835
{
29-
"id": "example",
30-
"type": "command",
31-
"command": "shellCommand.execute",
32-
"args": {
33-
"command": "egrep '\\[\\[example\\]\\]|name[ \t]+=' Cargo.toml | egrep '\\[\\[example\\]\\]' -A1 | egrep 'name[ \t]*=' | sed -E 's/name[ \t]*=[ \t]*//; s/\"//g'",
34-
"cwd": "${workspaceFolder}/../esp32-hal"
35-
}
36+
// more info at: https://github.com/Marus/cortex-debug/blob/master/package.json
37+
"name": "Flash & Launch",
38+
"type": "cortex-debug",
39+
"preLaunchTask": "Build Example",
40+
"request": "launch", // attach instead of launch, because otherwise flash write is attempted, but fails
41+
"cwd": "${workspaceRoot}",
42+
"executable": "target/current.elf",
43+
"servertype": "openocd",
44+
"interface": "jtag",
45+
"svdFile": "../esp32/svd/esp32.svd",
46+
"toolchainPrefix": "xtensa-esp32-elf",
47+
"openOCDPreConfigLaunchCommands": [
48+
"set ESP_RTOS none"
49+
],
50+
"configFiles": [
51+
"board/esp32-wrover-kit-3.3v.cfg"
52+
],
53+
"overrideLaunchCommands": [
54+
"mon program_esp32 target/current.bin 0x10000 verify reset hex",
55+
"flushregs",
56+
],
57+
"postStartSessionCommands": [
58+
"thb main",
59+
"continue"
60+
],
61+
"overrideRestartCommands": [
62+
"mon program_esp32 target/current.bin 0x10000 verify reset hex",
63+
"flushregs",
64+
"thb main",
65+
"continue",
66+
]
3667
},
37-
// alternatively type in manually
38-
{
39-
"id": "examplePrompt",
40-
"description": "Example:",
41-
"default": "serial",
42-
"type": "promptString"
43-
}
4468
]
4569
}

.vscode/tasks.json

+29-9
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,28 @@
44
"version": "2.0.0",
55
"tasks": [
66
{
7-
"label": "cargo xbuild --examples",
7+
"label": "Build and Flash Example",
88
"type": "shell",
9-
"command": "cargo xbuild --examples",
9+
"runOptions": {"reevaluateOnRerun": false},
10+
"command": "./flash -t --example ${input:example}",
11+
"problemMatcher": {
12+
"base": "$rustc",
13+
"fileLocation": [
14+
"relative"
15+
]
16+
},
17+
"group": "build",
18+
"presentation": {
19+
"reveal": "silent",
20+
"panel": "shared",
21+
"clear": true
22+
},
23+
},
24+
{
25+
"label": "Build Example",
26+
"type": "shell",
27+
"runOptions": {"reevaluateOnRerun": false},
28+
"command": "./flash -s --example ${input:example}",
1029
"problemMatcher": {
1130
"base": "$rustc",
1231
"fileLocation": [
@@ -24,25 +43,26 @@
2443
}
2544
},
2645
{
27-
"label": "cargo xdoc --open",
46+
"label": "Compile All Examples",
2847
"type": "shell",
29-
"command": "cargo xdoc --open",
48+
"command": "cargo xbuild --examples",
3049
"problemMatcher": {
3150
"base": "$rustc",
3251
"fileLocation": [
3352
"relative"
3453
]
3554
},
55+
"group": "build",
3656
"presentation": {
37-
"reveal": "silent",
57+
"reveal": "always",
3858
"panel": "shared",
3959
"clear": true
4060
}
4161
},
4262
{
43-
"label": "flash example",
63+
"label": "Build Documentation",
4464
"type": "shell",
45-
"command": "./flash -b 912600 -p /dev/ttyUSB1 -t ${input:example}",
65+
"command": "cargo xdoc --open --all-features",
4666
"problemMatcher": {
4767
"base": "$rustc",
4868
"fileLocation": [
@@ -55,7 +75,7 @@
5575
"panel": "shared",
5676
"clear": true
5777
}
58-
}
78+
},
5979
],
6080
"inputs": [
6181
// requires Tasks Shell Input extension
@@ -64,7 +84,7 @@
6484
"type": "command",
6585
"command": "shellCommand.execute",
6686
"args": {
67-
"command": "egrep '\\[\\[example\\]\\]|name[ \t]+=' Cargo.toml | egrep '\\[\\[example\\]\\]' -A1 | egrep 'name[ \t]*=' | sed -E 's/name[ \t]*=[ \t]*//; s/\"//g'",
87+
"command": "cargo check --offline --example 2>&1 |egrep '^ '| sed -E 's/[ \t]*//g'",
6888
"cwd": "${workspaceFolder}/../esp32-hal"
6989
}
7090
},

Cargo.toml

+32-11
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,46 @@ version = "0.1.0"
44
authors = ["Scott Mabin <[email protected]>", "Arjan Mels <[email protected]>"]
55
edition = "2018"
66

7+
8+
# Allow overriding of memcpy, memset, etc.
9+
[package.metadata.cargo-xbuild]
10+
memcpy = false
11+
12+
13+
[features]
14+
default=["mem"]
15+
16+
# Place program completely in ram (needed when e.g. using only ROM bootloader, or for debugging)
17+
all_in_ram=[]
18+
19+
# Allow use of external ram. Needs customized bootloader.
20+
external_ram=["esp32-hal-proc-macros/external_ram"]
21+
22+
# Add support for Global Allocator
23+
alloc=["linked_list_allocator"]
24+
25+
# Define memcpy, memset etc. as replacement of standard functions
26+
mem=[]
27+
28+
729
[dependencies]
8-
xtensa-lx6-rt = { git = "https://github.com/esp-rs/xtensa-lx6-rt.git", rev = "62229c1" }
9-
esp32 = { version = "0.3.0" }
30+
esp32-hal-proc-macros = { path = "procmacros" }
31+
32+
xtensa-lx6-rt = { version = "0.1.0" }
33+
esp32 = { version = "0.4.0" }
34+
bare-metal = "0.2"
1035
nb = "0.1.2"
1136
spin = "0.5.2"
1237
embedded-hal = { version = "0.2.3", features = ["unproven"] }
38+
linked_list_allocator = { version = "0.8.4", optional = true, default-features = false, features = ["alloc_ref"] }
1339

1440
[dev-dependencies]
1541
panic-halt = "0.2.0"
16-
spin = "0.5"
17-
18-
[[example]]
19-
name = "blinky"
20-
21-
[[example]]
22-
name = "serial"
2342

2443
[[example]]
25-
name = "rtccntl"
44+
name = "alloc"
45+
required-features = ["alloc"]
2646

2747
[[example]]
28-
name = "multicore"
48+
name = "mem"
49+
required-features = ["alloc"]

build.rs

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ fn main() {
1010
.unwrap()
1111
.write_all(include_bytes!("memory.x"))
1212
.unwrap();
13+
14+
File::create(out.join("alias.x"))
15+
.unwrap()
16+
.write_all(if cfg!(feature = "all_in_ram") {
17+
include_bytes!("ram.x")
18+
} else {
19+
include_bytes!("rom.x")
20+
})
21+
.unwrap();
22+
1323
println!("cargo:rustc-link-search={}", out.display());
1424

1525
// Only re-run the build script when memory.x is changed,

0 commit comments

Comments
 (0)