starfive-tech / freelight-u-sdk

28 stars 21 forks source link

make fails during OpenSBI build #4

Closed pdp7 closed 3 years ago

pdp7 commented 3 years ago
pdp7@x1:~/dev/starfive/freelight-u-sdk$ make -j4
<SNIP>
  AR      drivers/hwtracing/intel_th/built-in.a
  CC      drivers/nvmem/core.o
  CC      drivers/mmc/host/dw_mmc.o
  AR      drivers/rpmsg/built-in.a
  CC      drivers/mmc/host/dw_mmc-pltfm.o
  AR      drivers/firmware/efi/built-in.a
  AR      drivers/firmware/built-in.a
  CC      drivers/mmc/host/sdhci-pltfm.o
  CC      drivers/mmc/host/sdhci-of-dwcmshc.o
  AR      drivers/nvmem/built-in.a
  AR      drivers/mmc/host/built-in.a
  AR      drivers/mmc/built-in.a
  AR      drivers/built-in.a
  GEN     .version
  CHK     include/generated/compile.h
  LD      vmlinux.o
  MODPOST vmlinux.symvers
  MODINFO modules.builtin.modinfo
  GEN     modules.builtin
  LD      .tmp_vmlinux.kallsyms1
  KSYMS   .tmp_vmlinux.kallsyms1.S
  AS      .tmp_vmlinux.kallsyms1.S
  LD      .tmp_vmlinux.kallsyms2
  KSYMS   .tmp_vmlinux.kallsyms2.S
  AS      .tmp_vmlinux.kallsyms2.S
  LD      vmlinux
  SYSMAP  System.map
  MODPOST Module.symvers
  OBJCOPY arch/riscv/boot/Image
  CC [M]  fs/efivarfs/efivarfs.mod.o
  CC [M]  fs/nfs/flexfilelayout/nfs_layout_flexfiles.mod.o
  GZIP    arch/riscv/boot/Image.gz
  LD [M]  fs/nfs/flexfilelayout/nfs_layout_flexfiles.ko
  LD [M]  fs/efivarfs/efivarfs.ko
make[2]: Nothing to be done for 'modules'.
  Kernel: arch/riscv/boot/Image.gz is ready
make[2]: Leaving directory '/home/pdp7/dev/starfive/freelight-u-sdk/work/linux'
make[1]: Leaving directory '/home/pdp7/dev/starfive/freelight-u-sdk/linux'
rm -rf /home/pdp7/dev/starfive/freelight-u-sdk/work/opensbi
PATH=/home/pdp7/dev/starfive/freelight-u-sdk/work/buildroot_initramfs/host/bin:/home/pdp7/dev/fpga/symbiotic/symbiotic-20200324A/bin:/home/pdp7/.cargo/bin:/home/pdp7/.local/bin:/home/pdp7/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/pdp7/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin:/home/pdp7/dev/fpga/ecp5-toolchain/ecp5-toolchain-linux_x86_64-v1.6.9/bin riscv64-buildroot-linux-gnu-objcopy -O binary /home/pdp7/dev/starfive/freelight-u-sdk/work/linux/vmlinux /home/pdp7/dev/starfive/freelight-u-sdk/work/vmlinux.bin
mkdir -p /home/pdp7/dev/starfive/freelight-u-sdk/work/opensbi
cd /home/pdp7/dev/starfive/freelight-u-sdk/work/opensbi && O=/home/pdp7/dev/starfive/freelight-u-sdk/work/opensbi CFLAGS="-mabi=lp64d -march=rv64imafdc" make -C /home/pdp7/dev/starfive/freelight-u-sdk/opensbi CROSS_COMPILE=/home/pdp7/dev/starfive/freelight-u-sdk/work/buildroot_initramfs/host/bin/riscv64-buildroot-linux-gnu- \
    PLATFORM=starfive/vic7100 FW_PAYLOAD_PATH=/home/pdp7/dev/starfive/freelight-u-sdk/work/HiFive_U-Boot/u-boot.bin FW_PAYLOAD_FDT_PATH=/home/pdp7/dev/starfive/freelight-u-sdk/work/HiFive_U-Boot/arch/riscv/dts/starfive_vic7100_evb.dtb
