linux-on-litex-vexriscv: I cannot boot linux. [LITEX-TERM] Got unexpected response from device 'b'E''
Hi there!
I’m trying to boot with a Linux image created locally on a tang nano 20k, but I’m encountering an error that says “[LITEX-TERM] Got unexpected response from device ‘b’E’” and the log stops without booting. I have attached the detailed log below. Please provide any answer. Thank you!
- Files used for booting:
- sipeed_tang_nano_20k.fs: Created with “./make.py --board=sipeed_tang_nano_20k --build”
- sipeed_tang_nano_20k.dtb/dts: Created with “./make.py --board=sipeed_tang_nano_20k --build”
- Image, rootfs.cpio, fw_jump.bin: For the procedure, I followed https://github.com/litex-hub/linux-on-litex-vexriscv#-generating-the-linux-binaries-optional, and I used the ones obtained from https://buildroot.org/ to create each file.
- boot.json: I referred to the boot.json from https://github.com/litex-hub/linux-on-litex-vexriscv/issues/164, and I modified the parts that originally mentioned rv32.dtb and opensbi.bin.
{
"Image": "0x40000000",
"sipeed_tang_nano_20k.dtb": "0x40ef0000",
"rootfs.cpio": "0x41000000",
"fw_jump.bin": "0x40f00000"
}
- log
$ sudo openFPGALoader -f -c ft2232 ~/linux-on-litex-vexriscv/build/sipeed_tang_nano_20k/gateware/sipeed_tang_nano_20k.fs
write to flash
Jtag frequency : requested 6.00MHz -> real 6.00MHz
Parse file Parse /home/nohara/linux-on-litex-vexriscv/build/sipeed_tang_nano_20k/gateware/sipeed_tang_nano_20k.fs:
Done
DONE
Jtag frequency : requested 2.50MHz -> real 2.00MHz
Jtag frequency : requested 10.00MHz -> real 6.00MHz
erase SRAM Done
Detected: Winbond W25Q64 128 sectors size: 64Mb
Detected: Winbond W25Q64 128 sectors size: 64Mb
RDSR : 00
WIP : 0
WEL : 0
BP : 0
TB : 0
SRWD : 0
00000000 00000000 00000000 00
Erasing: [==================================================] 100.00%
Done
Writing: [==================================================] 100.00%
Done
$ sudo chmod 666 /dev/ttyUSB*
$ litex_term --serial-boot --images ~/TangNano-20K-example/linux/image5/boot.json /dev/ttyUSB1
litex> reboot
__ _ __ _ __
/ / (_) /____ | |/_/
/ /__/ / __/ -_)> <
/____/_/\__/\__/_/|_|
Build your hardware, easily!
(c) Copyright 2012-2023 Enjoy-Digital
(c) Copyright 2007-2015 M-Labs
BIOS CRC passed (5386dd7d)
LiteX git sha1: 36ce71d5
--=============== SoC ==================--
CPU: VexRiscv SMP-LINUX @ 48MHz
BUS: WISHBONE 32-bit @ 4GiB
CSR: 32-bit data
ROM: 64.0KiB
SRAM: 6.0KiB
L2: 128B
SDRAM: 8.0MiB 32-bit @ 48MT/s (CL-2 CWL-2)
MAIN-RAM: 8.0MiB
--========== Initialization ============--
Initializing SDRAM @0x40000000...
Switching SDRAM to software control.
Switching SDRAM to hardware control.
Memtest at 0x40000000 (2.0MiB)...
Write: 0x40000000-0x40200000 2.0MiB
Read: 0x40000000-0x40200000 2.0MiB
Memtest OK
Memspeed at 0x40000000 (Sequential, 2.0MiB)...
Write speed: 18.9MiB/s
Read speed: 21.9MiB/s
--============== Boot ==================--
Booting from serial...
Press Q or ESC to abort boot completely.
sL5DdSMmkekro
[LITEX-TERM] Received firmware download request from the device.
[LITEX-TERM] Uploading /home/nohara/TangNano-20K-example/linux/image5/Image to 0x40000000 (7726264 bytes)...
[LITEX-TERM] Upload calibration... (inter-frame: 10.00us, length: 64)
[LITEX-TERM] Upload complete (9.9KB/s).
[LITEX-TERM] Uploading /home/nohara/TangNano-20K-example/linux/image5/sipeed_tang_nano_20k.dtb to 0x40ef0000 (2115 bytes)...
[LITEX-TERM] Upload calibration... (inter-frame: 10.00us, length: 64)
[LITEX-TERM] Got unexpected response from device 'b'E''
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Reactions: 1
- Comments: 34 (2 by maintainers)
Thanks bro @avkghost,now i boot linux on my fpga board successfully.
Update:
@nohahanon FYI
I’ve successfully run linux on a Tang Nano 20k with the kernel provided in a TangNano-20K-example repository.
I use the linux-on-litex-vexriscv with following parameters/flags:
There is a boot log
At the moment I’m going to experiment with a Linux kernel (reduce size and remove unneeded modules/subsystems).
@Icenowy Could Jisheng Zhang help us with a kernel configuration for the board?
Hello @nohahanon,
I’ve seen the link you provided, thanks! However, I had neither found a solution for the Linux kernel configuration, nor a solution for litex for a board configuration. So, the example contains information about Tang Primer which has a different FPGA (Anlogic instead of Gowin). In addition, the example shows that an author can create a multicore VexRiscv bitstream and program the FPGA with it.
As I investigated the readme from TangNano-20K-example I’ve found that the Linux kernel, device tree, and boot loader provided by Icenowy. I’m going to ask her for details about the kernel configuration.
So, I’m going to create a debug version of a VexRiscv to debug the booting process. First of all, it would help me to understand a configuration difference between my own and @Icenowy 's.
Update:
Hi @nohahanon I have the same problem with booting via serial/sdcard boot.
The short answer: It’s need to create a customized project for small memory boards.
TL;DR
I've found that the build system generated an incorrect device tree and system configuration. The board has only 8 MB of SDRAM, as shown during self-diagnosis, but the addresses generated in the device tree and the base address for opensbi are incorrect and lie beyond the 8 MB limit. The address 0x40f00000 corresponds to 15 MB. You can try to read addresses 0x4000000 and 0x40f00000 via mem_read and got different results for a first and a second address (second is incorrect address for the device).make.py
part of device tree generated by make.py
boot.json
A tang nano 20k linux example
part of device tree from project contains right adresses in memory below 8 MB limit
boot.json
The problem is in a litex/soc/cores/cpu/vexriscv_smp/core.py
My suggestions:
@nohahanon Below is an archive with my experiments. nano_examples.zip It is possible to boot them via serial or SD card.
The SD card needs to be partitioned into 2 or 3 partitions.
A command line from the device tree sets mmcblk0p2 as the root partition. The root partition I extracted from root.cpio.
The kernel provided in the Tang Nano example did not have drivers for MMC, block devices, partition schemes, and file systems. It is impossible to mount any filesystem under the example’s kernel. It is built as an experiment to show the possibility of running Linux on the board.
Now, I have no idea where I can use this configuration. In other words, I don’t see any practical use for this configuration in my projects. In my opinion, there is the best way to use this board with bare metal OS, like FreeRTOS, etc, because in this case, Linux is an overhead for the board. For me, it is interesting in the case of porting/running Linux to embedding systems with an architecture different than x86.
If you need to build and run your own program on a device I recommend you start with litex_bare_metal_demo Build your own demo and run it on the board. For example:
litex_bare_metal_demo --with-cxx --build-path build/sipeed_tang_nano_20kin a directory contains build result. It creates a demo that you can run on a devicelitex_term --kernel demo/demo.binand see how it works.Hope you find it helpful.
@nohahanon Initially, I had a problem creating images with build root. For now, I’ve successfully built it but I need to tune the size due to an out-of-memory error while Linux loading.
I prefer to use separate kernel configurations to minimize its footprint. I cloned the litex-linux repo and checked out 6.1.0 branch, and used the config provided above to build the kernel image.
To cross-compile build the kernel I used the following command.
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu-Below, is a device tree I’ve used dt_nano_20k.zip
@nohahanon I’ve successfully booted from SDCard and added SDCard support to the kernel. As a root.cpio I continue using the old one from the example above. However, I’ve successfully built root.cpio with a buildroot, but not used it due to a big footprint and out-of-memory while booting.
A linux.config
Boot log
@nohahanon
linux.config
An
"Emit compressed instructions when building Linux"option is CONFIG_RISCV_ISA_C=yYes, it disables SMP.
Disable networking CONFIG_NET=n or remove it.
So close, but mine is 2993104 bytes.
root.cpio
I used binwalk to extrat root.cpio from the example’s kernel.
binwalk -e Image. An extracted cpio was placed in _Image.extracted directory.offtopic
I had not used buildroot for some reasons:
make configormake menuconfiggives me a fine kernel tuning.*** No C library enabled, this is not possible.. Stop.Maybe it depens on some addition parts like compiler I don’t know. I have a riscv coross-compiler + binutils installed from apt.@nohahanon Another small update I successfully booted up my own custom-built environment.
boot.json
device tree
boot log
@nohahanon Small update Below is my result of the kernel compilation and execution. I removed SMP, networking, and all compressions instead of GZIP. Enabled “Emit compressed instructions when building Linux” in the kernel config.
I had not used any additional scripts or ran make from buildroot. I’ve created a test build aiming to minimize the kernel.
Please pay attention to the addresses I used in boot.json. Unfortunately, the kernel did not boot properly. I’ve only created a kernel, not rootfs cpio and integrated it into the Image.
Boot log
@Dolu1990 Could I ask you for help with kernel debugging? Maybe I removed something important from the kernel configuration or did something wrong. Thanks.
@nohahanon As I wrote before, you are still using an incorrect memory map in a bootloader. Maybe you using the wrong address for opensbi/fw_jump for building and/or loading. The second possible problem I see is disabling verification during load into RAM. Your log file leds that rv32.dtb at 0x40ef0000, rootfs.cpio at 0x41000000, and placed at an unreachable memory region. On a Tang Nano 20k is possible to access the memory region from address 0x40000000 to 0x40800000 (default and your variant). All your code/data needs to be placed in this region. For example, the original kernel+root.cpio, opensbi.bin.tangnano20k, and device tree are placed below the memory limit (0x40800000).
All addresses below the memory limit are included in the original example. Please pay attention to the addresses provided below.
So, I also booted Tang Nano 20k from SDCard.
A boot log from SDCard
To reduce the memory footprint for the kernel try to use
make tinyconfigand then add the needed options. For buildroot I recommend using uclibc instead of glibc to reduce the memory footprint.@peiceliu I’ve successfully loaded Tang Primer 20k with Linux. So, I restored my board under the windows (using Gowin programmer). The second problem was with a bitstream. I was not able to program it with openFPGALoader. In some cases, the upload was freezing while flashing. When the bitstream uploaded successfully and FPGA was re-booted it did not start a Litex BIOS.
There is a step-by-step solution that I used for my own board, please take a look below.
There is my boot log
I would say running it in a simulation would give full visibility on what the CPU does, that’s the way in generaly always go.
Else there is the possibility to use the JTAG debug, and since recently you can even use the official RISC-V debug spec, which support linux kernel debugging aswell 😃
Hi @Icenowy.
Thanks for joining our discussion.
There are my experiments with litex-boards and linux-on-litex-vexriscv.
litex-boards
It produces csr.csv
make.py from linux-on-litex-vexriscv
produces following csr.csv
Could you please answer a few questions? See below.
Thanks for the advice.
Enabline RVC compressed instruction may help reaching it (need to be enable on both litex arguments and linux / busybody. Generaly, it reduce the kernel about 30 %