Skip to content

Commit

Permalink
lk2nd: fastboot: Add "fastboot oem dtb" to dump dtb passed by bootloader
Browse files Browse the repository at this point in the history
This allows inspecting the changes to the dtb made by the bootloader.

Usage: "fastboot oem dtb && fastboot get_staged output.dtb"

Fixes #372
  • Loading branch information
stephan-gh authored and wonderfulShrineMaidenOfParadise committed Jun 22, 2024
1 parent 6d8312b commit 3e665dc
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions Documentation/fastboot.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ commands for debugging and development.
> Not all fastboot commands may be enabled on a given build of lk2nd.
> Use `fastboot oem help` to find which commands are available.
- `oem dtb` - Stage dtb.
- `oem hash` - Hash staged data using hardware crypto.
- `oem log` - Stage lk log.
- `oem reboot-edl` - Reboot into EDL mode.
Expand Down
1 change: 1 addition & 0 deletions lk2nd/device/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ static void lk2nd_device_init(void)
return;
}

lk2nd_dev.dtb = dtb;
parse_dtb(dtb);
}
LK2ND_INIT(lk2nd_device_init);
Expand Down
4 changes: 4 additions & 0 deletions lk2nd/device/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ struct lk2nd_device {
const char *carrier;
const char *radio;
#endif

#if DEVICE_TREE
const void *dtb;
#endif
};
extern struct lk2nd_device lk2nd_dev;

Expand Down
13 changes: 13 additions & 0 deletions lk2nd/fastboot/dtb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright (c) 2021-2022, Stephan Gerhold <[email protected]> */

#include <fastboot.h>
#include <libfdt.h>

#include "../device/device.h"

static void cmd_oem_dtb(const char *arg, void *data, unsigned sz)
{
fastboot_stage(lk2nd_dev.dtb, fdt_totalsize(lk2nd_dev.dtb));
}
FASTBOOT_REGISTER("oem dtb", cmd_oem_dtb);
5 changes: 5 additions & 0 deletions lk2nd/fastboot/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ OBJS += \
$(LOCAL_DIR)/screenshot.o \
$(LOCAL_DIR)/screenshot-neon.o
endif

ifeq ($(DEVICE_TREE), 1)
OBJS += \
$(LOCAL_DIR)/dtb.o
endif

0 comments on commit 3e665dc

Please sign in to comment.