Fix riscv patches

- missing addappend (emtpy patch)
- failing to find DTB on QEMU

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
This commit is contained in:
David Abdurachmanov 2020-01-02 17:35:57 +02:00
parent 6848b8c211
commit 35bf0004b6
Signed by: davidlt
GPG Key ID: 8B7F1DA0E2C9FDBB
3 changed files with 153 additions and 5 deletions

View File

@ -1,14 +1,16 @@
diff --git a/configs/qemu-riscv64_smode_defconfig b/configs/qemu-riscv64_smode_defconfig
index a7b0e06a..8b70b7e0 100644
index a7b0e06a..99f8111a 100644
--- a/configs/qemu-riscv64_smode_defconfig
+++ b/configs/qemu-riscv64_smode_defconfig
@@ -14,3 +14,6 @@ CONFIG_CMD_NVEDIT_EFI=y
@@ -14,3 +14,8 @@ CONFIG_CMD_NVEDIT_EFI=y
CONFIG_OF_PRIOR_STAGE=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_DM_MTD=y
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyS0 earlycon"
+CONFIG_NR_CPUS=32
+CONFIG_USE_PREBOOT=y
+CONFIG_PREBOOT="cp.l ${fdtcontroladdr} ${fdt_addr_r} 0x10000;"
diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig
index 7d38ec9a..b120537d 100644
--- a/configs/sifive_fu540_defconfig

View File

