Skip to content

Commit d93466f

Browse files
committed
Test if kernel booted wit u-boot overlays
1 parent 451d50c commit d93466f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

source/common.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,27 @@ BBIO_err load_device_tree(const char *name)
450450
#endif
451451

452452
char line[256];
453+
char buf[1035];
454+
const char *cmd = "grep -c bone_capemgr.uboot_capemgr_enabled=1 /proc/cmdline";
455+
FILE *fp;
456+
457+
fprintf(stderr, "load_device_tree: cmd=%s\n", cmd);
458+
fp = popen(cmd, "r");
459+
if (fp == NULL) {
460+
fprintf(stderr, "load_device_tree: failed to run command\n");
461+
#ifndef NO_PYTHON
462+
PyErr_SetFromErrnoWithFilename(PyExc_IOError, cmd);
463+
#endif // !NO_PYTHON
464+
return BBIO_CAPE;
465+
}
466+
while (fgets(buf, sizeof(buf)-1, fp) != NULL) {
467+
fprintf(stderr, "load_device_tree: %s\n", buf);
468+
}
469+
pclose(fp);
470+
453471

454472
snprintf(slots, sizeof(slots), "%s/slots", ctrl_dir);
473+
fprintf(stderr, "load_device_tree: slots=%s\n", slots);
455474

456475
file = fopen(slots, "r+");
457476
if (!file) {
@@ -462,6 +481,7 @@ BBIO_err load_device_tree(const char *name)
462481
}
463482

464483
while (fgets(line, sizeof(line), file)) {
484+
fprintf(stderr, "load_device_tree: line=%s\n", slots);
465485
//the device is already loaded, return 1
466486
if (strstr(line, name)) {
467487
fclose(file);

0 commit comments

Comments
 (0)