The stock cboot has a few issues which should be easy to fix…
- The scripts embedded in u-boot on the Nano platform looked for both /boot/extlinux/extlinux.conf and /extlinux/extlinux.conf in the APP partition. This made it easier for other distros who normally place the boot files in their own partition and mount it as /boot in the rootfs. CBoot only looks for /boot/extlinux/extlinux.conf. The attached patch make CBoot look there first but then try /etxlinux/extlinux.conf before giving up.
While compiling to fix this issue, I ran across a few compile issues related to python.
- bootloader/partner/t18x/cboot/build/get_branch_name.py looks for an environment variable TOP which it can’t find and causes an exception. I’m guessing it should have been TEGRA_TOP?
- Even if it finds it, it tries to open a file
./repo/manifest.xml
which doesn’t exist again causing na exception. - Then it uses the python2 “print” construct without the parenthesis…
print prj.getAttribute("revision")
which causes an exception when run under python 3. - bootloader/partner/t18x/cboot/scripts/add_version_info.py was trying to use struct.pack without encoding the string to “bytes” causing an exception.
The patch also fixes these issues.
diff -uprN c-boot-stock/bootloader/partner/common/lib/linuxboot/extlinux_boot.c c-boot/bootloader/partner/common/lib/linuxboot/extlinux_boot.c
--- c-boot-stock/bootloader/partner/common/lib/linuxboot/extlinux_boot.c 2020-04-23 03:41:07.000000000 -0600
+++ c-boot/bootloader/partner/common/lib/linuxboot/extlinux_boot.c 2020-05-17 11:37:46.639229788 -0600
@@ -32,6 +32,7 @@
#include <tegrabl_auth.h>
#define EXTLINUX_CONF_PATH "/boot/extlinux/extlinux.conf"
+#define EXTLINUX_CONF_PATH_ALT "/extlinux/extlinux.conf"
#define EXTLINUX_CONF_MAX_SIZE 4096UL
static struct conf extlinux_conf;
@@ -230,12 +231,17 @@ static tegrabl_error_t load_and_parse_co
}
/* Read the extlinux.conf file */
- pr_info("Loading extlinux.conf ...\n");
+ pr_info("Trying to load extlinux.conf from %s ...\n", EXTLINUX_CONF_PATH);
file_size = EXTLINUX_CONF_MAX_SIZE;
err = tegrabl_fm_read(fm_handle, EXTLINUX_CONF_PATH, NULL, conf_load_addr, &file_size, NULL);
if (err != TEGRABL_NO_ERROR) {
- pr_error("Failed to find/load %s\n", EXTLINUX_CONF_PATH);
- goto fail;
+ pr_error("Failed to find/load primary %s\n", EXTLINUX_CONF_PATH);
+ pr_info("Trying to load extlinux.conf from %s ...\n", EXTLINUX_CONF_PATH_ALT);
+ err = tegrabl_fm_read(fm_handle, EXTLINUX_CONF_PATH_ALT, NULL, conf_load_addr, &file_size, NULL);
+ if (err != TEGRABL_NO_ERROR) {
+ pr_error("Failed to find/load secondary %s\n", EXTLINUX_CONF_PATH_ALT);
+ goto fail;
+ }
}
/* Parse extlinux.conf file */
diff -uprN c-boot-stock/bootloader/partner/t18x/cboot/build/get_branch_name.py c-boot/bootloader/partner/t18x/cboot/build/get_branch_name.py
--- c-boot-stock/bootloader/partner/t18x/cboot/build/get_branch_name.py 2020-04-23 03:41:07.000000000 -0600
+++ c-boot/bootloader/partner/t18x/cboot/build/get_branch_name.py 2020-05-17 11:06:34.719878642 -0600
@@ -13,13 +13,16 @@ import os
import sys
from xml.dom.minidom import parse
-top_dir = os.environ['TOP']
+top_dir = os.environ['TEGRA_TOP']
manifest_file = top_dir + '/.repo/manifest.xml'
-xml_tree = parse(manifest_file)
-collection = xml_tree.documentElement
-projects = collection.getElementsByTagName("default")
+try:
+ xml_tree = parse(manifest_file)
+ collection = xml_tree.documentElement
+ projects = collection.getElementsByTagName("default")
-for prj in projects:
- if prj.getAttribute("remote") == "origin":
- print prj.getAttribute("revision")
- break
+ for prj in projects:
+ if prj.getAttribute("remote") == "origin":
+ print(prj.getAttribute("revision"))
+ break
+except:
+ pass
diff -uprN c-boot-stock/bootloader/partner/t18x/cboot/scripts/add_version_info.py c-boot/bootloader/partner/t18x/cboot/scripts/add_version_info.py
--- c-boot-stock/bootloader/partner/t18x/cboot/scripts/add_version_info.py 2020-04-23 03:41:07.000000000 -0600
+++ c-boot/bootloader/partner/t18x/cboot/scripts/add_version_info.py 2020-05-17 11:05:03.464312214 -0600
@@ -40,4 +40,4 @@ if __name__ == "__main__":
version_string = '-'.join([str(item) for item in text])
sys.stdout.write('Appending version string: %s to %s\n' %
(version_string, binfile))
- f.write(struct.pack('%ds' % (length), version_string))
+ f.write(struct.pack('%ds' % (length), version_string.encode('utf-8')))