@ -0,0 +1,146 @@
diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index a636346b..9e2af76a 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -250,7 +250,7 @@ static struct pxe_label *label_create(void)
/*
* Free the memory used by a pxe_label, including that used by its name,
- * kernel, append and initrd members, if they're non NULL.
+ * kernel, append, addappend and initrd members, if they're non NULL.
*
* So - be sure to only use dynamically allocated memory for the members of
* the pxe_label struct, unless you want to clean it up first. These are
@@ -270,6 +270,9 @@ static void label_destroy(struct pxe_label *label)
if (label->append)
free(label->append);
+ if (label->addappend)
+ free(label->addappend);
+
if (label->initrd)
free(label->initrd);
@@ -301,7 +304,9 @@ static void label_print(void *data)
* environment variable is defined. Its contents will be executed as U-Boot
* command. If the label specified an 'append' line, its contents will be
* used to overwrite the contents of the 'bootargs' environment variable prior
- * to running 'localcmd'.
+ * to running 'localcmd'. If the label specified an 'addappend' line, it's
+ * contents will be appended to the 'bootargs' environment variable priot to
+ * running 'localcmd'.
*
* Returns 1 on success or < 0 on error.
*/
@@ -314,6 +319,22 @@ static int label_localboot(struct pxe_label *label)
if (!localcmd)
return -ENOENT;
+ if (label->addappend) {
+ char newbootargs[CONFIG_SYS_CBSIZE] = "";
+ char addappend[CONFIG_SYS_CBSIZE];
+
+ strncat(newbootargs, env_get("bootargs"), CONFIG_SYS_CBSIZE - 1);
+
+ cli_simple_process_macros(label->addappend, addappend);
+
+ if (strlen(newbootargs) + 1 < CONFIG_SYS_CBSIZE)
+ strcat(newbootargs, " ");
+ strncat(newbootargs, addappend,
+ CONFIG_SYS_CBSIZE - strlen(newbootargs) - 1);
+
+ env_set("bootargs", newbootargs);
+ }
+
if (label->append) {
char bootargs[CONFIG_SYS_CBSIZE];
@@ -340,6 +361,9 @@ static int label_localboot(struct pxe_label *label)
*
* If the label specifies an 'append' line, its contents will overwrite that
* of the 'bootargs' environment variable.
+ *
+ * If the label specifies an 'addappend' line, it's contents will be appended
+ * to the 'bootargs' environment variable.
*/
static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
{
@@ -406,19 +430,28 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
}
#endif
- if ((label->ipappend & 0x3) || label->append) {
+ if ((label->ipappend & 0x3) || label->append || label->addappend) {
char bootargs[CONFIG_SYS_CBSIZE] = "";
char finalbootargs[CONFIG_SYS_CBSIZE];
- if (strlen(label->append ?: "") +
+ if (strlen(label->append ?: "") + strlen(label->addappend ?: "") +
strlen(ip_str) + strlen(mac_str) + 1 > sizeof(bootargs)) {
- printf("bootarg overflow %zd+%zd+%zd+1 > %zd\n",
+ printf("bootarg overflow %zd+%zd+%zd+%zd+1 > %zd\n",
strlen(label->append ?: ""),
+ strlen(label->addappend ?: ""),
strlen(ip_str), strlen(mac_str),
sizeof(bootargs));
return 1;
}
+ if (label->addappend) {
+ strncat(bootargs, env_get("bootargs"), CONFIG_SYS_CBSIZE - 1);
+ if (strlen(bootargs) + 1 < CONFIG_SYS_CBSIZE)
+ strcat(bootargs, " ");
+ strncat(bootargs, label->addappend,
+ CONFIG_SYS_CBSIZE - strlen(bootargs) - 1);
+ }
+
if (label->append)
strncpy(bootargs, label->append, sizeof(bootargs));
@@ -570,6 +603,7 @@ enum token_type {
T_KERNEL,
T_LINUX,
T_APPEND,
+ T_ADDAPPEND,
T_INITRD,
T_LOCALBOOT,
T_DEFAULT,
@@ -605,6 +639,7 @@ static const struct token keywords[] = {
{"linux", T_LINUX},
{"localboot", T_LOCALBOOT},
{"append", T_APPEND},
+ {"addappend", T_ADDAPPEND},
{"initrd", T_INITRD},
{"include", T_INCLUDE},
{"devicetree", T_FDT},
@@ -1028,6 +1063,10 @@ static int parse_label(char **c, struct pxe_menu *cfg)
break;
+ case T_ADDAPPEND:
+ err = parse_sliteral(c, &label->addappend);
+ break;
+
case T_INITRD:
if (!label->initrd)
err = parse_sliteral(c, &label->initrd);
diff --git a/cmd/pxe_utils.h b/cmd/pxe_utils.h
index a38ac81a..a6770679 100644
--- a/cmd/pxe_utils.h
+++ b/cmd/pxe_utils.h
@@ -28,6 +28,7 @@
* name - the name of the menu as given on the 'menu label' line.
* kernel - the path to the kernel file to use for this label.
* append - kernel command line to use when booting this label
+ * addappend - additional kernel command line options
* initrd - path to the initrd to use for this label.
* attempted - 0 if we haven't tried to boot this label, 1 if we have.
* localboot - 1 if this label specified 'localboot', 0 otherwise.
@@ -40,6 +41,7 @@ struct pxe_label {
char *kernel;
char *config;
char *append;
+ char *addappend;
char *initrd;
char *fdt;
char *fdtdir;

View File

@ -2,7 +2,7 @@
Name: uboot-tools
Version: 2020.01
Release: 0.9%{?candidate:.%{candidate}}.0.riscv64%{?dist}
Release: 0.9%{?candidate:.%{candidate}}.1.riscv64%{?dist}
Summary: U-Boot utilities
License: GPLv2+ BSD LGPL-2.1+ LGPL-2.0+
URL: http://www.denx.de/wiki/U-Boot
@ -42,7 +42,7 @@ Patch20: riscv64-set-fdt_addr.patch
# Set bootargs (console and earlycon)
# Set CPUs to 32 (same as Linux)
Patch21: riscv-set-bootargs-nrcpus.patch
Patch21: riscv-set-bootargs-nrcpus-preboot.patch
# Not upstream
# Adds support for Image.gz to booti (RFC/RFT)
@ -307,7 +307,7 @@ cp -p board/warp7/README builds/docs/README.warp7
%endif
%changelog
* Sat Dec 28 2019 David Abdurachmanov <david.abdurachmanov@sifive.com> 2020.01-0.9-rc5.0.riscv64
* Thu Jan 02 2020 David Abdurachmanov <david.abdurachmanov@sifive.com> 2020.01-0.9-rc5.1.riscv64
- Add support for RISC-V (riscv64)
- Define filesize and kernel_comp_addr_r for QEMU virt and SiFive FU540 boards
to support Image.gz with booti