Commit 8ddaf943 authored by Tom Rini's avatar Tom Rini

Merge tag 'dm-pull-29apr21' of https://source.denx.de/u-boot/custodians/u-boot-dm

buildman environment fix
binman FMAP improvements
minor test improvements and fixes
minor dm improvements
parents f3a0d2c1 5b700cdc
......@@ -144,7 +144,7 @@ jobs:
export USER=azure
virtualenv -p /usr/bin/python3 /tmp/venv
. /tmp/venv/bin/activate
pip install pyelftools pytest pygit2
pip install -r test/py/requirements.txt
export UBOOT_TRAVIS_BUILD_DIR=/tmp/sandbox_spl
export PYTHONPATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt
export PATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}
......
......@@ -151,7 +151,7 @@ Run binman, buildman, dtoc, Kconfig and patman testsuites:
export USER=gitlab;
virtualenv -p /usr/bin/python3 /tmp/venv;
. /tmp/venv/bin/activate;
pip install pyelftools pytest pygit2;
pip install -r test/py/requirements.txt;
export UBOOT_TRAVIS_BUILD_DIR=/tmp/sandbox_spl;
export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
......
......@@ -303,6 +303,8 @@ fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size)
{
int na, ns;
*size = FDT_SIZE_T_NONE;
if (ofnode_is_np(node)) {
const __be32 *prop_val;
u64 size64;
......@@ -347,6 +349,15 @@ fdt_addr_t ofnode_get_addr(ofnode node)
return ofnode_get_addr_index(node, 0);
}
fdt_size_t ofnode_get_size(ofnode node)
{
fdt_size_t size;
ofnode_get_addr_size_index(node, 0, &size);
return size;
}
int ofnode_stringlist_search(ofnode node, const char *property,
const char *string)
{
......
......@@ -265,7 +265,7 @@ int dm_scan_plat(bool pre_reloc_only)
static int dm_scan_fdt_node(struct udevice *parent, ofnode parent_node,
bool pre_reloc_only)
{
int ret = 0, err;
int ret = 0, err = 0;
ofnode node;
if (!ofnode_valid(parent_node))
......
......@@ -30,8 +30,6 @@ int scmi_dt_get_smt_buffer(struct udevice *dev, struct scmi_smt *smt)
int ret;
struct ofnode_phandle_args args;
struct resource resource;
fdt32_t faddr;
phys_addr_t paddr;
ret = dev_read_phandle_with_args(dev, "shmem", NULL, 0, 0, &args);
if (ret)
......@@ -41,21 +39,13 @@ int scmi_dt_get_smt_buffer(struct udevice *dev, struct scmi_smt *smt)
if (ret)
return ret;
/* TEMP workaround for ofnode_read_resource translation issue */
if (of_live_active()) {
paddr = resource.start;
} else {
faddr = cpu_to_fdt32(resource.start);
paddr = ofnode_translate_address(args.node, &faddr);
}
smt->size = resource_size(&resource);
if (smt->size < sizeof(struct scmi_smt_header)) {
dev_err(dev, "Shared memory buffer too small\n");
return -EINVAL;
}
smt->buf = devm_ioremap(dev, paddr, smt->size);
smt->buf = devm_ioremap(dev, resource.start, smt->size);
if (!smt->buf)
return -ENOMEM;
......
......@@ -863,7 +863,6 @@ static int jr2_probe(struct udevice *dev)
int i;
int ret;
struct resource res;
fdt32_t faddr;
phys_addr_t addr_base;
unsigned long addr_size;
ofnode eth_node, node, mdio_node;
......@@ -926,9 +925,8 @@ static int jr2_probe(struct udevice *dev)
if (ofnode_read_resource(mdio_node, 0, &res))
return -ENOMEM;
faddr = cpu_to_fdt32(res.start);
addr_base = ofnode_translate_address(mdio_node, &faddr);
addr_base = res.start;
addr_size = res.end - res.start;
/* If the bus is new then create a new bus */
......
......@@ -530,7 +530,6 @@ static int ocelot_probe(struct udevice *dev)
struct ocelot_private *priv = dev_get_priv(dev);
int i, ret;
struct resource res;
fdt32_t faddr;
phys_addr_t addr_base;
unsigned long addr_size;
ofnode eth_node, node, mdio_node;
......@@ -578,9 +577,8 @@ static int ocelot_probe(struct udevice *dev)
if (ofnode_read_resource(mdio_node, 0, &res))
return -ENOMEM;
faddr = cpu_to_fdt32(res.start);
addr_base = ofnode_translate_address(mdio_node, &faddr);
addr_base = res.start;
addr_size = res.end - res.start;
/* If the bus is new then create a new bus */
......
......@@ -482,7 +482,6 @@ static int serval_probe(struct udevice *dev)
struct serval_private *priv = dev_get_priv(dev);
int i, ret;
struct resource res;
fdt32_t faddr;
phys_addr_t addr_base;
unsigned long addr_size;
ofnode eth_node, node, mdio_node;
......@@ -533,9 +532,8 @@ static int serval_probe(struct udevice *dev)
if (ofnode_read_resource(mdio_node, 0, &res))
return -ENOMEM;
faddr = cpu_to_fdt32(res.start);
addr_base = ofnode_translate_address(mdio_node, &faddr);
addr_base = res.start;
addr_size = res.end - res.start;
/* If the bus is new then create a new bus */
......
......@@ -412,7 +412,6 @@ static int servalt_probe(struct udevice *dev)
struct servalt_private *priv = dev_get_priv(dev);
int i;
struct resource res;
fdt32_t faddr;
phys_addr_t addr_base;
unsigned long addr_size;
ofnode eth_node, node, mdio_node;
......@@ -461,9 +460,8 @@ static int servalt_probe(struct udevice *dev)
if (ofnode_read_resource(mdio_node, 0, &res))
return -ENOMEM;
faddr = cpu_to_fdt32(res.start);
addr_base = ofnode_translate_address(mdio_node, &faddr);
addr_base = res.start;
addr_size = res.end - res.start;
/* If the bus is new then create a new bus */
......
......@@ -510,6 +510,16 @@ phys_addr_t ofnode_get_addr_index(ofnode node, int index);
*/
phys_addr_t ofnode_get_addr(ofnode node);
/**
* ofnode_get_size() - get size from a node
*
* This reads the register size from a node
*
* @node: node to read from
* @return size of the address, or FDT_SIZE_T_NONE if not present or invalid
*/
fdt_size_t ofnode_get_size(ofnode node);
/**
* ofnode_stringlist_search() - find a string in a string list and return index
*
......
......@@ -24,15 +24,16 @@
typedef phys_addr_t fdt_addr_t;
typedef phys_size_t fdt_size_t;
#ifdef CONFIG_PHYS_64BIT
#define FDT_ADDR_T_NONE (-1U)
#define FDT_SIZE_T_NONE (-1U)
#ifdef CONFIG_PHYS_64BIT
#define fdt_addr_to_cpu(reg) be64_to_cpu(reg)
#define fdt_size_to_cpu(reg) be64_to_cpu(reg)
#define cpu_to_fdt_addr(reg) cpu_to_be64(reg)
#define cpu_to_fdt_size(reg) cpu_to_be64(reg)
typedef fdt64_t fdt_val_t;
#else
#define FDT_ADDR_T_NONE (-1U)
#define fdt_addr_to_cpu(reg) be32_to_cpu(reg)
#define fdt_size_to_cpu(reg) be32_to_cpu(reg)
#define cpu_to_fdt_addr(reg) cpu_to_be32(reg)
......
......@@ -53,14 +53,22 @@ struct udevice;
#define TPM2_PT_MAX_COMMAND_SIZE (u32)(TPM2_PT_FIXED + 30)
#define TPM2_PT_MAX_RESPONSE_SIZE (u32)(TPM2_PT_FIXED + 31)
/* event types */
#define EV_POST_CODE ((u32)0x00000001)
#define EV_NO_ACTION ((u32)0x00000003)
#define EV_SEPARATOR ((u32)0x00000004)
#define EV_S_CRTM_CONTENTS ((u32)0x00000007)
#define EV_S_CRTM_VERSION ((u32)0x00000008)
#define EV_CPU_MICROCODE ((u32)0x00000009)
#define EV_TABLE_OF_DEVICES ((u32)0x0000000B)
/*
* event types, cf.
* "TCG Server Management Domain Firmware Profile Specification",
* rev 1.00, 2020-05-01
*/
#define EV_POST_CODE ((u32)0x00000001)
#define EV_NO_ACTION ((u32)0x00000003)
#define EV_SEPARATOR ((u32)0x00000004)
#define EV_ACTION ((u32)0x00000005)
#define EV_TAG ((u32)0x00000006)
#define EV_S_CRTM_CONTENTS ((u32)0x00000007)
#define EV_S_CRTM_VERSION ((u32)0x00000008)
#define EV_CPU_MICROCODE ((u32)0x00000009)
#define EV_PLATFORM_CONFIG_FLAGS ((u32)0x0000000A)
#define EV_TABLE_OF_DEVICES ((u32)0x0000000B)
#define EV_COMPACT_HASH ((u32)0x0000000C)
/* TPMS_TAGGED_PROPERTY Structure */
struct tpms_tagged_property {
......
......@@ -942,7 +942,11 @@ int fdt_get_resource(const void *fdt, int node, const char *property,
while (ptr + na + ns <= end) {
if (i == index) {
res->start = fdtdec_get_number(ptr, na);
if (CONFIG_IS_ENABLED(OF_TRANSLATE))
res->start = fdt_translate_address(fdt, node, ptr);
else
res->start = fdtdec_get_number(ptr, na);
res->end = res->start;
res->end += fdtdec_get_number(&ptr[na], ns) - 1;
return 0;
......
......@@ -2326,13 +2326,15 @@ sub get_raw_comment {
# suffix: Suffix to expect on member, e.g. "_priv"
# warning: Warning name, e.g. "PRIV_AUTO"
sub u_boot_struct_name {
my ($line, $auto, $suffix, $warning) = @_;
my ($line, $auto, $suffix, $warning, $herecurr) = @_;
# Use _priv as a suffix for the device-private data struct
if ($line =~ /^\+\s*\.${auto}\s*=\s*sizeof\(struct\((\w+)\).*/) {
my $struct_name = $1;
if ($struct_name !~ /^\w+${suffix}/) {
WARN($warning, "struct \'$struct_name\' should have a ${suffix} suffix");
WARN($warning,
"struct \'$struct_name\' should have a ${suffix} suffix\n"
. $herecurr);
}
}
}
......@@ -2410,17 +2412,17 @@ sub u_boot_line {
}
# Check struct names for the 'auto' members of struct driver
u_boot_struct_name($line, "priv_auto", "_priv", "PRIV_AUTO");
u_boot_struct_name($line, "plat_auto", "_plat", "PLAT_AUTO");
u_boot_struct_name($line, "per_child_auto", "_priv", "CHILD_PRIV_AUTO");
u_boot_struct_name($line, "priv_auto", "_priv", "PRIV_AUTO", $herecurr);
u_boot_struct_name($line, "plat_auto", "_plat", "PLAT_AUTO", $herecurr);
u_boot_struct_name($line, "per_child_auto", "_priv", "CHILD_PRIV_AUTO", $herecurr);
u_boot_struct_name($line, "per_child_plat_auto", "_plat",
"CHILD_PLAT_AUTO");
"CHILD_PLAT_AUTO", $herecurr);
# Now the ones for struct uclass, skipping those in common with above
u_boot_struct_name($line, "per_device_auto", "_priv",
"DEVICE_PRIV_AUTO");
"DEVICE_PRIV_AUTO", $herecurr);
u_boot_struct_name($line, "per_device_plat_auto", "_plat",
"DEVICE_PLAT_AUTO");
"DEVICE_PLAT_AUTO", $herecurr);
}
sub process {
......
......@@ -261,3 +261,34 @@ static int dm_test_ofnode_is_enabled(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_ofnode_is_enabled, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_ofnode_get_reg(struct unit_test_state *uts)
{
ofnode node;
fdt_addr_t addr;
fdt_size_t size;
node = ofnode_path("/translation-test@8000");
ut_assert(ofnode_valid(node));
addr = ofnode_get_addr(node);
size = ofnode_get_size(node);
ut_asserteq(0x8000, addr);
ut_asserteq(0x4000, size);
node = ofnode_path("/translation-test@8000/dev@1,100");
ut_assert(ofnode_valid(node));
addr = ofnode_get_addr(node);
size = ofnode_get_size(node);
ut_asserteq(0x9000, addr);
ut_asserteq(0x1000, size);
node = ofnode_path("/emul-mux-controller");
ut_assert(ofnode_valid(node));
addr = ofnode_get_addr(node);
size = ofnode_get_size(node);
ut_asserteq(FDT_ADDR_T_NONE, addr);
ut_asserteq(FDT_SIZE_T_NONE, size);
return 0;
}
DM_TEST(dm_test_ofnode_get_reg, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
......@@ -17,6 +17,7 @@ pyparsing==2.4.2
pytest==5.2.1
python-mimeparse==1.6.0
python-subunit==1.3.0
requests==2.25.1
six==1.12.0
testtools==2.3.0
traceback2==1.4.0
......
......@@ -135,25 +135,32 @@ static bool ut_test_run_on_flattree(struct unit_test *test)
static bool test_matches(const char *prefix, const char *test_name,
const char *select_name)
{
size_t len;
if (!select_name)
return true;
if (!strcmp(test_name, select_name))
/* Allow glob expansion in the test name */
len = select_name[strlen(select_name) - 1] == '*' ? strlen(select_name) : 0;
if (len-- == 1)
return true;
if (!prefix) {
const char *p = strstr(test_name, "_test_");
if (!strncmp(test_name, select_name, len))
return true;
/* convert xxx_test_yyy to yyy, i.e. remove the suite name */
if (p)
test_name = p + 6;
} else {
if (prefix) {
/* All tests have this prefix */
if (!strncmp(test_name, prefix, strlen(prefix)))
test_name += strlen(prefix);
} else {
const char *p = strstr(test_name, "_test_");
/* convert xxx_test_yyy to yyy, i.e. remove the suite name */
if (p)
test_name = p + strlen("_test_");
}
if (!strcmp(test_name, select_name))
if (!strncmp(test_name, select_name, len))
return true;
return false;
......
......@@ -461,8 +461,12 @@ see www.flashrom.org/Flashrom for more information.
When used, this entry will be populated with an FMAP which reflects the
entries in the current image. Note that any hierarchy is squashed, since
FMAP does not support this. Also, CBFS entries appear as a single entry -
the sub-entries are ignored.
FMAP does not support this. Sections are represented as an area appearing
before its contents, so that it is possible to reconstruct the hierarchy
from the FMAP by using the offset information. This convention does not
seem to be documented, but is used in Chromium OS.
CBFS entries appear as a single entry, i.e. the sub-entries are ignored.
......@@ -804,6 +808,11 @@ Properties:
missing their contents. The second will produce an image but of
course it will not work.
Properties:
_allow_missing: True if this section permits external blobs to be
missing their contents. The second will produce an image but of
course it will not work.
Since a section is also an entry, it inherits all the properies of entries
too.
......
......@@ -28,8 +28,12 @@ class Entry_fmap(Entry):
When used, this entry will be populated with an FMAP which reflects the
entries in the current image. Note that any hierarchy is squashed, since
FMAP does not support this. Also, CBFS entries appear as a single entry -
the sub-entries are ignored.
FMAP does not support this. Sections are represented as an area appearing
before its contents, so that it is possible to reconstruct the hierarchy
from the FMAP by using the offset information. This convention does not
seem to be documented, but is used in Chromium OS.
CBFS entries appear as a single entry, i.e. the sub-entries are ignored.
"""
def __init__(self, section, etype, node):
super().__init__(section, etype, node)
......@@ -45,6 +49,17 @@ class Entry_fmap(Entry):
tout.Debug("fmap: Add entry '%s' type '%s' (%s subentries)" %
(entry.GetPath(), entry.etype, ToHexSize(entries)))
if entries and entry.etype != 'cbfs':
# Create an area for the section, which encompasses all entries
# within it
if entry.image_pos is None:
pos = 0
else:
pos = entry.image_pos - entry.GetRootSkipAtStart()
# Drop @ symbols in name
name = entry.name.replace('@', '')
areas.append(
fmap_util.FmapArea(pos, entry.size or 0, name, 0))
for subentry in entries.values():
_AddEntries(areas, subentry)
else:
......
......@@ -1341,6 +1341,7 @@ class TestFunctional(unittest.TestCase):
def testSplNoDtb(self):
"""Test that an image with spl/u-boot-spl-nodtb.bin can be created"""
self._SetupSplElf()
data = self._DoReadFile('052_u_boot_spl_nodtb.dts')
self.assertEqual(U_BOOT_SPL_NODTB_DATA, data[:len(U_BOOT_SPL_NODTB_DATA)])
......@@ -1594,26 +1595,41 @@ class TestFunctional(unittest.TestCase):
self.assertEqual(1, fhdr.ver_major)
self.assertEqual(0, fhdr.ver_minor)
self.assertEqual(0, fhdr.base)
self.assertEqual(16 + 16 +
fmap_util.FMAP_HEADER_LEN +
fmap_util.FMAP_AREA_LEN * 3, fhdr.image_size)
expect_size = fmap_util.FMAP_HEADER_LEN + fmap_util.FMAP_AREA_LEN * 5
self.assertEqual(16 + 16 + expect_size, fhdr.image_size)
self.assertEqual(b'FMAP', fhdr.name)
self.assertEqual(3, fhdr.nareas)
for fentry in fentries:
self.assertEqual(0, fentry.flags)
self.assertEqual(0, fentries[0].offset)
self.assertEqual(4, fentries[0].size)
self.assertEqual(b'RO_U_BOOT', fentries[0].name)
self.assertEqual(16, fentries[1].offset)
self.assertEqual(4, fentries[1].size)
self.assertEqual(b'RW_U_BOOT', fentries[1].name)
self.assertEqual(32, fentries[2].offset)
self.assertEqual(fmap_util.FMAP_HEADER_LEN +
fmap_util.FMAP_AREA_LEN * 3, fentries[2].size)
self.assertEqual(b'FMAP', fentries[2].name)
self.assertEqual(5, fhdr.nareas)
fiter = iter(fentries)
fentry = next(fiter)
self.assertEqual(b'SECTION0', fentry.name)
self.assertEqual(0, fentry.offset)
self.assertEqual(16, fentry.size)
self.assertEqual(0, fentry.flags)
fentry = next(fiter)
self.assertEqual(b'RO_U_BOOT', fentry.name)
self.assertEqual(0, fentry.offset)
self.assertEqual(4, fentry.size)
self.assertEqual(0, fentry.flags)
fentry = next(fiter)
self.assertEqual(b'SECTION1', fentry.name)
self.assertEqual(16, fentry.offset)
self.assertEqual(16, fentry.size)
self.assertEqual(0, fentry.flags)
fentry = next(fiter)
self.assertEqual(b'RW_U_BOOT', fentry.name)
self.assertEqual(16, fentry.offset)
self.assertEqual(4, fentry.size)
self.assertEqual(0, fentry.flags)
fentry = next(fiter)
self.assertEqual(b'FMAP', fentry.name)
self.assertEqual(32, fentry.offset)
self.assertEqual(expect_size, fentry.size)
self.assertEqual(0, fentry.flags)
def testBlobNamedByArg(self):
"""Test we can add a blob with the filename coming from an entry arg"""
......@@ -2063,20 +2079,29 @@ class TestFunctional(unittest.TestCase):
self.assertEqual(expected, data[:32])
fhdr, fentries = fmap_util.DecodeFmap(data[36:])
self.assertEqual(0x100, fhdr.image_size)
self.assertEqual(0x180, fhdr.image_size)
expect_size = fmap_util.FMAP_HEADER_LEN + fmap_util.FMAP_AREA_LEN * 4
fiter = iter(fentries)
self.assertEqual(0, fentries[0].offset)
self.assertEqual(4, fentries[0].size)
self.assertEqual(b'U_BOOT', fentries[0].name)
fentry = next(fiter)
self.assertEqual(b'U_BOOT', fentry.name)
self.assertEqual(0, fentry.offset)
self.assertEqual(4, fentry.size)
self.assertEqual(4, fentries[1].offset)
self.assertEqual(3, fentries[1].size)
self.assertEqual(b'INTEL_MRC', fentries[1].name)
fentry = next(fiter)
self.assertEqual(b'SECTION', fentry.name)
self.assertEqual(4, fentry.offset)
self.assertEqual(0x20 + expect_size, fentry.size)
self.assertEqual(36, fentries[2].offset)
self.assertEqual(fmap_util.FMAP_HEADER_LEN +
fmap_util.FMAP_AREA_LEN * 3, fentries[2].size)
self.assertEqual(b'FMAP', fentries[2].name)
fentry = next(fiter)
self.assertEqual(b'INTEL_MRC', fentry.name)
self.assertEqual(4, fentry.offset)
self.assertEqual(3, fentry.size)
fentry = next(fiter)
self.assertEqual(b'FMAP', fentry.name)
self.assertEqual(36, fentry.offset)
self.assertEqual(expect_size, fentry.size)
def testElf(self):
"""Basic test of ELF entries"""
......@@ -4272,6 +4297,7 @@ class TestFunctional(unittest.TestCase):
def testTplNoDtb(self):
"""Test that an image with tpl/u-boot-tpl-nodtb.bin can be created"""
self._SetupTplElf()
data = self._DoReadFile('192_u_boot_tpl_nodtb.dts')
self.assertEqual(U_BOOT_TPL_NODTB_DATA,
data[:len(U_BOOT_TPL_NODTB_DATA)])
......
......@@ -7,7 +7,7 @@
binman {
end-at-4gb;
size = <0x100>;
size = <0x180>;
u-boot {
};
section {
......
......@@ -182,6 +182,7 @@ class Builder:
only useful for testing in-tree builds.
work_in_output: Use the output directory as the work directory and
don't write to a separate output directory.
thread_exceptions: List of exceptions raised by thread jobs
Private members:
_base_board_dict: Last-summarised Dict of boards
......@@ -235,7 +236,8 @@ class Builder:
no_subdirs=False, full_path=False, verbose_build=False,
mrproper=False, per_board_out_dir=False,
config_only=False, squash_config_y=False,
warnings_as_errors=False, work_in_output=False):
warnings_as_errors=False, work_in_output=False,
test_thread_exceptions=False):
"""Create a new Builder object
Args:
......@@ -262,6 +264,9 @@ class Builder:
warnings_as_errors: Treat all compiler warnings as errors
work_in_output: Use the output directory as the work directory and
don't write to a separate output directory.
test_thread_exceptions: Uses for tests only, True to make the
threads raise an exception instead of reporting their result.
This simulates a failure in the code somewhere
"""
self.toolchains = toolchains
self.base_dir = base_dir
......@@ -311,13 +316,16 @@ class Builder:
self._re_migration_warning = re.compile(r'^={21} WARNING ={22}\n.*\n=+\n',
re.MULTILINE | re.DOTALL)
self.thread_exceptions = []
self.test_thread_exceptions = test_thread_exceptions
if self.num_threads:
self._single_builder = None
self.queue = queue.Queue()
self.out_queue = queue.Queue()
for i in range(self.num_threads):
t = builderthread.BuilderThread(self, i, mrproper,
per_board_out_dir)
t = builderthread.BuilderThread(
self, i, mrproper, per_board_out_dir,
test_exception=test_thread_exceptions)
t.setDaemon(True)