summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Benn <evanbenn@chromium.org>2021-09-10 13:26:13 +1000
committerJoonas Niilola <juippis@gentoo.org>2021-09-30 15:37:47 +0300
commit6f4df5767f85db04ba4e008394ba13b44c79bed3 (patch)
tree6588456e12742bfdcc54c7046ef5dca4b44a1c83 /dev-embedded/stm32flash
parentnet-wireless/rtl-sdr: Drop 0.5.3_p20170919, 0.5.4, 0.6.0-r1, EAPI6-- (diff)
downloadgentoo-6f4df5767f85db04ba4e008394ba13b44c79bed3.tar.gz
gentoo-6f4df5767f85db04ba4e008394ba13b44c79bed3.tar.bz2
gentoo-6f4df5767f85db04ba4e008394ba13b44c79bed3.zip
dev-embedded/stm32flash: Update to release 0.6
Included patches to fix https://sourceforge.net/p/stm32flash/tickets/98/. Signed-off-by: Evan Benn <evanbenn@chromium.org> Signed-off-by: Joonas Niilola <juippis@gentoo.org>
Diffstat (limited to 'dev-embedded/stm32flash')
-rw-r--r--dev-embedded/stm32flash/Manifest1
-rw-r--r--dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-01fbb65.patch28
-rw-r--r--dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-17a24f8.patch65
-rw-r--r--dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-b079cd0.patch103
-rw-r--r--dev-embedded/stm32flash/stm32flash-0.6.ebuild29
5 files changed, 226 insertions, 0 deletions
diff --git a/dev-embedded/stm32flash/Manifest b/dev-embedded/stm32flash/Manifest
index 5af8d72bb9c1..533136206496 100644
--- a/dev-embedded/stm32flash/Manifest
+++ b/dev-embedded/stm32flash/Manifest
@@ -1 +1,2 @@
DIST stm32flash-0.5.tar.gz 41087 BLAKE2B 581ef883537783fafcff8a7471a697f50929b572d847791d692799040fd54845a67a7b6b608401df24f05810ae81b7e19df646f2835bc3d7cd35888d8649be6a SHA512 a01875a315d92d5e347372b736f2afa2f633851bf13af1326341c0c91e17cef54b6730ed1279280e86d3797033c856dfc25e8c595e010772b9287aaf965273f9
+DIST stm32flash-0.6.tar.gz 376186 BLAKE2B 82e479b4fad2c3ff832aea9d0d62d556500fd8c0530e879690b9b83cdf05f078b0051e1e104e7cb64b9c360ef84415904639ee67ee147045ce8e15ca3f6c61e1 SHA512 2d92ecf4f82b8a702b596cbf3c4ff594f67083f7dcec82c064555f73b47834b41a918efa1846e47fc8740ae63fa818b16dfb5b38fa242c17f465666a651eee3a
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
new file mode 100644
index 000000000000..c4c7a2a7fedc
--- /dev/null
+++ b/dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-01fbb65.patch
@@ -0,0 +1,28 @@
+From 01fbb65d4626e1c122e329075526bd6035cb0be6 Mon Sep 17 00:00:00 2001
+From: Tormod Volden <debian.tormod@gmail.com>
+Date: Thu, 2 Sep 2021 16:25:57 +0200
+Subject: [PATCH 06/15] stm32: Fix typo from recent commit
+
+Oops, I got this wrong while amending commit b079cd09.
+
+Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
+---
+ stm32.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/stm32.c b/stm32.c
+index 6e2e402..0edaf01 100644
+--- a/stm32.c
++++ b/stm32.c
+@@ -851,7 +851,7 @@ static stm32_err_t stm32_pages_erase(const stm32_t *stm, uint32_t spage, uint32_
+ buf[i++] = pages - 1;
+ cs ^= (pages-1);
+ /* For I2C send a checksum after the number of pages (AN4221) */
+- if (port->flags && PORT_NPAG_CSUM) {
++ if (port->flags & PORT_NPAG_CSUM) {
+ buf[i++] = cs;
+ p_err = port->write(port, buf, i);
+ if (p_err != PORT_ERR_OK) {
+--
+2.33.0.309.g3052b89438-goog
+
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
new file mode 100644
index 000000000000..e0b519c48413
--- /dev/null
+++ b/dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-17a24f8.patch
@@ -0,0 +1,65 @@
+From 17a24f873122b96481adefaadc128bd1abba594f Mon Sep 17 00:00:00 2001
+From: Tormod Volden <debian.tormod@gmail.com>
+Date: Sat, 21 Aug 2021 13:06:34 +0200
+Subject: [PATCH 02/15] stm32: Consistent and unique erase error messages
+
+Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
+---
+ stm32.c | 11 ++++++-----
+ 1 file changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/stm32.c b/stm32.c
+index 82fa26a..e071905 100644
+--- a/stm32.c
++++ b/stm32.c
+@@ -797,7 +797,7 @@ static stm32_err_t stm32_mass_erase(const stm32_t *stm)
+ return STM32_ERR_OK;
+ }
+
+- /* extended erase */
++ /* extended erase (0x44 or 0x45) */
+ buf[0] = 0xFF; /* 0xFFFF the magic number for mass erase */
+ buf[1] = 0xFF;
+ buf[2] = 0x00; /* checksum */
+@@ -870,11 +870,12 @@ static stm32_err_t stm32_pages_erase(const stm32_t *stm, uint32_t spage, uint32_
+ p_err = port->write(port, buf, i);
+ free(buf);
+ if (p_err != PORT_ERR_OK) {
+- fprintf(stderr, "Erase failed.\n");
++ fprintf(stderr, "Erase failed sending list of pages.\n");
+ return STM32_ERR_UNKNOWN;
+ }
+ s_err = stm32_get_ack_timeout(stm, pages * STM32_PAGEERASE_TIMEOUT);
+ if (s_err != STM32_ERR_OK) {
++ fprintf(stderr, "Erase failed.\n");
+ if (port->flags & PORT_STRETCH_W)
+ stm32_warn_stretching("erase");
+ return STM32_ERR_UNKNOWN;
+@@ -882,7 +883,7 @@ static stm32_err_t stm32_pages_erase(const stm32_t *stm, uint32_t spage, uint32_
+ return STM32_ERR_OK;
+ }
+
+- /* extended erase */
++ /* extended erase (0x44 or 0x45) */
+ buf = malloc(2 + 2 * pages + 1);
+ if (!buf)
+ return STM32_ERR_UNKNOWN;
+@@ -925,13 +926,13 @@ static stm32_err_t stm32_pages_erase(const stm32_t *stm, uint32_t spage, uint32_
+ p_err = port->write(port, buf, i);
+ free(buf);
+ if (p_err != PORT_ERR_OK) {
+- fprintf(stderr, "Page-by-page erase error.\n");
++ fprintf(stderr, "Extended erase failed sending list of pages.\n");
+ return STM32_ERR_UNKNOWN;
+ }
+
+ s_err = stm32_get_ack_timeout(stm, pages * STM32_PAGEERASE_TIMEOUT);
+ if (s_err != STM32_ERR_OK) {
+- fprintf(stderr, "Page-by-page erase failed. Check the maximum pages your device supports.\n");
++ fprintf(stderr, "Extended erase failed. Check the maximum pages your device supports.\n");
+ if ((port->flags & PORT_STRETCH_W)
+ && stm->cmd->er != STM32_CMD_EE_NS)
+ stm32_warn_stretching("erase");
+--
+2.33.0.309.g3052b89438-goog
+
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
new file mode 100644
index 000000000000..dcd7299570c5
--- /dev/null
+++ b/dev-embedded/stm32flash/files/stm32flash-0.6-fix-i2c-erase-b079cd0.patch
@@ -0,0 +1,103 @@
+From b079cd09bc942b4a489cad29524418441a44fc82 Mon Sep 17 00:00:00 2001
+From: Yann Sionneau <ysionneau@kalray.eu>
+Date: Wed, 28 Apr 2021 14:16:01 +0200
+Subject: [PATCH 01/15] Follow bootloader protocol for page-by-page erase over
+ I2C
+
+For I2C the protocol is slighly different than for USART,
+requiring a checksum after the number of pages.
+
+https://sourceforge.net/p/stm32flash/tickets/98/
+
+Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
+[Tormod: Add port flag, no wait, amend messages]
+Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
+---
+ i2c.c | 2 +-
+ port.h | 1 +
+ stm32.c | 37 +++++++++++++++++++++++++++++++++++++
+ 3 files changed, 39 insertions(+), 1 deletion(-)
+
+diff --git a/i2c.c b/i2c.c
+index bb99545..8425b41 100644
+--- a/i2c.c
++++ b/i2c.c
+@@ -204,7 +204,7 @@ static port_err_t i2c_flush(struct port_interface __unused *port)
+
+ struct port_interface port_i2c = {
+ .name = "i2c",
+- .flags = PORT_STRETCH_W,
++ .flags = PORT_STRETCH_W | PORT_NPAG_CSUM,
+ .open = i2c_open,
+ .close = i2c_close,
+ .flush = i2c_flush,
+diff --git a/port.h b/port.h
+index 4e728d7..1a28dc6 100644
+--- a/port.h
++++ b/port.h
+@@ -34,6 +34,7 @@ typedef enum {
+ #define PORT_CMD_INIT (1 << 2) /* use INIT cmd to autodetect speed */
+ #define PORT_RETRY (1 << 3) /* allowed read() retry after timeout */
+ #define PORT_STRETCH_W (1 << 4) /* warning for no-stretching commands */
++#define PORT_NPAG_CSUM (1 << 5) /* checksum after number of pages to erase */
+
+ /* all options and flags used to open and configure an interface */
+ struct port_options {
+diff --git a/stm32.c b/stm32.c
+index 966048b..82fa26a 100644
+--- a/stm32.c
++++ b/stm32.c
+@@ -843,6 +843,25 @@ static stm32_err_t stm32_pages_erase(const stm32_t *stm, uint32_t spage, uint32_
+
+ buf[i++] = pages - 1;
+ cs ^= (pages-1);
++ /* For I2C send a checksum after the number of pages (AN4221) */
++ if (port->flags && PORT_NPAG_CSUM) {
++ buf[i++] = cs;
++ p_err = port->write(port, buf, i);
++ if (p_err != PORT_ERR_OK) {
++ fprintf(stderr, "Erase failed sending number of pages.");
++ free(buf);
++ return STM32_ERR_UNKNOWN;
++ }
++ s_err = stm32_get_ack(stm);
++ if (s_err != STM32_ERR_OK) {
++ fprintf(stderr, "Erase failed, no ack after number of pages.");
++ free(buf);
++ return STM32_ERR_UNKNOWN;
++ }
++ cs = 0;
++ i = 0;
++ }
++
+ for (pg_num = spage; pg_num < (pages + spage); pg_num++) {
+ buf[i++] = pg_num;
+ cs ^= pg_num;
+@@ -876,6 +895,24 @@ static stm32_err_t stm32_pages_erase(const stm32_t *stm, uint32_t spage, uint32_
+ buf[i++] = pg_byte;
+ cs ^= pg_byte;
+
++ if (port->flags & PORT_NPAG_CSUM) {
++ buf[i++] = cs;
++ p_err = port->write(port, buf, i);
++ if (p_err != PORT_ERR_OK) {
++ fprintf(stderr, "Extended erase failed sending number of pages.");
++ free(buf);
++ return STM32_ERR_UNKNOWN;
++ }
++ s_err = stm32_get_ack(stm);
++ if (s_err != STM32_ERR_OK) {
++ fprintf(stderr, "Extended erase failed, no ack after number of pages.");
++ free(buf);
++ return STM32_ERR_UNKNOWN;
++ }
++ cs = 0;
++ i = 0;
++ }
++
+ for (pg_num = spage; pg_num < spage + pages; pg_num++) {
+ pg_byte = pg_num >> 8;
+ cs ^= pg_byte;
+--
+2.33.0.309.g3052b89438-goog
+
diff --git a/dev-embedded/stm32flash/stm32flash-0.6.ebuild b/dev-embedded/stm32flash/stm32flash-0.6.ebuild
new file mode 100644
index 000000000000..db1e7e8c649b
--- /dev/null
+++ b/dev-embedded/stm32flash/stm32flash-0.6.ebuild
@@ -0,0 +1,29 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+inherit toolchain-funcs
+
+DESCRIPTION="Open source flash program for STM32 using the ST serial bootloader"
+HOMEPAGE="https://sourceforge.net/projects/stm32flash/"
+SRC_URI="mirror://sourceforge/project/${PN}/${P}.tar.gz"
+
+LICENSE="GPL-2+"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+
+PATCHES=(
+ "${FILESDIR}/stm32flash-0.6-fix-i2c-erase-b079cd0.patch"
+ "${FILESDIR}/stm32flash-0.6-fix-i2c-erase-17a24f8.patch"
+ "${FILESDIR}/stm32flash-0.6-fix-i2c-erase-01fbb65.patch"
+)
+
+src_prepare() {
+ default
+ tc-export CC
+}
+
+src_install() {
+ dobin ${PN}
+ doman ${PN}.1
+}