Skip to content

Commit

Permalink
Add Flattened uImage Tree (FIT) image support (WIP).
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske committed Nov 6, 2024
1 parent 248a598 commit 5e9a28f
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 36 deletions.
28 changes: 25 additions & 3 deletions IDE/XilinxSDK/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,34 @@ These template settings are also in this `.cproject` as preprocessor macros. The
#define WOLFBOOT_LOAD_DTS_ADDRESS 0x11800000
```

The default .cproject build symbols is setup for RSA using:
The default .cproject build symbols are:

```
WOLFBOOT_SIGN_RSA4096
WOLFBOOT_HASH_SHA3_384
ARCH_AARCH64
ARCH_FLASH_OFFSET=0x0
CORTEX_A53
DEBUG_ZYNQ=1
EXT_FLASH=1
FILL_BYTE=0xFF
IMAGE_HEADER_SIZE=1024
MMU
NO_QNX
NO_XIP
PART_BOOT_EXT=1
PART_SWAP_EXT=1
PART_UPDATE_EXT=1
TARGET_zynq
WC_HASH_DATA_ALIGNMENT=8
WOLFBOOT_ARCH_AARCH64
WOLFBOOT_DUALBOOT
WOLFBOOT_ELF
WOLFBOOT_HASH_SHA3_384
WOLFBOOT_ORIGIN=0x0
WOLFBOOT_SHA_BLOCK_SIZE=4096
WOLFBOOT_SIGN_RSA4096
WOLFBOOT_UBOOT_LEGACY
WOLFSSL_ARMASM
WOLFSSL_ARMASM_INLINE
```

Note: If not using Position Independent Code (PIC) the linker script `ldscript.ld` must have the start address offset to match the `WOLFBOOT_LOAD_ADDRESS`.
Expand Down
10 changes: 5 additions & 5 deletions arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1059,12 +1059,12 @@ ifeq ($(ARCH),AARCH64)
CFLAGS+=-DMMU -DWOLFBOOT_DUALBOOT
OBJS+=src/fdt.o
UPDATE_OBJS:=src/update_ram.o
else
ifeq ($(DUALBANK_SWAP),1)
CFLAGS+=-DWOLFBOOT_DUALBOOT
UPDATE_OBJS:=src/update_flash_hwswap.o
endif
endif
ifeq ($(DUALBANK_SWAP),1)
CFLAGS+=-DWOLFBOOT_DUALBOOT
UPDATE_OBJS:=src/update_flash_hwswap.o
endif

# Set default update object (if not library)
ifneq ($(TARGET),library)
ifeq ($(UPDATE_OBJS),)
Expand Down
3 changes: 3 additions & 0 deletions config/examples/sim-tpm-seal.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ WOLFBOOT_TPM_SEAL?=1
WOLFBOOT_TPM_SEAL_NV_BASE=0x01400300
#WOLFBOOT_TPM_SEAL_AUTH?=SealAuth

# Default image header size is larger to support room for policy
IMAGE_HEADER_SIZE?=512

# TPM Logging
#CFLAGS_EXTRA+=-DDEBUG_WOLFTPM
#CFLAGS_EXTRA+=-DWOLFTPM_DEBUG_VERBOSE
3 changes: 3 additions & 0 deletions include/fdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ const char* fdt_get_string(const void *fdt, int stroffset, int *lenp);
const void *fdt_getprop(const void *fdt, int nodeoffset, const char *name, int *lenp);
int fdt_setprop(void *fdt, int nodeoffset, const char *name, const void *val, int len);

int fdt_find_node_offset(void* fdt, int startoff, const char* node);
int fdt_find_prop_offset(void* fdt, int startoff, const char* propname, const char* propval);

int fdt_find_devtype(void* fdt, int startoff, const char* node);
int fdt_node_check_compatible(const void *fdt, int nodeoffset, const char *compatible);
int fdt_node_offset_by_compatible(const void *fdt, int startoffset, const char *compatible);
Expand Down
38 changes: 31 additions & 7 deletions src/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name, const void *val,
}
}
if (err != 0) {
wolfBoot_printf("FDT: Set prop failed! %d (name %d, off %d)\n",
wolfBoot_printf("FDT: Set prop failed! %d (name %s, off %d)\n",
err, name, nodeoffset);
}
return err;
Expand All @@ -577,23 +577,47 @@ const void *fdt_getprop(const void *fdt, int nodeoffset, const char *name,
return NULL;
}

int fdt_find_devtype(void* fdt, int startoff, const char* node)
int fdt_find_node_offset(void* fdt, int startoff, const char* node)
{
int off;
int nodelen = strlen(node);
int nlen;
const char* nstr = NULL;

for (off = fdt_next_node(fdt, startoff, NULL);
off >= 0;
off = fdt_next_node(fdt, off, NULL))
{
nstr = fdt_get_name(fdt, off, &nlen);
if ((nlen == nodelen) && (memcmp(nstr, node, nodelen) == 0)) {
break;
}
}
return off;
}

int fdt_find_prop_offset(void* fdt, int startoff, const char* propname,
const char* propval)
{
int len, off;
const void* val;
const char* propname = "device_type";
int nodelen = strlen(node)+1;
int nodelen = strlen(propval)+1;

for (off = fdt_next_node(fdt, startoff, NULL);
off >= 0;
off = fdt_next_node(fdt, off, NULL))
{
val = fdt_getprop(fdt, off, propname, &len);
if (val && (len == nodelen) && (memcmp(val, node, len) == 0)) {
return off;
if (val && (len == nodelen) && (memcmp(val, propval, len) == 0)) {
break;
}
}
return off; /* return error from fdt_next_node() */
return off;
}

int fdt_find_devtype(void* fdt, int startoff, const char* node)
{
return fdt_find_prop_offset(fdt, startoff, "device_type", node);
}

int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
Expand Down
13 changes: 11 additions & 2 deletions tools/fdt-parser/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Flattened Device Tree (FDT) Parser

This tool uses our internal FDT (fdt.c) parsing code to dump the device tree. There is also a `-t` option that tests making several updates to the device tree.
This tool uses our internal FDT (fdt.c) parsing code to dump the device tree.

Use `-i` to parse a Flattened uImage Tree (FIT) image.

There is also a `-t` option that tests making several updates to the device tree (useful with the nxp_t1024.dtb).

## Building fdt-parser

From root: `make fdt-parser`
OR
From `tools/fdt-parser` use `make clean && make`

## Example Output
## Example FDT Output

```sh
% ./tools/fdt-parser/fdt-parser ./tools/fdt-parser/nxp_t1024.dtb
Expand All @@ -28,3 +32,8 @@ root (node offset 0, depth 1, len 0):
power-isa-cs (prop offset 180, len 0): NULL
...
```

## Example FIT Output

```sh
```
Loading

0 comments on commit 5e9a28f

Please sign in to comment.