Commit Graph

726 Commits (cb4a1ec4d15acd650e9f4fed347dfc04186da2a2)

Author SHA1 Message Date
Leah Rowe f9e20b8a1d util/nvmutil: optimise rhex() further
reduce the number of calls to read() by using
bit shifts. when rnum is zero, read again. in
most cases, a nibble will not be zero, so this
will usually result in about 13-15 of of 16
nibbles being used. this is in comparison to
8 nibbles being used before, which means that
the number of calls to read() are roughly
halved. at the same time, the extra amount of
logic is minimal (and probably less) when
compiled, outside of calls to read(), because
shifting is better optimised (on 64-bit machines,
the uint64_t will be shifted with just a single
instruction, if the compiler is decent), whereas
the alternative would be to always precisely use
exactly 16 nibbles by counting up to 16, which
would involve the use of an and mask and still
need a shift, plus...

you get the point. this is probably the most
efficient code ever written, for generating
random numbers between the value of 0 and 15
2023-03-06 21:30:33 +00:00
Leah Rowe f04855c29d fix flashrom download error 2023-03-06 11:44:54 +00:00
Leah Rowe e2945f02b7 payload/grub: force terminal_output to console 2023-03-05 21:25:35 +00:00
Leah Rowe 909d3b31db grub.cfg: set default timeout to 5 seconds 2023-03-05 19:14:24 +00:00
Leah Rowe 544737c864 scripts: build cbutils, not specific utils
some checks check for specific utils, which are
then used to indicate the existence of other utils,
which means that building them singularly, as is
currently done, may result in errors later if another
tool doesn't exist compiled yet

this is an obscure bug, fixed by this patch. more of a
workaround really. a dirty hack. when checking for any
of the coreboot utilities required, build all coreboot
utilities that are possibly required

the utilities are small enough that this does not add
much extra time to build, and in most cases, all of them
will be needed anyway
2023-03-05 14:00:06 +00:00
Leah Rowe 9398ad08db also fix data.vbt path for lenovo/w541
using the same method as the previous patch for t440p
2023-03-05 13:50:09 +00:00
Konstantinos Koukopoulos d2465e8291 Fix CONFIG_INTEL_GMA_VBT_FILE for the t440p_12mb config 2023-03-05 13:46:33 +00:00
Leah Rowe 0e34d199fb update debian dependencies (for sid) 2023-03-05 13:42:06 +00:00
Leah Rowe a5aa5bca77 ICH9M: default to 256MB VRAM, not 352MB
352MB VRAM causes stability issues, according to some reports

users can still set it to the higher level when building, if
they wish to
2023-03-04 23:58:17 +00:00
Leah Rowe 6421af5dcb bump seabios revision 2023-02-21 18:29:06 +00:00
Leah Rowe aba6307d13 bump grub revision 2023-02-21 07:39:07 +00:00
Leah Rowe 36982ab5f4 fix bad ifdtool patch from earlier commit 2023-02-19 23:21:37 +00:00
Leah Rowe 3857b4b65b build/dependencies/debian: add python3 dependency 2023-02-19 23:16:47 +00:00
Leah Rowe dac9ea86d3 build/boot/roms: fail when build cbutils fails 2023-02-19 23:16:01 +00:00
Leah Rowe 0d0f6cf3b8 coreboot: update revision of cbtree "default" 2023-02-19 19:24:01 +00:00
Leah Rowe dc1fedf920 Merge branch 'uboot-v2023.01' of alpernebbi/lbmk into master 2023-02-19 17:09:57 +00:00
Alper Nebi Yasak 7932d5fa95 u-boot: Disable environment storage
U-Boot can be configured via environment variables which can be saved to
various storage devices. This usually defaults to MMC or SPI depending
on where it boots from, but assumes the device's layout is controlled by
U-Boot.

We should store the environment in SPI flash, but we also need to
configure coreboot FMAPs to reserve the area U-Boot would use as its
environment storage. For now, disable environment storage by setting
ENV_IS_NOWHERE=y to avoid overwriting random regions of SPI or MMC if
someone tries to save the variables.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2023-02-14 00:58:08 +03:00
Alper Nebi Yasak 8d57468ee5 u-boot: Update to v2023.01
Set default U-Boot revision to v2023.01 and rebase patches on top of
that. Upstream kconfig status is a bit unstable, so updating configs
with `make oldconfig` would miss important upstream changes.

For each board, run `make savedefconfig` and `diffconfig -m` at the old
version to get a diff from upstream defconfigs. Fix those affected by
upstream changes, like SYS_TEXT_BASE being renamed to TEXT_BASE. Then
append those to the new version's defconfigs and run `make olddefconfig`
to get updated configs.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2023-02-14 00:58:08 +03:00
Leah Rowe 6b4a14ce4a util/nvmutil: tidy up variable declarations 2023-01-28 23:21:53 +00:00
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