Merge branch '2020-04-10-gitlab-travis-gcc9' into next

- Switch over to using GCC-9.2.0 in our Azure, GitLab and Travis-CI
  instances
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 192c7ef..65e07bf 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -1,7 +1,7 @@
 variables:
   windows_vm: vs2017-win2016
   ubuntu_vm: ubuntu-18.04
-  ci_runner_image: trini/u-boot-gitlab-ci-runner:bionic-20200112-21Feb2020
+  ci_runner_image: trini/u-boot-gitlab-ci-runner:bionic-20200311-10Apr2020
   # Add '-u 0' options for Azure pipelines, otherwise we get "permission
   # denied" error when it tries to "useradd -m -u 1001 vsts_azpcontainer",
   # since our $(ci_runner_image) user is not root.
@@ -216,10 +216,22 @@
           TEST_PY_BD: "qemu-ppce500"
           TEST_PY_TEST_SPEC: "not sleep"
           BUILDMAN: "^qemu-ppce500$"
+        qemu_riscv32:
+          TEST_PY_BD: "qemu-riscv32"
+          TEST_PY_TEST_SPEC: "not sleep"
+          BUILDMAN: "^qemu-riscv32$"
         qemu_riscv64:
           TEST_PY_BD: "qemu-riscv64"
           TEST_PY_TEST_SPEC: "not sleep"
           BUILDMAN: "^qemu-riscv64$"
+        qemu_riscv32_spl:
+          TEST_PY_BD: "qemu-riscv32_spl"
+          TEST_PY_TEST_SPEC: "not sleep"
+          BUILDMAN: "^qemu-riscv32_spl$"
+        qemu_riscv64_spl:
+          TEST_PY_BD: "qemu-riscv64_spl"
+          TEST_PY_TEST_SPEC: "not sleep"
+          BUILDMAN: "^qemu-riscv64_spl$"
         qemu_x86:
           TEST_PY_BD: "qemu-x86"
           TEST_PY_TEST_SPEC: "not sleep"
@@ -264,8 +276,17 @@
           grub-mkimage --prefix=\"\" -o ~/grub_x86.efi -O i386-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
           grub-mkimage --prefix=\"\" -o ~/grub_x64.efi -O x86_64-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
           cp /opt/grub/grubriscv64.efi ~/grub_riscv64.efi
+          cp /opt/grub/grubriscv32.efi ~/grub_riscv32.efi
           cp /opt/grub/grubaa64.efi ~/grub_arm64.efi
           cp /opt/grub/grubarm.efi ~/grub_arm.efi
+          if [[ "${TEST_PY_BD}" == "qemu-riscv32_spl" ]]; then
+              wget -O - https://github.com/riscv/opensbi/releases/download/v0.6/opensbi-0.6-rv32-bin.tar.xz | tar -C /tmp -xJ;
+              export OPENSBI=/tmp/opensbi-0.6-rv32-bin/platform/qemu/virt/firmware/fw_dynamic.bin;
+          fi
+          if [[ "${TEST_PY_BD}" == "qemu-riscv64_spl" ]]; then
+              wget -O - https://github.com/riscv/opensbi/releases/download/v0.6/opensbi-0.6-rv64-bin.tar.xz | tar -C /tmp -xJ;
+              export OPENSBI=/tmp/opensbi-0.6-rv64-bin/platform/qemu/virt/firmware/fw_dynamic.bin;
+          fi
           # the below corresponds to .gitlab-ci.yml "script"
           cd ${WORK_DIR}
           if [[ "${BUILDMAN}" != "" ]]; then
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ae158aa..bf39435 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@
 
 # Grab our configured image.  The source for this is found at:
 # https://gitlab.denx.de/u-boot/gitlab-ci-runner
-image: trini/u-boot-gitlab-ci-runner:bionic-20200112-21Feb2020
+image: trini/u-boot-gitlab-ci-runner:bionic-20200311-10Apr2020
 
 # We run some tests in different order, to catch some failures quicker.
 stages:
