aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini2020-08-24 20:24:21 -0400
committerTom Rini2020-08-25 08:12:05 -0400
commit8ee3a24fdc237c76cead618a173740594287dd96 (patch)
treea19a58ee49166c02dce5bdb35262bb48c2078e8c
parent3c0cec035e5b06b638fb52ccd7383bbd5bcede35 (diff)
parent3337b291442e31b1db0ff5975f74fec7d9741794 (diff)
Merge branch '2020-08-24-misc-improvements'
- Squashfs compression support - Coverity fixes - XEN guest updates - Finish previous MediaTek updates - Arm Total Compute platform support
-rw-r--r--MAINTAINERS16
-rw-r--r--arch/arm/Kconfig11
-rw-r--r--arch/arm/dts/Makefile4
-rw-r--r--arch/arm/dts/mt7622-bananapi-bpi-r64.dts (renamed from arch/arm/dts/mt7622-bpi-r64.dts)8
-rw-r--r--arch/arm/dts/mt7622-rfb.dts8
-rw-r--r--arch/arm/dts/mt7622.dtsi56
-rw-r--r--arch/arm/dts/mt7623.dtsi46
-rw-r--r--arch/arm/dts/mt7623n-bananapi-bpi-r2.dts16
-rw-r--r--arch/arm/dts/total_compute.dts48
-rw-r--r--arch/arm/include/asm/gpio.h2
-rw-r--r--board/armltd/total_compute/Kconfig12
-rw-r--r--board/armltd/total_compute/MAINTAINERS7
-rw-r--r--board/armltd/total_compute/Makefile6
-rw-r--r--board/armltd/total_compute/total_compute.c67
-rw-r--r--board/xen/xenguest_arm64/MAINTAINERS3
-rw-r--r--board/xen/xenguest_arm64/xenguest_arm64.c5
-rw-r--r--cmd/clone.c8
-rw-r--r--common/Kconfig20
-rw-r--r--common/avb_verify.c1
-rw-r--r--configs/total_compute_defconfig53
-rw-r--r--configs/xenguest_arm64_defconfig75
-rw-r--r--drivers/ata/mtk_ahci.c6
-rw-r--r--drivers/clk/mediatek/clk-mt7622.c43
-rw-r--r--drivers/firmware/psci.c6
-rw-r--r--drivers/phy/phy-mtk-tphy.c5
-rw-r--r--drivers/virtio/virtio_blk.c1
-rw-r--r--drivers/xen/gnttab.c3
-rw-r--r--drivers/xen/pvblock.c12
-rw-r--r--fs/squashfs/sqfs.c80
-rw-r--r--fs/squashfs/sqfs_decompressor.c104
-rw-r--r--fs/squashfs/sqfs_decompressor.h7
-rw-r--r--fs/squashfs/sqfs_dir.c3
-rw-r--r--fs/squashfs/sqfs_filesystem.h12
-rw-r--r--fs/squashfs/sqfs_inode.c5
-rw-r--r--include/avb_verify.h4
-rw-r--r--include/configs/total_compute.h89
-rw-r--r--include/configs/xenguest_arm64.h7
-rw-r--r--include/xen/gnttab.h3
-rw-r--r--lib/sscanf.c3
-rw-r--r--test/py/tests/test_fs/test_squashfs/sqfs_common.py76
-rw-r--r--test/py/tests/test_fs/test_squashfs/test_sqfs_load.py40
-rw-r--r--test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py33
42 files changed, 838 insertions, 176 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 17ac45587b7..bebe87b4d1f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1097,6 +1097,22 @@ T: git https://gitlab.denx.de/u-boot/custodians/u-boot-x86.git
F: arch/x86/
F: cmd/x86/
+XEN
+M: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
+M: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
+S: Maintained
+F: arch/arm/cpu/armv8/xen/
+F: arch/arm/include/asm/xen.h
+F: arch/arm/include/asm/xen/
+F: cmd/pvblock.c
+F: drivers/serial/serial_xen.c
+F: drivers/xen/
+F: include/pvblock.h
+F: include/xen/
+F: include/xen.h
+F: lib/sscanf.c
+F: test/lib/sscanf.c
+
XTENSA
M: Max Filippov <jcmvbkbc@gmail.com>
S: Maintained
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9b8dadce837..c5ebd59d340 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1198,6 +1198,15 @@ config TARGET_VEXPRESS64_JUNO
select USB
select DM_USB
+config TARGET_TOTAL_COMPUTE
+ bool "Support Total Compute Platform"
+ select ARM64
+ select PL01X_SERIAL
+ select DM
+ select DM_SERIAL
+ select DM_MMC
+ select DM_GPIO
+
config TARGET_LS2080A_EMU
bool "Support ls2080a_emu"
select ARCH_LS2080A
@@ -1904,6 +1913,8 @@ source "arch/arm/mach-imx/Kconfig"
source "arch/arm/mach-nexell/Kconfig"
+source "board/armltd/total_compute/Kconfig"
+
source "board/bosch/shc/Kconfig"
source "board/bosch/guardian/Kconfig"
source "board/CarMediaLab/flea3/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index b2b5360f6d8..f8f529435bf 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -962,7 +962,7 @@ dtb-$(CONFIG_SOC_K3_J721E) += k3-j721e-common-proc-board.dtb \
dtb-$(CONFIG_ARCH_MEDIATEK) += \
mt7622-rfb.dtb \
mt7623a-unielec-u7623-02-emmc.dtb \
- mt7622-bpi-r64.dtb \
+ mt7622-bananapi-bpi-r64.dtb \
mt7623n-bananapi-bpi-r2.dtb \
mt7629-rfb.dtb \
mt8512-bm1-emmc.dtb \
@@ -981,6 +981,8 @@ dtb-$(CONFIG_TARGET_VEXPRESS_CA5X2) += vexpress-v2p-ca5s.dtb
dtb-$(CONFIG_TARGET_VEXPRESS_CA9X4) += vexpress-v2p-ca9.dtb
dtb-$(CONFIG_TARGET_VEXPRESS_CA15_TC2) += vexpress-v2p-ca15_a7.dtb
+dtb-$(CONFIG_TARGET_TOTAL_COMPUTE) += total_compute.dtb
+
dtb-$(CONFIG_TARGET_DURIAN) += phytium-durian.dtb
dtb-$(CONFIG_TARGET_PRESIDIO_ASIC) += ca-presidio-engboard.dtb
diff --git a/arch/arm/dts/mt7622-bpi-r64.dts b/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
index 51287cea3ac..4f2f04851d1 100644
--- a/arch/arm/dts/mt7622-bpi-r64.dts
+++ b/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
@@ -244,3 +244,11 @@
output-low;
};
};
+
+&ssusb {
+ status = "okay";
+};
+
+&u3phy {
+ status = "okay";
+};
diff --git a/arch/arm/dts/mt7622-rfb.dts b/arch/arm/dts/mt7622-rfb.dts
index 317fc78abda..ef7d0f0270e 100644
--- a/arch/arm/dts/mt7622-rfb.dts
+++ b/arch/arm/dts/mt7622-rfb.dts
@@ -222,3 +222,11 @@
full-duplex;
};
};
+
+&ssusb {
+ status = "okay";
+};
+
+&u3phy {
+ status = "okay";
+};
diff --git a/arch/arm/dts/mt7622.dtsi b/arch/arm/dts/mt7622.dtsi
index c43ad657029..d8885458091 100644
--- a/arch/arm/dts/mt7622.dtsi
+++ b/arch/arm/dts/mt7622.dtsi
@@ -192,6 +192,14 @@
status = "disabled";
};
+ ssusbsys: ssusbsys@1a000000 {
+ compatible = "mediatek,mt7622-ssusbsys",
+ "syscon";
+ reg = <0x1a000000 0x1000>;
+ #clock-cells = <1>;
+ #reset-cells = <1>;
+ };
+
pciesys: pciesys@1a100800 {
compatible = "mediatek,mt7622-pciesys", "syscon";
reg = <0x1a100800 0x1000>;
@@ -302,6 +310,54 @@
};
};
+ ssusb: usb@1a0c0000 {
+ compatible = "mediatek,mt7622-xhci",
+ "mediatek,mtk-xhci";
+ reg = <0x1a0c0000 0x01000>,
+ <0x1a0c4700 0x0100>;
+ reg-names = "mac", "ippc";
+ interrupts = <GIC_SPI 232 IRQ_TYPE_LEVEL_LOW>;
+ power-domains = <&scpsys MT7629_POWER_DOMAIN_HIF1>;
+ clocks = <&ssusbsys CLK_SSUSB_SYS_EN>,
+ <&ssusbsys CLK_SSUSB_REF_EN>,
+ <&ssusbsys CLK_SSUSB_MCU_EN>,
+ <&ssusbsys CLK_SSUSB_DMA_EN>;
+ clock-names = "sys_ck", "ref_ck", "mcu_ck", "dma_ck";
+ phys = <&u2port0 PHY_TYPE_USB2>,
+ <&u3port0 PHY_TYPE_USB3>,
+ <&u2port1 PHY_TYPE_USB2>;
+ status = "disabled";
+ };
+
+ u3phy: usb-phy@1a0c4000 {
+ compatible = "mediatek,mt7622-u3phy",
+ "mediatek,generic-tphy-v1";
+ reg = <0x1a0c4000 0x700>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges;
+ status = "disabled";
+
+ u2port0: usb-phy@1a0c4800 {
+ reg = <0x1a0c4800 0x0100>;
+ #phy-cells = <1>;
+ clocks = <&ssusbsys CLK_SSUSB_U2_PHY_EN>;
+ clock-names = "ref";
+ };
+
+ u3port0: usb-phy@1a0c4900 {
+ reg = <0x1a0c4900 0x0700>;
+ #phy-cells = <1>;
+ };
+
+ u2port1: usb-phy@1a0c5000 {
+ reg = <0x1a0c5000 0x0100>;
+ #phy-cells = <1>;
+ clocks = <&ssusbsys CLK_SSUSB_U2_PHY_1P_EN>;
+ clock-names = "ref";
+ };
+ };
+
ethsys: syscon@1b000000 {
compatible = "mediatek,mt7622-ethsys", "syscon";
reg = <0x1b000000 0x1000>;
diff --git a/arch/arm/dts/mt7623.dtsi b/arch/arm/dts/mt7623.dtsi
index 0452889ef80..b5a802552b1 100644
--- a/arch/arm/dts/mt7623.dtsi
+++ b/arch/arm/dts/mt7623.dtsi
@@ -352,6 +352,52 @@
};
};
+ usb1: usb@1a1c0000 {
+ compatible = "mediatek,mt7623-xhci", "mediatek,mtk-xhci";
+ reg = <0x1a1c0000 0x1000>, <0x1a1c4700 0x0100>;
+ reg-names = "mac", "ippc";
+ power-domains = <&scpsys MT7623_POWER_DOMAIN_HIF>;
+ clocks = <&hifsys CLK_HIFSYS_USB0PHY>, <&topckgen CLK_TOP_ETHIF_SEL>;
+ clock-names = "sys_ck", "ref_ck";
+ phys = <&u2port0 PHY_TYPE_USB2>, <&u3port0 PHY_TYPE_USB3>;
+ status = "disabled";
+ };
+
+ u3phy1: usb-phy@1a1c4000 {
+ compatible = "mediatek,mt7623-tphy", "mediatek,generic-tphy-v1";
+
+ reg = <0x1a1c4000 0x0700>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges;
+ status = "disabled";
+
+ u2port0: usb-phy@1a1c4800 {
+ reg = <0x1a1c4800 0x0100>;
+ #phy-cells = <1>;
+ clocks = <&topckgen CLK_TOP_USB_PHY48M>;
+ clock-names = "ref";
+ };
+
+ u3port0: usb-phy@1a1c4900 {
+ reg = <0x1a1c4900 0x0700>;
+ #phy-cells = <1>;
+ clocks = <&clk26m>;
+ clock-names = "ref";
+ };
+ };
+
+ usb2: usb@1a240000 {
+ compatible = "mediatek,mt7623-xhci", "mediatek,mtk-xhci";
+ reg = <0x1a240000 0x1000>, <0x1a244700 0x0100>;
+ reg-names = "mac", "ippc";
+ power-domains = <&scpsys MT7623_POWER_DOMAIN_HIF>;
+ clocks = <&hifsys CLK_HIFSYS_USB1PHY>, <&topckgen CLK_TOP_ETHIF_SEL>;
+ clock-names = "sys_ck", "ref_ck";
+ phys = <&u2port1 PHY_TYPE_USB2>, <&u3port1 PHY_TYPE_USB3>;
+ status = "disabled";
+ };
+
u3phy2: usb-phy@1a244000 {
compatible = "mediatek,generic-tphy-v1";
reg = <0x1a244000 0x0700>;
diff --git a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
index bcedcf20f13..ef073696273 100644
--- a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
+++ b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
@@ -248,3 +248,19 @@
pinctrl-0 = <&uart2_pins_a>;
status = "okay";
};
+
+&usb1 {
+ status = "okay";
+};
+
+&u3phy1 {
+ status = "okay";
+};
+
+&usb2 {
+ status = "okay";
+};
+
+&u3phy2 {
+ status = "okay";
+};
diff --git a/arch/arm/dts/total_compute.dts b/arch/arm/dts/total_compute.dts
new file mode 100644
index 00000000000..4399269a441
--- /dev/null
+++ b/arch/arm/dts/total_compute.dts
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2020 Arm Limited
+ */
+
+/dts-v1/;
+
+/ {
+ model = "total_compute";
+ compatible = "arm,total_compute";
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ sysreg: sysreg@1c010000 {
+ compatible = "arm,vexpress-sysreg";
+ reg = <0x0 0x001c010000 0x0 0x1000>;
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+
+ fixed_3v3: v2m-3v3 {
+ compatible = "regulator-fixed";
+ regulator-name = "3V3";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-always-on;
+ };
+
+ mmci@1c050000 {
+ compatible = "arm,pl180", "arm,primecell";
+ reg = <0x0 0x001c050000 0x0 0x1000>;
+ cd-gpios = <&sysreg 0 0>;
+ arm,primecell-periphid = <0x00880180>;
+ wp-gpios = <&sysreg 1 0>;
+ bus-width = <8>;
+ max-frequency = <12000000>;
+ vmmc-supply = <&fixed_3v3>;
+ clocks = <&clock24mhz>, <&clock24mhz>;
+ clock-names = "mclk", "apb_pclk";
+ };
+
+ clock24mhz: clock24mhz {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <24000000>;
+ clock-output-names = "bp:clock24mhz";
+ };
+};
diff --git a/arch/arm/include/asm/gpio.h b/arch/arm/include/asm/gpio.h
index 7dc87afb83a..6ecb876eda5 100644
--- a/arch/arm/include/asm/gpio.h
+++ b/arch/arm/include/asm/gpio.h
@@ -3,7 +3,7 @@
!defined(CONFIG_ARCH_BCM6858) && !defined(CONFIG_ARCH_BCM63158) && \
!defined(CONFIG_ARCH_ROCKCHIP) && !defined(CONFIG_ARCH_ASPEED) && \
!defined(CONFIG_ARCH_U8500) && !defined(CONFIG_CORTINA_PLATFORM) && \
- !defined(CONFIG_TARGET_BCMNS3)
+ !defined(CONFIG_TARGET_BCMNS3) && !defined(CONFIG_TARGET_TOTAL_COMPUTE)
#include <asm/arch/gpio.h>
#endif
#include <asm-generic/gpio.h>
diff --git a/board/armltd/total_compute/Kconfig b/board/armltd/total_compute/Kconfig
new file mode 100644
index 00000000000..62e6e6f4ac3
--- /dev/null
+++ b/board/armltd/total_compute/Kconfig
@@ -0,0 +1,12 @@
+if TARGET_TOTAL_COMPUTE
+
+config SYS_BOARD
+ default "total_compute"
+
+config SYS_VENDOR
+ default "armltd"
+
+config SYS_CONFIG_NAME
+ default "total_compute"
+
+endif
diff --git a/board/armltd/total_compute/MAINTAINERS b/board/armltd/total_compute/MAINTAINERS
new file mode 100644
index 00000000000..3dc1cd188ab
--- /dev/null
+++ b/board/armltd/total_compute/MAINTAINERS
@@ -0,0 +1,7 @@
+TOTAL_COMPUTE BOARD
+M: Usama Arif <usama.arif@arm.com>
+S: Maintained
+F: board/armltd/total_compute/
+F: include/configs/total_compute.h
+F: configs/total_compute_defconfig
+F: arch/arm/dts/total_compute.dts
diff --git a/board/armltd/total_compute/Makefile b/board/armltd/total_compute/Makefile
new file mode 100644
index 00000000000..8b104584312
--- /dev/null
+++ b/board/armltd/total_compute/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2020 Arm Limited
+# Usama Arif <usama.arif@arm.com>
+
+obj-y := total_compute.o
diff --git a/board/armltd/total_compute/total_compute.c b/board/armltd/total_compute/total_compute.c
new file mode 100644
index 00000000000..0be6435fe3b
--- /dev/null
+++ b/board/armltd/total_compute/total_compute.c
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2020 Arm Limited
+ * Usama Arif <usama.arif@arm.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/platform_data/serial_pl01x.h>
+#include <asm/armv8/mmu.h>
+
+static const struct pl01x_serial_platdata serial_platdata = {
+ .base = UART0_BASE,
+ .type = TYPE_PL011,
+ .clock = CONFIG_PL011_CLOCK,
+};
+
+U_BOOT_DEVICE(total_compute_serials) = {
+ .name = "serial_pl01x",
+ .platdata = &serial_platdata,
+};
+
+static struct mm_region total_compute_mem_map[] = {
+ {
+ .virt = 0x0UL,
+ .phys = 0x0UL,
+ .size = 0x80000000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+ PTE_BLOCK_NON_SHARE |
+ PTE_BLOCK_PXN | PTE_BLOCK_UXN
+ }, {
+ .virt = 0x80000000UL,
+ .phys = 0x80000000UL,
+ .size = 0xff80000000UL,
+ .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE
+ }, {
+ /* List terminator */
+ 0,
+ }
+};
+
+struct mm_region *mem_map = total_compute_mem_map;
+
+int board_init(void)
+{
+ return 0;
+}
+
+int dram_init(void)
+{
+ gd->ram_size = PHYS_SDRAM_1_SIZE;
+ return 0;
+}
+
+int dram_init_banksize(void)
+{
+ gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+ gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
+
+ return 0;
+}
+
+/* Nothing to be done here as handled by PSCI interface */
+void reset_cpu(ulong addr)
+{
+}
diff --git a/board/xen/xenguest_arm64/MAINTAINERS b/board/xen/xenguest_arm64/MAINTAINERS
index 787e9e0d0e1..264920e240f 100644
--- a/board/xen/xenguest_arm64/MAINTAINERS
+++ b/board/xen/xenguest_arm64/MAINTAINERS
@@ -1,5 +1,6 @@
XEN GUEST FOR ARM64
-M: Andrii Anisov <andrii_anisov@epam.com>
+M: Anastasiia Lukianenko <anastasiia_lukianenko@epam.com>
+M: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
S: Maintained
F: board/xen/xenguest_arm64/
F: doc/board/xen/
diff --git a/board/xen/xenguest_arm64/xenguest_arm64.c b/board/xen/xenguest_arm64/xenguest_arm64.c
index cce54369bb3..4660f3fff20 100644
--- a/board/xen/xenguest_arm64/xenguest_arm64.c
+++ b/board/xen/xenguest_arm64/xenguest_arm64.c
@@ -184,11 +184,6 @@ int ft_board_setup(void *blob, struct bd_info *bd)
return 0;
}
-int board_early_init_f(void)
-{
- return 0;
-}
-
int print_cpuinfo(void)
{
printf("Xen virtual CPU\n");
diff --git a/cmd/clone.c b/cmd/clone.c
index 97747f8f080..32473a032c1 100644
--- a/cmd/clone.c
+++ b/cmd/clone.c
@@ -38,7 +38,7 @@ static int do_clone(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv
srcbz = srcdesc->blksz;
destbz = destdesc->blksz;
- if ((srcbz * (buffersize / srcbz) != buffersize) &&
+ if ((srcbz * (buffersize / srcbz) != buffersize) ||
(destbz * (buffersize / destbz) != buffersize)) {
printf("failed: cannot match device block sizes\n");
return 1;
@@ -55,10 +55,12 @@ static int do_clone(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv
switch (unit[0]) {
case 'g':
case 'G':
- requested *= 1024;
+ requested *= 1024 * 1024 * 1024;
+ break;
case 'm':
case 'M':
- requested *= 1024;
+ requested *= 1024 * 1024;
+ break;
case 'k':
case 'K':
requested *= 1024;
diff --git a/common/Kconfig b/common/Kconfig
index 8f61aa76024..c58f08ba91b 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1003,7 +1003,7 @@ config HASH
config AVB_VERIFY
bool "Build Android Verified Boot operations"
- depends on LIBAVB && FASTBOOT
+ depends on LIBAVB
depends on PARTITION_UUIDS
help
This option enables compilation of bootloader-dependent operations,
@@ -1012,6 +1012,24 @@ config AVB_VERIFY
* Helpers to access MMC, similar to drivers/fastboot/fb_mmc.c.
* Helpers to alloc/init/free avb ops.
+if AVB_VERIFY
+
+config AVB_BUF_ADDR
+ hex "Define AVB buffer address"
+ default FASTBOOT_BUF_ADDR
+ help
+ AVB requires a buffer for memory transactions. This variable defines the
+ buffer address.
+
+config AVB_BUF_SIZE
+ hex "Define AVB buffer SIZE"
+ default FASTBOOT_BUF_SIZE
+ help
+ AVB requires a buffer for memory transactions. This variable defines the
+ buffer size.
+
+endif # AVB_VERIFY
+
config SPL_HASH
bool # "Support hashing API (SHA1, SHA256, etc.)"
help
diff --git a/common/avb_verify.c b/common/avb_verify.c
index a2b739626b5..db10d0f21fc 100644
--- a/common/avb_verify.c
+++ b/common/avb_verify.c
@@ -7,7 +7,6 @@
#include <avb_verify.h>
#include <blk.h>
#include <cpu_func.h>
-#include <fastboot.h>
#include <image.h>
#include <malloc.h>
#include <part.h>
diff --git a/configs/total_compute_defconfig b/configs/total_compute_defconfig
new file mode 100644
index 00000000000..e36d701ff49
--- /dev/null
+++ b/configs/total_compute_defconfig
@@ -0,0 +1,53 @@
+CONFIG_ARM=y
+CONFIG_TARGET_TOTAL_COMPUTE=y
+CONFIG_SYS_TEXT_BASE=0xe0000000
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_ENV_SIZE=0x2a00000
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_DEFAULT_DEVICE_TREE="total_compute"
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_ANDROID_BOOT_IMAGE=y
+CONFIG_FIT=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
+CONFIG_BOOTDELAY=5
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyAMA0 debug user_debug=31 earlycon=pl011,0x7ff80000 loglevel=9 androidboot.hardware=total_compute video=640x480-32@60 androidboot.boot_devices=1c050000.mmci ip=dhcp androidboot.selinux=permissive"
+# CONFIG_USE_BOOTCOMMAND is not set
+# CONFIG_DISPLAY_CPUINFO is not set
+# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_AVB_VERIFY=y
+CONFIG_AVB_BUF_ADDR=0x90000000
+CONFIG_AVB_BUF_SIZE=0x10000000
+CONFIG_SYS_PROMPT="TOTAL_COMPUTE# "
+# CONFIG_CMD_CONSOLE is not set
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_EDITENV is not set
+CONFIG_CMD_MEMTEST=y
+CONFIG_SYS_MEMTEST_START=0x80000000
+CONFIG_SYS_MEMTEST_END=0xff000000
+CONFIG_CMD_ARMFLASH=y
+CONFIG_CMD_GPT=y
+# CONFIG_RANDOM_UUID is not set
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+# CONFIG_CMD_ITEST is not set
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_CACHE=y
+# CONFIG_CMD_MISC is not set
+CONFIG_CMD_AVB=y
+CONFIG_CMD_UBI=y
+# CONFIG_ISO_PARTITION is not set
+CONFIG_OF_CONTROL=y
+# CONFIG_NET is not set
+CONFIG_CLK=y
+# CONFIG_MMC_WRITE is not set
+CONFIG_ARM_PL180_MMCI=y
+CONFIG_MTD=y
+CONFIG_MTD_NOR_FLASH=y
+CONFIG_FLASH_CFI_DRIVER=y
+CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
+CONFIG_SYS_FLASH_PROTECTION=y
+CONFIG_SYS_FLASH_CFI=y
+CONFIG_LIBAVB=y
+CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/xenguest_arm64_defconfig b/configs/xenguest_arm64_defconfig
index 46473c251da..042ea79729d 100644
--- a/configs/xenguest_arm64_defconfig
+++ b/configs/xenguest_arm64_defconfig
@@ -1,60 +1,39 @@
CONFIG_ARM=y
CONFIG_POSITION_INDEPENDENT=y
+CONFIG_TARGET_XENGUEST_ARM64=y
CONFIG_SYS_TEXT_BASE=0x40080000
CONFIG_SYS_MALLOC_F_LEN=0x2000
CONFIG_IDENT_STRING=" xenguest"
-CONFIG_TARGET_XENGUEST_ARM64=y
CONFIG_BOOTDELAY=10
-
CONFIG_SYS_PROMPT="xenguest# "
-
-CONFIG_CMD_NET=n
-CONFIG_CMD_BDI=n
-CONFIG_CMD_BOOTD=n
-CONFIG_CMD_BOOTEFI=n
-CONFIG_CMD_BOOTEFI_HELLO_COMPILE=n
-CONFIG_CMD_ELF=n
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_BOOTD is not set
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_GO is not set
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_EXPORTENV is not set
+# CONFIG_CMD_IMPORTENV is not set
+# CONFIG_CMD_EDITENV is not set
+# CONFIG_CMD_SAVEENV is not set
+# CONFIG_CMD_ENV_EXISTS is not set
+# CONFIG_CMD_CRC32 is not set
+# CONFIG_CMD_LZMADEC is not set
+# CONFIG_CMD_UNZIP is not set
+# CONFIG_CMD_LOADB is not set
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_PVBLOCK=y
+# CONFIG_CMD_ECHO is not set
+# CONFIG_CMD_ITEST is not set
+# CONFIG_CMD_SOURCE is not set
+# CONFIG_CMD_SETEXPR is not set
+# CONFIG_CMD_NET is not set
+# CONFIG_CMD_MISC is not set
CONFIG_CMD_EXT4=y
CONFIG_CMD_FAT=y
-CONFIG_CMD_GO=n
-CONFIG_CMD_RUN=n
-CONFIG_CMD_IMI=n
-CONFIG_CMD_IMLS=n
-CONFIG_CMD_XIMG=n
-CONFIG_CMD_EXPORTENV=n
-CONFIG_CMD_IMPORTENV=n
-CONFIG_CMD_EDITENV=n
-CONFIG_CMD_ENV_EXISTS=n
-CONFIG_CMD_MEMORY=y
-CONFIG_CMD_CRC32=n
-CONFIG_CMD_DM=n
-CONFIG_CMD_LOADB=n
-CONFIG_CMD_LOADS=n
-CONFIG_CMD_FLASH=n
-CONFIG_CMD_GPT=n
-CONFIG_CMD_FPGA=n
-CONFIG_CMD_ECHO=n
-CONFIG_CMD_ITEST=n
-CONFIG_CMD_SOURCE=n
-CONFIG_CMD_SETEXPR=n
-CONFIG_CMD_MISC=n
-CONFIG_CMD_UNZIP=n
-CONFIG_CMD_LZMADEC=n
-CONFIG_CMD_SAVEENV=n
-CONFIG_CMD_UMS=n
-
-CONFIG_CMD_PVBLOCK=y
-
-#CONFIG_USB=n
-# CONFIG_ISO_PARTITION is not set
-
-#CONFIG_EFI_PARTITION=y
-# CONFIG_EFI_LOADER is not set
-
+CONFIG_OF_BOARD=y
CONFIG_DM=y
# CONFIG_MMC is not set
-CONFIG_DM_SERIAL=y
# CONFIG_REQUIRE_SERIAL_CONSOLE is not set
-
-CONFIG_OF_BOARD=y
-CONFIG_OF_LIBFDT=y
+CONFIG_DM_SERIAL=y
+# CONFIG_EFI_LOADER is not set
diff --git a/drivers/ata/mtk_ahci.c b/drivers/ata/mtk_ahci.c
index 8e09c5f9e63..4ad260a5bb9 100644
--- a/drivers/ata/mtk_ahci.c
+++ b/drivers/ata/mtk_ahci.c
@@ -2,12 +2,10 @@
/*
* MTK SATA platform driver
*
- * (C) Copyright 2020
- * Mediatek
+ * Copyright (C) 2020 MediaTek Inc.
*
- * Author: Frank Wunderlich <frank-w@public-files.de>
- * based on https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/ata/ahci_mtk.c
* Author: Ryder Lee <ryder.lee@mediatek.com>
+ * Author: Frank Wunderlich <frank-w@public-files.de>
*/
#include <common.h>
diff --git a/drivers/clk/mediatek/clk-mt7622.c b/drivers/clk/mediatek/clk-mt7622.c
index d53ed691892..02461491078 100644
--- a/drivers/clk/mediatek/clk-mt7622.c
+++ b/drivers/clk/mediatek/clk-mt7622.c
@@ -521,6 +521,20 @@ static const struct mtk_gate_regs sgmii_cg_regs = {
.flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \
}
+static const struct mtk_gate_regs ssusb_cg_regs = {
+ .set_ofs = 0x30,
+ .clr_ofs = 0x30,
+ .sta_ofs = 0x30,
+};
+
+#define GATE_SSUSB(_id, _parent, _shift) { \
+ .id = _id, \
+ .parent = _parent, \
+ .regs = &ssusb_cg_regs, \
+ .shift = _shift, \
+ .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \
+}
+
static const struct mtk_gate sgmii_cgs[] = {
GATE_SGMII(CLK_SGMII_TX250M_EN, CLK_TOP_SSUSB_TX250M, 2),
GATE_SGMII(CLK_SGMII_RX250M_EN, CLK_TOP_SSUSB_EQ_RX250M, 3),
@@ -528,6 +542,15 @@ static const struct mtk_gate sgmii_cgs[] = {
GATE_SGMII(CLK_SGMII_CDR_FB, CLK_TOP_SSUSB_CDR_FB, 5),
};
+static const struct mtk_gate ssusb_cgs[] = {
+ GATE_SSUSB(CLK_SSUSB_U2_PHY_1P_EN, CLK_TOP_TO_U2_PHY_1P, 0),
+ GATE_SSUSB(CLK_SSUSB_U2_PHY_EN, CLK_TOP_TO_U2_PHY, 1),
+ GATE_SSUSB(CLK_SSUSB_REF_EN, CLK_TOP_TO_USB3_REF, 5),
+ GATE_SSUSB(CLK_SSUSB_SYS_EN, CLK_TOP_TO_USB3_SYS, 6),
+ GATE_SSUSB(CLK_SSUSB_MCU_EN, CLK_TOP_AXI_SEL, 7),
+ GATE_SSUSB(CLK_SSUSB_DMA_EN, CLK_TOP_HIF_SEL, 8),
+};
+
static const struct mtk_clk_tree mt7622_clk_tree = {
.xtal_rate = 25 * MHZ,
.xtal2_rate = 25 * MHZ,
@@ -599,7 +622,6 @@ static int mt7622_pciesys_bind(struct udevice *dev)
int ret = 0;
if (IS_ENABLED(CONFIG_RESET_MEDIATEK)) {
-// PCIESYS uses in linux also 0x34 = ETHSYS reset controller
ret = mediatek_reset_bind(dev, ETHSYS_HIFSYS_RST_CTRL_OFS, 1);
if (ret)
debug("Warning: failed to bind reset controller\n");
@@ -631,6 +653,11 @@ static int mt7622_sgmiisys_probe(struct udevice *dev)
return mtk_common_clk_gate_init(dev, &mt7622_clk_tree, sgmii_cgs);
}
+static int mt7622_ssusbsys_probe(struct udevice *dev)
+{
+ return mtk_common_clk_gate_init(dev, &mt7622_clk_tree, ssusb_cgs);
+}
+
static const struct udevice_id mt7622_apmixed_compat[] = {
{ .compatible = "mediatek,mt7622-apmixedsys" },
{ }
@@ -671,6 +698,11 @@ static const struct udevice_id mt7622_mcucfg_compat[] = {
{ }
};
+static const struct udevice_id mt7622_ssusbsys_compat[] = {
+ { .compatible = "mediatek,mt7622-ssusbsys" },
+ { }
+};
+
U_BOOT_DRIVER(mtk_mcucfg) = {
.name = "mt7622-mcucfg",
.id = UCLASS_SYSCON,
@@ -747,3 +779,12 @@ U_BOOT_DRIVER(mtk_clk_sgmiisys) = {
.priv_auto_alloc_size = sizeof(struct mtk_cg_priv),
.ops = &mtk_clk_gate_ops,
};
+
+U_BOOT_DRIVER(mtk_clk_ssusbsys) = {
+ .name = "mt7622-clock-ssusbsys",
+ .id = UCLASS_CLK,
+ .of_match = mt7622_ssusbsys_compat,
+ .probe = mt7622_ssusbsys_probe,
+ .priv_auto_alloc_size = sizeof(struct mtk_cg_priv),
+ .ops = &mtk_clk_gate_ops,
+};
diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index 7d2e49fd3e3..68953cc4f4e 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -19,6 +19,7 @@
#include <linux/errno.h>
#include <linux/printk.h>
#include <linux/psci.h>
+#include <asm/system.h>
#define DRIVER_NAME "psci"
@@ -73,6 +74,11 @@ static int psci_probe(struct udevice *dev)
{
const char *method;
+#if defined(CONFIG_ARM64)
+ if (current_el() == 3)
+ return -EINVAL;
+#endif
+
method = ofnode_read_string(dev_ofnode(dev), "method");
if (!method) {
pr_warn("missing \"method\" property\n");
diff --git a/drivers/phy/phy-mtk-tphy.c b/drivers/phy/phy-mtk-tphy.c
index 326227a30dd..3d7b9cd2b12 100644
--- a/drivers/phy/phy-mtk-tphy.c
+++ b/drivers/phy/phy-mtk-tphy.c
@@ -698,11 +698,10 @@ static int mtk_tphy_probe(struct udevice *dev)
tphy->dev = dev;
tphy->version = dev_get_driver_data(dev);
- /* v1 has shared banks */
+ /* v1 has shared banks for usb/pcie mode, */
+ /* but not for sata mode */
if (tphy->version == MTK_TPHY_V1) {
tphy->sif_base = dev_read_addr_ptr(dev);
- if (!tphy->sif_base)
- return -ENOENT;
}
dev_for_each_subnode(subnode, dev) {
diff --git a/drivers/virtio/virtio_blk.c b/drivers/virtio/virtio_blk.c
index 992118c6075..1799f5c5eb3 100644
--- a/drivers/virtio/virtio_blk.c
+++ b/drivers/virtio/virtio_blk.c
@@ -115,6 +115,7 @@ static int virtio_blk_probe(struct udevice *dev)
return ret;
desc->blksz = 512;
+ desc->log2blksz = 9;
virtio_cread(dev, struct virtio_blk_config, capacity, &cap);
desc->lba = cap;
diff --git a/drivers/xen/gnttab.c b/drivers/xen/gnttab.c
index becf7a79fbf..9bf1091ab32 100644
--- a/drivers/xen/gnttab.c
+++ b/drivers/xen/gnttab.c
@@ -100,7 +100,8 @@ int gnttab_end_access(grant_ref_t ref)
nflags = gnttab_table[ref].flags;
do {
- if ((flags = nflags) & (GTF_reading | GTF_writing)) {
+ flags = nflags;
+ if ((flags) & (GTF_reading | GTF_writing)) {
printf("WARNING: g.e. still in use! (%x)\n", flags);
return 0;
}
diff --git a/drivers/xen/pvblock.c b/drivers/xen/pvblock.c
index 76e82fbf41d..1b3325bbe2a 100644
--- a/drivers/xen/pvblock.c
+++ b/drivers/xen/pvblock.c
@@ -294,8 +294,8 @@ static void shutdown_blkfront(struct blkfront_dev *dev)
snprintf(path, sizeof(path), "%s/state", dev->backend);
snprintf(nodename, sizeof(nodename), "%s/state", dev->nodename);
- if ((err = xenbus_switch_state(XBT_NIL, nodename,
- XenbusStateClosing)) != NULL) {
+ err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosing);
+ if (err) {
printf("%s: error changing state to %d: %s\n", __func__,
XenbusStateClosing, err);
goto close;
@@ -306,8 +306,8 @@ static void shutdown_blkfront(struct blkfront_dev *dev)
err = xenbus_wait_for_state_change(path, &state);
free(err);
- if ((err = xenbus_switch_state(XBT_NIL, nodename,
- XenbusStateClosed)) != NULL) {
+ err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed);
+ if (err) {
printf("%s: error changing state to %d: %s\n", __func__,
XenbusStateClosed, err);
goto close;
@@ -319,8 +319,8 @@ static void shutdown_blkfront(struct blkfront_dev *dev)
free(err);
}
- if ((err = xenbus_switch_state(XBT_NIL, nodename,
- XenbusStateInitialising)) != NULL) {
+ err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateInitialising);
+ if (err) {
printf("%s: error changing state to %d: %s\n", __func__,
XenbusStateInitialising, err);
goto close;
diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
index 340e5ebdb9d..f67f7c4a40a 100644
--- a/fs/squashfs/sqfs.c
+++ b/fs/squashfs/sqfs.c
@@ -23,12 +23,6 @@
#include "sqfs_filesystem.h"
#include "sqfs_utils.h"
-struct squashfs_ctxt {
- struct disk_partition cur_part_info;
- struct blk_desc *cur_dev;
- struct squashfs_super_block *sblk;
-};
-
static struct squashfs_ctxt ctxt;
static int sqfs_disk_read(__u32 block, __u32 nr_blocks, void *buf)
@@ -110,9 +104,7 @@ static int sqfs_frag_lookup(u32 inode_fragment_index,
struct squashfs_super_block *sblk = ctxt.sblk;
unsigned long dest_len;
int block, offset, ret;
- u16 header, comp_type;
-
- comp_type = get_unaligned_le16(&sblk->compression);
+ u16 header;
if (inode_fragment_index >= get_unaligned_le32(&sblk->fragments))
return -EINVAL;
@@ -162,6 +154,11 @@ static int sqfs_frag_lookup(u32 inode_fragment_index,
header = get_unaligned_le16(metadata_buffer + table_offset);
metadata = metadata_buffer + table_offset + SQFS_HEADER_SIZE;
+ if (!metadata) {
+ ret = -ENOMEM;
+ goto free_buffer;
+ }
+
entries = malloc(SQFS_METADATA_BLOCK_SIZE);
if (!entries) {
ret = -ENOMEM;
@@ -171,7 +168,7 @@ static int sqfs_frag_lookup(u32 inode_fragment_index,
if (SQFS_COMPRESSED_METADATA(header)) {
src_len = SQFS_METADATA_SIZE(header);
dest_len = SQFS_METADATA_BLOCK_SIZE;
- ret = sqfs_decompress(comp_type, entries, &dest_len, metadata,
+ ret = sqfs_decompress(&ctxt, entries, &dest_len, metadata,
src_len);
if (ret) {
ret = -EINVAL;
@@ -280,8 +277,8 @@ static int sqfs_join(char **strings, char *dest, int start, int end,
*/
static int sqfs_tokenize(char **tokens, int count, const char *str)
{
+ int i, j, ret = 0;
char *aux, *strc;
- int i, j;
strc = strdup(str);
if (!strc)
@@ -290,8 +287,8 @@ static int sqfs_tokenize(char **tokens, int count, const char *str)
if (!strcmp(strc, "/")) {
tokens[0] = strdup(strc);
if (!tokens[0]) {
- free(strc);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto free_strc;
}
} else {
for (j = 0; j < count; j++) {
@@ -300,15 +297,16 @@ static int sqfs_tokenize(char **tokens, int count, const char *str)
if (!tokens[j]) {
for (i = 0; i < j; i++)
free(tokens[i]);
- free(strc);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto free_strc;
}
}
}
+free_strc:
free(strc);
- return 0;
+ return ret;
}
/*
@@ -436,9 +434,9 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
{
struct squashfs_super_block *sblk = ctxt.sblk;
char *path, *target, **sym_tokens, *res, *rem;
+ struct squashfs_ldir_inode *ldir = NULL;
int j, ret, new_inode_number, offset;
struct squashfs_symlink_inode *sym;
- struct squashfs_ldir_inode *ldir;
struct squashfs_dir_inode *dir;
struct fs_dir_stream *dirsp;
struct fs_dirent *dent;
@@ -635,13 +633,12 @@ static int sqfs_read_inode_table(unsigned char **inode_table)
{
struct squashfs_super_block *sblk = ctxt.sblk;
u64 start, n_blks, table_offset, table_size;
- int j, ret = 0, metablks_count, comp_type;
+ int j, ret = 0, metablks_count;
unsigned char *src_table, *itb;
u32 src_len, dest_offset = 0;
- unsigned long dest_len;
+ unsigned long dest_len = 0;
bool compressed;
- comp_type = get_unaligned_le16(&sblk->compression);
table_size = get_unaligned_le64(&sblk->directory_table_start) -
get_unaligned_le64(&sblk->inode_table_start);
start = get_unaligned_le64(&sblk->inode_table_start) /
@@ -686,7 +683,7 @@ static int sqfs_read_inode_table(unsigned char **inode_table)
sqfs_read_metablock(itb, table_offset, &compressed, &src_len);
if (compressed) {
dest_len = SQFS_METADATA_BLOCK_SIZE;
- ret = sqfs_decompress(comp_type, *inode_table +
+ ret = sqfs_decompress(&ctxt, *inode_table +
dest_offset, &dest_len,
src_table, src_len);
if (ret) {
@@ -694,6 +691,7 @@ static int sqfs_read_inode_table(unsigned char **inode_table)
goto free_itb;
}
+ dest_offset += dest_len;
} else {
memcpy(*inode_table + (j * SQFS_METADATA_BLOCK_SIZE),
src_table, src_len);
@@ -703,7 +701,7 @@ static int sqfs_read_inode_table(unsigned char **inode_table)
* Offsets to the decompression destination, to the metadata
* buffer 'itb' and to the decompression source, respectively.
*/
- dest_offset += dest_len;
+
table_offset += src_len + SQFS_HEADER_SIZE;
src_table += src_len + SQFS_HEADER_SIZE;
}
@@ -717,15 +715,13 @@ free_itb:
static int sqfs_read_directory_table(unsigned char **dir_table, u32 **pos_list)
{
u64 start, n_blks, table_offset, table_size;
- int j, ret = 0, metablks_count = -1, comp_type;
struct squashfs_super_block *sblk = ctxt.sblk;
+ int j, ret = 0, metablks_count = -1;
unsigned char *src_table, *dtb;
u32 src_len, dest_offset = 0;
- unsigned long dest_len;
+ unsigned long dest_len = 0;
bool compressed;
- comp_type = get_unaligned_le16(&sblk->compression);
-
/* DIRECTORY TABLE */
table_size = get_unaligned_le64(&sblk->fragment_table_start) -
get_unaligned_le64(&sblk->directory_table_start);
@@ -779,7 +775,7 @@ static int sqfs_read_directory_table(unsigned char **dir_table, u32 **pos_list)
sqfs_read_metablock(dtb, table_offset, &compressed, &src_len);
if (compressed) {
dest_len = SQFS_METADATA_BLOCK_SIZE;
- ret = sqfs_decompress(comp_type, *dir_table +
+ ret = sqfs_decompress(&ctxt, *dir_table +
(j * SQFS_METADATA_BLOCK_SIZE),
&dest_len, src_table, src_len);
if (ret) {
@@ -792,6 +788,8 @@ static int sqfs_read_directory_table(unsigned char **dir_table, u32 **pos_list)
dest_offset += dest_len;
break;
}
+
+ dest_offset += dest_len;
} else {
memcpy(*dir_table + (j * SQFS_METADATA_BLOCK_SIZE),
src_table, src_len);
@@ -801,7 +799,6 @@ static int sqfs_read_directory_table(unsigned char **dir_table, u32 **pos_list)
* Offsets to the decompression destination, to the metadata
* buffer 'dtb' and to the decompression source, respectively.
*/
- dest_offset += dest_len;
table_offset += src_len + SQFS_HEADER_SIZE;
src_table += src_len + SQFS_HEADER_SIZE;
}
@@ -1023,6 +1020,14 @@ int sqfs_probe(struct blk_desc *fs_dev_desc, struct disk_partition *fs_partition
ctxt.sblk = sblk;
+ ret = sqfs_decompressor_init(&ctxt);
+
+ if (ret) {
+ ctxt.cur_dev = NULL;
+ free(ctxt.sblk);
+ return -EINVAL;
+ }
+
return 0;
}
@@ -1141,6 +1146,9 @@ static int sqfs_get_regfile_info(struct squashfs_reg_inode *reg,
finfo->start = get_unaligned_le32(&reg->start_block);
finfo->frag = SQFS_IS_FRAGMENTED(get_unaligned_le32(&reg->fragment));
+ if (finfo->size < 1 || finfo->offset < 0 || finfo->start < 0)
+ return -EINVAL;
+
if (finfo->frag) {
datablk_count = finfo->size / le32_to_cpu(blksz);
ret = sqfs_frag_lookup(get_unaligned_le32(&reg->fragment),
@@ -1148,6 +1156,8 @@ static int sqfs_get_regfile_info(struct squashfs_reg_inode *reg,
if (ret < 0)
return -EINVAL;
finfo->comp = true;
+ if (fentry->size < 1 || fentry->start < 0)
+ return -EINVAL;
} else {
datablk_count = DIV_ROUND_UP(finfo->size, le32_to_cpu(blksz));
}
@@ -1171,6 +1181,9 @@ static int sqfs_get_lregfile_info(struct squashfs_lreg_inode *lreg,
finfo->start = get_unaligned_le64(&lreg->start_block);
finfo->frag = SQFS_IS_FRAGMENTED(get_unaligned_le32(&lreg->fragment));
+ if (finfo->size < 1 || finfo->offset < 0 || finfo->start < 0)
+ return -EINVAL;
+
if (finfo->frag) {
datablk_count = finfo->size / le32_to_cpu(blksz);
ret = sqfs_frag_lookup(get_unaligned_le32(&lreg->fragment),
@@ -1178,6 +1191,8 @@ static int sqfs_get_lregfile_info(struct squashfs_lreg_inode *lreg,
if (ret < 0)
return -EINVAL;
finfo->comp = true;
+ if (fentry->size < 1 || fentry->start < 0)
+ return -EINVAL;
} else {
datablk_count = DIV_ROUND_UP(finfo->size, le32_to_cpu(blksz));
}
@@ -1195,7 +1210,7 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
char *dir, *fragment_block, *datablock = NULL, *data_buffer = NULL;
char *fragment, *file, *resolved, *data;
u64 start, n_blks, table_size, data_offset, table_offset;
- int ret, j, i_number, comp_type, datablk_count = 0;
+ int ret, j, i_number, datablk_count = 0;
struct squashfs_super_block *sblk = ctxt.sblk;
struct squashfs_fragment_block_entry frag_entry;
struct squashfs_file_info finfo = {0};
@@ -1211,8 +1226,6 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
*actread = 0;
- comp_type = get_unaligned_le16(&sblk->compression);
-
/*
* sqfs_opendir will uncompress inode and directory tables, and will
* return a pointer to the directory that contains the requested file.
@@ -1344,7 +1357,7 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
/* Load the data */
if (SQFS_COMPRESSED_BLOCK(finfo.blk_sizes[j])) {
dest_len = get_unaligned_le32(&sblk->block_size);
- ret = sqfs_decompress(comp_type, datablock, &dest_len,
+ ret = sqfs_decompress(&ctxt, datablock, &dest_len,
data, table_size);
if (ret)
goto free_buffer;
@@ -1394,7 +1407,7 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
goto free_fragment;
}
- ret = sqfs_decompress(comp_type, fragment_block, &dest_len,
+ ret = sqfs_decompress(&ctxt, fragment_block, &dest_len,
(void *)fragment + table_offset,
frag_entry.size);
if (ret) {
@@ -1525,6 +1538,7 @@ void sqfs_close(void)
{
free(ctxt.sblk);
ctxt.cur_dev = NULL;
+ sqfs_decompressor_cleanup(&ctxt);
}
void sqfs_closedir(struct fs_dir_stream *dirs)
diff --git a/fs/squashfs/sqfs_decompressor.c b/fs/squashfs/sqfs_decompressor.c
index 09ca6cf6d0c..d69ddb24a41 100644
--- a/fs/squashfs/sqfs_decompressor.c
+++ b/fs/squashfs/sqfs_decompressor.c
@@ -9,14 +9,71 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+
+#if IS_ENABLED(CONFIG_LZO)
+#include <linux/lzo.h>
+#endif
+
#if IS_ENABLED(CONFIG_ZLIB)
#include <u-boot/zlib.h>
#endif
+#if IS_ENABLED(CONFIG_ZSTD)
+#include <linux/zstd.h>
+#endif
+
#include "sqfs_decompressor.h"
-#include "sqfs_filesystem.h"
#include "sqfs_utils.h"
+int sqfs_decompressor_init(struct squashfs_ctxt *ctxt)
+{
+ u16 comp_type = get_unaligned_le16(&ctxt->sblk->compression);
+
+ switch (comp_type) {
+#if IS_ENABLED(CONFIG_LZO)
+ case SQFS_COMP_LZO:
+ break;
+#endif
+#if IS_ENABLED(CONFIG_ZLIB)
+ case SQFS_COMP_ZLIB:
+ break;
+#endif
+#if IS_ENABLED(CONFIG_ZSTD)
+ case SQFS_COMP_ZSTD:
+ ctxt->zstd_workspace = malloc(ZSTD_DCtxWorkspaceBound());
+ if (!ctxt->zstd_workspace)
+ return -ENOMEM;
+ break;
+#endif
+ default:
+ printf("Error: unknown compression type.\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+void sqfs_decompressor_cleanup(struct squashfs_ctxt *ctxt)
+{
+ u16 comp_type = get_unaligned_le16(&ctxt->sblk->compression);
+
+ switch (comp_type) {
+#if IS_ENABLED(CONFIG_LZO)
+ case SQFS_COMP_LZO:
+ break;
+#endif
+#if IS_ENABLED(CONFIG_ZLIB)
+ case SQFS_COMP_ZLIB:
+ break;
+#endif
+#if IS_ENABLED(CONFIG_ZSTD)
+ case SQFS_COMP_ZSTD:
+ free(ctxt->zstd_workspace);
+ break;
+#endif
+ }
+}
+
#if IS_ENABLED(CONFIG_ZLIB)
static void zlib_decompression_status(int ret)
{
@@ -34,15 +91,44 @@ static void zlib_decompression_status(int ret)
}
#endif
-int sqfs_decompress(u16 comp_type, void *dest, unsigned long *dest_len,
- void *source, u32 lenp)
+#if IS_ENABLED(CONFIG_ZSTD)
+static int sqfs_zstd_decompress(struct squashfs_ctxt *ctxt, void *dest,
+ unsigned long dest_len, void *source, u32 src_len)
+{
+ ZSTD_DCtx *ctx;
+ size_t wsize;
+ int ret;
+
+ wsize = ZSTD_DCtxWorkspaceBound();
+ ctx = ZSTD_initDCtx(ctxt->zstd_workspace, wsize);
+ ret = ZSTD_decompressDCtx(ctx, dest, dest_len, source, src_len);
+
+ return ZSTD_isError(ret);
+}
+#endif /* CONFIG_ZSTD */
+
+int sqfs_decompress(struct squashfs_ctxt *ctxt, void *dest,
+ unsigned long *dest_len, void *source, u32 src_len)
{
+ u16 comp_type = get_unaligned_le16(&ctxt->sblk->compression);
int ret = 0;
switch (comp_type) {
+#if IS_ENABLED(CONFIG_LZO)
+ case SQFS_COMP_LZO: {
+ size_t lzo_dest_len = *dest_len;
+ ret = lzo1x_decompress_safe(source, src_len, dest, &lzo_dest_len);
+ if (ret) {
+ printf("LZO decompression failed. Error code: %d\n", ret);
+ return -EINVAL;
+ }
+
+ break;
+ }
+#endif
#if IS_ENABLED(CONFIG_ZLIB)
case SQFS_COMP_ZLIB:
- ret = uncompress(dest, dest_len, source, lenp);
+ ret = uncompress(dest, dest_len, source, src_len);
if (ret) {
zlib_decompression_status(ret);
return -EINVAL;
@@ -50,6 +136,16 @@ int sqfs_decompress(u16 comp_type, void *dest, unsigned long *dest_len,
break;
#endif
+#if IS_ENABLED(CONFIG_ZSTD)
+ case SQFS_COMP_ZSTD:
+ ret = sqfs_zstd_decompress(ctxt, dest, *dest_len, source, src_len);
+ if (ret) {
+ printf("ZSTD Error code: %d\n", ZSTD_getErrorCode(ret));
+ return -EINVAL;
+ }
+
+ break;
+#endif
default:
printf("Error: unknown compression type.\n");
return -EINVAL;
diff --git a/fs/squashfs/sqfs_decompressor.h b/fs/squashfs/sqfs_decompressor.h
index 378965dda8e..892cfb69744 100644
--- a/fs/squashfs/sqfs_decompressor.h
+++ b/fs/squashfs/sqfs_decompressor.h
@@ -9,6 +9,7 @@
#define SQFS_DECOMPRESSOR_H
#include <stdint.h>
+#include "sqfs_filesystem.h"
#define SQFS_COMP_ZLIB 1
#define SQFS_COMP_LZMA 2
@@ -52,7 +53,9 @@ union squashfs_compression_opts {
struct squashfs_lzo_opts *lzo;
};
-int sqfs_decompress(u16 comp_type, void *dest, unsigned long *dest_len,
- void *source, u32 lenp);
+int sqfs_decompress(struct squashfs_ctxt *ctxt, void *dest,
+ unsigned long *dest_len, void *source, u32 src_len);
+int sqfs_decompressor_init(struct squashfs_ctxt *ctxt);
+void sqfs_decompressor_cleanup(struct squashfs_ctxt *ctxt);
#endif /* SQFS_DECOMPRESSOR_H */
diff --git a/fs/squashfs/sqfs_dir.c b/fs/squashfs/sqfs_dir.c
index 5f7660aeae8..00d2891e7da 100644
--- a/fs/squashfs/sqfs_dir.c
+++ b/fs/squashfs/sqfs_dir.c
@@ -53,6 +53,9 @@ int sqfs_dir_offset(void *dir_i, u32 *m_list, int m_count)
return -EINVAL;
}
+ if (offset < 0)
+ return -EINVAL;
+
for (j = 0; j < m_count; j++) {
if (m_list[j] == start_block)
return (++j * SQFS_METADATA_BLOCK_SIZE) + offset;
diff --git a/fs/squashfs/sqfs_filesystem.h b/fs/squashfs/sqfs_filesystem.h
index d63e3a41adf..856cd15e349 100644
--- a/fs/squashfs/sqfs_filesystem.h
+++ b/fs/squashfs/sqfs_filesystem.h
@@ -9,8 +9,9 @@
#define SQFS_FILESYSTEM_H
#include <asm/unaligned.h>
-#include <stdint.h>
#include <fs.h>
+#include <part.h>
+#include <stdint.h>
#define SQFS_UNCOMPRESSED_DATA 0x0002
#define SQFS_MAGIC_NUMBER 0x73717368
@@ -72,6 +73,15 @@ struct squashfs_super_block {
__le64 export_table_start;
};
+struct squashfs_ctxt {
+ struct disk_partition cur_part_info;
+ struct blk_desc *cur_dev;
+ struct squashfs_super_block *sblk;
+#if IS_ENABLED(CONFIG_ZSTD)
+ void *zstd_workspace;
+#endif
+};
+
struct squashfs_directory_index {
u32 index;
u32 start;
diff --git a/fs/squashfs/sqfs_inode.c b/fs/squashfs/sqfs_inode.c
index b037a9b2ac2..1387779a85f 100644
--- a/fs/squashfs/sqfs_inode.c
+++ b/fs/squashfs/sqfs_inode.c
@@ -138,11 +138,14 @@ void *sqfs_find_inode(void *inode_table, int inode_number, __le32 inode_count,
int sqfs_read_metablock(unsigned char *file_mapping, int offset,
bool *compressed, u32 *data_size)
{
- unsigned char *data;
+ const unsigned char *data;
u16 header;
data = file_mapping + offset;
header = get_unaligned((u16 *)data);
+ if (!header || !data)
+ return -EINVAL;
+
*compressed = SQFS_COMPRESSED_METADATA(header);
*data_size = SQFS_METADATA_SIZE(header);
diff --git a/include/avb_verify.h b/include/avb_verify.h
index a8d7090f794..1e787ba6668 100644
--- a/include/avb_verify.h
+++ b/include/avb_verify.h
@@ -72,12 +72,12 @@ static inline uint64_t calc_offset(struct mmc_part *part, int64_t offset)
static inline size_t get_sector_buf_size(void)
{
- return (size_t)CONFIG_FASTBOOT_BUF_SIZE;
+ return (size_t)CONFIG_AVB_BUF_SIZE;
}
static inline void *get_sector_buf(void)
{
- return map_sysmem(CONFIG_FASTBOOT_BUF_ADDR, CONFIG_FASTBOOT_BUF_SIZE);
+ return map_sysmem(CONFIG_AVB_BUF_ADDR, CONFIG_AVB_BUF_SIZE);
}
static inline bool is_buf_unaligned(void *buffer)
diff --git a/include/configs/total_compute.h b/include/configs/total_compute.h
new file mode 100644
index 00000000000..cc93f1930a1
--- /dev/null
+++ b/include/configs/total_compute.h
@@ -0,0 +1,89 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Configuration for Total Compute platform. Parts were derived from other ARM
+ * configurations.
+ * (C) Copyright 2020 Arm Limited
+ * Usama Arif <usama.arif@arm.com>
+ */
+
+#ifndef __TOTAL_COMPUTE_H
+#define __TOTAL_COMPUTE_H
+
+#define CONFIG_REMAKE_ELF
+
+/* Link Definitions */
+#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x7fff0)
+
+#define CONFIG_SYS_BOOTM_LEN (64 << 20)
+
+#define UART0_BASE 0x7ff80000
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (8 << 20))
+
+/* PL011 Serial Configuration */
+#define CONFIG_PL011_CLOCK 7372800
+
+/* Miscellaneous configurable options */
+#define CONFIG_SYS_LOAD_ADDR 0x90000000
+
+/* Physical Memory Map */
+#define PHYS_SDRAM_1 0x80000000
+/* Top 48MB reserved for secure world use */
+#define DRAM_SEC_SIZE 0x03000000
+#define PHYS_SDRAM_1_SIZE 0x80000000 - DRAM_SEC_SIZE
+#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1
+
+#define CONFIG_ARM_PL180_MMCI_BASE 0x001c050000
+#define CONFIG_SYS_MMC_MAX_BLK_COUNT 127
+#define CONFIG_ARM_PL180_MMCI_CLOCK_FREQ 12000000
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ "bootm_size=0x20000000\0" \
+ "load_addr=0xa0000000\0" \
+ "kernel_addr_r=0x80080000\0" \
+ "initrd_addr_r=0x88000000\0" \
+ "fdt_addr_r=0x83000000\0"
+/*
+ * If vbmeta partition is present, boot Android with verification using AVB.
+ * Else if system partition is present (no vbmeta partition), boot Android
+ * without verification (for development purposes).
+ * Else boot FIT image.
+ */
+#define CONFIG_BOOTCOMMAND \
+ "if part number mmc 0 vbmeta is_avb; then" \
+ " echo MMC with vbmeta partition detected.;" \
+ " echo starting Android Verified boot.;" \
+ " avb init 0; " \
+ " if avb verify; then " \
+ " set bootargs $bootargs $avb_bootargs; " \
+ " part start mmc 0 boot boot_start; " \
+ " part size mmc 0 boot boot_size; " \
+ " mmc read ${load_addr} ${boot_start} ${boot_size}; " \
+ " bootm ${load_addr} ${load_addr} ${fdt_addr_r}; " \
+ " else; " \
+ " echo AVB verification failed.; " \
+ " exit; " \
+ " fi; " \
+ "elif part number mmc 0 system is_non_avb_android; then " \
+ " booti ${kernel_addr_r} ${initrd_addr_r} ${fdt_addr_r};" \
+ "else;" \
+ " echo Booting FIT image.;" \
+ " bootm ${load_addr} ${load_addr} ${fdt_addr_r}; " \
+ "fi;"
+
+/* Monitor Command Prompt */
+#define CONFIG_SYS_CBSIZE 512 /* Console I/O Buffer Size */
+#define CONFIG_SYS_MAXARGS 64 /* max command args */
+
+#define CONFIG_SYS_FLASH_BASE 0x0C000000
+/* 256 x 256KiB sectors */
+#define CONFIG_SYS_MAX_FLASH_SECT 256
+
+#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_32BIT
+#define CONFIG_SYS_MAX_FLASH_BANKS 1
+
+#define CONFIG_SYS_FLASH_EMPTY_INFO /* flinfo indicates empty blocks */
+#define FLASH_MAX_SECTOR_SIZE 0x00040000
+
+#endif /* __TOTAL_COMPUTE_H */
diff --git a/include/configs/xenguest_arm64.h b/include/configs/xenguest_arm64.h
index db3059a82c6..c44381e966c 100644
--- a/include/configs/xenguest_arm64.h
+++ b/include/configs/xenguest_arm64.h
@@ -9,8 +9,6 @@
#include <linux/types.h>
#endif
-#define CONFIG_BOARD_EARLY_INIT_F
-
#define CONFIG_EXTRA_ENV_SETTINGS
#undef CONFIG_NR_DRAM_BANKS
@@ -38,11 +36,6 @@
#define CONFIG_OF_SYSTEM_SETUP
-#define CONFIG_CMDLINE_TAG 1
-#define CONFIG_INITRD_TAG 1
-
-#define CONFIG_CMD_RUN
-
#undef CONFIG_EXTRA_ENV_SETTINGS
#define CONFIG_EXTRA_ENV_SETTINGS \
"loadimage=ext4load pvblock 0 0x90000000 /boot/Image;\0" \
diff --git a/include/xen/gnttab.h b/include/xen/gnttab.h
index db1d5361fed..db615004aa5 100644
--- a/include/xen/gnttab.h
+++ b/include/xen/gnttab.h
@@ -1,5 +1,4 @@
-/*
- * SPDX-License-Identifier: GPL-2.0
+/* SPDX-License-Identifier: GPL-2.0
*
* (C) 2006, Steven Smith <sos22@cam.ac.uk>
* (C) 2006, Grzegorz Milos <gm281@cam.ac.uk>
diff --git a/lib/sscanf.c b/lib/sscanf.c
index d1e2dc272cc..4c35c035fe1 100644
--- a/lib/sscanf.c
+++ b/lib/sscanf.c
@@ -555,7 +555,8 @@ literal:
if (flags & SUPPRESS) {
size_t sum = 0;
- if ((n = inr) < width) {
+ n = inr;
+ if (n < width) {
sum += n;
width -= n;
inp += n;
diff --git a/test/py/tests/test_fs/test_squashfs/sqfs_common.py b/test/py/tests/test_fs/test_squashfs/sqfs_common.py
index 2dc344d1b24..c96f92c1d8f 100644
--- a/test/py/tests/test_fs/test_squashfs/sqfs_common.py
+++ b/test/py/tests/test_fs/test_squashfs/sqfs_common.py
@@ -5,6 +5,7 @@
import os
import random
import string
+import subprocess
def sqfs_get_random_letters(size):
letters = []
@@ -19,24 +20,57 @@ def sqfs_generate_file(path, size):
file.write(content)
file.close()
-# generate image with three files and a symbolic link
-def sqfs_generate_image(cons):
- src = os.path.join(cons.config.build_dir, "sqfs_src/")
- dest = os.path.join(cons.config.build_dir, "sqfs")
- os.mkdir(src)
- sqfs_generate_file(src + "frag_only", 100)
- sqfs_generate_file(src + "blks_frag", 5100)
- sqfs_generate_file(src + "blks_only", 4096)
- os.symlink("frag_only", src + "sym")
- os.system("mksquashfs " + src + " " + dest + " -b 4096 -always-use-fragments")
-
-# removes all files created by sqfs_generate_image()
-def sqfs_clean(cons):
- src = os.path.join(cons.config.build_dir, "sqfs_src/")
- dest = os.path.join(cons.config.build_dir, "sqfs")
- os.remove(src + "frag_only")
- os.remove(src + "blks_frag")
- os.remove(src + "blks_only")
- os.remove(src + "sym")
- os.rmdir(src)
- os.remove(dest)
+class Compression:
+ def __init__(self, name, files, sizes, block_size = 4096):
+ self.name = name
+ self.files = files
+ self.sizes = sizes
+ self.mksquashfs_opts = " -b " + str(block_size) + " -comp " + self.name
+
+ def add_opt(self, opt):
+ self.mksquashfs_opts += " " + opt
+
+ def gen_image(self, build_dir):
+ src = os.path.join(build_dir, "sqfs_src/")
+ os.mkdir(src)
+ for (f, s) in zip(self.files, self.sizes):
+ sqfs_generate_file(src + f, s)
+
+ # the symbolic link always targets the first file
+ os.symlink(self.files[0], src + "sym")
+
+ sqfs_img = os.path.join(build_dir, "sqfs-" + self.name)
+ i_o = src + " " + sqfs_img
+ opts = self.mksquashfs_opts
+ try:
+ subprocess.run(["mksquashfs " + i_o + opts], shell = True, check = True)
+ except:
+ print("mksquashfs error. Compression type: " + self.name)
+ raise RuntimeError
+
+ def clean_source(self, build_dir):
+ src = os.path.join(build_dir, "sqfs_src/")
+ for f in self.files:
+ os.remove(src + f)
+ os.remove(src + "sym")
+ os.rmdir(src)
+
+ def cleanup(self, build_dir):
+ self.clean_source(build_dir)
+ sqfs_img = os.path.join(build_dir, "sqfs-" + self.name)
+ os.remove(sqfs_img)
+
+files = ["blks_only", "blks_frag", "frag_only"]
+sizes = [4096, 5100, 100]
+gzip = Compression("gzip", files, sizes)
+zstd = Compression("zstd", files, sizes)
+lzo = Compression("lzo", files, sizes)
+
+# use fragment blocks for files larger than block_size
+gzip.add_opt("-always-use-fragments")
+zstd.add_opt("-always-use-fragments")
+
+# avoid fragments if lzo is used
+lzo.add_opt("-no-fragments")
+
+comp_opts = [gzip, zstd, lzo]
diff --git a/test/py/tests/test_fs/test_squashfs/test_sqfs_load.py b/test/py/tests/test_fs/test_squashfs/test_sqfs_load.py
index eb1baae5c52..9e900623846 100644
--- a/test/py/tests/test_fs/test_squashfs/test_sqfs_load.py
+++ b/test/py/tests/test_fs/test_squashfs/test_sqfs_load.py
@@ -12,23 +12,35 @@ from sqfs_common import *
@pytest.mark.buildconfigspec('fs_squashfs')
@pytest.mark.requiredtool('mksquashfs')
def test_sqfs_load(u_boot_console):
- cons = u_boot_console
- sqfs_generate_image(cons)
+ build_dir = u_boot_console.config.build_dir
command = "sqfsload host 0 $kernel_addr_r "
- path = os.path.join(cons.config.build_dir, "sqfs")
- try:
+ for opt in comp_opts:
+ # generate and load the squashfs image
+ try:
+ opt.gen_image(build_dir)
+ except RuntimeError:
+ opt.clean_source(build_dir)
+ # skip unsupported compression types
+ continue
+
+ path = os.path.join(build_dir, "sqfs-" + opt.name)
output = u_boot_console.run_command("host bind 0 " + path)
+
output = u_boot_console.run_command(command + "xxx")
assert "File not found." in output
- output = u_boot_console.run_command(command + "frag_only")
- assert "100 bytes read in" in output
- output = u_boot_console.run_command(command + "blks_frag")
- assert "5100 bytes read in" in output
- output = u_boot_console.run_command(command + "blks_only")
- assert "4096 bytes read in" in output
+
+ for (f, s) in zip(opt.files, opt.sizes):
+ try:
+ output = u_boot_console.run_command(command + f)
+ assert str(s) in output
+ except:
+ assert False
+ opt.cleanup(build_dir)
+
+ # test symbolic link
output = u_boot_console.run_command(command + "sym")
- assert "100 bytes read in" in output
- except:
- sqfs_clean(cons)
- sqfs_clean(cons)
+ assert str(opt.sizes[0]) in output
+
+ # remove generated files
+ opt.cleanup(build_dir)
diff --git a/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py b/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py
index 3a7b75c778f..a0dca2e2fc8 100644
--- a/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py
+++ b/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py
@@ -12,16 +12,25 @@ from sqfs_common import *
@pytest.mark.buildconfigspec('fs_squashfs')
@pytest.mark.requiredtool('mksquashfs')
def test_sqfs_ls(u_boot_console):
- cons = u_boot_console
- sqfs_generate_image(cons)
- path = os.path.join(cons.config.build_dir, "sqfs")
- try:
+ build_dir = u_boot_console.config.build_dir
+ for opt in comp_opts:
+ try:
+ opt.gen_image(build_dir)
+ except RuntimeError:
+ opt.clean_source(build_dir)
+ # skip unsupported compression types
+ continue
+ path = os.path.join(build_dir, "sqfs-" + opt.name)
output = u_boot_console.run_command("host bind 0 " + path)
- output = u_boot_console.run_command("sqfsls host 0")
- assert "4 file(s), 0 dir(s)" in output
- assert "<SYM> sym" in output
- output = u_boot_console.run_command("sqfsls host 0 xxx")
- assert "** Cannot find directory. **" in output
- except:
- sqfs_clean(cons)
- sqfs_clean(cons)
+
+ try:
+ # list files in root directory
+ output = u_boot_console.run_command("sqfsls host 0")
+ assert str(len(opt.files) + 1) + " file(s), 0 dir(s)" in output
+ assert "<SYM> sym" in output
+ output = u_boot_console.run_command("sqfsls host 0 xxx")
+ assert "** Cannot find directory. **" in output
+ except:
+ opt.cleanup(build_dir)
+ assert False
+ opt.cleanup(build_dir)