Hello,
I don't use Ubuntu I use Centos7 and devtoolset-9 but that's no the point. I have found the cause it is a shortcoming in dtbtool, the test:
while ((dp = readdir(dir)) != NULL) {
if ((dp->d_type == DT_REG)) {
is wrong if the subjacent filesystem doesn't set d_type, which is the case with xfs. According to man 3 readdir:
Only the fields d_name and d_ino are specified in POSIX.1-2001
So dtbtool didn't find any .dtb file and the masterDTB was not built.
Here is a patch to fix the issue, tested it works as expected I have now a firmware image:
--- tools/dtbtool/dtbtool.c-org 2020-05-04 07:06:14.000000000 +0200
+++ tools/dtbtool/dtbtool.c 2021-03-22 20:28:30.207909020 +0100
@@ -758,22 +758,21 @@
extract "qcom,msm-id" parameter
*/
while ((dp = readdir(dir)) != NULL) {
- if ((dp->d_type == DT_REG)) {
+ flen = strlen(input_dir) + strlen(dp->d_name) + 1;
+ filename = (char *)malloc(flen);
+ if (!filename) {
+ log_err("Out of memory\n");
+ rc = RC_ERROR;
+ break;
+ }
+ strncpy(filename, input_dir, flen);
+ strncat(filename, dp->d_name, flen);
+ if (stat(filename, &st) != -1 && (st.st_mode & S_IFMT) == S_IFREG) {
flen = strlen(dp->d_name);
if ((flen > 4) &&
(strncmp(&dp->d_name[flen-4], ".dtb", 4) == 0)) {
log_info("Found file: %s ... \n", dp->d_name);
- flen = strlen(input_dir) + strlen(dp->d_name) + 1;
- filename = (char *)malloc(flen);
- if (!filename) {
- log_err("Out of memory\n");
- rc = RC_ERROR;
- break;
- }
- strncpy(filename, input_dir, flen);
- strncat(filename, dp->d_name, flen);
-
/* To identify the version number */
msmversion = GetVersionInfo(filename);
@@ -805,8 +804,7 @@
}
}
- if ((stat(filename, &st) != 0) ||
- (st.st_size == 0)) {
+ if (st.st_size == 0) {
log_err("skip, failed to get DTB size\n");
free(filename);
continue;
Regards,