@@ -21,8 +21,17 @@
     - grub-mkimage --prefix="" -o ~/grub_x86.efi -O i386-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
     - grub-mkimage --prefix="" -o ~/grub_x64.efi -O x86_64-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
     - cp /opt/grub/grubriscv64.efi ~/grub_riscv64.efi
+    - cp /opt/grub/grubriscv32.efi ~/grub_riscv32.efi
     - cp /opt/grub/grubaa64.efi ~/grub_arm64.efi
     - cp /opt/grub/grubarm.efi ~/grub_arm.efi
+    - if [[ "${TEST_PY_BD}" == "qemu-riscv32_spl" ]]; then
+        wget -O - https://github.com/riscv/opensbi/releases/download/v0.6/opensbi-0.6-rv32-bin.tar.xz | tar -C /tmp -xJ;
+        export OPENSBI=/tmp/opensbi-0.6-rv32-bin/platform/qemu/virt/firmware/fw_dynamic.bin;
+      fi
+    - if [[ "${TEST_PY_BD}" == "qemu-riscv64_spl" ]]; then
+        wget -O - https://github.com/riscv/opensbi/releases/download/v0.6/opensbi-0.6-rv64-bin.tar.xz | tar -C /tmp -xJ;
+        export OPENSBI=/tmp/opensbi-0.6-rv64-bin/platform/qemu/virt/firmware/fw_dynamic.bin;
+      fi
 
   after_script:
     - rm -rf /tmp/uboot-test-hooks /tmp/venv
@@ -297,6 +306,14 @@
     BUILDMAN: "^qemu-ppce500$"
   <<: *buildman_and_testpy_dfn
 
+qemu-riscv32 test.py:
+  tags: [ 'all' ]
+  variables:
+    TEST_PY_BD: "qemu-riscv32"
+    TEST_PY_TEST_SPEC: "not sleep"
+    BUILDMAN: "^qemu-riscv32$"
+  <<: *buildman_and_testpy_dfn
+
 qemu-riscv64 test.py:
   tags: [ 'all' ]
   variables:
@@ -305,6 +322,22 @@
     BUILDMAN: "^qemu-riscv64$"
   <<: *buildman_and_testpy_dfn
 
+qemu-riscv32_spl test.py:
+  tags: [ 'all' ]
+  variables:
+    TEST_PY_BD: "qemu-riscv32_spl"
+    TEST_PY_TEST_SPEC: "not sleep"
+    BUILDMAN: "^qemu-riscv32_spl$"
+  <<: *buildman_and_testpy_dfn
+
+qemu-riscv64_spl test.py:
+  tags: [ 'all' ]
+  variables:
+    TEST_PY_BD: "qemu-riscv64_spl"
+    TEST_PY_TEST_SPEC: "not sleep"
+    BUILDMAN: "^qemu-riscv64_spl$"
+  <<: *buildman_and_testpy_dfn
+
 qemu-x86 test.py:
   tags: [ 'all' ]
   variables:
diff --git a/.travis.yml b/.travis.yml
index 8a4a45c..5309a0b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,6 +14,7 @@
     - ubuntu-toolchain-r-test
     - llvm-toolchain-bionic-7
     packages:
+    - autopoint
     - cppcheck
     - sloccount
     - sparse
@@ -55,10 +56,6 @@
  - cat ~/.buildman
  - grub-mkimage --prefix="" -o ~/grub_x86.efi -O i386-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
  - grub-mkimage --prefix="" -o ~/grub_x64.efi -O x86_64-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
