61 Commits (65f821adf8f2be6a48830ad4fb63f78e2160c84a)

Author SHA1 Message Date
Adam Joseph 9dd5bdf298 eliminate "magic numbers", support 8mbyte single-image flash chips
Prior to this commit, ownerboot had quite a lot of "magic addresses"
and flash chip layouts.  This commit eliminates all of them.

All flash chip geometry is now computed from first principles and
two parameters:

  1. The flash chip size
  2. The number of images per chip (two means NORMAL/FALLBACK)

If (flash-chip-size / num-images) is too small, coreboot's build
process will notice this and fail.

It should be possible to build a single-image (i.e. no FALLBACK)
ownerboot for use on 8mbyte flash chips, which lets people try this
out without having to buy a new flash chip or (in the case of the
rk3399-gru-kevin laptop) doing any soldering.
1 year ago
Adam Joseph c72e1a55be src/platform/*: use pkgs.writeText for custom.fmap files 1 year ago
Adam Joseph a2c0e1ddfb initramfs: pass contents using an attrset
This commit significantly cleans up the assembly of the initramfs by
specifying and manipulating its contents using an attrset (in { dest
= src; } form) rather than chunks of bash script.
2 years ago
Adam Joseph 6dbb2f8c92 initramfs: eliminate custom $build variable
Previously the initramfs required overriders to use a custom
`$build` environment variable as the destination for files to be
packed into an initramfs image.  This commit eliminates it, so the
standard $NIX_BUILD_TOP can be used instead.
2 years ago
Adam Joseph 98c5638e64 src/userspace: merge back into initramfs
Previously ownerboot had separate `userspace` (the initramfs
contents without kernel modules) and `initramfs` (the complete
initramfs) expressions.  This was done in order to allow the use of
CONFIG_INITRAMFS_SOURCE, which links an initramfs image into the
kernel itself.

I did this because I was having a hard time getting coreboot to load
a separate initrd on rk3399.  I have since solved that problem, and
am now using coreboot to load an initramfs on all platforms.  There
is no longer any need for this unusual separation.
2 years ago
Adam Joseph 1b602c7f98 common/arm64.nix: allow to pass extra flags to flashrom scripts 2 years ago
Adam Joseph db21d5d2ac common/amd64.nix: remove redundant `$@` from flashrom script 2 years ago
Adam Joseph d217c4eff4 fmap, payload: move to top-level scope
This commit moves the `fmap` and `payload` arguments to `coreboot`
into the top-level scope, so they can be provided without needing to
override the `coreboot` expression.
2 years ago
Adam Joseph 01549c9400 src/image: rename parameter initramfs_image -> initramfs
This allows to have the argument automatically populated by
`callPackage`.
2 years ago
Adam Joseph 2c30620ed2 coreboot: separate compilation from payload installation
This commit causes the coreboot payload (i.e. the Linux kernel,
initramfs, and any necessary DTBs) to be inserted into the coreboot
image as part of a separate derivation from the one which compiles
coreboot.

As a result, changing the contents of the initramfs is extremely
fast -- it can now be done without any recompilation.

As a result of this, the attribute name for the final image to be
flashed has changed from `coreboot` to `image`.  The `coreboot`
attribute now builds a payloadless `coreboot.rom`.
2 years ago
Adam Joseph 8efee177f2 platform/kevin/fit: add missing pre/postBuild hooks 2 years ago
Adam Joseph 5ac11dd7fd kgpe: add patch for USE_WATCHDOG_ON_BOOT and enable it
This commit adds a coreboot patch which enables
CONFIG_USE_WATCHDOG_ON_BOOT for kgpe-d16; in upstream coreboot this
feature is found on only a few intel cpu platforms.

When enabled, this feature starts the hardware watchdog very early
in the boot process -- before PNP enumeration or DRAM
initialization.  This ensures that any hangs or freezes due to
transient conditions (flakiness, temperature, electrical noise)
won't prevent the machine from eventually booting.  This is very
useful for unattended servers.

On kgpe-d16 the watchdog is cancelled immediately before jumping to
the payload (i.e. Linux kernel).  I found that if I left the
watchdog enabled, any attempt to use it (for example, to cancel it
or extend it) from Linux resulted in the machine resetting.  Perhaps
this can be fixed, but for now I am content to simply re-enable the
watchdog from Linux rather than leaving it running.
2 years ago
Adam Joseph c7c4370f18 platform/common/arm64: only pass --fmap to flashrom when passing -i
Previously, the flashrom scripts would pass --fmap to every
invocation of flashrom, even when overwriting the entire image.
This was unnecessary, and would cause issues if the chip being
written to had a corrupted fmap table.  This commit passes the
--fmap flag only when it is needed due to the -i flag being present.
2 years ago
Adam Joseph 1a92a17774 src/plat/kevin: allow to override atf and fit
This commit lifts `atf` and `fit` into the ownerboot scope where
they can be selectively overridden.
2 years ago
Adam Joseph 5ad23de431 eliminate all <nixpkgs> path-references
This commit eliminates all path-references to <nixpkgs>, so we can
stop using NIX_PATH.
2 years ago
Adam Joseph 71bc5b7beb platform/kevin: eliminate path-reference to nixpkgs
Now that 6deb86f6138265a715dd005c310ad33a2e2865ff has merged
upstream in nixpkgs we can directly reference arm-trusted-firmware
as part of the nixpkgs package set.  This allows to eliminate a
<nixpkgs>-style path reference.
2 years ago
Adam Joseph b564f8897f arm64: flashrom.forChromebook only for ec
In order to write to the chromebook embedded controller flash we
need to use Google's fork of flashrom.  However for writing to the
chromebook CPU firmware flash (which is a different flash chip) we
can use mainline flashrom.  So let's do that.
2 years ago
Adam Joseph 75141bfe4d kevin/custom.fmap: drop BIOS@0 region
On x86 platforms, it is necessary to wrap the entire image in a
BIOS@0 region which marks the memory-mapped flash image as needing
SMM protection.  Unfortunately this creates overlapping FMAP
regions, which flashrom cannot handle without a patch.

On arm64 platforms, the BIOS@0 region is not needed.  So let's not
include it.  This allows us to skip the flashrom patch on arm64.
2 years ago
Adam Joseph 277ec9e263 src/platform/kgpe/default.nix: set USE_OPTION_TABLE=no
Upstream describes this option as "Enable this option if coreboot
shall read options from the CMOS NVRAM instead of using hard-coded
values."

The RTC_BOOT_BYTE (which controls normal/fallback) indicator is
always taken from CMOS NVRAM, regardless of how this option is set.
When set to `no`, no other parts of the CMOS NVRAM are read or
written.

On KGPE-D16 I have found that USE_OPTION_TABLE=yes is frustratingly
flaky and unstable; about 1 in 20 boots will hang in the PNP device
enumeration.  Apparently during SMP boot, multiple cores attempt to
access the (single) CMOS NVRAM concurrently, causing massive
headaches.  Please don't turn this option on unless you are willing
to deal with extreme frustration.
2 years ago
Adam Joseph 7e4dfde706 platform/common/amd64.nix: omit --fmap when writing the entire chip
Trying to write to a chip using --fmap will fail if the chip does
not yet have a valid fmap table (for example, a blank chip).  Let's
omit this flag when writing the entire image.
2 years ago
Adam Joseph 88d20a5f63 src/coreboot: switch to lib/modules.nix-style Kconfig
This commit drops the verbatim `.config` files for coreboot that
were previously in the repository and converts them to NixOS-style
module configurations.

The big benefit of doing this is that the perl script in nixpkgs
that handles this will check to make sure that coreboot's Kconfig
machinery isn't silently ignoring any of our settings.  It also
makes this configuration easier for end-users to customize.
2 years ago
Adam Joseph 4391f2fb0f {kgpe,kevin,am1i}/coreboot.config: minimize file
This commit reduces kgpe/coreboot.config to the minimum set of
entries that will reproduce the original file after running "make
oldconfig"
2 years ago
Adam Joseph 0b1af95337 atf: ignore warnings emitted by newer compilers
This commit is needed in order to get arm-trusted-firmware to build
with recent gcc and binutils.
2 years ago
Adam Joseph aa61ed1bd2 coreboot: uniformize serial console handling
This commit cleans up the selection of the serial console device and
gives it sensible default values (usually, the DB9 header on the
back I/O panel) on each platform.
2 years ago
Adam Joseph b48635fa1d src/main: init
This commit adds several useful scripts (alongside the coreboot
image) in a `main` expression, which should be the primary build
expression going forward.

The following scripts should exists on all platforms:

- flashrom wrappers:
  - `flashrom.sh`
  - `flash-write-all.sh`
  - `flash-write-fallback.sh`
  - `flash-write-normal.sh`

- scripts to select which image (normal or fallback) is used for the
  next boot:
  - `nextboot-show.sh`
  - `nextboot-use-fallback.sh`
  - `nextboot-use-normal.sh`

- a script to write an image to the em100 flash-chip-emulator device:
  - `em100-write.sh`
2 years ago
Adam Joseph 52e330e4aa factor out serial console device choice
This commit generalizes the selection and activation of the serial
console by promoting it to a top-level package-set member.

The top-level package set is starting to attract clutter, so I will
soon be moving all the non-package constitutents into a `config`
attrset.
2 years ago
Adam Joseph c5fdfbff1b src/platform/*: move hostPlatform into the packageset
This commit makes `hostPlatform` part of the packageset for more
consistent handling.  A top-level `hostPlatform` argument is exposed
to the caller, in case they want to customize the `hostPlatform`
(compiler flags, etc).

The `hostPlatform` argument is inherited into the ownerboot package
set, where it will be overridden by `src/platform/*.nix` if it has
not been set explicitly.

Making `hostPlatform` part of the package set allows for more
sophisticated overriding schemes, for example adding additional
compiler flags or sanity-checking the flags that the user has
provided.
2 years ago
Adam Joseph 197e82f050 src/platforms/common: factor out {amd,arm}64.nix
This commit creates a (currently empty) overlay list for things
common to each of the amd64 and arm64 platform-classes.
2 years ago
Adam Joseph 0ecb6e67da default.nix: move flashrom into the ownerboot packageset
Since we (unfortunately) need to use different forks of flashrom for
different platforms, flashrom must be overrideable.  Moving it into
the ownerboot packageset is the way to do that.
2 years ago
Adam Joseph 3bdb75a387 src/default.nix: use a list of overlays rather than a single overlay
This commit changes from using a single overlay to using a
nixpkgs-like list of overlays chained together by
`lib.composeExtensions`.
2 years ago
Adam Joseph 516b86434a kgpe: allow to configure recovery nvram values
On amd64 platforms, booting ownerboot with the recovery jumper
installed will wipe the battery-backed nvram (aka "cmos" aka "rtc
nvram") and overwrite it with known-safe values taken from the
coreboot source code (`src/mainboard/asus/kgpe-d16/cmos.default`).

You should always do this when flashing a motherboard with ownerboot
for the first time.

This commit allows the user to customize the set of known-safe
values which are written when the recovery jumper is installed.  To
do so, copy `src/mainboard/asus/kgpe-d16/cmos.default` out of
coreboot, edit to suit your tastes, and then override
`cmos-defaults` with the path to your customized `cmos.default`
file.
2 years ago
Adam Joseph 25bf9f95e0 kgpe: formatting 2 years ago
Adam Joseph 218f2f8e83 kgpe: move microcode blob out of ownerboot
The microcode blob is only needed for Opteron 63xx chips.  I have a
few of these, so I add the blob in a local overlay.

If other people are interested in this I will publish the overlay.

The 63xx chips are kind of rare and more expensive than the 62xx
chips -- their only real benefit is lower power draw.  I ended up
receiving some by accident due to an incorrect eBay listing.
2 years ago
Adam Joseph 0eb193a149 src/platform/kgpe/default.nix: typo 2 years ago
Adam Joseph 276723681d kevin/linux.config: enable ath9k spectral scan and debugfs 2 years ago
Adam Joseph 0f15fd86a8 kgpe/linux.config: remove sb700 watchdog-related settings
The KGPE-D16 southbridge contains a watchdog; the kernel module for
this watchdog is sp5100_tco.

Unfortunately this watchdog keeps its counter in the main system CPU
RAM.  This means that the IOMMU will block the watchdog's attempts
to read and write its own counter (through the SMBus, which is PCI
device 0000:00:14.0), resulting in massive amounts of dmesg spam
like this:

```
        pci 0000:00:14.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0004 address=0xfdf9103300 flags=0x0030]
piix4_smbus 0000:00:14.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0004 address=0xfdf9103300 flags=0x0030]
```

Setting the IOMMU to allow these accesses is a headache, and
pointless anyways: the KGPE-D16 board disallows the use of the
watchdog by the CPU; it is reserved for the exclusive use of the
BMC.  Attempting to enable the watchdog does nothing; the enable bit
will not turn on.  Recent kernels check for this situation and
report when it is detected:

  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f7781b067522aa269213e8025c80cbed1868d349

Fortunately there is *another* watchdog on the motherboard, inside
the `W83667HG-A` SuperIO chip, and it is supported by
`w83627hf_wdt.ko`.  Subsequent commits to ownerboot will use *that*
watchdog instead.

Dump of my collection of possibly-related links:

- https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266325
- https://forums.freebsd.org/threads/ivhd-errors-after-upgrade-host-to-13-1.85234/
- https://lists.linuxfoundation.org/pipermail/iommu/2015-October/014523.html
- https://lkml.org/lkml/2014/4/22/562
- https://bugzilla.kernel.org/show_bug.cgi?id=170741
- https://marc.info/?l=linuxbios&m=152035277020470&w=2
2 years ago
Adam Joseph 6cf5223d41 ecfw: move flashing scripts to separate derivation 2 years ago
Adam Joseph e5824b756d ecfw: fix comment 2 years ago
Adam Joseph 4cf0b70ae3 ecfw: fix version attr 2 years ago
Adam Joseph bdebb940c9 platform/kevin/ecfw: init 2 years ago
Adam Joseph 9e592c9751 ectool: make boardName a non-package argument 2 years ago
Adam Joseph 30ac75903b src/util/ectool/: init 2 years ago
Adam Joseph 709bb2104d src/plat/*: allow to override hostPlatform 2 years ago
Adam Joseph 0bdf6e9355 src/plat/*: pass `lib` as a parameter instead of reimporting it 2 years ago
Adam Joseph ed0d745ca4 kgpe: add missing `mkdir` and path component 2 years ago
Adam Joseph 018e75000a optionally build nvramtool, put it and the .layout files in the initramfs 2 years ago
Adam Joseph 0bf512385d coreboot: add linux-command-line parameter for CONFIG_LINUX_COMMAND_LINE 2 years ago
Adam Joseph 184d2421b2 kgpe: include microcode updates for 63xx cpus 2 years ago
Adam Joseph 9658f9f551 kgpe/coreboot.config: remove extraneous CONFIG_LOCALVERSION 2 years ago
Adam Joseph 1732d9c14e src/coreboot: add console-loglevel parameter 2 years ago