1 |
commit: 6f4df5767f85db04ba4e008394ba13b44c79bed3 |
2 |
Author: Evan Benn <evanbenn <AT> chromium <DOT> org> |
3 |
AuthorDate: Fri Sep 10 03:26:13 2021 +0000 |
4 |
Commit: Joonas Niilola <juippis <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Sep 30 12:37:47 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6f4df576 |
7 |
|
8 |
dev-embedded/stm32flash: Update to release 0.6 |
9 |
|
10 |
Included patches to fix |
11 |
https://sourceforge.net/p/stm32flash/tickets/98/. |
12 |
|
13 |
Signed-off-by: Evan Benn <evanbenn <AT> chromium.org> |
14 |
Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org> |
15 |
|
16 |
dev-embedded/stm32flash/Manifest | 1 + |
17 |
.../stm32flash-0.6-fix-i2c-erase-01fbb65.patch | 28 ++++++ |
18 |
.../stm32flash-0.6-fix-i2c-erase-17a24f8.patch | 65 +++++++++++++ |
19 |
.../stm32flash-0.6-fix-i2c-erase-b079cd0.patch | 103 +++++++++++++++++++++ |
20 |
dev-embedded/stm32flash/stm32flash-0.6.ebuild | 29 ++++++ |
21 |
5 files changed, 226 insertions(+) |
22 |
|
23 |
diff --git a/dev-embedded/stm32flash/Manifest b/dev-embedded/stm32flash/Manifest |
24 |
index 5af8d72bb9c..53313620649 100644 |
25 |
--- a/dev-embedded/stm32flash/Manifest |
26 |
+++ b/dev-embedded/stm32flash/Manifest |
27 |
@@ -1 +1,2 @@ |
28 |
DIST stm32flash-0.5.tar.gz 41087 BLAKE2B 581ef883537783fafcff8a7471a697f50929b572d847791d692799040fd54845a67a7b6b608401df24f05810ae81b7e19df646f2835bc3d7cd35888d8649be6a SHA512 a01875a315d92d5e347372b736f2afa2f633851bf13af1326341c0c91e17cef54b6730ed1279280e86d3797033c856dfc25e8c595e010772b9287aaf965273f9 |
29 |
+DIST stm32flash-0.6.tar.gz 376186 BLAKE2B 82e479b4fad2c3ff832aea9d0d62d556500fd8c0530e879690b9b83cdf05f078b0051e1e104e7cb64b9c360ef84415904639ee67ee147045ce8e15ca3f6c61e1 SHA512 2d92ecf4f82b8a702b596cbf3c4ff594f67083f7dcec82c064555f73b47834b41a918efa1846e47fc8740ae63fa818b16dfb5b38fa242c17f465666a651eee3a |
30 |
|
31 |
diff --git a/dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-01fbb65.patch b/dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-01fbb65.patch |
32 |
new file mode 100644 |
33 |
index 00000000000..c4c7a2a7fed |
34 |
--- /dev/null |
35 |
+++ b/dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-01fbb65.patch |
36 |
@@ -0,0 +1,28 @@ |
37 |
+From 01fbb65d4626e1c122e329075526bd6035cb0be6 Mon Sep 17 00:00:00 2001 |
38 |
+From: Tormod Volden <debian.tormod@×××××.com> |
39 |
+Date: Thu, 2 Sep 2021 16:25:57 +0200 |
40 |
+Subject: [PATCH 06/15] stm32: Fix typo from recent commit |
41 |
+ |
42 |
+Oops, I got this wrong while amending commit b079cd09. |
43 |
+ |
44 |
+Signed-off-by: Tormod Volden <debian.tormod@×××××.com> |
45 |
+--- |
46 |
+ stm32.c | 2 +- |
47 |
+ 1 file changed, 1 insertion(+), 1 deletion(-) |
48 |
+ |
49 |
+diff --git a/stm32.c b/stm32.c |
50 |
+index 6e2e402..0edaf01 100644 |
51 |
+--- a/stm32.c |
52 |
++++ b/stm32.c |
53 |
+@@ -851,7 +851,7 @@ static stm32_err_t stm32_pages_erase(const stm32_t *stm, uint32_t spage, uint32_ |
54 |
+ buf[i++] = pages - 1; |
55 |
+ cs ^= (pages-1); |
56 |
+ /* For I2C send a checksum after the number of pages (AN4221) */ |
57 |
+- if (port->flags && PORT_NPAG_CSUM) { |
58 |
++ if (port->flags & PORT_NPAG_CSUM) { |
59 |
+ buf[i++] = cs; |
60 |
+ p_err = port->write(port, buf, i); |
61 |
+ if (p_err != PORT_ERR_OK) { |
62 |
+-- |
63 |
+2.33.0.309.g3052b89438-goog |
64 |
+ |
65 |
|
66 |
diff --git a/dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-17a24f8.patch b/dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-17a24f8.patch |
67 |
new file mode 100644 |
68 |
index 00000000000..e0b519c4841 |
69 |
--- /dev/null |
70 |
+++ b/dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-17a24f8.patch |
71 |
@@ -0,0 +1,65 @@ |
72 |
+From 17a24f873122b96481adefaadc128bd1abba594f Mon Sep 17 00:00:00 2001 |
73 |
+From: Tormod Volden <debian.tormod@×××××.com> |
74 |
+Date: Sat, 21 Aug 2021 13:06:34 +0200 |
75 |
+Subject: [PATCH 02/15] stm32: Consistent and unique erase error messages |
76 |
+ |
77 |
+Signed-off-by: Tormod Volden <debian.tormod@×××××.com> |
78 |
+--- |
79 |
+ stm32.c | 11 ++++++----- |
80 |
+ 1 file changed, 6 insertions(+), 5 deletions(-) |
81 |
+ |
82 |
+diff --git a/stm32.c b/stm32.c |
83 |
+index 82fa26a..e071905 100644 |
84 |
+--- a/stm32.c |
85 |
++++ b/stm32.c |
86 |
+@@ -797,7 +797,7 @@ static stm32_err_t stm32_mass_erase(const stm32_t *stm) |
87 |
+ return STM32_ERR_OK; |
88 |
+ } |
89 |
+ |
90 |
+- /* extended erase */ |
91 |
++ /* extended erase (0x44 or 0x45) */ |
92 |
+ buf[0] = 0xFF; /* 0xFFFF the magic number for mass erase */ |
93 |
+ buf[1] = 0xFF; |
94 |
+ buf[2] = 0x00; /* checksum */ |
95 |
+@@ -870,11 +870,12 @@ static stm32_err_t stm32_pages_erase(const stm32_t *stm, uint32_t spage, uint32_ |
96 |
+ p_err = port->write(port, buf, i); |
97 |
+ free(buf); |
98 |
+ if (p_err != PORT_ERR_OK) { |
99 |
+- fprintf(stderr, "Erase failed.\n"); |
100 |
++ fprintf(stderr, "Erase failed sending list of pages.\n"); |
101 |
+ return STM32_ERR_UNKNOWN; |
102 |
+ } |
103 |
+ s_err = stm32_get_ack_timeout(stm, pages * STM32_PAGEERASE_TIMEOUT); |
104 |
+ if (s_err != STM32_ERR_OK) { |
105 |
++ fprintf(stderr, "Erase failed.\n"); |
106 |
+ if (port->flags & PORT_STRETCH_W) |
107 |
+ stm32_warn_stretching("erase"); |
108 |
+ return STM32_ERR_UNKNOWN; |
109 |
+@@ -882,7 +883,7 @@ static stm32_err_t stm32_pages_erase(const stm32_t *stm, uint32_t spage, uint32_ |
110 |
+ return STM32_ERR_OK; |
111 |
+ } |
112 |
+ |
113 |
+- /* extended erase */ |
114 |
++ /* extended erase (0x44 or 0x45) */ |
115 |
+ buf = malloc(2 + 2 * pages + 1); |
116 |
+ if (!buf) |
117 |
+ return STM32_ERR_UNKNOWN; |
118 |
+@@ -925,13 +926,13 @@ static stm32_err_t stm32_pages_erase(const stm32_t *stm, uint32_t spage, uint32_ |
119 |
+ p_err = port->write(port, buf, i); |
120 |
+ free(buf); |
121 |
+ if (p_err != PORT_ERR_OK) { |
122 |
+- fprintf(stderr, "Page-by-page erase error.\n"); |
123 |
++ fprintf(stderr, "Extended erase failed sending list of pages.\n"); |
124 |
+ return STM32_ERR_UNKNOWN; |
125 |
+ } |
126 |
+ |
127 |
+ s_err = stm32_get_ack_timeout(stm, pages * STM32_PAGEERASE_TIMEOUT); |
128 |
+ if (s_err != STM32_ERR_OK) { |
129 |
+- fprintf(stderr, "Page-by-page erase failed. Check the maximum pages your device supports.\n"); |
130 |
++ fprintf(stderr, "Extended erase failed. Check the maximum pages your device supports.\n"); |
131 |
+ if ((port->flags & PORT_STRETCH_W) |
132 |
+ && stm->cmd->er != STM32_CMD_EE_NS) |
133 |
+ stm32_warn_stretching("erase"); |
134 |
+-- |
135 |
+2.33.0.309.g3052b89438-goog |
136 |
+ |
137 |
|
138 |
diff --git a/dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-b079cd0.patch b/dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-b079cd0.patch |
139 |
new file mode 100644 |
140 |
index 00000000000..dcd7299570c |
141 |
--- /dev/null |
142 |
+++ b/dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-b079cd0.patch |
143 |
@@ -0,0 +1,103 @@ |
144 |
+From b079cd09bc942b4a489cad29524418441a44fc82 Mon Sep 17 00:00:00 2001 |
145 |
+From: Yann Sionneau <ysionneau@××××××.eu> |
146 |
+Date: Wed, 28 Apr 2021 14:16:01 +0200 |
147 |
+Subject: [PATCH 01/15] Follow bootloader protocol for page-by-page erase over |
148 |
+ I2C |
149 |
+ |
150 |
+For I2C the protocol is slighly different than for USART, |
151 |
+requiring a checksum after the number of pages. |
152 |
+ |
153 |
+https://sourceforge.net/p/stm32flash/tickets/98/ |
154 |
+ |
155 |
+Signed-off-by: Yann Sionneau <ysionneau@××××××.eu> |
156 |
+[Tormod: Add port flag, no wait, amend messages] |
157 |
+Signed-off-by: Tormod Volden <debian.tormod@×××××.com> |
158 |
+--- |
159 |
+ i2c.c | 2 +- |
160 |
+ port.h | 1 + |
161 |
+ stm32.c | 37 +++++++++++++++++++++++++++++++++++++ |
162 |
+ 3 files changed, 39 insertions(+), 1 deletion(-) |
163 |
+ |
164 |
+diff --git a/i2c.c b/i2c.c |
165 |
+index bb99545..8425b41 100644 |
166 |
+--- a/i2c.c |
167 |
++++ b/i2c.c |
168 |
+@@ -204,7 +204,7 @@ static port_err_t i2c_flush(struct port_interface __unused *port) |
169 |
+ |
170 |
+ struct port_interface port_i2c = { |
171 |
+ .name = "i2c", |
172 |
+- .flags = PORT_STRETCH_W, |
173 |
++ .flags = PORT_STRETCH_W | PORT_NPAG_CSUM, |
174 |
+ .open = i2c_open, |
175 |
+ .close = i2c_close, |
176 |
+ .flush = i2c_flush, |
177 |
+diff --git a/port.h b/port.h |
178 |
+index 4e728d7..1a28dc6 100644 |
179 |
+--- a/port.h |
180 |
++++ b/port.h |
181 |
+@@ -34,6 +34,7 @@ typedef enum { |
182 |
+ #define PORT_CMD_INIT (1 << 2) /* use INIT cmd to autodetect speed */ |
183 |
+ #define PORT_RETRY (1 << 3) /* allowed read() retry after timeout */ |
184 |
+ #define PORT_STRETCH_W (1 << 4) /* warning for no-stretching commands */ |
185 |
++#define PORT_NPAG_CSUM (1 << 5) /* checksum after number of pages to erase */ |
186 |
+ |
187 |
+ /* all options and flags used to open and configure an interface */ |
188 |
+ struct port_options { |
189 |
+diff --git a/stm32.c b/stm32.c |
190 |
+index 966048b..82fa26a 100644 |
191 |
+--- a/stm32.c |
192 |
++++ b/stm32.c |
193 |
+@@ -843,6 +843,25 @@ static stm32_err_t stm32_pages_erase(const stm32_t *stm, uint32_t spage, uint32_ |
194 |
+ |
195 |
+ buf[i++] = pages - 1; |
196 |
+ cs ^= (pages-1); |
197 |
++ /* For I2C send a checksum after the number of pages (AN4221) */ |
198 |
++ if (port->flags && PORT_NPAG_CSUM) { |
199 |
++ buf[i++] = cs; |
200 |
++ p_err = port->write(port, buf, i); |
201 |
++ if (p_err != PORT_ERR_OK) { |
202 |
++ fprintf(stderr, "Erase failed sending number of pages."); |
203 |
++ free(buf); |
204 |
++ return STM32_ERR_UNKNOWN; |
205 |
++ } |
206 |
++ s_err = stm32_get_ack(stm); |
207 |
++ if (s_err != STM32_ERR_OK) { |
208 |
++ fprintf(stderr, "Erase failed, no ack after number of pages."); |
209 |
++ free(buf); |
210 |
++ return STM32_ERR_UNKNOWN; |
211 |
++ } |
212 |
++ cs = 0; |
213 |
++ i = 0; |
214 |
++ } |
215 |
++ |
216 |
+ for (pg_num = spage; pg_num < (pages + spage); pg_num++) { |
217 |
+ buf[i++] = pg_num; |
218 |
+ cs ^= pg_num; |
219 |
+@@ -876,6 +895,24 @@ static stm32_err_t stm32_pages_erase(const stm32_t *stm, uint32_t spage, uint32_ |
220 |
+ buf[i++] = pg_byte; |
221 |
+ cs ^= pg_byte; |
222 |
+ |
223 |
++ if (port->flags & PORT_NPAG_CSUM) { |
224 |
++ buf[i++] = cs; |
225 |
++ p_err = port->write(port, buf, i); |
226 |
++ if (p_err != PORT_ERR_OK) { |
227 |
++ fprintf(stderr, "Extended erase failed sending number of pages."); |
228 |
++ free(buf); |
229 |
++ return STM32_ERR_UNKNOWN; |
230 |
++ } |
231 |
++ s_err = stm32_get_ack(stm); |
232 |
++ if (s_err != STM32_ERR_OK) { |
233 |
++ fprintf(stderr, "Extended erase failed, no ack after number of pages."); |
234 |
++ free(buf); |
235 |
++ return STM32_ERR_UNKNOWN; |
236 |
++ } |
237 |
++ cs = 0; |
238 |
++ i = 0; |
239 |
++ } |
240 |
++ |
241 |
+ for (pg_num = spage; pg_num < spage + pages; pg_num++) { |
242 |
+ pg_byte = pg_num >> 8; |
243 |
+ cs ^= pg_byte; |
244 |
+-- |
245 |
+2.33.0.309.g3052b89438-goog |
246 |
+ |
247 |
|
248 |
diff --git a/dev-embedded/stm32flash/stm32flash-0.6.ebuild b/dev-embedded/stm32flash/stm32flash-0.6.ebuild |
249 |
new file mode 100644 |
250 |
index 00000000000..db1e7e8c649 |
251 |
--- /dev/null |
252 |
+++ b/dev-embedded/stm32flash/stm32flash-0.6.ebuild |
253 |
@@ -0,0 +1,29 @@ |
254 |
+# Copyright 1999-2017 Gentoo Foundation |
255 |
+# Distributed under the terms of the GNU General Public License v2 |
256 |
+ |
257 |
+EAPI=8 |
258 |
+inherit toolchain-funcs |
259 |
+ |
260 |
+DESCRIPTION="Open source flash program for STM32 using the ST serial bootloader" |
261 |
+HOMEPAGE="https://sourceforge.net/projects/stm32flash/" |
262 |
+SRC_URI="mirror://sourceforge/project/${PN}/${P}.tar.gz" |
263 |
+ |
264 |
+LICENSE="GPL-2+" |
265 |
+SLOT="0" |
266 |
+KEYWORDS="~amd64 ~x86" |
267 |
+ |
268 |
+PATCHES=( |
269 |
+ "${FILESDIR}/stm32flash-0.6-fix-i2c-erase-b079cd0.patch" |
270 |
+ "${FILESDIR}/stm32flash-0.6-fix-i2c-erase-17a24f8.patch" |
271 |
+ "${FILESDIR}/stm32flash-0.6-fix-i2c-erase-01fbb65.patch" |
272 |
+) |
273 |
+ |
274 |
+src_prepare() { |
275 |
+ default |
276 |
+ tc-export CC |
277 |
+} |
278 |
+ |
279 |
+src_install() { |
280 |
+ dobin ${PN} |
281 |
+ doman ${PN}.1 |
282 |
+} |