- - mkdir ~/grub2-arm
- - ( cd ~/grub2-arm; wget -O - http://download.opensuse.org/ports/armv7hl/distribution/leap/42.2/repo/oss/suse/armv7hl/grub2-arm-efi-2.02~beta2-87.1.armv7hl.rpm | rpm2cpio | cpio -di )
- - mkdir ~/grub2-arm64
- - ( cd ~/grub2-arm64; wget -O - http://download.opensuse.org/ports/aarch64/distribution/leap/42.2/repo/oss/suse/aarch64/grub2-arm64-efi-2.02~beta2-87.1.aarch64.rpm | rpm2cpio | cpio -di )
  - wget http://mirrors.kernel.org/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.4-1_amd64.deb && sudo dpkg -i libmpfr4_3.1.4-1_amd64.deb && rm libmpfr4_3.1.4-1_amd64.deb
 
 env:
@@ -100,6 +97,7 @@
     fi
   - if [[ "${TOOLCHAIN}" == "powerpc" ]]; then ./tools/buildman/buildman --fetch-arch powerpc; fi
   - if [[ "${TOOLCHAIN}" == "riscv" ]]; then
+       ./tools/buildman/buildman --fetch-arch riscv32 &&
        ./tools/buildman/buildman --fetch-arch riscv64;
     fi
   - if [[ "${QEMU_TARGET}" != "" ]]; then
@@ -112,6 +110,96 @@
        popd;
     fi
 
+  # Build GRUB UEFI targets
+  - if [[ "${QEMU_TARGET}" == "arm-softmmu" ]]; then
+       git clone git://git.savannah.gnu.org/grub.git /tmp/grub &&
+       pushd /tmp/grub &&
+       git checkout grub-2.04 &&
+       ./bootstrap &&
+       ./configure --target=arm --with-platform=efi
+       CC=gcc
+       TARGET_CC=~/.buildman-toolchains/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc
+       TARGET_OBJCOPY=~/.buildman-toolchains/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy
+       TARGET_STRIP=~/.buildman-toolchains/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip
+       TARGET_NM=~/.buildman-toolchains/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm
+       TARGET_RANLIB=~/.buildman-toolchains/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib &&
+       make -j4 &&
+       ./grub-mkimage -O arm-efi -o ~/grub_arm.efi --prefix= -d
+       grub-core cat chain configfile echo efinet ext2 fat halt help linux
+       lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot
+       search search_fs_file search_fs_uuid search_label serial sleep test
+       true &&
+       popd;
+    fi
+  - if [[ "${QEMU_TARGET}" == "aarch64-softmmu" ]]; then
+       git clone git://git.savannah.gnu.org/grub.git /tmp/grub &&
+       pushd /tmp/grub &&
+       git checkout grub-2.04 &&
+       ./bootstrap &&
+       ./configure --target=aarch64 --with-platform=efi
+       CC=gcc
+       TARGET_CC=~/.buildman-toolchains/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc
+       TARGET_OBJCOPY=~/.buildman-toolchains/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy
+       TARGET_STRIP=~/.buildman-toolchains/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-strip
+       TARGET_NM=~/.buildman-toolchains/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-nm
+       TARGET_RANLIB=~/.buildman-toolchains/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib &&
+       make -j4 &&
+       ./grub-mkimage -O arm64-efi -o ~/grub_arm64.efi --prefix= -d
+       grub-core cat chain configfile echo efinet ext2 fat halt help linux
+       lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot
+       search search_fs_file search_fs_uuid search_label serial sleep test
+       true &&
+       popd;
+    fi
+  - if [[ "${QEMU_TARGET}" == "riscv32-softmmu" ]]; then
+       git clone git://git.savannah.gnu.org/grub.git /tmp/grub &&
+       pushd /tmp/grub &&
+       git checkout grub-2.04 &&
+       ./bootstrap &&
+       ./configure --target=riscv32 --with-platform=efi
+       CC=gcc
+       TARGET_CC=~/.buildman-toolchains/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-gcc
+       TARGET_OBJCOPY=~/.buildman-toolchains/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-objcopy
+       TARGET_STRIP=~/.buildman-toolchains/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-strip
+       TARGET_NM=~/.buildman-toolchains/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-nm
+       TARGET_RANLIB=~/.buildman-toolchains/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-ranlib &&
+       make -j4 &&
+       ./grub-mkimage -O riscv32-efi -o ~/grub_riscv32.efi --prefix= -d
+       grub-core cat chain configfile echo efinet ext2 fat halt help linux
+       lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot
+       search search_fs_file search_fs_uuid search_label serial sleep test
+       true &&
+       popd;
+    fi
+  - if [[ "${QEMU_TARGET}" == "riscv64-softmmu" ]]; then
+       git clone git://git.savannah.gnu.org/grub.git /tmp/grub &&
+       pushd /tmp/grub &&
+       git checkout grub-2.04 &&
+       ./bootstrap &&
+       ./configure --target=riscv64 --with-platform=efi
+       CC=gcc
+       TARGET_CC=~/.buildman-toolchains/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc
+       TARGET_OBJCOPY=~/.buildman-toolchains/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy
+       TARGET_STRIP=~/.buildman-toolchains/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-strip
+       TARGET_NM=~/.buildman-toolchains/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-nm
+       TARGET_RANLIB=~/.buildman-toolchains/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib &&
+       make -j4 &&
+       ./grub-mkimage -O riscv64-efi -o ~/grub_riscv64.efi --prefix= -d
+       grub-core cat chain configfile echo efinet ext2 fat halt help linux
+       lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot
+       search search_fs_file search_fs_uuid search_label serial sleep test
+       true &&
+       popd;
+    fi
+  - if [[ "${TEST_PY_BD}" == "qemu-riscv32_spl" ]]; then
+       wget -O - https://github.com/riscv/opensbi/releases/download/v0.6/opensbi-0.6-rv32-bin.tar.xz | tar -C /tmp -xJ;
+       export OPENSBI=/tmp/opensbi-0.6-rv32-bin/platform/qemu/virt/firmware/fw_dynamic.bin;
+    fi
+  - if [[ "${TEST_PY_BD}" == "qemu-riscv64_spl" ]]; then
+       wget -O - https://github.com/riscv/opensbi/releases/download/v0.6/opensbi-0.6-rv64-bin.tar.xz | tar -C /tmp -xJ;
+       export OPENSBI=/tmp/opensbi-0.6-rv64-bin/platform/qemu/virt/firmware/fw_dynamic.bin;
+    fi
+
 script:
  # Comments must be outside the command strings below, or the Travis parser
  # will get confused.
@@ -133,8 +221,18 @@
  - export UBOOT_TRAVIS_BUILD_DIR=`cd .. && pwd`/.bm-work/${TEST_PY_BD};
    cp ~/grub_x86.efi $UBOOT_TRAVIS_BUILD_DIR/;
    cp ~/grub_x64.efi $UBOOT_TRAVIS_BUILD_DIR/;
-   cp ~/grub2-arm/usr/lib/grub2/arm-efi/grub.efi $UBOOT_TRAVIS_BUILD_DIR/grub_arm.efi;
-   cp ~/grub2-arm64/usr/lib/grub2/arm64-efi/grub.efi $UBOOT_TRAVIS_BUILD_DIR/grub_arm64.efi;
+   if [[ -e ~/grub_arm.efi ]]; then
+     cp ~/grub_arm.efi $UBOOT_TRAVIS_BUILD_DIR/;
+   fi;
+   if [[ -e ~/grub_arm64.efi ]]; then
+     cp ~/grub_arm64.efi $UBOOT_TRAVIS_BUILD_DIR/;
+   fi;
+   if [[ -e ~/grub_riscv32.efi ]]; then
+     cp ~/grub_riscv32.efi $UBOOT_TRAVIS_BUILD_DIR/;
+   fi;
+   if [[ -e ~/grub_riscv64.efi ]]; then
+     cp ~/grub_riscv64.efi $UBOOT_TRAVIS_BUILD_DIR/;
+   fi;
    if [[ "${TEST_PY_BD}" != "" ]]; then
      virtualenv -p /usr/bin/python3 /tmp/venv;
      . /tmp/venv/bin/activate;
@@ -482,6 +580,13 @@
           QEMU_TARGET="ppc-softmmu"
           BUILDMAN="^qemu-ppce500$"
           TOOLCHAIN="powerpc"
+    - name: "test/py qemu-riscv32"
+      env:
+        - TEST_PY_BD="qemu-riscv32"
+          TEST_PY_TEST_SPEC="not sleep"
+          QEMU_TARGET="riscv32-softmmu"
+          BUILDMAN="^qemu-riscv32$"
+          TOOLCHAIN="riscv"
     - name: "test/py qemu-riscv64"
       env:
         - TEST_PY_BD="qemu-riscv64"
@@ -489,6 +594,20 @@
           QEMU_TARGET="riscv64-softmmu"
           BUILDMAN="^qemu-riscv64$"
           TOOLCHAIN="riscv"
+    - name: "test/py qemu-riscv32_spl"
+      env:
+        - TEST_PY_BD="qemu-riscv32_spl"
+          TEST_PY_TEST_SPEC="not sleep"
+          QEMU_TARGET="riscv32-softmmu"
+          BUILDMAN="^qemu-riscv32_spl$"
+          TOOLCHAIN="riscv"
+    - name: "test/py qemu-riscv64_spl"
+      env:
+        - TEST_PY_BD="qemu-riscv64_spl"
+          TEST_PY_TEST_SPEC="not sleep"
+          QEMU_TARGET="riscv64-softmmu"
+          BUILDMAN="^qemu-riscv64_spl$"
+          TOOLCHAIN="riscv"
     - name: "test/py qemu-x86"
       env:
         - TEST_PY_BD="qemu-x86"
diff --git a/drivers/video/sunxi/sunxi_display.c b/drivers/video/sunxi/sunxi_display.c
index 31f0aa7..4e1720e 100644
--- a/drivers/video/sunxi/sunxi_display.c
+++ b/drivers/video/sunxi/sunxi_display.c
@@ -1014,7 +1014,6 @@
 static const char *sunxi_get_mon_desc(enum sunxi_monitor monitor)
 {
 	switch (monitor) {
-	case sunxi_monitor_none:		return "none";
 	case sunxi_monitor_dvi:			return "dvi";
 	case sunxi_monitor_hdmi:		return "hdmi";
 	case sunxi_monitor_lcd:			return "lcd";
@@ -1023,8 +1022,9 @@
 	case sunxi_monitor_composite_ntsc:	return "composite-ntsc";
 	case sunxi_monitor_composite_pal_m:	return "composite-pal-m";
 	case sunxi_monitor_composite_pal_nc:	return "composite-pal-nc";
+	case sunxi_monitor_none:		/* fall through */
+	default:				return "none";
 	}
-	return NULL; /* never reached */
 }
 
 ulong board_get_usable_ram_top(ulong total_size)
diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py
index bf2a0fc..939d82e 100644
--- a/test/py/u_boot_utils.py
+++ b/test/py/u_boot_utils.py
@@ -237,10 +237,11 @@
             raise Exception('Failed to find RAM bank start in `bdinfo`')
 
     # We don't want ram_base to be zero as some functions test if the given
-    # address is NULL (0). Let's add 2MiB then (size of an ARM LPAE/v8 section).
+    # address is NULL (0). Besides, on some RISC-V targets the low memory
+    # is protected that prevents S-mode U-Boot from access.
+    # Let's add 2MiB then (size of an ARM LPAE/v8 section).
 
-    if ram_base == 0:
-        ram_base += 1024 * 1024 * 2
+    ram_base += 1024 * 1024 * 2
 
     return ram_base
 
diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py
index 89c54d6..4456a80 100644
--- a/tools/buildman/toolchain.py
+++ b/tools/buildman/toolchain.py
@@ -490,7 +490,7 @@
         if arch == 'aarch64':
             arch = 'arm64'
         base = 'https://www.kernel.org/pub/tools/crosstool/files/bin'
-        versions = ['7.3.0', '6.4.0', '4.9.4']
+        versions = ['9.2.0', '7.3.0', '6.4.0', '4.9.4']
         links = []
         for version in versions:
             url = '%s/%s/%s/' % (base, arch, version)