Problem in spike bbl vmlinux

This is Poorvaja Bhaskaran, I have cross compiled the riscv using freedom-u-sdk but i have a problem to configure spike and boot my linux using the command “spike bbl vmlinux”. Can anyone guide me?

Try typing “make sim” in the freedom-u-sdk top level dir. It will build everything you need and then boot the kernel in spike.
If that doesn’t work, then you need to be more specific about what problem you are running into.

Thank you for responding immediately. But I came across some issue :

/usr/src/freedom-u-sdk/work/riscv-pk/bbl
terminate called after throwing an instance of 'std::runtime_error’
what(): couldn’t allocate 2147483648 bytes of target memory
make: *** [sim] Aborted

Could you please tell me on how to over come this error?

I got it working now. Thanking you all for your immense pleasure.

I haven’t seen that problem before. Is this unmodified freedom-u-sdk sources, built using the default arch and isa? It should just work.

I did find a similar question on stack overflow
https://stackoverflow.com/questions/45408760/terminated-called-after-throwing-an-instance-of-stdruntime-error
Maybe you just need more free memory available for the process. Looks like it needs 2GB of memory. If the “free” command reports less than 2GB of memory available, then it won’t run. Adding swap space could fix this. Also make sure that you don’t have per process limits that could be a problem. In bash, “ulimit -a” will show you your process limits. For instance, I can reproduce your error message if I do “ulimit -v 1000000” to reduce per process virtual memory to 1GB.

If you are on a 32-bit linux system, that might be a problem. This may require a 64-bit linux system as host so you can access enough memory for it to run.

Thank you for your response. My Buildroot started working now. But I am having a doubt in how to progress further. Could you tell me on how to proceed further :

/usr/src/freedom-u-sdk/work/riscv-isa-sim/prefix/bin/spike --isa=rv64imafdc -p4 /usr/src/freedom-u-sdk/work/riscv-pk/bbl

            SIFIVE, INC.

     5555555555555555555555555
    5555                   5555
   5555                     5555
  5555                       5555
 5555       5555555555555555555555
5555       555555555555555555555555

5555 5555
5555 5555
5555 5555
5555555555555555555555555555 55555
55555 555555555 55555
55555 55555 55555
55555 5 55555
55555 55555
55555 55555
55555 55555
55555 55555
55555 55555
555555555
55555
5

       SiFive RISC-V Coreplex

