[Bug 1668291] [NEW] [libfdt]: does not create array nodes properly
FFO
francois.ozog at linaro.org
Mon Feb 27 14:58:06 UTC 2017
Public bug reported:
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 at 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;
}
** Affects: device-tree-compiler (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to device-tree-compiler in Ubuntu.
https://bugs.launchpad.net/bugs/1668291
Title:
[libfdt]: does not create array nodes properly
Status in device-tree-compiler package in Ubuntu:
New
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 at 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 manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/device-tree-compiler/+bug/1668291/+subscriptions
More information about the foundations-bugs
mailing list