cd /home/pdp7/dev/starfive/freelight-u-sdk/work/linux && \
    /home/pdp7/dev/starfive/freelight-u-sdk/linux/usr/gen_initramfs_list.sh \
    -o /home/pdp7/dev/starfive/freelight-u-sdk/work/initramfs.cpio.gz -u 1000 -g 1000 \
    /home/pdp7/dev/starfive/freelight-u-sdk/conf/initramfs.txt \
    /home/pdp7/dev/starfive/freelight-u-sdk/work/buildroot_initramfs_sysroot
make[1]: Entering directory '/home/pdp7/dev/starfive/freelight-u-sdk/opensbi'
make[1]: *** No targets specified and no makefile found.  Stop.
make[1]: Leaving directory '/home/pdp7/dev/starfive/freelight-u-sdk/opensbi'
make: *** [Makefile:213: sbi] Error 2
make: *** Waiting for unfinished jobs....
pdp7@x1:~/dev/starfive/freelight-u-sdk$ 

The contents of work:

pdp7@x1:~/dev/starfive/freelight-u-sdk$ ls -ltar work/
total 36292
drwxrwxr-x 10 pdp7 pdp7     4096 Apr 16 13:08 ..
drwxr-xr-x 16 pdp7 pdp7     4096 Apr 16 14:57 buildroot_initramfs_sysroot
drwxrwxr-x  7 pdp7 pdp7     4096 Apr 16 14:58 buildroot_initramfs
-rw-rw-r--  1 pdp7 pdp7        0 Apr 16 14:58 .buildroot_initramfs_sysroot
-rw-rw-r--  1 pdp7 pdp7   275994 Apr 16 14:58 initramfs.cpio.gz.d
drwxrwxr-x 17 pdp7 pdp7     4096 Apr 16 14:58 HiFive_U-Boot
drwxrwxr-x 20 pdp7 pdp7     4096 Apr 16 15:03 linux
drwxrwxr-x  2 pdp7 pdp7     4096 Apr 16 15:03 opensbi
-rwxrwxr-x  1 pdp7 pdp7 15558144 Apr 16 15:03 vmlinux.bin
drwxrwxr-x  7 pdp7 pdp7     4096 Apr 16 15:03 .
-rw-rw-r--  1 pdp7 pdp7 26653105 Apr 16 15:04 initramfs.cpio.gz

There is nothing in work/opensbi:

pdp7@x1:~/dev/starfive/freelight-u-sdk$ ls -ltar work/opensbi/
total 8
drwxrwxr-x 2 pdp7 pdp7 4096 Apr 16 15:03 .
drwxrwxr-x 7 pdp7 pdp7 4096 Apr 16 15:03 ..
pdp7@x1:~/dev/starfive/freelight-u-sdk$ 

It looks like opensbi is not on the correct branch:

pdp7@x1:~/dev/starfive/freelight-u-sdk/opensbi$ ls
README.md
pdp7@x1:~/dev/starfive/freelight-u-sdk/opensbi$ git branch
* (HEAD detached at 7fdc4583e8ee)
  main

That commit is the HEAD of main:

pdp7@x1:~/dev/starfive/freelight-u-sdk/opensbi$ git log 7fdc4583e8ee
commit 7fdc4583e8eefdd14c23db912df212fc2c9e1396 (HEAD, origin/main, origin/HEAD, main)
Author: starfivetech <54930809+starfivetech@users.noreply.github.com>
Date:   Thu Apr 1 14:32:35 2021 +0800

    Initial commit
pdp7 commented 3 years ago

I believe the problem is that the opensbi submodule points to 7fdc458 which is the initial commit in main branch. Screenshot from 2021-04-18 12-46-22 but it should be on the HEAD of starfive branch: https://github.com/starfive-tech/sft-riscv-opensbi/commit/b4f8f7ca312804fd99bc3ebfa0644ea4b369c307

pdp7 commented 3 years ago

I tried to update the submodule but got error:

pdp7@x1:~/dev/starfive/freelight-u-sdk$ git submodule update --remote --merge
fatal: refusing to merge unrelated histories
Unable to merge 'b4f8f7ca312804fd99bc3ebfa0644ea4b369c307' in submodule path 'opensbi'

