Skip to content

Issue Running Linux on FPGA #110

@tbemre

Description

@tbemre

Hello,
I’m trying to run Linux using a Genesys2 FPGA.

When I load the FPGA, the UART output is blank, the system freezes, and Linux does not boot.

When I tested it via qemu:

emre@emre:~/cheshire/sw/boot$ /home/emre/qemu/build/qemu-system-riscv64 
-machine virt 
-nographic 
-m 512M 
-kernel /home/emre/cheshire/sw/boot/linux.genesys2.gpt.bin 
-append "root=/dev/ram rw console=ttyS0"
OpenSBI v1.5.1
/ __ \                  / |  _ _   |
| |  | | __   ___ _ __ | ( | |) || |
| |  | | '_ \ / _ \ '_ \ ___ |  _ < | |
| || | |) |  __/ | | |) | |) || |
_/| ./ _|| ||/|____/|
| |
|_|
Platform Name             : riscv-virtio,qemu
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 10000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform PMU Device       : ---
Platform Reboot Device    : syscon-reboot
Platform Shutdown Device  : syscon-poweroff
Platform Suspend Device   : ---
Platform CPPC Device      : ---
Firmware Base             : 0x80000000
Firmware Size             : 327 KB
Firmware RW Offset        : 0x40000
Firmware RW Size          : 71 KB
Firmware Heap Offset      : 0x49000
Firmware Heap Size        : 35 KB (total), 2 KB (reserved), 11 KB (used), 21 KB (free)
Firmware Scratch Size     : 4096 B (total), 416 B (used), 3680 B (free)
Runtime SBI Version       : 2.0
Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x0000000000100000-0x0000000000100fff M: (I,R,W) S/U: (R,W)
Domain0 Region01          : 0x0000000010000000-0x0000000010000fff M: (I,R,W) S/U: (R,W)
Domain0 Region02          : 0x0000000002000000-0x000000000200ffff M: (I,R,W) S/U: ()
Domain0 Region03          : 0x0000000080040000-0x000000008005ffff M: (R,W) S/U: ()
Domain0 Region04          : 0x0000000080000000-0x000000008003ffff M: (R,X) S/U: ()
Domain0 Region05          : 0x000000000c400000-0x000000000c5fffff M: (I,R,W) S/U: (R,W)
Domain0 Region06          : 0x000000000c000000-0x000000000c3fffff M: (I,R,W) S/U: (R,W)
Domain0 Region07          : 0x0000000000000000-0xffffffffffffffff M: () S/U: (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x000000009fe00000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes
Domain0 SysSuspend        : yes
Boot HART ID              : 0
Boot HART Domain          : root
Boot HART Priv Version    : v1.12
Boot HART Base ISA        : rv64imafdch
Boot HART ISA Extensions  : sstc,zicntr,zihpm,zicboz,zicbom,sdtrig,svadu
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 2 bits
Boot HART PMP Address Bits: 54
Boot HART MHPM Info       : 16 (0x0007fff8)
Boot HART Debug Triggers  : 2 triggers
Boot HART MIDELEG         : 0x0000000000001666
Boot HART MEDELEG         : 0x0000000000f0b509

After this point, qemu freezes. I disassembled the fw_payload.elf file and analyzed the pc with gdb and noticed that it was stuck at 0x80000620.

When installing buildroot, there was an error in the fakeroot package, so I replaced it with the current version. When I pull the current buildroot repo, I get the following error:

emre@emre:~/cheshire/sw/deps/cva6-sdk$ make images
make -C buildroot defconfig BR2_DEFCONFIG=../configs/buildroot64_defconfig
make[1]: Entering directory '/home/emre/cheshire/sw/deps/cva6-sdk/buildroot'

configuration written to /home/emre/cheshire/sw/deps/cva6-sdk/buildroot/.config

make[1]: Leaving directory '/home/emre/cheshire/sw/deps/cva6-sdk/buildroot'
make -C buildroot host-gcc-final -j16
make[1]: Entering directory '/home/emre/cheshire/sw/deps/cva6-sdk/buildroot'
/usr/bin/make -j1  O=/home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output HOSTCC="/usr/bin/gcc" HOSTCXX="/usr/bin/g++" syncconfig
make[3]: warning: -j1 forced in submake: resetting jobserver mode.

uclibc 1.0.52 Building
/usr/bin/make  -C /home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output/build/uclibc-1.0.52 ARCH="riscv64" CROSS_COMPILE="/home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output/host/bin/riscv64-buildroot-linux-uclibc-" UCLIBC_EXTRA_CFLAGS=" -g0 -fno-lto" HOSTCC="/home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output/host/bin/ccache /usr/bin/gcc" headers
make[3]: 'headers' is up to date.
/usr/bin/make  -C /home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output/build/uclibc-1.0.52 ARCH="riscv64" CROSS_COMPILE="/home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output/host/bin/riscv64-buildroot-linux-uclibc-" UCLIBC_EXTRA_CFLAGS=" -g0 -fno-lto" HOSTCC="/home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output/host/bin/ccache /usr/bin/gcc"
make[4]: 'lib/ld-uClibc.so' is up to date.
LD libuClibc-1.0.52.so
/home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output/host/lib/gcc/riscv64-buildroot-linux-uclibc/14.3.0/../../../../riscv64-buildroot-linux-uclibc/bin/ld: libc/libc_so.a(err.os): in function vwarn_work': err.c:(.text+0xa0): undefined reference to __atomic_compare_exchange_4'
/home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output/host/lib/gcc/riscv64-buildroot-linux-uclibc/14.3.0/../../../../riscv64-buildroot-linux-uclibc/bin/ld: err.c:(.text+0x130): undefined reference to __atomic_exchange_4' /home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output/host/lib/gcc/riscv64-buildroot-linux-uclibc/14.3.0/../../../../riscv64-buildroot-linux-uclibc/bin/ld: libc/libc_so.a(__cxa_finalize.os): in function __cxa_finalize':
__cxa_finalize.c:(.text+0xac): undefined reference to __atomic_compare_exchange_8' /home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output/host/lib/gcc/riscv64-buildroot-linux-uclibc/14.3.0/../../../../riscv64-buildroot-linux-uclibc/bin/ld: libc/libc_so.a(fork.oS): in function __GI_fork':
fork.c:(.text+0x128): undefined reference to __atomic_fetch_add_4' /home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output/host/lib/gcc/riscv64-buildroot-linux-uclibc/14.3.0/../../../../riscv64-buildroot-linux-uclibc/bin/ld: libc/libc_so.a(sem_timedwait.oS): in function sem_timedwait':
sem_timedwait.c:(.text+0xd8): undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[3]: *** [libc/Makefile.in:77: lib/libc.so] Error 1
make[2]: *** [package/pkg-generic.mk:273: /home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output/build/uclibc-1.0.52/.stamp_built] Error 2
make[1]: *** [Makefile:83: _all] Error 2
make[1]: Leaving directory '/home/emre/cheshire/sw/deps/cva6-sdk/buildroot'
make: *** [Makefile:78: /home/emre/cheshire/sw/deps/cva6-sdk/buildroot/output/host/bin/riscv64-buildroot-linux-gnu-gcc] Error 2

I am getting the same error when installing musl.

What could be the most likely reason Linux is not booting on the FPGA? (fw_payload, kernel image, device tree, alignment, etc.)

Any suggestions for debugging this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions