Attention is currently required from: Stefan Reinauer, Anastasia Klimchuk, Peter Marheine.
Thomas Heijligen has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/73359 )
Change subject: doc: Add build instructions
......................................................................
Patch Set 3:
(4 comments)
File doc/developers_doc/building_from_source.rst:
https://review.coreboot.org/c/flashrom/+/73359/comment/421502b0_20305b6c
PS3, Line 105: py-
This is py39-sphinx
https://review.coreboot.org/c/flashrom/+/73359/comment/dda257ab_52ac5d2f
PS3, Line 113: install
just `pkg_add`, no `install` needed
https://review.coreboot.org/c/flashrom/+/73359/comment/0d4c81fe_b19d8f7f
PS3, Line 114: py-sphinx
py3-sphinx
https://review.coreboot.org/c/flashrom/+/73359/comment/9dea45ef_c7f09493
PS3, Line 175: .. todo:: Write a sphinx extension to render ``meson_options.txt`` here
> `meson configure` will print out all options including project-specific ones, and the inline documen […]
IIRC `meson configure` will only work when you already have a builddir configured.
I'll document the options manually.
--
To view, visit https://review.coreboot.org/c/flashrom/+/73359
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I96771e98b313a6d26dd2be940ff37998d4124324
Gerrit-Change-Number: 73359
Gerrit-PatchSet: 3
Gerrit-Owner: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: Alexander Goncharov <chat(a)joursoir.net>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-CC: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-CC: Stefan Reinauer <stefan.reinauer(a)coreboot.org>
Gerrit-Attention: Stefan Reinauer <stefan.reinauer(a)coreboot.org>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Comment-Date: Mon, 06 Mar 2023 14:58:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-MessageType: comment
Attention is currently required from: Nikolai Artemiev.
Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/73495 )
Change subject: linux_mtd.c: Factor out detection phases from setup func
......................................................................
linux_mtd.c: Factor out detection phases from setup func
The setup phase function is performing detection logic,
move this to a earlier phase in the init sequence such
that it can be used seperately.
Change-Id: I15915b71e1a030548c5f082cde78c42ece28bb37
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
---
M linux_mtd.c
1 file changed, 70 insertions(+), 59 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/95/73495/1
diff --git a/linux_mtd.c b/linux_mtd.c
index b3be72a..708e340 100644
--- a/linux_mtd.c
+++ b/linux_mtd.c
@@ -443,57 +443,6 @@
.wp_get_ranges = linux_mtd_wp_get_available_ranges,
};
-/* Returns 0 if setup is successful, non-zero to indicate error */
-static int linux_mtd_setup(int dev_num, struct linux_mtd_data *data)
-{
- char sysfs_path[32];
- int ret = 1;
-
- /* Start by checking /sys/class/mtd/mtdN/type which should be "nor" for NOR flash */
- if (snprintf(sysfs_path, sizeof(sysfs_path), "%s/mtd%d/", LINUX_MTD_SYSFS_ROOT, dev_num) < 0)
- goto linux_mtd_setup_exit;
-
- char buf[4] = { 0 };
- if (read_sysfs_string(sysfs_path, "type", buf, sizeof(buf)))
- return 1;
-
- if (strcmp(buf, "nor")) {
- msg_perr("MTD device %d type is not \"nor\"\n", dev_num);
- goto linux_mtd_setup_exit;
- }
-
- /* sysfs shows the correct device type, see if corresponding device node exists */
- char dev_path[32];
- struct stat s;
- snprintf(dev_path, sizeof(dev_path), "%s/mtd%d", LINUX_DEV_ROOT, dev_num);
- errno = 0;
- if (stat(dev_path, &s) < 0) {
- msg_pdbg("Cannot stat \"%s\": %s\n", dev_path, strerror(errno));
- goto linux_mtd_setup_exit;
- }
-
- /* so far so good, get more info from other files in this dir */
- if (snprintf(sysfs_path, sizeof(sysfs_path), "%s/mtd%d/", LINUX_MTD_SYSFS_ROOT, dev_num) < 0)
- goto linux_mtd_setup_exit;
- if (get_mtd_info(sysfs_path, data))
- goto linux_mtd_setup_exit;
-
- /* open file stream and go! */
- if ((data->dev_fp = fopen(dev_path, "r+")) == NULL) {
- msg_perr("Cannot open file stream for %s\n", dev_path);
- goto linux_mtd_setup_exit;
- }
- ret = setvbuf(data->dev_fp, NULL, _IONBF, 0);
- if (ret)
- msg_pwarn("Failed to set MTD device to unbuffered: %d\n", ret);
-
- msg_pinfo("Opened %s successfully\n", dev_path);
-
- ret = 0;
-linux_mtd_setup_exit:
- return ret;
-}
-
static int get_params(const struct programmer_cfg *cfg, int *dev_num)
{
char *param_str = extract_programmer_param_str(cfg, "dev");
@@ -516,17 +465,18 @@
return 0;
}
-static int check_sysfs_devnum_path(int dev_num)
+static int detect_spinor_in_sysfs(int dev_num, char *dev_path, size_t dp_len)
{
+ /* Start by checking /sys/class/mtd/mtdN/type which should be "nor" for NOR flash */
+ char sysfs_path[32];
+ if (snprintf(sysfs_path, sizeof(sysfs_path), "%s/mtd%d", LINUX_MTD_SYSFS_ROOT, dev_num) < 0)
+ return -1;
+
/*
* If user specified the MTD device number then error out if it doesn't
* appear to exist. Otherwise assume the error is benign and print a
* debug message. Bail out in either case.
*/
- char sysfs_path[32];
- if (snprintf(sysfs_path, sizeof(sysfs_path), "%s/mtd%d", LINUX_MTD_SYSFS_ROOT, dev_num) < 0)
- return -1;
-
struct stat s;
if (stat(sysfs_path, &s) < 0) {
if (dev_num)
@@ -535,17 +485,64 @@
msg_pdbg("%s does not exist\n", sysfs_path);
return -1;
}
+
+ /* Check sysfs shows the correct device type. */
+ char buf[4] = { 0 };
+ if (read_sysfs_string(sysfs_path, "type", buf, sizeof(buf)))
+ return -1;
+
+ if (strcmp(buf, "nor")) {
+ msg_perr("MTD device %d type is not \"nor\"\n", dev_num);
+ return -1;
+ }
+
+ /* Check if the corresponding device node exists. */
+ snprintf(dev_path, dp_len, "%s/mtd%d", LINUX_DEV_ROOT, dev_num);
+ errno = 0;
+ if (stat(dev_path, &s) < 0) {
+ msg_pdbg("Cannot stat \"%s\": %s\n", dev_path, strerror(errno));
+ return -1;
+ }
+
return 0;
}
+/* Returns 0 if setup is successful, non-zero to indicate error */
+static int linux_mtd_setup(int dev_num, const char *dev_path, struct linux_mtd_data *data)
+{
+ char sysfs_path[32];
+ int ret = 1;
+
+ /* Get more info from other files in the sysfs_path dir. */
+ if (snprintf(sysfs_path, sizeof(sysfs_path), "%s/mtd%d/", LINUX_MTD_SYSFS_ROOT, dev_num) < 0)
+ goto linux_mtd_setup_exit;
+ if (get_mtd_info(sysfs_path, data))
+ goto linux_mtd_setup_exit;
+
+ /* open file stream and go! */
+ if ((data->dev_fp = fopen(dev_path, "r+")) == NULL) {
+ msg_perr("Cannot open file stream for %s\n", dev_path);
+ goto linux_mtd_setup_exit;
+ }
+ ret = setvbuf(data->dev_fp, NULL, _IONBF, 0);
+ if (ret)
+ msg_pwarn("Failed to set MTD device to unbuffered: %d\n", ret);
+
+ msg_pinfo("Opened %s successfully\n", dev_path);
+
+ ret = 0;
+linux_mtd_setup_exit:
+ return ret;
+}
+
static int linux_mtd_init(const struct programmer_cfg *cfg)
{
int dev_num;
-
if (get_params(cfg, &dev_num) < 0)
return 1;
- if (check_sysfs_devnum_path(dev_num) < 0)
+ char dev_path[32];
+ if (detect_spinor_in_sysfs(dev_num, dev_path, sizeof(dev_path)) < 0)
return 1;
struct linux_mtd_data *data = calloc(1, sizeof(*data));
@@ -555,7 +552,7 @@
}
/* Get MTD info and store it in `data` */
- if (linux_mtd_setup(dev_num, data)) {
+ if (linux_mtd_setup(dev_num, dev_path, data)) {
free(data);
return 1;
}
--
To view, visit https://review.coreboot.org/c/flashrom/+/73495
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I15915b71e1a030548c5f082cde78c42ece28bb37
Gerrit-Change-Number: 73495
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Attention: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-MessageType: newchange
Attention is currently required from: Nikolai Artemiev.
Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/73494 )
Change subject: linux_mtd.c: Split linux_mtd_init() into sub-functions
......................................................................
linux_mtd.c: Split linux_mtd_init() into sub-functions
Here we split up the linux_mtd_init() entry-point into its
constituent phases;
get_params -> check_sysfs_path ->
alloc resources -> setup drv -> register.
The motivation is that we wish for linux_mtd to have a pre_init
hook for the purposes of detection only. This is a requirement
for the internal programmer via the current try_mtd() hack.
Change-Id: Ic81068adbc7da8b28de07a161b5cec2fff0fce49
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
---
M linux_mtd.c
1 file changed, 56 insertions(+), 26 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/94/73494/1
diff --git a/linux_mtd.c b/linux_mtd.c
index 495db9a..b3be72a 100644
--- a/linux_mtd.c
+++ b/linux_mtd.c
@@ -494,26 +494,30 @@
return ret;
}
-static int linux_mtd_init(const struct programmer_cfg *cfg)
+static int get_params(const struct programmer_cfg *cfg, int *dev_num)
{
- char *param_str;
- int dev_num = 0;
- int ret = 1;
- struct linux_mtd_data *data = NULL;
-
- param_str = extract_programmer_param_str(cfg, "dev");
- if (param_str) {
- char *endptr;
-
- dev_num = strtol(param_str, &endptr, 0);
- if ((*endptr != '\0') || (dev_num < 0)) {
- msg_perr("Invalid device number %s. Use flashrom -p "
- "linux_mtd:dev=N where N is a valid MTD\n"
- "device number.\n", param_str);
- goto linux_mtd_init_exit;
- }
+ char *param_str = extract_programmer_param_str(cfg, "dev");
+ if (!param_str) {
+ *dev_num = 0;
+ return 0;
}
+ char *endptr;
+ *dev_num = strtol(param_str, &endptr, 0);
+ if ((*endptr != '\0') || (*dev_num < 0)) {
+ msg_perr("Invalid device number %s. Use flashrom -p "
+ "linux_mtd:dev=N where N is a valid MTD\n"
+ "device number.\n", param_str);
+ free(param_str);
+ return -1;
+ }
+
+ free(param_str);
+ return 0;
+}
+
+static int check_sysfs_devnum_path(int dev_num)
+{
/*
* If user specified the MTD device number then error out if it doesn't
* appear to exist. Otherwise assume the error is benign and print a
@@ -521,19 +525,30 @@
*/
char sysfs_path[32];
if (snprintf(sysfs_path, sizeof(sysfs_path), "%s/mtd%d", LINUX_MTD_SYSFS_ROOT, dev_num) < 0)
- goto linux_mtd_init_exit;
+ return -1;
struct stat s;
if (stat(sysfs_path, &s) < 0) {
- if (param_str)
+ if (dev_num)
msg_perr("%s does not exist\n", sysfs_path);
else
msg_pdbg("%s does not exist\n", sysfs_path);
- goto linux_mtd_init_exit;
+ return -1;
}
- free(param_str);
+ return 0;
+}
- data = calloc(1, sizeof(*data));
+static int linux_mtd_init(const struct programmer_cfg *cfg)
+{
+ int dev_num;
+
+ if (get_params(cfg, &dev_num) < 0)
+ return 1;
+
+ if (check_sysfs_devnum_path(dev_num) < 0)
+ return 1;
+
+ struct linux_mtd_data *data = calloc(1, sizeof(*data));
if (!data) {
msg_perr("Unable to allocate memory for linux_mtd_data\n");
return 1;
@@ -546,10 +561,6 @@
}
return register_opaque_master(&linux_mtd_opaque_master, data);
-
-linux_mtd_init_exit:
- free(param_str);
- return ret;
}
const struct programmer_entry programmer_linux_mtd = {
--
To view, visit https://review.coreboot.org/c/flashrom/+/73494
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ic81068adbc7da8b28de07a161b5cec2fff0fce49
Gerrit-Change-Number: 73494
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-Attention: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-MessageType: newchange
Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/73492 )
Change subject: flashrom,internal: Move board_cfg up in the CFG to prog_init
......................................................................
flashrom,internal: Move board_cfg up in the CFG to prog_init
Avoid the need for a copy of the programmer_cfg within the
internal programmer. Move the board_cfg up into programmer_init().
TEST=`$ ./flashrom -p internal --flash-name`.
Change-Id: I30bc4eefeb589d3ee7827fcfea81985292c88a10
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
---
M flashrom.c
M internal.c
2 files changed, 29 insertions(+), 15 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/92/73492/1
diff --git a/flashrom.c b/flashrom.c
index da46354..f2ee3a9 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -144,7 +144,8 @@
/* Default to allowing writes. Broken programmers set this to 0. */
programmer_may_write = true;
- struct programmer_cfg cfg;
+ struct board_cfg bcfg = {0};
+ struct programmer_cfg cfg = { .bcfg = &bcfg };
if (param) {
cfg.params = strdup(param);
diff --git a/internal.c b/internal.c
index bba7043..f2fff0d 100644
--- a/internal.c
+++ b/internal.c
@@ -149,7 +149,6 @@
const char *cb_model = NULL;
#endif
bool force_boardenable = false;
- struct board_cfg bcfg = {0};
ret = get_params(cfg,
&force_boardenable, &force_boardmismatch,
@@ -162,7 +161,7 @@
* is found, the host controller init routine sets the
* internal_buses_supported bitfield.
*/
- bcfg.internal_buses_supported = BUS_NONSPI;
+ cfg->bcfg->internal_buses_supported = BUS_NONSPI;
if (try_mtd(cfg) == 0) {
ret = 0;
@@ -201,12 +200,12 @@
}
}
- bcfg.is_laptop = 2; /* Assume that we don't know by default. */
+ cfg->bcfg->is_laptop = 2; /* Assume that we don't know by default. */
- dmi_init(&bcfg.is_laptop);
+ dmi_init(&(cfg->bcfg->is_laptop));
/* In case Super I/O probing would cause pretty explosions. */
- board_handle_before_superio(&bcfg, force_boardenable);
+ board_handle_before_superio(cfg->bcfg, force_boardenable);
/* Probe for the Super I/O chip and fill global struct superio. */
probe_superio();
@@ -219,22 +218,21 @@
#endif
/* Check laptop whitelist. */
- board_handle_before_laptop(&bcfg, force_boardenable);
+ board_handle_before_laptop(cfg->bcfg, force_boardenable);
/*
* Disable all internal buses by default if we are not sure
* this isn't a laptop. Board-enables may override this,
* non-legacy buses (SPI and opaque atm) are probed anyway.
*/
- if (bcfg.is_laptop && !(bcfg.laptop_ok || force_laptop || (not_a_laptop && bcfg.is_laptop == 2)))
- bcfg.internal_buses_supported = BUS_NONE;
+ if (cfg->bcfg->is_laptop && !(cfg->bcfg->laptop_ok ||
+ force_laptop || (not_a_laptop && cfg->bcfg->is_laptop == 2)))
+ cfg->bcfg->internal_buses_supported = BUS_NONE;
/* try to enable it. Failure IS an option, since not all motherboards
* really need this to be done, etc., etc.
*/
- struct programmer_cfg icfg = *cfg;
- icfg.bcfg = &bcfg;
- ret = chipset_flash_enable(&icfg);
+ ret = chipset_flash_enable(cfg);
if (ret == -2) {
msg_perr("WARNING: No chipset found. Flash detection "
"will most likely fail.\n");
@@ -247,7 +245,7 @@
* parallel writes on IT8705F. Also, this handles the manual chip select for Gigabyte's DualBIOS. */
init_superio_ite(cfg);
- if (board_flash_enable(&bcfg,
+ if (board_flash_enable(cfg->bcfg,
board_vendor, board_model, cb_vendor, cb_model, force_boardenable)) {
msg_perr("Aborting to be safe.\n");
ret = 1;
@@ -255,10 +253,10 @@
}
#endif
- internal_par_init(bcfg.internal_buses_supported);
+ internal_par_init(cfg->bcfg->internal_buses_supported);
/* Report if a non-whitelisted laptop is detected that likely uses a legacy bus. */
- report_nonwl_laptop_detected(&bcfg);
+ report_nonwl_laptop_detected(cfg->bcfg);
ret = 0;
--
To view, visit https://review.coreboot.org/c/flashrom/+/73492
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I30bc4eefeb589d3ee7827fcfea81985292c88a10
Gerrit-Change-Number: 73492
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-MessageType: newchange
Attention is currently required from: Thomas Heijligen, Angel Pons.
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/73456 )
Change subject: internal: Move laptop_ok into board_cfg
......................................................................
Patch Set 2:
(1 comment)
File internal.c:
https://review.coreboot.org/c/flashrom/+/73456/comment/082790bb_9b72befa
PS1, Line 158:
: /* Unconditionally reset global state from previous operation. */
: bcfg.laptop_ok = false;
> actually can delete this now.
Ack
--
To view, visit https://review.coreboot.org/c/flashrom/+/73456
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I459215253845c2af73262943ce91a36464e9eb06
Gerrit-Change-Number: 73456
Gerrit-PatchSet: 2
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Comment-Date: Mon, 06 Mar 2023 06:20:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-MessageType: comment