RT-Thread / userapps

user applications for rt-smart
GNU General Public License v2.0
26 stars 30 forks source link

methods to create the prebuilt kernel #35

Closed yf13 closed 1 year ago

yf13 commented 1 year ago

Hi,

May I ask how to built the prebuilt kernel such as prebuilt/qemu-virt64-riscv/rtthread.bin?

I download the v5.0.1 release of RT-Thread and built a bsp/qemu-virt64-riscv/rtthread.bin successfuly, but when I replaced the prebuilt kernel with mine and runs the demo, it complains that: [E/DBG] virtio-blk0 mount failed.

I guess the ext4 file system driver is absent from my kernel, so I turned on CONFIG_PKG_USING_LWEXT4 and rebuild, but got the following error:

CC build/packages/lwext4-latest/src/ext4.o
In file included from /opt/rv64/10.1/riscv64-unknown-linux-musl/include/signal.h:48,
                 from /home/yf/Projects/rt-thread/components/libc/compilers/common/include/sys/signal.h:23,
                 from /home/yf/Projects/rt-thread/components/libc/compilers/common/include/sys/time.h:180,
                 from /home/yf/Projects/rt-thread/components/libc/compilers/common/include/sys/select.h:17,
                 from /opt/rv64/10.1/riscv64-unknown-linux-musl/include/sys/types.h:71,
                 from /home/yf/Projects/rt-thread/components/libc/compilers/common/include/sys/unistd.h:16,
                 from /home/yf/Projects/rt-thread/components/libc/compilers/common/include/unistd.h:14,
                 from packages/lwext4-latest/include/ext4_oflags.h:91,
                 from packages/lwext4-latest/src/ext4.c:41:
/opt/rv64/10.1/riscv64-unknown-linux-musl/include/bits/signal.h:63:15: error: expected identifier or '(' before '[' token
   63 |  char __unused[1024 / 8 - sizeof(sigset_t)];
      |               ^
scons: *** [build/packages/lwext4-latest/src/ext4.o] Error 1
scons: building terminated because of errors.

My toolchain is from https://download.rt-thread.org/rt-smart/riscv64/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_180881.tar.bz2:

yf@a4:$ /opt/rv64/10.1/bin/riscv64-unknown-linux-musl-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/rv64/10.1/bin/riscv64-unknown-linux-musl-gcc
COLLECT_LTO_WRAPPER=/opt/rv64/10.1/bin/../libexec/gcc/riscv64-unknown-linux-musl/10.1.0/lto-wrapper
Target: riscv64-unknown-linux-musl
Configured with: /builds/alliance/risc-v-toolchain/riscv-gcc/configure --target=riscv64-unknown-linux-musl --prefix=/builds/alliance/risc-v-toolchain/install-native/ --with-sysroot=/builds/alliance/risc-v-toolchain/install-native//riscv64-unknown-linux-musl --with-system-zlib --enable-shared --enable-tls --enable-languages=c,c++ --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libsanitizer --disable-nls --disable-bootstrap --src=/builds/alliance/risc-v-toolchain/riscv-gcc --disable-multilib --with-abi=lp64 --with-arch=rv64imafdc --with-tune=rocket 'CFLAGS_FOR_TARGET=-O2   -mcmodel=medany -march=rv64imafdc -mabi=lp64' 'CXXFLAGS_FOR_TARGET=-O2   -mcmodel=medany -march=rv64imafdc -mabi=lp64'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.1.0 (GCC) 
build date: Jun 21 2023 16:23:45
build sha: 1e9cc6e05c1d3f67abf532747071137fa58a549d
build job: 491872

Regards, yf

ziyouchutuwenwu commented 1 year ago

using latest, do not use tag 5.0.1

git clone https://github.com/RT-Thread/rt-thread

cd bsp/qemu-virt64-aarch64
scons --menuconfig
RT-Thread Kernel --->
  [*] Enable RT-Thread Smart (microkernel on kernel/userland)

RT-Thread online packages  --->
  system packages  --->
    [*] lwext4: an excellent choice of ext2/3/4 filesystem for microcontrol
source ~/.env/env.sh
pkgs --update

scons -c; scons
# scons --dist
yf13 commented 1 year ago

@ziyouchutuwenwu

Thanks for the information. I noticed that you were using qemu-virt64-aarch64 while I am using qemu-virt64-riscv. I then tried the latest version of RT-Thread/rt-thread following your suggestion, but it still doesn't build for qemu-virt64-riscv here:

CC build/packages/lwext4-latest/src/ext4.o
In file included from /opt/rv64/10.1/riscv64-unknown-linux-musl/include/signal.h:48,
                 from /home/yf/Projects/rt-thread-master/components/libc/compilers/common/include/sys/signal.h:23,
                 from /home/yf/Projects/rt-thread-master/components/libc/compilers/common/include/sys/time.h:211,
                 from /home/yf/Projects/rt-thread-master/components/libc/compilers/common/include/sys/select.h:17,
                 from /opt/rv64/10.1/riscv64-unknown-linux-musl/include/sys/types.h:71,
                 from /home/yf/Projects/rt-thread-master/components/libc/compilers/common/include/sys/unistd.h:16,
                 from /home/yf/Projects/rt-thread-master/components/libc/compilers/common/include/unistd.h:14,
                 from packages/lwext4-latest/include/ext4_oflags.h:91,
                 from packages/lwext4-latest/src/ext4.c:41:
