summaryrefslogtreecommitdiff
path: root/util/nvmutil
diff options
context:
space:
mode:
Diffstat (limited to 'util/nvmutil')
-rw-r--r--util/nvmutil/AUTHORS1
-rw-r--r--util/nvmutil/COPYING3
-rw-r--r--util/nvmutil/Makefile20
-rw-r--r--util/nvmutil/nvmutil.c12
4 files changed, 25 insertions, 11 deletions
diff --git a/util/nvmutil/AUTHORS b/util/nvmutil/AUTHORS
index f3c00385..f38ea210 100644
--- a/util/nvmutil/AUTHORS
+++ b/util/nvmutil/AUTHORS
@@ -1 +1,2 @@
Leah Rowe
+Riku Viitanen
diff --git a/util/nvmutil/COPYING b/util/nvmutil/COPYING
index 784581dd..a6ecf266 100644
--- a/util/nvmutil/COPYING
+++ b/util/nvmutil/COPYING
@@ -1,4 +1,5 @@
-Copyright (C) 2022, 2023 Leah Rowe <leah@libreboot.org>
+Copyright (C) 2022-2025 Leah Rowe <leah@libreboot.org>
+Copyright (c) 2023 Riku Viitanen <riku.viitanen@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
diff --git a/util/nvmutil/Makefile b/util/nvmutil/Makefile
index f25f6dd5..b8ec2ad3 100644
--- a/util/nvmutil/Makefile
+++ b/util/nvmutil/Makefile
@@ -1,16 +1,24 @@
# SPDX-License-Identifier: MIT
-# SPDX-FileCopyrightText: 2022 Leah Rowe <leah@libreboot.org>
+# SPDX-FileCopyrightText: 2022,2025 Leah Rowe <leah@libreboot.org>
# SPDX-FileCopyrightText: 2023 Riku Viitanen <riku.viitanen@protonmail.com>
-CC=cc
-CFLAGS=-Os -Wall -Wextra -Werror -pedantic
-PREFIX?=/usr/bin
+CC?=cc
+CFLAGS?=-Os -Wall -Wextra -Werror -pedantic
+DESTDIR?=
+PREFIX?=/usr/local
+INSTALL?=install
nvm: nvmutil.c
$(CC) $(CFLAGS) nvmutil.c -o nvm
-install: nvm
- install nvm $(PREFIX)/nvm
+install:
+ $(INSTALL) nvm $(DESTDIR)$(PREFIX)/bin/nvm
+
+uninstall:
+ rm -f $(DESTDIR)$(PREFIX)/bin/nvm
+
+distclean:
+ rm -f nvm
clean:
rm -f nvm
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index f95df4cf..68bb95da 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -24,6 +24,7 @@ uint8_t hextonum(char chs), rhex(void);
#define MAC_ADDRESS argv[3]
#define PARTN argv[3]
#define SIZE_4KB 0x1000
+#define NVM_CHECKSUM 0xBABA
uint16_t buf16[SIZE_4KB], mac[3] = {0, 0, 0};
uint8_t *buf = (uint8_t *) &buf16;
@@ -63,6 +64,7 @@ int
main(int argc, char *argv[])
{
if (argc < 3) {
+ fprintf(stderr, "Modify Intel GbE NVM images e.g. set MAC\n");
fprintf(stderr, "USAGE:\n");
fprintf(stderr, " %s FILE dump\n", argv[0]);
fprintf(stderr, " %s FILE setmac [MAC]\n", argv[0]);
@@ -219,10 +221,12 @@ void
hexdump(int partnum)
{
for (int row = 0; row < 8; row++) {
- printf("%07x", row << 4);
+ printf("%08x ", row << 4);
for (int c = 0; c < 8; c++) {
uint16_t val16 = word((row << 3) + c, partnum);
- printf(" %02x%02x", val16 >> 8, val16 & 0xff);
+ if (c == 4)
+ printf(" ");
+ printf(" %02x %02x", val16 & 0xff, val16 >> 8);
} printf("\n");
}
}
@@ -233,7 +237,7 @@ cmd_setchecksum(void)
uint16_t val16 = 0;
for (int c = 0; c < 0x3F; c++)
val16 += word(c, part);
- setWord(0x3F, part, 0xBABA - val16);
+ setWord(0x3F, part, NVM_CHECKSUM - val16);
}
void
@@ -256,7 +260,7 @@ goodChecksum(int partnum)
uint16_t total = 0;
for(int w = 0; w <= 0x3F; w++)
total += word(w, partnum);
- if (total == 0xBABA)
+ if (total == NVM_CHECKSUM)
return 1;
fprintf(stderr, "WARNING: BAD checksum in part %d\n", partnum);
return (errno = ECANCELED) & 0;