That commit is HEAD of starfive branch:

pdp7@x1:~/dev/starfive/freelight-u-sdk/opensbi$ git log b4f8f7ca312804fd99bc3ebfa0644ea4b369c307
commit b4f8f7ca312804fd99bc3ebfa0644ea4b369c307 (origin/starfive)
Author: Huan.Feng <huan.feng@starfivetech.com>
Date:   Tue Feb 9 14:51:36 2021 +0800

    change default memory size for opensbi

commit c94c243f55e2817643e14e87aaae3b6069345d45
Author: 封欢 <huan.feng@starfivetech.com>
Date:   Tue Feb 9 11:41:26 2021 +0800

    add vic7100 support

commit c4a0624c3cf59069e95dfe47ebffa38cd85bea6c
Author: 封欢 <huan.feng@starfivetech.com>
Date:   Tue Feb 9 11:40:43 2021 +0800

    initial opensbi use v0.9 release package from github.com/riscv/opensbi
pdp7@x1:~/dev/starfive/freelight-u-sdk/opensbi$ 
pdp7 commented 3 years ago

This seems to have solved the problem:

pdp7@x1:~/dev/starfive/freelight-u-sdk$ git submodule update --remote
Submodule path 'opensbi': checked out 'b4f8f7ca312804fd99bc3ebfa0644ea4b369c307'
pdp7@x1:~/dev/starfive/freelight-u-sdk/opensbi$ git log --oneline
b4f8f7ca3128 (HEAD, origin/starfive) change default memory size for opensbi
c94c243f55e2 add vic7100 support
c4a0624c3cf5 initial opensbi use v0.9 release package from github.com/riscv/opensbi
pdp7 commented 3 years ago

make completed succesfully:

pdp7@x1:~/dev/starfive/freelight-u-sdk$ ls -ltar work/
total 209260
drwxrwxr-x 10 pdp7 pdp7      4096 Apr 16 13:08 ..
drwxr-xr-x 16 pdp7 pdp7      4096 Apr 16 14:57 buildroot_initramfs_sysroot
drwxrwxr-x  7 pdp7 pdp7      4096 Apr 16 14:58 buildroot_initramfs
-rw-rw-r--  1 pdp7 pdp7         0 Apr 16 14:58 .buildroot_initramfs_sysroot
-rw-rw-r--  1 pdp7 pdp7    275994 Apr 16 14:58 initramfs.cpio.gz.d
drwxrwxr-x 17 pdp7 pdp7      4096 Apr 16 14:58 HiFive_U-Boot
drwxrwxr-x 20 pdp7 pdp7      4096 Apr 16 15:03 linux
-rwxrwxr-x  1 pdp7 pdp7  15558144 Apr 16 15:03 vmlinux.bin
-rw-rw-r--  1 pdp7 pdp7  26653105 Apr 16 15:04 initramfs.cpio.gz
drwxrwxr-x  4 pdp7 pdp7      4096 Apr 18 13:32 opensbi
-rw-rw-r--  1 pdp7 pdp7  42229814 Apr 18 13:32 image.fit
drwxrwxr-x  7 pdp7 pdp7      4096 Apr 18 13:32 .
-rw-rw-r--  1 pdp7 pdp7 134888448 Apr 18 13:32 hifive-unleashed-vfat.part

here is the log:

<SNIP>
 OBJCOPY   platform/starfive/vic7100/firmware/fw_dynamic.bin
 OBJCOPY   platform/starfive/vic7100/firmware/fw_payload.bin
