[libfdt]: does not create array nodes properly

Bug #1668291 reported by FFO
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
device-tree-compiler (Ubuntu)
New
Undecided
Unassigned

Bug Description

Note: this is a bug of DTC version 1.4.0 that is working properly with 1.4.2 (don't know what version actually solved the bug)

Way to reproduce:
compile the test program below:

gcc -o testdt testdt.c -lfdt
./testdt > test.dtb
fdtdump test.dtb

The values of reg are incorrect for 1.4.0 and correct for 1.4.2

-----
# testdt.c

#include <libfdt.h>
#include <stdlib.h>
#include <stdio.h>

#define _FDT(code) \
 { \
  int err = (code); \
  if (err) \
   fprintf(stderr, #code ": %s", fdt_strerror(err)); \
 }

static inline int fdt_property_reg64(void *fdt, const char *name, uint64_t val1, uint32_t val2)
{
 struct {
  fdt64_t address;
  fdt32_t size;
 } __attribute__((packed)) val;
 val.address = cpu_to_fdt64(val1);
 val.size = cpu_to_fdt32(val2);
 return fdt_property(fdt, name, (void*)&val, sizeof(val));
}

int main(void)
{
#define SIZE 4096
 void *staging_fdt = calloc(SIZE, 1);
 _FDT(fdt_create(staging_fdt, SIZE));
 _FDT(fdt_finish_reservemap(staging_fdt));
 _FDT(fdt_begin_node(staging_fdt, ""));
 _FDT(fdt_begin_node(staging_fdt, "soc"));
 _FDT(fdt_property_cell(staging_fdt, "#address-cells", 0x2));
 _FDT(fdt_property_cell(staging_fdt, "#size-cells", 0x1));
 _FDT(fdt_begin_node(staging_fdt, "kvm-gpio@0e0000"));
 _FDT(fdt_property_string(staging_fdt, "compatible", "basic-mmio-gpio"));
 _FDT(fdt_property_reg64(staging_fdt, "reg", 0xe0000ULL, 4));
 _FDT(fdt_end_node(staging_fdt));
 _FDT(fdt_end_node(staging_fdt));
 _FDT(fdt_end_node(staging_fdt));
 _FDT(fdt_finish(staging_fdt));

 fwrite(staging_fdt, fdt_totalsize(staging_fdt), 1, stdout);

 return 0;
}

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.