/opt/rv64/10.1/riscv64-unknown-linux-musl/include/bits/signal.h:63:15: error: expected identifier or '(' before '[' token
   63 |  char __unused[1024 / 8 - sizeof(sigset_t)];
      |               ^
scons: *** [build/packages/lwext4-latest/src/ext4.o] Error 1
scons: building terminated because of errors.

As I can't clone the RT-Thread/rt-thread from github directly, I cloned it to gitee first then grabbed the latest code to my PC for test.

Would you mind check with qemu-virt64-riscv target?

Regards, yf

ziyouchutuwenwu commented 1 year ago

failed for qemu-virt64-riscv

packages/lwext4-latest/ports/rtthread/dfs_ext.c:569:5: warning: initialization of 'ssize_t (*)(struct dfs_file *, void *, size_t)' {aka 'long int (*)(struct dfs_file *, void *, long unsigned int)'} from incompatible pointer type 'int (*)(struct dfs_file *, void *, size_t)' {aka 'int (*)(struct dfs_file *, void *, long unsigned int)'} [-Wincompatible-pointer-types]
  569 |     dfs_ext_read,
      |     ^~~~~~~~~~~~
packages/lwext4-latest/ports/rtthread/dfs_ext.c:569:5: note: (near initialization for '_ext_fops.read')
packages/lwext4-latest/ports/rtthread/dfs_ext.c:570:5: warning: initialization of 'ssize_t (*)(struct dfs_file *, const void *, size_t)' {aka 'long int (*)(struct dfs_file *, const void *, long unsigned int)'} from incompatible pointer type 'int (*)(struct dfs_file *, const void *, size_t)' {aka 'int (*)(struct dfs_file *, const void *, long unsigned int)'} [-Wincompatible-pointer-types]
  570 |     dfs_ext_write,
      |     ^~~~~~~~~~~~~
packages/lwext4-latest/ports/rtthread/dfs_ext.c:570:5: note: (near initialization for '_ext_fops.write')
packages/lwext4-latest/ports/rtthread/dfs_ext.c:572:5: warning: initialization of 'off_t (*)(struct dfs_file *, off_t)' {aka 'long int (*)(struct dfs_file *, long int)'} from incompatible pointer type 'int (*)(struct dfs_file *, off_t)' {aka 'int (*)(struct dfs_file *, long int)'} [-Wincompatible-pointer-types]
  572 |     dfs_ext_lseek,
      |     ^~~~~~~~~~~~~
packages/lwext4-latest/ports/rtthread/dfs_ext.c:572:5: note: (near initialization for '_ext_fops.lseek')
CC build/packages/lwext4-latest/ports/rtthread/dfs_ext_blockdev.o
CC build/packages/lwext4-latest/src/ext4.o
In file included from /home/mmc/downloads/rtt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/riscv64-unknown-linux-musl/include/signal.h:48,
                 from /home/mmc/downloads/rtt/rt-thread-master/components/libc/compilers/common/include/sys/signal.h:23,
                 from /home/mmc/downloads/rtt/rt-thread-master/components/libc/compilers/common/include/sys/time.h:211,
                 from /home/mmc/downloads/rtt/rt-thread-master/components/libc/compilers/common/include/sys/select.h:17,
                 from /home/mmc/downloads/rtt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/riscv64-unknown-linux-musl/include/sys/types.h:71,
                 from /home/mmc/downloads/rtt/rt-thread-master/components/libc/compilers/common/include/sys/unistd.h:16,
                 from /home/mmc/downloads/rtt/rt-thread-master/components/libc/compilers/common/include/unistd.h:14,
                 from packages/lwext4-latest/include/ext4_oflags.h:91,
                 from packages/lwext4-latest/src/ext4.c:41:
/home/mmc/downloads/rtt/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu/riscv64-unknown-linux-musl/include/bits/signal.h:63:15: error: expected identifier or '(' before '[' token
   63 |  char __unused[1024 / 8 - sizeof(sigset_t)];
      |               ^
scons: *** [build/packages/lwext4-latest/src/ext4.o] Error 1
scons: building terminated because of errors.
BernardXiong commented 1 year ago

please use fatfs for rootfs or use dfsv1 for ext4.

yf13 commented 1 year ago

@BernardXiong

Thanks for the suggestions. It seems that I have been using dfvs1 with ext4. I confirmed this error using toolchain from https://github.com/RT-Thread/toolchains-ci/releases/download/v1.7/riscv64-linux-musleabi_for_x86_64-pc-linux-gnu_latest.tar.bz2 as I can't download the original one.

Since the prebuilt kernel uses ext4, I am wondering how it was built from RT-Thread v5.0.1?

I will see if I can use FATFS later, still searching for it in menuconfig.

xqyjlj commented 1 year ago

The reasons for the conflict are as follows

image

image

xqyjlj commented 1 year ago

fix patch https://github.com/RT-Thread-packages/lwext4/issues/24