Commit Graph

307 Commits (031a0b553ba15e495ce1696ea19a606b239909e4)

Author SHA1 Message Date
Leah Rowe 031a0b553b util/nvmutil: setWord(): declare variables first 2023-01-28 22:40:01 +00:00
Leah Rowe 257eedca0c util/nvmutil: reset errno if any write attempted
the way nvmutil is designed, setWord() is only ever called
under non-error conditions. however, if one part is valid but
the other one isn't, and a command is run that touches both parts,
errno is non-zero write writeGbeFile is called

in situations where one part is valid, but the other isn't, AND the
writes to gbe (in memory) results in a non-change, writeGbeFile is
not called; in this situation, errno is not being reset, despite
non-error condition

this patch fixed the bug, resulting in zero status upon exit under
such conditions
2023-01-28 22:14:35 +00:00
Leah Rowe adc76e3814 util/nvmutil: do not write non-changes to disk 2023-01-28 21:26:36 +00:00
Leah Rowe 3e150bf303 util/nvmutil: cmd_swap(): write sequentually
the current code writes part 1 first, and part 0 next,
on the disk, due to the way the swap works.

with this change, swap still swaps the two parts of the file,
on disk, but writes the new file sequentially.

this change might speed up i/o on the file system, on HDDs.
on SSDs, this change likely makes no difference at all.
2023-01-28 20:30:34 +00:00
Leah Rowe 7e3a73558e util/nvmutil: don't use malloc() 2023-01-28 19:39:34 +00:00
Leah Rowe a924d43bdd util/nvmutil: fix clang build errors 2023-01-28 14:11:17 +00:00
Leah Rowe c822033bee util/nvmutil: simplify rhex()
don't use malloc(). instead, just load random bytes
into a uint64_t
2023-01-28 12:24:50 +00:00
Leah Rowe 0f4852450c util/nvmutil: use gbe[] in word() and setword()
this will make the code more flexible, if (when) i
add changes that allow multiple commands to be used
in a single run, on any given number of files
2023-01-27 20:13:15 +00:00
Leah Rowe b1186968e8 util/nvmutil: code cleanup 2023-01-27 19:52:11 +00:00
Leah Rowe 7a98649764 util/nvmutil: call pledge() earlier, in main() 2023-01-27 15:34:09 +00:00
Leah Rowe bb6fe263e7 util/nvmutil: remove unused #define 2023-01-27 15:28:50 +00:00
Leah Rowe 5a5a8662a6 util/nvmutil: optimised disk reads
only read the required number of bytes, per command
2023-01-27 15:09:34 +00:00
Leah Rowe 24d5645676 util/nvmutil: optimise cmd_swap()
On many Lenovo GbE regions (in factory firmware), part 0 is
invalid but part 1 is valid.

This change means part 1 is checked first. If part 1 is valid,
part 0 won't be checked at all (due to how most C compilers
optimise).

Most people are just going to extract the factory GbE file,
modify it and re-insert it into the ROM image, so this causes
a nice speedup.
2023-01-27 14:26:24 +00:00
Leah Rowe ef84329a81 util/nvmutil: optimise rhex() for speed
don't constantly open/close the file: /dev/urandom

only read 12 bytes at a time

because of this change, the readFromFile() function now only
handles gbe files
2023-01-27 14:18:46 +00:00
Leah Rowe 88a51531cf util/nvmutil: code cleanup in rhex() 2023-01-27 13:54:01 +00:00
Alexei Sorokin ac1cab288d x230edp_12mb: Correct the path to data.vbt 2023-01-26 23:57:13 +00:00
Leah Rowe afc80b89ec util/nvmutil: update copyright years 2023-01-17 12:48:14 +00:00
Leah Rowe 8242dca57b util/nvmutil: limit bytes written per command
Massive reduction in number of bytes written, if copy/swap
commands are not used.
2023-01-17 11:03:55 +00:00
Leah Rowe e398331b38 util/nvmutil: make writeGbeFile more readable 2023-01-17 10:52:45 +00:00
Leah Rowe 8dea350a62 util/nvmutil: only write parts that are modified
Old behaviour: always write both gbe sections.

New behaviour: only write back what was changed.
2023-01-17 10:23:21 +00:00
Leah Rowe d0fa08d58d blobs/inject: fix wrong nvmutil path for make 2023-01-10 03:48:46 +00:00
Leah Rowe e8072934f2 Merge branch 'veyron-uboot-dmreset' of alpernebbi/lbmk into master 2023-01-10 03:26:49 +00:00
Leah Rowe 6b10454271 Merge branch 'peach-uboot-usbehci' of alpernebbi/lbmk into master 2023-01-10 03:26:40 +00:00
Alper Nebi Yasak 80bf54b2a7 u-boot: Enable USB_EHCI_EXYNOS on peach boards
The USB 2.0 ports on Exynos boards need the relevant driver enabled by
USB_EHCI_EXYNOS. This is enabled by default depending on USB_EHCI_HCD.
It's already enabled on snow and spring, but apparently not on peach
boards, as discovered from other people's attempts to enable it [1][2].
Enable it also on the peach_pi and peach_pit.

[1] 8f12e43dbf
[2] 11cacf55ad

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-12-31 21:34:01 +03:00
Alper Nebi Yasak e11650c3c7 u-boot: Enable DM_RESET for veyron boards
The display driver on the veyron boards needs reset drivers, more
specifically RESET_ROCKCHIP. This is enabled by default depending on
DM_RESET, which an upstream commit enables for veyron_jerry claiming it
fixes the display [1]. Enable it also in our configs, but for other
veyrons as well.

