aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-02-11 12:22:24 +0100
committerGitHub <[email protected]>2025-02-11 12:22:24 +0100
commit05bbb99603e16dd58604bfd1b59871eb551c74a3 (patch)
tree0ed12675f9923e0190834e15c95273a13fb76dff
parent76fb3a54f38c20f1b16de60da12d21d98bf250fd (diff)
parent01b7ff8ff04af62cc04331a229f5305d320907fe (diff)
Merge pull request #3870 from kkrolczyk/kk/mostly-docu-changes-and-examples-fix
dfu documentation update, fix a couple issues
-rw-r--r--docs/examples/layer-by-layer/Cargo.toml1
-rw-r--r--docs/examples/layer-by-layer/blinky-async/Cargo.toml2
-rw-r--r--docs/examples/layer-by-layer/blinky-hal/Cargo.toml2
-rw-r--r--docs/examples/layer-by-layer/blinky-irq/Cargo.toml4
-rw-r--r--docs/examples/layer-by-layer/blinky-pac/Cargo.toml2
-rw-r--r--docs/examples/layer-by-layer/memory.x5
-rw-r--r--embassy-usb-dfu/src/consts.rs46
7 files changed, 56 insertions, 6 deletions
diff --git a/docs/examples/layer-by-layer/Cargo.toml b/docs/examples/layer-by-layer/Cargo.toml
index f18c9e7e4..01666ec6e 100644
--- a/docs/examples/layer-by-layer/Cargo.toml
+++ b/docs/examples/layer-by-layer/Cargo.toml
@@ -3,7 +3,6 @@ resolver = "2"
3members = [ 3members = [
4 "blinky-pac", 4 "blinky-pac",
5 "blinky-hal", 5 "blinky-hal",
6 "blinky-irq",
7 "blinky-async", 6 "blinky-async",
8] 7]
9 8
diff --git a/docs/examples/layer-by-layer/blinky-async/Cargo.toml b/docs/examples/layer-by-layer/blinky-async/Cargo.toml
index 51ddf87d4..541eb6edf 100644
--- a/docs/examples/layer-by-layer/blinky-async/Cargo.toml
+++ b/docs/examples/layer-by-layer/blinky-async/Cargo.toml
@@ -5,7 +5,7 @@ edition = "2021"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
6 6
7[dependencies] 7[dependencies]
8cortex-m = "0.7" 8cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
9cortex-m-rt = "0.7" 9cortex-m-rt = "0.7"
10embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32l475vg", "memory-x", "exti"] } 10embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32l475vg", "memory-x", "exti"] }
11embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] } 11embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] }
diff --git a/docs/examples/layer-by-layer/blinky-hal/Cargo.toml b/docs/examples/layer-by-layer/blinky-hal/Cargo.toml
index 1e292e6b4..dd574c3e7 100644
--- a/docs/examples/layer-by-layer/blinky-hal/Cargo.toml
+++ b/docs/examples/layer-by-layer/blinky-hal/Cargo.toml
@@ -5,8 +5,8 @@ edition = "2021"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
6 6
7[dependencies] 7[dependencies]
8cortex-m = "0.7"
9cortex-m-rt = "0.7" 8cortex-m-rt = "0.7"
9cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
10embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32l475vg", "memory-x"] } 10embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32l475vg", "memory-x"] }
11 11
12defmt = "0.3" 12defmt = "0.3"
diff --git a/docs/examples/layer-by-layer/blinky-irq/Cargo.toml b/docs/examples/layer-by-layer/blinky-irq/Cargo.toml
index 04ffc23ba..8733ee894 100644
--- a/docs/examples/layer-by-layer/blinky-irq/Cargo.toml
+++ b/docs/examples/layer-by-layer/blinky-irq/Cargo.toml
@@ -1,3 +1,5 @@
1[workspace]
2
1[package] 3[package]
2name = "blinky-irq" 4name = "blinky-irq"
3version = "0.1.0" 5version = "0.1.0"
@@ -5,7 +7,7 @@ edition = "2021"
5license = "MIT OR Apache-2.0" 7license = "MIT OR Apache-2.0"
6 8
7[dependencies] 9[dependencies]
8cortex-m = "0.7" 10cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
9cortex-m-rt = { version = "0.7" } 11cortex-m-rt = { version = "0.7" }
10embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32l475vg", "memory-x", "unstable-pac"] } 12embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32l475vg", "memory-x", "unstable-pac"] }
11 13
diff --git a/docs/examples/layer-by-layer/blinky-pac/Cargo.toml b/docs/examples/layer-by-layer/blinky-pac/Cargo.toml
index cf2d7fede..155c41ec6 100644
--- a/docs/examples/layer-by-layer/blinky-pac/Cargo.toml
+++ b/docs/examples/layer-by-layer/blinky-pac/Cargo.toml
@@ -5,7 +5,7 @@ edition = "2021"
5license = "MIT OR Apache-2.0" 5license = "MIT OR Apache-2.0"
6 6
7[dependencies] 7[dependencies]
8cortex-m = "0.7" 8cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
9cortex-m-rt = "0.7" 9cortex-m-rt = "0.7"
10stm32-metapac = { version = "16", features = ["stm32l475vg"] } 10stm32-metapac = { version = "16", features = ["stm32l475vg"] }
11 11
diff --git a/docs/examples/layer-by-layer/memory.x b/docs/examples/layer-by-layer/memory.x
new file mode 100644
index 000000000..69f5b28a1
--- /dev/null
+++ b/docs/examples/layer-by-layer/memory.x
@@ -0,0 +1,5 @@
1MEMORY
2{
3 FLASH : ORIGIN = 0x08000000, LENGTH = 2048K /* BANK_1 */
4 RAM : ORIGIN = 0x20000000, LENGTH = 640K /* SRAM */
5}
diff --git a/embassy-usb-dfu/src/consts.rs b/embassy-usb-dfu/src/consts.rs
index 190b5ad5a..8701dabc4 100644
--- a/embassy-usb-dfu/src/consts.rs
+++ b/embassy-usb-dfu/src/consts.rs
@@ -1,10 +1,16 @@
1//! USB DFU constants. 1//! USB DFU constants, taken from
2//! https://www.usb.org/sites/default/files/DFU_1.1.pdf
3/// Device Firmware Upgrade class, App specific
2pub(crate) const USB_CLASS_APPN_SPEC: u8 = 0xFE; 4pub(crate) const USB_CLASS_APPN_SPEC: u8 = 0xFE;
5/// Device Firmware Upgrade subclass, App specific
3pub(crate) const APPN_SPEC_SUBCLASS_DFU: u8 = 0x01; 6pub(crate) const APPN_SPEC_SUBCLASS_DFU: u8 = 0x01;
4#[allow(unused)] 7#[allow(unused)]
8/// USB interface alternative setting
5pub(crate) const DFU_PROTOCOL_DFU: u8 = 0x02; 9pub(crate) const DFU_PROTOCOL_DFU: u8 = 0x02;
6#[allow(unused)] 10#[allow(unused)]
11/// DFU runtime class
7pub(crate) const DFU_PROTOCOL_RT: u8 = 0x01; 12pub(crate) const DFU_PROTOCOL_RT: u8 = 0x01;
13/// DFU functional descriptor
8pub(crate) const DESC_DFU_FUNCTIONAL: u8 = 0x21; 14pub(crate) const DESC_DFU_FUNCTIONAL: u8 = 0x21;
9 15
10macro_rules! define_dfu_attributes { 16macro_rules! define_dfu_attributes {
@@ -34,51 +40,89 @@ define_dfu_attributes!(bitflags::bitflags);
34#[derive(Copy, Clone, PartialEq, Eq)] 40#[derive(Copy, Clone, PartialEq, Eq)]
35#[repr(u8)] 41#[repr(u8)]
36#[allow(unused)] 42#[allow(unused)]
43/// An indication of the state that the device is going to enter immediately following transmission of this response.
37pub(crate) enum State { 44pub(crate) enum State {
45 /// Device is running its normal application.
38 AppIdle = 0, 46 AppIdle = 0,
47 /// Device is running its normal application, has received the DFU_DETACH request, and is waiting for a USB reset.
39 AppDetach = 1, 48 AppDetach = 1,
49 /// Device is operating in the DFU mode and is waiting for requests.
40 DfuIdle = 2, 50 DfuIdle = 2,
51 /// Device has received a block and is waiting for the host to solicit the status via DFU_GETSTATUS.
41 DlSync = 3, 52 DlSync = 3,
53 /// Device is programming a control-write block into its nonvolatile memories.
42 DlBusy = 4, 54 DlBusy = 4,
55 /// Device is processing a download operation. Expecting DFU_DNLOAD requests.
43 Download = 5, 56 Download = 5,
57 /// Device has received the final block of firmware from the host, waits for DFU_GETSTATUS to start Manifestation phase or completed this phase
44 ManifestSync = 6, 58 ManifestSync = 6,
59 /// Device is in the Manifestation phase. Not all devices will be able to respond to DFU_GETSTATUS when in this state.
45 Manifest = 7, 60 Manifest = 7,
61 /// Device has programmed its memories and is waiting for a USB reset or a power on reset.
46 ManifestWaitReset = 8, 62 ManifestWaitReset = 8,
63 /// The device is processing an upload operation. Expecting DFU_UPLOAD requests.
47 UploadIdle = 9, 64 UploadIdle = 9,
65 /// An error has occurred. Awaiting the DFU_CLRSTATUS request.
48 Error = 10, 66 Error = 10,
49} 67}
50 68
51#[derive(Copy, Clone, PartialEq, Eq)] 69#[derive(Copy, Clone, PartialEq, Eq)]
52#[repr(u8)] 70#[repr(u8)]
53#[allow(unused)] 71#[allow(unused)]
72/// An indication of the status resulting from the execution of the most recent request.
54pub(crate) enum Status { 73pub(crate) enum Status {
74 /// No error
55 Ok = 0x00, 75 Ok = 0x00,
76 /// File is not targeted for use by this device
56 ErrTarget = 0x01, 77 ErrTarget = 0x01,
78 /// File is for this device but fails some vendor-specific verification test
57 ErrFile = 0x02, 79 ErrFile = 0x02,
80 /// Device is unable to write memory
58 ErrWrite = 0x03, 81 ErrWrite = 0x03,
82 /// Memory erase function failed
59 ErrErase = 0x04, 83 ErrErase = 0x04,
84 /// Memory erase check failed
60 ErrCheckErased = 0x05, 85 ErrCheckErased = 0x05,
86 /// Program memory function failed
61 ErrProg = 0x06, 87 ErrProg = 0x06,
88 /// Programmed memory failed verification
62 ErrVerify = 0x07, 89 ErrVerify = 0x07,
90 /// Cannot program memory due to received address that is out of range
63 ErrAddress = 0x08, 91 ErrAddress = 0x08,
92 /// Received DFU_DNLOAD with wLength = 0, but device does not think it has all of the data yet
64 ErrNotDone = 0x09, 93 ErrNotDone = 0x09,
94 /// Device’s firmware is corrupt. It cannot return to run-time (non-DFU) operations
65 ErrFirmware = 0x0A, 95 ErrFirmware = 0x0A,
96 /// iString indicates a vendor-specific error
66 ErrVendor = 0x0B, 97 ErrVendor = 0x0B,
98 /// Device detected unexpected USB reset signaling
67 ErrUsbr = 0x0C, 99 ErrUsbr = 0x0C,
100 /// Device detected unexpected power on reset
68 ErrPor = 0x0D, 101 ErrPor = 0x0D,
102 /// Something went wrong, but the device does not know what
69 ErrUnknown = 0x0E, 103 ErrUnknown = 0x0E,
104 /// Device stalled an unexpected request
70 ErrStalledPkt = 0x0F, 105 ErrStalledPkt = 0x0F,
71} 106}
72 107
73#[derive(Copy, Clone, PartialEq, Eq)] 108#[derive(Copy, Clone, PartialEq, Eq)]
74#[repr(u8)] 109#[repr(u8)]
110/// DFU requests
75pub(crate) enum Request { 111pub(crate) enum Request {
112 /// Host instructs the device to generate a detach-attach sequence
76 Detach = 0, 113 Detach = 0,
114 /// Host initiates control-write transfers with this request, and sends a DFU_DNLOAD request
115 /// with wLength = 0 to indicate that it has completed transferring the firmware image file
77 Dnload = 1, 116 Dnload = 1,
117 /// The DFU_UPLOAD request is employed by the host to solicit firmware from the device.
78 Upload = 2, 118 Upload = 2,
119 /// The host employs the DFU_GETSTATUS request to facilitate synchronization with the device.
79 GetStatus = 3, 120 GetStatus = 3,
121 /// Any time the device detects an error, it waits with transition until ClrStatus
80 ClrStatus = 4, 122 ClrStatus = 4,
123 /// Requests a report about a state of the device
81 GetState = 5, 124 GetState = 5,
125 /// Enables the host to exit from certain states and return to the DFU_IDLE state
82 Abort = 6, 126 Abort = 6,
83} 127}
84 128