[ 0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[ 0.000000] Linux version 4.14.0-00030-gc2d852c (root@poorvi-Lenovo-B460e) (gcc version 7.2.0 (GCC)) #1 SMP Sat Dec 30 02:59:16 IST 2017
[ 0.000000] bootconsole [early0] enabled
[ 0.000000] Initial ramdisk at: 0xffffffe00001e200 (5672960 bytes)
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x0000000080200000-0x00000000ffffffff]
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000080200000-0x00000000ffffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x00000000ffffffff]
[ 0.000000] elf_hwcap is 0x112d
[ 0.000000] percpu: Embedded 14 pages/cpu @ffffffe07e1c3000 s28376 r0 d28968 u57344
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 516615
[ 0.000000] Kernel command line: earlyprintk
[ 0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[ 0.000000] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes)
[ 0.000000] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes)
[ 0.000000] Sorting __ex_table…
[ 0.000000] Memory: 2052788K/2095104K available (2826K kernel code, 238K rwdata, 744K rodata, 5695K init, 774K bss, 42316K reserved, 0K cma-reserved)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[ 0.000000] Hierarchical RCU implementation.
[ 0.000000] RCU event tracing is enabled.
[ 0.000000] RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
[ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[ 0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
[ 0.000000] riscv,cpu_intc,0: 64 local interrupts mapped
[ 0.000000] riscv,cpu_intc,1: 64 local interrupts mapped
[ 0.000000] riscv,cpu_intc,2: 64 local interrupts mapped
[ 0.000000] riscv,cpu_intc,3: 64 local interrupts mapped
[ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns
[ 0.000000] console [hvc0] enabled
[ 0.000000] console [hvc0] enabled
[ 0.000000] bootconsole [early0] disabled
[ 0.000000] bootconsole [early0] disabled
[ 0.000000] Calibrating delay loop (skipped), value calculated using timer frequency… 20.00 BogoMIPS (lpj=100000)
[ 0.000000] pid_max: default: 32768 minimum: 301
[ 0.000000] Mount-cache hash table entries: 4096 (order: 3, 32768 bytes)
[ 0.000000] Mountpoint-cache hash table entries: 4096 (order: 3, 32768 bytes)
[ 0.000000] Hierarchical SRCU implementation.
[ 0.000000] smp: Bringing up secondary CPUs …
[ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns
[ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns
[ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns
[ 0.000000] smp: Brought up 1 node, 4 CPUs
[ 0.010000] devtmpfs: initialized
[ 0.010000] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.010000] futex hash table entries: 1024 (order: 4, 65536 bytes)
[ 0.010000] random: get_random_u32 called from bucket_table_alloc+0xe6/0x276 with crng_init=0
[ 0.010000] NET: Registered protocol family 16
[ 0.010000] vgaarb: loaded
[ 0.010000] SCSI subsystem initialized
[ 0.010000] usbcore: registered new interface driver usbfs
[ 0.020000] usbcore: registered new interface driver hub
[ 0.020000] usbcore: registered new device driver usb
[ 0.020000] pps_core: LinuxPPS API ver. 1 registered
[ 0.020000] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti giometti@linux.it
[ 0.020000] PTP clock support registered
[ 0.020000] clocksource: Switched to clocksource riscv_clocksource
[ 0.020000] NET: Registered protocol family 2
[ 0.020000] TCP established hash table entries: 16384 (order: 5, 131072 bytes)
[ 0.020000] TCP bind hash table entries: 16384 (order: 6, 262144 bytes)
[ 0.020000] TCP: Hash tables configured (established 16384 bind 16384)
[ 0.020000] UDP hash table entries: 1024 (order: 3, 32768 bytes)
[ 0.020000] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes)
[ 0.030000] NET: Registered protocol family 1
[ 0.040000] Unpacking initramfs…
[ 0.050000] workingset: timestamp_bits=62 max_order=19 bucket_order=0
[ 0.060000] random: fast init done
[ 0.070000] jitterentropy: Initialization failed with host not compliant with requirements: 2
[ 0.070000] io scheduler noop registered
[ 0.070000] io scheduler cfq registered (default)
[ 0.070000] io scheduler mq-deadline registered
[ 0.070000] io scheduler kyber registered
[ 0.110000] e1000e: Intel® PRO/1000 Network Driver - 3.2.6-k
[ 0.110000] e1000e: Copyright© 1999 - 2015 Intel Corporation.
[ 0.110000] ehci_hcd: USB 2.0 ‘Enhanced’ Host Controller (EHCI) Driver
[ 0.110000] ehci-pci: EHCI PCI platform driver
[ 0.110000] usbcore: registered new interface driver usb-storage
[ 0.110000] IR NEC protocol handler initialized
[ 0.120000] IR RC5(x/sz) protocol handler initialized
[ 0.120000] IR RC6 protocol handler initialized
[ 0.120000] IR JVC protocol handler initialized
[ 0.120000] IR Sony protocol handler initialized
[ 0.120000] IR SANYO protocol handler initialized
[ 0.120000] IR Sharp protocol handler initialized
[ 0.120000] IR MCE Keyboard/mouse protocol handler initialized
[ 0.120000] IR XMP protocol handler initialized
[ 0.120000] usbcore: registered new interface driver usbhid
[ 0.120000] usbhid: USB HID core driver
[ 0.120000] NET: Registered protocol family 17
[ 0.120000] Freeing unused kernel memory: 5692K
[ 0.120000] This architecture does not have kernel memory protection.
Starting logging: OK
Starting mdev…
modprobe: can’t change directory to ‘/lib/modules’: No such file or directory
Initializing random number generator… done.
Starting network…
Waiting for interface eth0 to appear… timeout!
run-parts: /etc/network/if-pre-up.d/wait_iface: exit status 1
Starting dropbear sshd: OK

Welcome to Buildroot
buildroot login: root
root
Password: sifive

I am able to run my shell commands here. Could you also explain on how it works?

What you do next depends on what you want to do. Booting to a shell with busybox/dropbear is all that freedom-u-sdk does.

I’m not an OS guy so I don’t know how all of this works. But the question is a little ambiguous. Which part do you want explained? Explaining how the linux kernel works for instance could take a few years. There are plenty of online references to this stuff though. Do web searches for busybox, dropbear, embedded linux development, etc.

Thank you for your kind response. I just want to know whether I have ported my linux kernel to risc-v through cross compilation correctly. How can I invoke spike to boot the vmlinux by “spike bbl vmlinux”? Because this is the first time I am learning RISC-V ISA and keenly interested in working with it.