make[1]: Leaving directory '/home/pdp7/dev/starfive/freelight-u-sdk/opensbi'
/home/pdp7/dev/starfive/freelight-u-sdk/work/HiFive_U-Boot/tools/mkimage -f /home/pdp7/dev/starfive/freelight-u-sdk/conf/u74_nvdla-uboot-fit-image.its -A riscv -O linux -T flat_dt /home/pdp7/dev/starfive/freelight-u-sdk/work/image.fit
FIT description: U-boot FIT image for HiFive Nvdla
Created:         Sun Apr 18 13:32:57 2021
 Image 0 (vmlinux)
  Description:  vmlinux
  Created:      Sun Apr 18 13:32:57 2021
  Type:         Kernel Image
  Compression:  uncompressed
  Data Size:    15558144 Bytes = 15193.50 KiB = 14.84 MiB
  Architecture: RISC-V
  OS:           Linux
  Load Address: 0x80200000
  Entry Point:  0x80200000
 Image 1 (ramdisk)
  Description:  buildroot initramfs
  Created:      Sun Apr 18 13:32:57 2021
  Type:         RAMDisk Image
  Compression:  uncompressed
  Data Size:    26653105 Bytes = 26028.42 KiB = 25.42 MiB
  Architecture: RISC-V
  OS:           Linux
  Load Address: 0x86100000
  Entry Point:  unavailable
  Hash algo:    sha256
  Hash value:   c48da5cbe34ae1763de9815406d4aac09ee7c90ad749f34daa4402d5d215a4ce
 Image 2 (fdt)
  Description:  unavailable
  Created:      Sun Apr 18 13:32:57 2021
  Type:         Flat Device Tree
  Compression:  uncompressed
  Data Size:    16615 Bytes = 16.23 KiB = 0.02 MiB
  Architecture: RISC-V
  Load Address: 0x86000000
  Hash algo:    sha256
  Hash value:   053878cf119adeece6fefb74f210948905a48cab9ab9da278d9bff3fdd045f33
 Default Configuration: 'config-1'
 Configuration 0 (config-1)
  Description:  HiFive Nvdla with opensbi
  Kernel:       vmlinux
  FDT:          fdt
  Loadables:    ramdisk
inFile: /home/pdp7/dev/starfive/freelight-u-sdk/work/opensbi/platform/starfive/vic7100/firmware/fw_payload.bin
inSize: 641336 (0x0009c938, LE:0x38c90900)
outFile: /home/pdp7/dev/starfive/freelight-u-sdk/work/opensbi/platform/starfive/vic7100/firmware/fw_payload.bin.out
outSize: 641340 (0x0009c93c)
dd if=/dev/zero of=/home/pdp7/dev/starfive/freelight-u-sdk/work/hifive-unleashed-vfat.part bs=512 count=263454
263454+0 records in
263454+0 records out
134888448 bytes (135 MB, 129 MiB) copied, 0.271447 s, 497 MB/s
/sbin/mkfs.vfat /home/pdp7/dev/starfive/freelight-u-sdk/work/hifive-unleashed-vfat.part
mkfs.fat 4.1 (2017-01-24)
PATH=/home/pdp7/dev/starfive/freelight-u-sdk/work/buildroot_initramfs/host/bin:/home/pdp7/dev/fpga/symbiotic/symbiotic-20200324A/bin:/home/pdp7/.cargo/bin:/home/pdp7/.local/bin:/home/pdp7/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/pdp7/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin:/home/pdp7/dev/fpga/ecp5-toolchain/ecp5-toolchain-linux_x86_64-v1.6.9/bin MTOOLS_SKIP_CHECK=1 mcopy -i /home/pdp7/dev/starfive/freelight-u-sdk/work/hifive-unleashed-vfat.part /home/pdp7/dev/starfive/freelight-u-sdk/work/image.fit ::hifiveu.fit
PATH=/home/pdp7/dev/starfive/freelight-u-sdk/work/buildroot_initramfs/host/bin:/home/pdp7/dev/fpga/symbiotic/symbiotic-20200324A/bin:/home/pdp7/.cargo/bin:/home/pdp7/.local/bin:/home/pdp7/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/pdp7/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin:/home/pdp7/dev/fpga/ecp5-toolchain/ecp5-toolchain-linux_x86_64-v1.6.9/bin MTOOLS_SKIP_CHECK=1 mcopy -i /home/pdp7/dev/starfive/freelight-u-sdk/work/hifive-unleashed-vfat.part /home/pdp7/dev/starfive/freelight-u-sdk/conf/u74_uEnv.txt ::u74_uEnv.txt
To completely erase, reformat, and program a disk sdX, run:
  make DISK=/dev/sdX format-nvdla-disk
  ... you will need gdisk and e2fsprogs installed
  Please note this will not currently format the SDcard ext4 partition
  This can be done manually if needed