[1] https://lore.kernel.org/u-boot/20220928024046.2657593-1-sjg@chromium.org/

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-12-31 20:43:58 +03:00
Ferass 'Vitali64' EL HAFIDI 7f5dfebf7d Do not rely on bashisms and behaviour undefined by the POSIX specification. Part 2
Signed-off-by: Ferass 'Vitali64' EL HAFIDI <vitali64pmemail@protonmail.com>
2022-12-28 18:43:49 +00:00
Ferass 'Vitali64' EL HAFIDI f787044642 Do not rely on bashisms and behaviour undefined by the POSIX specification.
By making lbmk fully POSIX-compliant, it will be easier to port lbmk to
other systems implementing POSIX such as Alpine Linux and FreeBSD.

Signed-off-by: Ferass 'Vitali64' EL HAFIDI <vitali64pmemail@protonmail.com>
2022-12-27 15:50:41 +00:00
lbmkplaceholder d45b2e70dc util/nvmutil: use err() more consistently 2022-12-24 01:18:17 +00:00
Leah Rowe d726b16f5f util/nvmutil: more robust pointer handling
i didn't like the previous commits, they felt really hacky

running malloc and then changing the pointer directly just rubs
me the wrong way

fix that
2022-12-24 01:10:55 +00:00
lbmkplaceholder 448ee5105d util/nvmutil: optimise cmd_swap() further
don't do xor swap. we know gbe2 is always 4KB higher than
gbe in memory, so we can just set gbe2 to the value of gbe,
and OR the size in bytes of 4KB into gbe2

this is only a marginal speed boost, negligible even, but it's
done for the lulz
2022-12-23 10:42:19 +00:00
lbmkplaceholder effcb942ce util/nvmutil: greatly optimise cmd_copy()
similar to the last change by concept. we now write
individual 4KB blocks per part 0 and 1, at the end
of nvmutil, based on pointer values gbe and gbe2

instead of running memcpy, simply overwrite the pointer

this results in less I/O, thus more speed
2022-12-23 10:28:25 +00:00
lbmkplaceholder 6e5828e4a8 util/nvmutil: greatly optimise cmd_swap()
instead of XOR-swapping every byte, have pointers to the
two parts and *XOR swap the pointers*. at the end of the
program execution, when writing, pwrite the two parts into
the same file
2022-12-23 08:41:18 +00:00
lbmkplaceholder 7aafc62bf7 scripts/blobs/inject: fix bad cbfstool build check 2022-12-22 23:09:03 +00:00
lbmkplaceholder 6ebd178f28 util/nvmutil: simplified error handling in rhex() 2022-12-21 15:45:17 +00:00
lbmkplaceholder 04da953c71 util/nvmutil: return errno when calling err() 2022-12-21 15:31:02 +00:00
lbmkplaceholder 001878112a util/nvmutil: exit non-zero if close() fails 2022-12-21 15:28:15 +00:00
lbmkplaceholder c6bb4d25f3 build/release/src: don't delete .gitcheck 2022-12-14 10:46:06 +00:00
Leah Rowe 0fbf3325e1 correct a faulty if statement in build/release/src 2022-12-14 10:19:02 +00:00
lbmkplaceholder 3e266650c2 disable grub and memtest on 1MB ROM configs
due to upstream bloat, these no longer fit. it will have to be
fixed in the next libreboot release
2022-12-14 08:31:07 +00:00
lbmkplaceholder ab2cfb8639 util/nvmutil: only mask random unicast/local macs
Without this change, arbitrary MAC addresses will always be masked.

This change restores the intended behaviour.
2022-12-14 08:15:07 +00:00
lbmkplaceholder fea3e51ccd update the readme 2022-12-14 08:09:52 +00:00
lbmkplaceholder 664cdcfb36 fix ./build boot roms all 2022-12-14 06:46:41 +00:00
Leah Rowe 48c7318627 p2b_ls/p3b_f boards: Disable memtest payload
memtest can't fit in such tiny space alongside SeaBIOS
2022-12-11 06:29:39 +00:00
Leah Rowe 31111c645f build/boot roms: add exits for failing commands 2022-12-11 06:25:09 +00:00
Leah Rowe 4eba525bba p2b_ls/p3b_f boards: no payload and no vga init
The configs were enabling SeaBIOS payload, but this is to be
handled by lbmk, not coreboot.

Further, they were enabling VGA ROM execution in coreboot, but
this should be handled by SeaBIOS.

This board should not have a GRUB payload enabled either; this
will be checked and fixed if necessary in the next commit.
2022-12-11 06:20:34 +00:00
Leah Rowe c931b40e4b Merge branch 'master' of qeeg/lbmk into master 2022-12-11 06:09:06 +00:00
Leah Rowe 34a56281ac Merge branch 'cros-postmerge-fixes' of alpernebbi/lbmk into master 2022-12-11 05:30:23 +00:00
qeeg 6351a4a484 Add P2B-LS and P3B-F configs 2022-12-10 08:42:29 -06:00
Alper Nebi Yasak f079b83dd9 build/release/src: Include U-Boot sources in source archive
Add U-Boot to the source release script's modules list so that it is
included in source release tarballs. Don't include the unused upstream
source and .git directories.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-12-10 15:40:11 +03:00
Alper Nebi Yasak 70435784ec build/clean: Add helper script to clean U-Boot builds
Copy the resources/scripts/build/clean/crossgcc script and adapt it to
run "make distclean" on U-Boot build trees. Some build artifacts persist
after the run, so also run "git clean -fdx" if we can.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-12-10 15:39:33 +03:00