Attention is currently required from: Felix Singer, Paul Menzel, Angel Pons, Arthur Heymans, Michael Niewöhner.
Michał Żygowski has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/56023 )
Change subject: board_enable.c: Add ME unlock function for Clevo laptops
......................................................................
Patch Set 13:
(1 comment)
File meson.build:
https://review.coreboot.org/c/flashrom/+/56023/comment/0a0d95cb_bdcc46c1
PS12, Line 351: srcs += 'acpi_ec.c'
> should go in CB:55714
You are right. Done.
--
To view, visit https://review.coreboot.org/c/flashrom/+/56023
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I6bf1c40900aa674e3ea4f6add12dae8b73759fbb
Gerrit-Change-Number: 56023
Gerrit-PatchSet: 13
Gerrit-Owner: Michał Żygowski <michal.zygowski(a)3mdeb.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Felix Singer <felixsinger(a)posteo.net>
Gerrit-CC: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-CC: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-CC: Michael Niewöhner <foss(a)mniewoehner.de>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Attention: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Attention: Michael Niewöhner <foss(a)mniewoehner.de>
Gerrit-Comment-Date: Thu, 18 Nov 2021 11:22:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-MessageType: comment
Attention is currently required from: Angel Pons, Michael Niewöhner.
Hello build bot (Jenkins), Nico Huber, Sergii Dmytruk,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/55714
to look at the new patch set (#12).
Change subject: acpi_ec: Implement basic ACPI embedded controller API
......................................................................
acpi_ec: Implement basic ACPI embedded controller API
Implement basic functions to read/write EC registers and send standard
ACPI EC commands. Those may prove useful in possible future
implementations of embedded controllers in flashrom and are required
to support EC firmware flashing on Tuxedo laptops.
Signed-off-by: Michał Żygowski <michal.zygowski(a)3mdeb.com>
Signed-off-by: Sergii Dmytruk <sergii.dmytruk(a)3mdeb.com>
Change-Id: Ie3bae8d81c80ae2f286b619e974869e3f2f4545d
---
M Makefile
A acpi_ec.c
A acpi_ec.h
M meson.build
4 files changed, 152 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/14/55714/12
--
To view, visit https://review.coreboot.org/c/flashrom/+/55714
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie3bae8d81c80ae2f286b619e974869e3f2f4545d
Gerrit-Change-Number: 55714
Gerrit-PatchSet: 12
Gerrit-Owner: Michał Żygowski <michal.zygowski(a)3mdeb.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-CC: Michael Niewöhner <foss(a)mniewoehner.de>
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-CC: Sergii Dmytruk <sergii.dmytruk(a)3mdeb.com>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Michael Niewöhner <foss(a)mniewoehner.de>
Gerrit-MessageType: newpatchset
Sergii Dmytruk has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/59408 )
Change subject: flashrom.8.tmpl: remove outdated warning about v1.0
......................................................................
flashrom.8.tmpl: remove outdated warning about v1.0
Change-Id: Id7e0ce412901ccb27124a9958d5ef214ab289518
Signed-off-by: Sergii Dmytruk <sergii.dmytruk(a)3mdeb.com>
---
M flashrom.8.tmpl
1 file changed, 0 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/08/59408/1
diff --git a/flashrom.8.tmpl b/flashrom.8.tmpl
index 3187ab8..92da460 100644
--- a/flashrom.8.tmpl
+++ b/flashrom.8.tmpl
@@ -70,11 +70,6 @@
TSOP48, and BGA chips, which use various protocols such as LPC, FWH,
parallel flash, or SPI.
.SH OPTIONS
-.B IMPORTANT:
-Please note that the command line interface for flashrom will change before
-flashrom 1.0. Do not use flashrom in scripts or other automated tools without
-checking that your flashrom version won't interpret options in a different way.
-.PP
You can specify one of
.BR \-h ", " \-R ", " \-L ", " \-z ", " \-E ", " \-r ", " \-w ", " \-v
or no operation.
--
To view, visit https://review.coreboot.org/c/flashrom/+/59408
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Id7e0ce412901ccb27124a9958d5ef214ab289518
Gerrit-Change-Number: 59408
Gerrit-PatchSet: 1
Gerrit-Owner: Sergii Dmytruk <sergii.dmytruk(a)3mdeb.com>
Gerrit-MessageType: newchange
Sergii Dmytruk has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/59402 )
Change subject: [RFC] spi: add functions for OTP regions
......................................................................
[RFC] spi: add functions for OTP regions
These are functions for entering/leaving OTP mode and
reading/writing/erasing secure registers.
Also introduces part of the structure that describes OTP, because new
code uses it.
This one and other patches resurrecting the work of Hatim Kanchwala
aimed at adding OTP to flashrom.
This chain of patches are based on CB:59075, which in turn depend on
patches that introduce write-protect support.
Change-Id: Ic33e2c1de8b0ca02df9118218a663ce63826f339
Signed-off-by: Hatim Kanchwala <hatim at hatimak.me>
Signed-off-by: Sergii Dmytruk <sergii.dmytruk(a)3mdeb.com>
---
M chipdrivers.h
M flash.h
A otp.h
M spi.h
M spi25.c
5 files changed, 167 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/02/59402/1
diff --git a/chipdrivers.h b/chipdrivers.h
index e1d6aa9..a5fbec9 100644
--- a/chipdrivers.h
+++ b/chipdrivers.h
@@ -59,6 +59,11 @@
int spi_enter_4ba(struct flashctx *flash);
int spi_exit_4ba(struct flashctx *flash);
int spi_set_extended_address(struct flashctx *, uint8_t addr_high);
+int spi_otp_mode_enter(struct flashctx *flash);
+int spi_otp_mode_exit(struct flashctx *flash);
+int spi_sec_reg_read(struct flashctx *flash, uint8_t *buf, uint32_t start_addr, uint32_t len);
+int spi_sec_reg_prog(struct flashctx *flash, uint8_t const *buf, uint32_t start_addr, uint32_t len);
+int spi_sec_reg_erase(struct flashctx *flash, uint32_t addr);
/* spi25_statusreg.c */
diff --git a/flash.h b/flash.h
index 391a2d4..d4b364e 100644
--- a/flash.h
+++ b/flash.h
@@ -245,7 +245,7 @@
/* SPI specific options (TODO: Make it a union in case other bustypes get specific options.) */
uint8_t wrea_override; /**< override opcode for write extended address register */
- struct wp *wp;
+ struct otp *otp;
};
typedef int (*chip_restore_fn_cb_t)(struct flashctx *flash, uint8_t status);
diff --git a/otp.h b/otp.h
new file mode 100644
index 0000000..635d6cb
--- /dev/null
+++ b/otp.h
@@ -0,0 +1,52 @@
+/*
+ * This file is part of the flashrom project.
+ *
+ * Copyright (C) 2016 Hatim Kanchwala <hatim at hatimak.me>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __OTP_H__
+#define __OTP_H__ 1
+
+#include <stdint.h>
+
+#include "flash.h"
+
+struct flashctx;
+
+/* Bits for otp.feature_bits field */
+/* Need to enter special mode to work with OTP */
+#define OTP_KIND_MODE (1 << 0)
+/* Need to use special opcodes to interact with OTP */
+#define OTP_KIND_REGS (1 << 1)
+/* Block protect bits must be cleared before entering OTP mode */
+#define OTP_MODE_CLEAR_BP (1 << 2)
+/* OTP lock must be set while in OTP mode */
+#define OTP_MODE_LOCK_WHILE_IN (1 << 3)
+/* OTP registers are read as one (FIXME: not implemented) */
+#define OTP_REGS_FUSED_READ (1 << 4)
+/* OTP registers are erased as one (FIXME: not implemented) */
+#define OTP_REGS_FUSED_ERASE (1 << 5)
+
+struct otp {
+ int feature_bits; /* must contain either OTP_KIND_MODE or OTP_KIND_REGS */
+
+ /* These opcodes are different for different manufacturers. */
+ uint8_t otp_enter_opcode;
+ uint8_t otp_exit_opcode;
+};
+
+#endif /* !__OTP_H__ */
diff --git a/spi.h b/spi.h
index 09da579..203ef19 100644
--- a/spi.h
+++ b/spi.h
@@ -178,6 +178,26 @@
#define JEDEC_AAI_WORD_PROGRAM_CONT_OUTSIZE 0x03
#define JEDEC_AAI_WORD_PROGRAM_INSIZE 0x00
+/* Enter OTP mode (supported by most Eon chips) */
+#define JEDEC_ENTER_OTP 0x3A
+#define JEDEC_ENTER_OTP_OUTSIZE 0x01
+#define JEDEC_ENTER_OTP_INSIZE 0x00
+
+/* Read Security Register(s) (supported by most GigaDevice chips) */
+#define JEDEC_READ_SEC_REG 0x48
+#define JEDEC_READ_SEC_REG_OUTSIZE 0x05
+/* JEDEC_READ_SEC_REG_INSIZE any length */
+
+/* Program Security Register(s) (supported by most GigaDevice chips) */
+#define JEDEC_PROG_BYTE_SEC_REG 0x42
+#define JEDEC_PROG_BYTE_SEC_REG_OUTSIZE 0x05
+#define JEDEC_PROG_BYTE_SEC_REG_INSIZE 0x00
+
+/* Erase Security Register(s) (supported by most GigaDevice chips) */
+#define JEDEC_ERASE_SEC_REG 0x44
+#define JEDEC_ERASE_SEC_REG_OUTSIZE 0x04
+#define JEDEC_ERASE_SEC_REG_INSIZE 0x00
+
/* Read the memory with 4-byte address
From ANY mode (3-bytes or 4-bytes) it works with 4-byte address */
#define JEDEC_READ_4BA 0x13
diff --git a/spi25.c b/spi25.c
index 213273f..629e239 100644
--- a/spi25.c
+++ b/spi25.c
@@ -26,6 +26,7 @@
#include "chipdrivers.h"
#include "programmer.h"
#include "spi.h"
+#include "otp.h"
enum id_type {
RDID,
@@ -839,3 +840,91 @@
{
return spi_enter_exit_4ba(flash, false);
}
+
+/* This function maps the additional OTP sector to the top or bottom sector
+ * (depending on the chip). The mapped sector behaves like just another normal
+ * sector. */
+int spi_otp_mode_enter(struct flashctx *flash)
+{
+ if (!flash->chip->otp || !flash->chip->otp->otp_enter_opcode)
+ return 1;
+
+ const unsigned char cmd[1] = {
+ flash->chip->otp->otp_enter_opcode
+ };
+ return spi_send_command(flash, sizeof(cmd), 0, cmd, NULL);
+}
+
+int spi_otp_mode_exit(struct flashctx *flash)
+{
+ if (!flash->chip->otp || !flash->chip->otp->otp_exit_opcode)
+ return 1;
+
+ const unsigned char cmd[1] = {
+ flash->chip->otp->otp_exit_opcode
+ };
+ return spi_send_command(flash, sizeof(cmd), 0, cmd, NULL);
+}
+
+int spi_sec_reg_read(struct flashctx *flash, uint8_t *buf, uint32_t start_addr, uint32_t len)
+{
+ /* We assume that start_addr and len are correct and proceed without any error checking. */
+ uint8_t cmd[JEDEC_READ_SEC_REG_OUTSIZE] = {
+ JEDEC_READ_SEC_REG,
+ (start_addr >> 16),
+ (start_addr >> 8),
+ start_addr,
+ 0x00, /* dummy data */
+ };
+
+ int result = spi_send_command(flash, sizeof(cmd), len, cmd, buf);
+ if (result)
+ msg_cerr("%s failed.\n", __func__);
+ return result;
+}
+
+int spi_sec_reg_prog(struct flashctx *flash, uint8_t const *buf, uint32_t start_addr, uint32_t len)
+{
+ /* We assume that start_addr and len are correct, the security register is unlocked
+ * and proceed without any error checking. */
+ int ret = spi_write_enable(flash);
+ if (ret) {
+ msg_cerr("%s failed\n", __func__);
+ return ret;
+ }
+
+ uint8_t cmd[JEDEC_PROG_BYTE_SEC_REG_OUTSIZE - 1 + len];
+ cmd[0] = JEDEC_PROG_BYTE_SEC_REG;
+ cmd[1] = (start_addr >> 16);
+ cmd[2] = (start_addr >> 8);
+ cmd[3] = start_addr;
+ memcpy(&cmd[4], buf, len);
+
+ ret = spi_send_command(flash, sizeof(cmd), 0, cmd, NULL);
+ if (ret || spi_poll_wip(flash, 10))
+ msg_cerr("%s\n", __func__);
+
+ return ret;
+}
+
+int spi_sec_reg_erase(struct flashctx *flash, uint32_t addr)
+{
+ /* We assume that addr is correct and proceed without any error checking. */
+ int ret = spi_write_enable(flash);
+ if (ret) {
+ msg_cerr("%s failed\n", __func__);
+ return ret;
+ }
+
+ uint8_t cmd[JEDEC_ERASE_SEC_REG_OUTSIZE] = {
+ JEDEC_ERASE_SEC_REG,
+ (addr >> 16),
+ (addr >> 8),
+ addr,
+ };
+
+ ret = spi_send_command(flash, sizeof(cmd), 0, cmd, NULL);
+ if (ret || spi_poll_wip(flash, 10))
+ msg_cerr("%s\n", __func__);
+ return ret;
+}
--
To view, visit https://review.coreboot.org/c/flashrom/+/59402
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ic33e2c1de8b0ca02df9118218a663ce63826f339
Gerrit-Change-Number: 59402
Gerrit-PatchSet: 1
Gerrit-Owner: Sergii Dmytruk <sergii.dmytruk(a)3mdeb.com>
Gerrit-MessageType: newchange
Attention is currently required from: Nico Huber, Angel Pons, Anastasia Klimchuk.
Sergii Dmytruk has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/59075 )
Change subject: [RFC] tests: test write protection
......................................................................
Patch Set 5:
(13 comments)
Patchset:
PS5:
> Thank you for working on tests!! I did more detailed code review. […]
Previous patches in the chain make tests possible. I've seen your name in `git blame` for dummyflasher, so I'd appreciate if you could take a look at those changes.
File tests/meson.build:
https://review.coreboot.org/c/flashrom/+/59075/comment/7dfb619c_32c0d6d1
PS5, Line 26: write_protect
> I know I asked you to rename the file, but now I did more detailed review and I think the better nam […]
Done
File tests/tests.h:
https://review.coreboot.org/c/flashrom/+/59075/comment/ede9ed34_950fdc89
PS5, Line 67: write_protection.c
> chip_wp. […]
Done
File tests/tests.c:
https://review.coreboot.org/c/flashrom/+/59075/comment/4f5eee49_5f821cc8
PS5, Line 357: write_protection
> chip_wp
Done
https://review.coreboot.org/c/flashrom/+/59075/comment/24266dfa_3509c179
PS5, Line 364: write_protection.c
> chip_wp. […]
Done
File tests/write_protect.c:
https://review.coreboot.org/c/flashrom/+/59075/comment/a6c445d8_380d6f57
PS5, Line 27: No mocking. Using WP emulation in dummy programmer.
> Maybe a complete phrase is better, like "Tests in this file do not use any mocking, because using wr […]
Done
https://review.coreboot.org/c/flashrom/+/59075/comment/bb68168c_c391d9c6
PS5, Line 101: invalid_setup
> We can be more specific in test name, since it covers invalid range (not just any invalid setup). […]
Done
https://review.coreboot.org/c/flashrom/+/59075/comment/0208bba5_1a451d3f
PS5, Line 117: struct flashrom_wp_chip_config cfg;
> Lets move this declaration in the beginning , together with flash, layout, mock_chip. […]
Done
https://review.coreboot.org/c/flashrom/+/59075/comment/0379418b_bef99b4f
PS5, Line 120: /* Invalid range. */
: range.start = 0x1000;
: range.len = 0x1000;
> why chip_len is initialised at creation time, but start/len initialised separately, few lines later? […]
There used to me more checks, but changes to WP patches cased their removal. Done.
https://review.coreboot.org/c/flashrom/+/59075/comment/00f10e2d_61ba7747
PS5, Line 143: wp=no
> I haven't looked at the rest of your chain (tell me if I should), but this looks confusing: param sa […]
Here "wp" means WP pin of the flash chip. Could rename it to "wppin" or "hwp" (hardware write-protection). The latter might be better because actual pin is negated and I wanted param to set state of hardware protection rather than state of a pin.
https://review.coreboot.org/c/flashrom/+/59075/comment/3548f97f_d7ceb39a
PS5, Line 152: /* Use first 4 KiB for a range. */
: range.len = 0x1000;
: assert_int_equal(0, flashrom_wp_set_range(&cfg, &range));
:
: /* Change range to last 4 KiB. */
: range.start = 0x00fff000;
: assert_int_equal(0, flashrom_wp_set_range(&cfg, &range));
> This code looks like as if test is testing two scenarios? If there are indeed two different scenario […]
Broke it into set_wp_range_dummyflasher_test_success and set_wp_mode_dummyflasher_test_success.
https://review.coreboot.org/c/flashrom/+/59075/comment/949de99f_3a491bcb
PS5, Line 164: /* Switch modes in configuration only. */
: assert_int_equal(0, flashrom_wp_set_mode(&cfg, WP_MODE_HARDWARE));
: assert_int_equal(0, flashrom_wp_set_mode(&cfg, WP_MODE_DISABLED));
: assert_int_equal(0, flashrom_wp_set_mode(&cfg, WP_MODE_POWER_CYCLE));
: assert_int_equal(0, flashrom_wp_set_mode(&cfg, WP_MODE_PERMANENT));
> Do all these need flash context, chip, layout? If not, extract into separate small tests that only d […]
Done
https://review.coreboot.org/c/flashrom/+/59075/comment/3b0d090f_ab8e3ccd
PS5, Line 170: /* Switch modes in dummyflasher. */
: assert_int_equal(0, flashrom_wp_write_chip_config(&flash, &cfg));
: assert_int_equal(0, flashrom_wp_set_mode(&cfg, WP_MODE_POWER_CYCLE));
: assert_int_equal(0, flashrom_wp_write_chip_config(&flash, &cfg));
:
: /* Check final mode. */
: assert_int_equal(0, flashrom_wp_read_chip_config(&flash, &cfg));
: assert_int_equal(0, flashrom_wp_get_mode(&cfg, &mode));
: assert_int_equal(WP_MODE_PERMANENT, mode);
> Which ones of these need layout, if any? […]
Reduced checks performed by the two tests. Layout isn't needed, but dummyflasher is needed to test how WP code behaves on saving state.
--
To view, visit https://review.coreboot.org/c/flashrom/+/59075
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I49af7f6d173eb4c56c22d80b01a473b8c499c0f8
Gerrit-Change-Number: 59075
Gerrit-PatchSet: 5
Gerrit-Owner: Sergii Dmytruk <sergii.dmytruk(a)3mdeb.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Maciej Pijanowski <maciej.pijanowski(a)3mdeb.com>
Gerrit-CC: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Wed, 17 Nov 2021 16:42:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: comment