Board:emulation/spike-riscv: Difference between revisions

From coreboot
Jump to navigation Jump to search
(Replace the boot log with a newer one.)
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
[https://riscv.org/software-tools/risc-v-isa-simulator/ SPIKE] is [https://riscv.org/ RISC-V]'s primary emulator. The Spike support in coreboot is mostly being developed by [[User:Jn|jn]] as part of his GSoC 2016.
[https://riscv.org/software-tools/risc-v-isa-simulator/ SPIKE] is [https://riscv.org/ RISC-V]'s primary emulator. The Spike support in coreboot is maintained by Ron Minnich and [[User:Jn|jn]].


=Build instructions=
=Build instructions=


These instructions may easily become out of date as coreboot or RISC-V moves forward. If that happens, please complain on the [[Talk:Board:emulation/spike-riscv|discussion page]] or IRC (or just fix it).
These instructions may easily become out of date as coreboot or RISC-V moves forward. If that happens, please complain on the [[Talk:Board:emulation/spike-riscv|discussion page]] or IRC (or just fix it).
The instructions are also not yet complete.


==Building the toolchain==
==Building the toolchain==
Line 11: Line 9:
* clone the coreboot git repository
* clone the coreboot git repository
* download and apply the following patches:
* download and apply the following patches:
** [https://review.coreboot.org/#/c/14604/| 14604: xcompile: rename riscv to riscv64]
** [https://review.coreboot.org/#/c/14604/11 14604: buildgcc: Update to GCC 6.1.0, and binutils riscv update (version 11)].
** [https://review.coreboot.org/#/c/14257/| 14257: buildgcc: Update to GCC 6.1.0, and binutils riscv update].
* run <code>make crossgcc-riscv</code> and a have a cup of $BEVERAGE
* run <code>make crossgcc-riscv</code> and a have a cup of $BEVERAGE


Line 20: Line 17:
* download and apply [https://github.com/neuschaefer/riscv-isa-sim/commit/664118976cd487c9dec8cc6b5b3b9d52bd3f861c this patch that implements an 8250 UART]
* download and apply [https://github.com/neuschaefer/riscv-isa-sim/commit/664118976cd487c9dec8cc6b5b3b9d52bd3f861c this patch that implements an 8250 UART]
* TODO: fesvr: patch device_list_t::handle_command to ignore HTIF writes
* TODO: fesvr: patch device_list_t::handle_command to ignore HTIF writes
* TODO: running make
* Edit riscv/processor.cc, processor_t::get_csr(), and add "case CSR_TIME: return 0;"
 
* run make
==Building coreboot without a payload==
 
* You need the following patches:
** [https://review.coreboot.org/#/c/15290/| 15290: change all eret instructions to mret]
** [https://review.coreboot.org/#/c/15289/| 15289: Remove HTIF and SBI related code]
** [https://review.coreboot.org/#/c/15288/| 15288: Provide a tohost symbol so Spike doesn't hang]
** [https://review.coreboot.org/#/c/15284/| 15284: Move CBMEM into RAM]
* run <code>make menuconfig</code> and select <tt>Emulation</tt>/<tt>SPIKE ucb riscv</tt> from the Mainboard menu
* run <code>make</code>
* run <code>util/riscvtools/make-spike-elf.sh build/coreboot.rom build/coreboot.elf</code> to create an ELF file (spike can only load ELF files)
* run <code>spike build/coreboot.elf</code>
 
For general spike usage, look at [https://github.com/riscv/riscv-isa-sim/ its GitHub page].


==Building Linux==
==Building Linux==
Line 45: Line 29:
* <code>make ARCH=riscv</code>
* <code>make ARCH=riscv</code>


==Building bbl==
==Building coreboot==
 
* TODO: libc stuff
* TODO: payload linker script foo
* TODO: patching the console output handler
* mkdir build
* cd build; ../configure --with-payload=path/to/vmlinux CC=path/to/riscv64-unknown-elf-gcc LD=path/to/riscv64-unknown-elf-ld
* make
 
==Building coreboot with bbl==


* apply the same coreboot patches as above, and select <tt>Emulation</tt>/<tt>Spike ucb riscv</tt>
* select <tt>Emulation</tt>/<tt>Spike ucb riscv</tt>
* in the Payload menu of <code>menuconfig</code>, select "ELF Payload" and enter the path to the bbl binary
* in the Payload menu of <code>menuconfig</code>, select "ELF Payload" and enter the path to the vmlinux binary
* run <code>make</code> and the <code>make-spike-elf.sh</code> script as described above
* run <code>make</code> and the <code>make-spike-elf.sh</code> script as described above


===boot log===
For general spike usage, look at [https://github.com/riscv/riscv-isa-sim/ its GitHub page].


<code>
=Boot log=
we don't have virtual memory...
?


coreboot-4.4-652-gbfb3fee Thu Jun 30 01:03:13 UTC 2016 bootblock starting...
Boot log of coreboot/linux booting. I included bash in the initrd.
CBFS @ 20100 size 3dff00
CBFS: 'Master Header Locator' located CBFS at [20100:400000)
CBFS: Locating 'fallback/romstage'
CBFS: Checking offset 0
CBFS: File @ offset 0 size 20
CBFS:  Unmatched 'cbfs master header' at 0
CBFS: Checking offset 80
CBFS: File @ offset 80 size 2d17
CBFS: Found @ offset 80 size 2d17
?


coreboot-4.4-652-gbfb3fee Thu Jun 30 01:03:13 UTC 2016 romstage starting...
CBFS @ 20100 size 3dff00
CBFS: 'Master Header Locator' located CBFS at [20100:400000)
coreboot-4.5-320-g2e525bf Fri Nov 18 13:29:36 UTC 2016 bootblock starting...
CBFS: Locating 'fallback/ramstage'
CBFS @ 20100 size 7dff00
CBFS: Checking offset 0
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
CBFS: File @ offset 0 size 20
CBFS: Locating 'fallback/romstage'
CBFSUnmatched 'cbfs master header' at 0
CBFS: Found @ offset 80 size 3013
CBFS: Checking offset 80
CBFS: File @ offset 80 size 2d17
CBFS: Unmatched 'fallback/romstage' at 80
coreboot-4.5-320-g2e525bf Fri Nov 18 13:29:36 UTC 2016 romstage starting...
CBFS: Checking offset 2e00
  0x40000000 bytes of memory at 0x80000000
CBFS: File @ offset 2e00 size 4ed7
CBFS @ 20100 size 7dff00
CBFS: Found @ offset 2e00 size 4ed7
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
?
CBFS: Locating 'fallback/ramstage'
 
CBFS: Found @ offset 3100 size 5403
coreboot-4.4-652-gbfb3fee Thu Jun 30 01:03:13 UTC 2016 ramstage starting...
Enumerating buses...
Show all devs... Before device enumeration.
coreboot-4.5-320-g2e525bf Fri Nov 18 13:29:36 UTC 2016 ramstage starting...
Root Device: enabled 1
BS: Entering BS_PRE_DEVICE state.
CPU_CLUSTER: 0: enabled 1
BS: Exiting BS_PRE_DEVICE state.
I2C: 00:06: enabled 1
----------------------------------------
Compare with tree...
BS: Entering BS_DEV_INIT_CHIPS state.
Root Device: enabled 1
BS: Exiting BS_DEV_INIT_CHIPS state.
----------------------------------------
BS: Entering BS_DEV_ENUMERATE state.
Enumerating buses...
Show all devs... Before device enumeration.
Root Device: enabled 1
CPU_CLUSTER: 0: enabled 1
I2C: 00:06: enabled 1
Compare with tree...
Root Device: enabled 1
  CPU_CLUSTER: 0: enabled 1
  I2C: 00:06: enabled 1
CBMEM:
IMD: root @ 00000000bffff000 254 entries.
IMD: root @ 00000000bfffec00 62 entries.
Root Device scanning...
root_dev_scan_bus for Root Device
CPU_CLUSTER: 0 enabled
I2C: 00:06 enabled
root_dev_scan_bus for Root Device done
scan_bus: scanning of bus Root Device took 0 usecs
done
BS: Exiting BS_DEV_ENUMERATE state.
----------------------------------------
BS: Entering BS_DEV_RESOURCES state.
Allocating resources...
Reading resources...
Root Device read_resources bus 0 link: 0
CPU_CLUSTER: 0 missing read_resources
I2C: 00:06 missing read_resources
Root Device read_resources bus 0 link: 0 done
Done reading resources.
Show resources in subtree (Root Device)...After reading.
  Root Device child on link 0 CPU_CLUSTER: 0
  Root Device resource base 80000000 size 40000000 align 0 gran 0 limit 0 flags e0004200 index 0
  CPU_CLUSTER: 0
  I2C: 00:06
Setting resources...
Root Device assign_resources, bus 0 link: 0
Root Device assign_resources, bus 0 link: 0
Done setting resources.
Show resources in subtree (Root Device)...After assigning values.
  Root Device child on link 0 CPU_CLUSTER: 0
  Root Device resource base 80000000 size 40000000 align 0 gran 0 limit 0 flags e0004200 index 0
  CPU_CLUSTER: 0
  I2C: 00:06
Done allocating resources.
BS: Exiting BS_DEV_RESOURCES state.
----------------------------------------
BS: Entering BS_DEV_ENABLE state.
Enabling resources...
done.
BS: Exiting BS_DEV_ENABLE state.
----------------------------------------
BS: Entering BS_DEV_INIT state.
Initializing devices...
Root Device init ...
Devices initialized
Show all devs... After init.
Root Device: enabled 1
  CPU_CLUSTER: 0: enabled 1
  CPU_CLUSTER: 0: enabled 1
  I2C: 00:06: enabled 1
  I2C: 00:06: enabled 1
memalign Enter, boundary 8, size 3584, free_mem_ptr 0000000080840c18
BS: Exiting BS_DEV_INIT state.
memalign 0000000080840c18
BS: callback (000000008083e308) @ src/vboot/bootmode.c:68.
CBMEM:
----------------------------------------
IMD: root @ 00000000bffff000 254 entries.
BS: Entering BS_POST_DEVICE state.
IMD: root @ 00000000bfffec00 62 entries.
Finalize devices...
Root Device scanning...
Devices finalized
root_dev_scan_bus for Root Device
BS: Exiting BS_POST_DEVICE state.
CPU_CLUSTER: 0 enabled
----------------------------------------
I2C: 00:06 enabled
  BS: Entering BS_OS_RESUME_CHECK state.
root_dev_scan_bus for Root Device done
BS: Exiting BS_OS_RESUME_CHECK state.
scan_bus: scanning of bus Root Device took 0 usecs
----------------------------------------
done
BS: Entering BS_WRITE_TABLES state.
Allocating resources...
  Writing coreboot table at 0xbffdc000
Reading resources...
  0. 0000000080000000-00000000bffdbfff: RAM
Root Device read_resources bus 0 link: 0
   1. 00000000bffdc000-00000000bfffffff: CONFIGURATION TABLES
CPU_CLUSTER: 0 missing read_resources
CBFS @ 20100 size 7dff00
I2C: 00:06 missing read_resources
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
Root Device read_resources bus 0 link: 0 done
FMAP: Found "FLASH" version 1.1 at 20000.
Done reading resources.
FMAP: base = 0 size = 800000 #areas = 4
Show resources in subtree (Root Device)...After reading.
Wrote coreboot table at: 00000000bffdc000, 0x150 bytes, checksum d4c8
Root Device child on link 0 CPU_CLUSTER: 0
coreboot table: 360 bytes.
  Root Device resource base 80000000 size 40000000 align 0 gran 0 limit 0 flags e0004200 index 0
  IMD ROOT    0. 00000000bffff000 00001000
  CPU_CLUSTER: 0
  IMD SMALL  1. 00000000bfffe000 00001000
  I2C: 00:06
CONSOLE    2. 00000000bffde000 00020000
Setting resources...
COREBOOT    3. 00000000bffdc000 00002000
Root Device assign_resources, bus 0 link: 0
IMD small region:
Root Device assign_resources, bus 0 link: 0
  IMD ROOT    0. 00000000bfffec00 00000400
Done setting resources.
BS: Exiting BS_WRITE_TABLES state.
Show resources in subtree (Root Device)...After assigning values.
----------------------------------------
  Root Device child on link 0 CPU_CLUSTER: 0
BS: Entering BS_PAYLOAD_LOAD state.
Root Device resource base 80000000 size 40000000 align 0 gran 0 limit 0 flags e0004200 index 0
CBFS @ 20100 size 7dff00
  CPU_CLUSTER: 0
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
   I2C: 00:06
CBFS: Locating 'fallback/payload'
Done allocating resources.
CBFS: Found @ offset 8900 size 34081c
Enabling resources...
  Loading segment from ROM address 0x0000000080028a38
done.
  code (compression=0)
Initializing devices...
  New segment dstaddr 0x81000000 memsize 0x300000 srcaddr 0x80028a8c filesize 0x2ffa78
Root Device init ...
  Loading segment from ROM address 0x0000000080028a54
Devices initialized
  data (compression=0)
Show all devs... After init.
  New segment dstaddr 0x81300000 memsize 0x40d50 srcaddr 0x80328504 filesize 0x40d50
Root Device: enabled 1
  Loading segment from ROM address 0x0000000080028a70
CPU_CLUSTER: 0: enabled 1
  Entry Point 0xffffffff81000000
I2C: 00:06: enabled 1
Loading Segment: addr: 0x0000000081000000 memsz: 0x0000000000300000 filesz: 0x00000000002ffa78
Finalize devices...
lb: [0x0000000080832000, 0x0000000080847170)
Devices finalized
Post relocation: addr: 0x0000000081000000 memsz: 0x0000000000300000 filesz: 0x00000000002ffa78
Writing coreboot table at 0xbffdc000
  it's not compressed!
memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841a18
[ 0x81000000, 812ffa78, 0x81300000) <- 80028a8c
memalign 0000000080841a18
Clearing Segment: addr: 0x00000000812ffa78 memsz: 0x0000000000000588
memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841a38
dest 0000000081000000, end 0000000081300000, bouncebuffer ffffffffffffffff
memalign 0000000080841a38
Loading Segment: addr: 0x0000000081300000 memsz: 0x0000000000040d50 filesz: 0x0000000000040d50
  0. 0000000080000000-00000000bffdbfff: RAM
lb: [0x0000000080832000, 0x0000000080847170)
  1. 00000000bffdc000-00000000bfffffff: CONFIGURATION TABLES
Post relocation: addr: 0x0000000081300000 memsz: 0x0000000000040d50 filesz: 0x0000000000040d50
CBFS @ 20100 size 3dff00
it's not compressed!
CBFS: 'Master Header Locator' located CBFS at [20100:400000)
[ 0x81300000, 81340d50, 0x81340d50) <- 80328504
FMAP: Found "FLASH" version 1.1 at 20000.
dest 0000000081300000, end 0000000081340d50, bouncebuffer ffffffffffffffff
FMAP: base = 0 size = 400000 #areas = 4
Loaded segments
Wrote coreboot table at: 00000000bffdc000, 0x150 bytes, checksum f468
BS: Exiting BS_PAYLOAD_LOAD state.
coreboot table: 360 bytes.
----------------------------------------
IMD ROOT    0. 00000000bffff000 00001000
BS: Entering BS_PAYLOAD_BOOT state.
IMD SMALL  1. 00000000bfffe000 00001000
Jumping to boot code at ffffffff81000000(00000000bffdc000)
CONSOLE    2. 00000000bffde000 00020000
Stack overrun on CPU0 (address 0000000080800000 overwritten). Increase stack from current 4096 bytes
COREBOOT    3. 00000000bffdc000 00002000
ERROR: BUG ENCOUNTERED at file 'src/lib/stack.c', line 40
IMD small region:
Config string: 'platform {
  IMD ROOT    0. 00000000bfffec00 00000400
  vendor ucb;
CBFS @ 20100 size 3dff00
  arch spike;
CBFS: 'Master Header Locator' located CBFS at [20100:400000)
};
CBFS: Locating 'fallback/payload'
rtc {
CBFS: Checking offset 0
  addr 0x40000000;
CBFS: File @ offset 0 size 20
};
CBFS: Unmatched 'cbfs master header' at 0
uart {
CBFS: Checking offset 80
  addr 0x40001000;
CBFS: File @ offset 80 size 2d17
};
CBFS: Unmatched 'fallback/romstage' at 80
ram {
CBFS: Checking offset 2e00
  0 {
CBFS: File @ offset 2e00 size 4ed7
    addr 0x80000000;
CBFS: Unmatched 'fallback/ramstage' at 2e00
    size 0x40000000;
CBFS: Checking offset 7d40
  };
CBFS: File @ offset 7d40 size 114
};
CBFS: Unmatched 'config' at 7d40
core {
CBFS: Checking offset 7ec0
  0 {
CBFS: File @ offset 7ec0 size 239
    0 {
CBFSUnmatched 'revision' at 7ec0
      isa rv64imafdc;
CBFS: Checking offset 8140
      timecmp 0x40000008;
CBFS: File @ offset 8140 size 120258
      ipi 0x40002000;
CBFS: Found @ offset 8140 size 120258
    };
Loading segment from rom address 0x0000000080028278
  };
  code (compression=1)
};
memalign Enter, boundary 8, size 56, free_mem_ptr 0000000080841a58
'
memalign 0000000080841a58
-----------------------------
  New segment dstaddr 0x80000000 memsize 0x7e40 srcaddr 0x800282e8 filesize 0x3525
Virtual memory status enabled
Loading segment from rom address 0x0000000080028294
  -----------------------------
  code (compression=1)
Initializing virtual memory...
memalign Enter, boundary 8, size 56, free_mem_ptr 0000000080841a90
Finished initializing virtual memory
memalign 0000000080841a90
OK, let's go
  New segment dstaddr 0x80008000 memsize 0x1000 srcaddr 0x8002b80d filesize 0x86
Getting hart id...
Loading segment from rom address 0x00000000800282b0
[    0.000000] Linux version 4.6.3-riscv-g1ef29a9 (jn@latitude) (gcc version 6.1.0 (coreboot toolchain v1.44 October 3nd, 2016) ) #144 Fri Nov 25 02:18:13 CET 2016
  data (compression=1)
[    0.000000] bootconsole [early0] enabled
memalign Enter, boundary 8, size 56, free_mem_ptr 0000000080841ac8
Querying memory, CPU #0...
memalign 0000000080841ac8
[    0.000000] Available physical memory: 1008MB
  New segment dstaddr 0x81000000 memsize 0x3314c8 srcaddr 0x8002b893 filesize 0x11cc3d
[    0.000000] Initial ramdisk at: 0xffffffff81013758 (1415600 bytes)
Loading segment from rom address 0x00000000800282cc
[    0.000000] Zone ranges:
  Entry Point 0x0000000080000000
[    0.000000]  Normal  [mem 0x0000000081000000-0x00000000bfffffff]
memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841b00
[    0.000000] Movable zone start for each node
memalign 0000000080841b00
[    0.000000] Early memory node ranges
memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841b20
[    0.000000]  node  0: [mem 0x0000000081000000-0x00000000bfffffff]
memalign 0000000080841b20
[    0.000000] Initmem setup node 0 [mem 0x0000000081000000-0x00000000bfffffff]
memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841b40
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 254520
memalign 0000000080841b40
[    0.000000] Kernel command line: earlyprintk=sbi_console0 keep init=/bin/sh
memalign Enter, boundary 8, size 32, free_mem_ptr 0000000080841b60
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
memalign 0000000080841b60
[    0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes)
Bounce Buffer at 00000000bffb6000, 153648 bytes
[    0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes)
Loading Segment: addr: 0x0000000080000000 memsz: 0x0000000000007e40 filesz: 0x0000000000003525
[    0.000000] Sorting __ex_table...
lb: [0x0000000080832000, 0x0000000080844c18)
[    0.000000] Memory: 1013124K/1032192K available (1317K kernel code, 77K rwdata, 288K rodata, 1464K init, 180K bss, 19068K reserved, 0K cma-reserved)
Post relocation: addr: 0x0000000080000000 memsz: 0x0000000000007e40 filesz: 0x0000000000003525
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
using LZMA
[    0.000000] NR_IRQS:0 nr_irqs:0 0
[ 0x80000000, 80007d7c, 0x80007e40) <- 800282e8
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446 ns
Clearing Segment: addr: 0x0000000080007d7c memsz: 0x00000000000000c4
Setting timer to 0000000000989680 (current time is 0000000000000000)...
dest 0000000080000000, end 0000000080007e40, bouncebuffer bffb6000
mcall_set_timer is currently not implemented, ignoring
Loading Segment: addr: 0x0000000080008000 memsz: 0x0000000000001000 filesz: 0x0000000000000086
[   0.000000] Calibrating delay loop (skipped), value calculated using timer frequency.. 2000.00 BogoMIPS (lpj=10000000)
lb: [0x0000000080832000, 0x0000000080844c18)
[    0.000000] pid_max: default: 32768 minimum: 301
Post relocation: addr: 0x0000000080008000 memsz: 0x0000000000001000 filesz: 0x0000000000000086
[    0.000000] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes)
using LZMA
[    0.000000] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes)
[ 0x80008000, 80009000, 0x80009000) <- 8002b80d
[    0.000000] devtmpfs: initialized
dest 0000000080008000, end 0000000080009000, bouncebuffer bffb6000
[    0.000000] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
Loading Segment: addr: 0x0000000081000000 memsz: 0x00000000003314c8 filesz: 0x000000000011cc3d
[    0.000000] clocksource: Switched to clocksource riscv_clocksource
lb: [0x0000000080832000, 0x0000000080844c18)
[    0.000000] Trying to unpack rootfs image as initramfs...
Post relocation: addr: 0x0000000081000000 memsz: 0x00000000003314c8 filesz: 0x000000000011cc3d
[    0.000000] console [sbi_console0] enabled
using LZMA
[    0.000000] console [sbi_console0] enabled
[ 0x81000000, 813314c8, 0x813314c8) <- 8002b893
[    0.000000] bootconsole [early0] disabled
dest 0000000081000000, end 00000000813314c8, bouncebuffer bffb6000
[   0.000000] bootconsole [early0] disabled
Loaded segments
[    0.000000] futex hash table entries: 256 (order: 0, 6144 bytes)
Jumping to boot code at 0000000080000000(00000000bffdc000)
[    0.000000] io scheduler noop registered
CPU0: stack: 0000000080800000 - 0000000080810000, lowest used address 0000000080800004, stack used: 65532 bytes
[    0.000000] io scheduler cfq registered (default)
handle_command([255,255,80203a00])
[    0.000000] brd: module loaded
              vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
[    0.000000] Freeing unused kernel memory: 1464K (ffffffff81000000 - ffffffff8116e000)
                  vvvvvvvvvvvvvvvvvvvvvvvvvvvv
[    0.000000] This architecture does not have kernel memory protection.
rrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvvvvvv
init: cannot set terminal process group (-1): Inappropriate ioctl for device
rrrrrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvvvv
init: no job control in this shell
rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
init-4.3#
rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvv  
rrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvv   
rr                vvvvvvvvvvvvvvvvvvvvvv     
rr            vvvvvvvvvvvvvvvvvvvvvvvv      rr
rrrr      vvvvvvvvvvvvvvvvvvvvvvvvvv      rrrr
rrrrrr      vvvvvvvvvvvvvvvvvvvvvv      rrrrrr
rrrrrrrr      vvvvvvvvvvvvvvvvvv      rrrrrrrr
rrrrrrrrrr      vvvvvvvvvvvvvv      rrrrrrrrrr
rrrrrrrrrrrr      vvvvvvvvvv      rrrrrrrrrrrr
rrrrrrrrrrrrrr      vvvvvv      rrrrrrrrrrrrrr
rrrrrrrrrrrrrrrr      vv      rrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrr          rrrrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrrrr      rrrrrrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrrrrrr  rrrrrrrrrrrrrrrrrrrrrr
 
      INSTRUCTION SETS WANT TO BE FREE
[    0.000000] Linux version 4.6.3 (jn@latitude) (gcc version 6.1.0 (coreboot toolchain v1.40 May 4th, 2016) ) #1 Sun Jun 26 02:48:43 CEST 2016
[    0.000000] Available physical memory: 2044MB
[    0.000000] Zone ranges:
[    0.000000]   Normal  [mem 0x0000000080200000-0x00000000ffdfffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]  node  0: [mem 0x0000000080200000-0x00000000ffdfffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x00000000ffdfffff]
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 516110
[    0.000000] Kernel command line:  
[    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: 2058448K/2093056K available (1952K kernel code, 104K rwdata, 396K rodata, 64K init, 221K bss, 34608K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS:0 nr_irqs:0 0
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 191126044627 ns
[   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] devtmpfs: initialized
[    0.000000] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.000000] NET: Registered protocol family 16
[    0.000000] clocksource: Switched to clocksource riscv_clocksource
[    0.000000] NET: Registered protocol family 2
[    0.000000] TCP established hash table entries: 16384 (order: 5, 131072 bytes)
[    0.000000] TCP bind hash table entries: 16384 (order: 5, 131072 bytes)
[   0.000000] TCP: Hash tables configured (established 16384 bind 16384)
[    0.000000] UDP hash table entries: 1024 (order: 3, 32768 bytes)
[    0.000000] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes)
[    0.000000] NET: Registered protocol family 1
[    0.010000] console [sbi_console0] enabled
[    0.010000] futex hash table entries: 256 (order: 0, 6144 bytes)
[    0.010000] workingset: timestamp_bits=61 max_order=19 bucket_order=0
[    0.020000] jitterentropy: Initialization failed with host not compliant with requirements: 2
[    0.020000] io scheduler noop registered
[    0.020000] io scheduler cfq registered (default)
[    0.020000] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    0.020000] Please append a correct "root=" boot option; here are the available partitions:
[    0.020000] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    0.020000] CPU: 0 PID: 1 Comm: swapper Not tainted 4.6.3 #1
[    0.020000] Call Trace:
[    0.020000] [<ffffffff80011f5c>] walk_stackframe+0x0/0xc8
[    0.020000] [<ffffffff80053a00>] panic+0xe0/0x1f4
[    0.020000] [<ffffffff8000115c>] mount_block_root+0x234/0x310
[    0.020000] [<ffffffff800013f0>] prepare_namespace+0x138/0x188
[    0.020000] [<ffffffff80000d48>] kernel_init_freeable+0x1b0/0x1e8
[    0.020000] [<ffffffff801f41ac>] rest_init+0x7c/0x80
[    0.020000] [<ffffffff801f41c0>] kernel_init+0x10/0x110
[    0.020000] [<ffffffff801f41ac>] rest_init+0x7c/0x80
[    0.020000] [<ffffffff80010bdc>] ret_from_syscall+0x10/0x14
[    0.020000] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
</code>

Latest revision as of 01:33, 25 November 2016

SPIKE is RISC-V's primary emulator. The Spike support in coreboot is maintained by Ron Minnich and jn.

Build instructions

These instructions may easily become out of date as coreboot or RISC-V moves forward. If that happens, please complain on the discussion page or IRC (or just fix it).

Building the toolchain

Building spike

Building Linux

  • git clone https://github.com/riscv/riscv-linux
  • download linux 4.6.x from kernel.org
  • cd linux-4.6.x/arch; ln -s ../../riscv-linux/arch/riscv .
  • make ARCH=riscv defconfig
  • make ARCH=riscv menuconfig, configure General setup/Cross-compiler tool prefix
  • make ARCH=riscv

Building coreboot

  • select Emulation/Spike ucb riscv
  • in the Payload menu of menuconfig, select "ELF Payload" and enter the path to the vmlinux binary
  • run make and the make-spike-elf.sh script as described above

For general spike usage, look at its GitHub page.

Boot log

Boot log of coreboot/linux booting. I included bash in the initrd.

�

coreboot-4.5-320-g2e525bf Fri Nov 18 13:29:36 UTC 2016 bootblock starting...
CBFS @ 20100 size 7dff00
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
CBFS: Locating 'fallback/romstage'
CBFS: Found @ offset 80 size 3013
�

coreboot-4.5-320-g2e525bf Fri Nov 18 13:29:36 UTC 2016 romstage starting...
0x40000000 bytes of memory at 0x80000000
CBFS @ 20100 size 7dff00
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
CBFS: Locating 'fallback/ramstage'
CBFS: Found @ offset 3100 size 5403
�

coreboot-4.5-320-g2e525bf Fri Nov 18 13:29:36 UTC 2016 ramstage starting...
BS: Entering BS_PRE_DEVICE state.
BS: Exiting BS_PRE_DEVICE state.
----------------------------------------
BS: Entering BS_DEV_INIT_CHIPS state.
BS: Exiting BS_DEV_INIT_CHIPS state.
----------------------------------------
BS: Entering BS_DEV_ENUMERATE state.
Enumerating buses...
Show all devs... Before device enumeration.
Root Device: enabled 1
CPU_CLUSTER: 0: enabled 1
I2C: 00:06: enabled 1
Compare with tree...
Root Device: enabled 1
 CPU_CLUSTER: 0: enabled 1
 I2C: 00:06: enabled 1
CBMEM:
IMD: root @ 00000000bffff000 254 entries.
IMD: root @ 00000000bfffec00 62 entries.
Root Device scanning...
root_dev_scan_bus for Root Device
CPU_CLUSTER: 0 enabled
I2C: 00:06 enabled
root_dev_scan_bus for Root Device done
scan_bus: scanning of bus Root Device took 0 usecs
done
BS: Exiting BS_DEV_ENUMERATE state.
----------------------------------------
BS: Entering BS_DEV_RESOURCES state.
Allocating resources...
Reading resources...
Root Device read_resources bus 0 link: 0
CPU_CLUSTER: 0 missing read_resources
I2C: 00:06 missing read_resources
Root Device read_resources bus 0 link: 0 done
Done reading resources.
Show resources in subtree (Root Device)...After reading.
 Root Device child on link 0 CPU_CLUSTER: 0
 Root Device resource base 80000000 size 40000000 align 0 gran 0 limit 0 flags e0004200 index 0
  CPU_CLUSTER: 0
  I2C: 00:06
Setting resources...
Root Device assign_resources, bus 0 link: 0
Root Device assign_resources, bus 0 link: 0
Done setting resources.
Show resources in subtree (Root Device)...After assigning values.
 Root Device child on link 0 CPU_CLUSTER: 0
 Root Device resource base 80000000 size 40000000 align 0 gran 0 limit 0 flags e0004200 index 0
  CPU_CLUSTER: 0
  I2C: 00:06
Done allocating resources.
BS: Exiting BS_DEV_RESOURCES state.
----------------------------------------
BS: Entering BS_DEV_ENABLE state.
Enabling resources...
done.
BS: Exiting BS_DEV_ENABLE state.
----------------------------------------
BS: Entering BS_DEV_INIT state.
Initializing devices...
Root Device init ...
Devices initialized
Show all devs... After init.
Root Device: enabled 1
CPU_CLUSTER: 0: enabled 1
I2C: 00:06: enabled 1
BS: Exiting BS_DEV_INIT state.
BS: callback (000000008083e308) @ src/vboot/bootmode.c:68.
----------------------------------------
BS: Entering BS_POST_DEVICE state.
Finalize devices...
Devices finalized
BS: Exiting BS_POST_DEVICE state.
----------------------------------------
BS: Entering BS_OS_RESUME_CHECK state.
BS: Exiting BS_OS_RESUME_CHECK state.
----------------------------------------
BS: Entering BS_WRITE_TABLES state.
Writing coreboot table at 0xbffdc000
 0. 0000000080000000-00000000bffdbfff: RAM
 1. 00000000bffdc000-00000000bfffffff: CONFIGURATION TABLES
CBFS @ 20100 size 7dff00
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
FMAP: Found "FLASH" version 1.1 at 20000.
FMAP: base = 0 size = 800000 #areas = 4
Wrote coreboot table at: 00000000bffdc000, 0x150 bytes, checksum d4c8
coreboot table: 360 bytes.
IMD ROOT    0. 00000000bffff000 00001000
IMD SMALL   1. 00000000bfffe000 00001000
CONSOLE     2. 00000000bffde000 00020000
COREBOOT    3. 00000000bffdc000 00002000
IMD small region:
  IMD ROOT    0. 00000000bfffec00 00000400
BS: Exiting BS_WRITE_TABLES state.
----------------------------------------
BS: Entering BS_PAYLOAD_LOAD state.
CBFS @ 20100 size 7dff00
CBFS: 'Master Header Locator' located CBFS at [20100:800000)
CBFS: Locating 'fallback/payload'
CBFS: Found @ offset 8900 size 34081c
Loading segment from ROM address 0x0000000080028a38
  code (compression=0)
  New segment dstaddr 0x81000000 memsize 0x300000 srcaddr 0x80028a8c filesize 0x2ffa78
Loading segment from ROM address 0x0000000080028a54
  data (compression=0)
  New segment dstaddr 0x81300000 memsize 0x40d50 srcaddr 0x80328504 filesize 0x40d50
Loading segment from ROM address 0x0000000080028a70
  Entry Point 0xffffffff81000000
Loading Segment: addr: 0x0000000081000000 memsz: 0x0000000000300000 filesz: 0x00000000002ffa78
lb: [0x0000000080832000, 0x0000000080847170)
Post relocation: addr: 0x0000000081000000 memsz: 0x0000000000300000 filesz: 0x00000000002ffa78
it's not compressed!
[ 0x81000000, 812ffa78, 0x81300000) <- 80028a8c
Clearing Segment: addr: 0x00000000812ffa78 memsz: 0x0000000000000588
dest 0000000081000000, end 0000000081300000, bouncebuffer ffffffffffffffff
Loading Segment: addr: 0x0000000081300000 memsz: 0x0000000000040d50 filesz: 0x0000000000040d50
lb: [0x0000000080832000, 0x0000000080847170)
Post relocation: addr: 0x0000000081300000 memsz: 0x0000000000040d50 filesz: 0x0000000000040d50
it's not compressed!
[ 0x81300000, 81340d50, 0x81340d50) <- 80328504
dest 0000000081300000, end 0000000081340d50, bouncebuffer ffffffffffffffff
Loaded segments
BS: Exiting BS_PAYLOAD_LOAD state.
----------------------------------------
BS: Entering BS_PAYLOAD_BOOT state.
Jumping to boot code at ffffffff81000000(00000000bffdc000)
Stack overrun on CPU0 (address 0000000080800000 overwritten). Increase stack from current 4096 bytes
ERROR: BUG ENCOUNTERED at file 'src/lib/stack.c', line 40
Config string: 'platform {
  vendor ucb;
  arch spike;
};
rtc {
  addr 0x40000000;
};
uart {
  addr 0x40001000;
};
ram {
  0 {
    addr 0x80000000;
    size 0x40000000;
  };
};
core {
  0 {
    0 {
      isa rv64imafdc;
      timecmp 0x40000008;
      ipi 0x40002000;
    };
  };
};
'
-----------------------------
Virtual memory status enabled
-----------------------------
Initializing virtual memory...
Finished initializing virtual memory
OK, let's go
Getting hart id...
[    0.000000] Linux version 4.6.3-riscv-g1ef29a9 (jn@latitude) (gcc version 6.1.0 (coreboot toolchain v1.44 October 3nd, 2016) ) #144 Fri Nov 25 02:18:13 CET 2016
[    0.000000] bootconsole [early0] enabled
Querying memory, CPU #0...
[    0.000000] Available physical memory: 1008MB
[    0.000000] Initial ramdisk at: 0xffffffff81013758 (1415600 bytes)
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000081000000-0x00000000bfffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000081000000-0x00000000bfffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000081000000-0x00000000bfffffff]
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 254520
[    0.000000] Kernel command line: earlyprintk=sbi_console0 keep init=/bin/sh
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes)
[    0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes)
[    0.000000] Sorting __ex_table...
[    0.000000] Memory: 1013124K/1032192K available (1317K kernel code, 77K rwdata, 288K rodata, 1464K init, 180K bss, 19068K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS:0 nr_irqs:0 0
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446 ns
Setting timer to 0000000000989680 (current time is 0000000000000000)...
mcall_set_timer is currently not implemented, ignoring
[    0.000000] Calibrating delay loop (skipped), value calculated using timer frequency.. 2000.00 BogoMIPS (lpj=10000000)
[    0.000000] pid_max: default: 32768 minimum: 301
[    0.000000] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes)
[    0.000000] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes)
[    0.000000] devtmpfs: initialized
[    0.000000] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.000000] clocksource: Switched to clocksource riscv_clocksource
[    0.000000] Trying to unpack rootfs image as initramfs...
[    0.000000] console [sbi_console0] enabled
[    0.000000] console [sbi_console0] enabled
[    0.000000] bootconsole [early0] disabled
[    0.000000] bootconsole [early0] disabled
[    0.000000] futex hash table entries: 256 (order: 0, 6144 bytes)
[    0.000000] io scheduler noop registered
[    0.000000] io scheduler cfq registered (default)
[    0.000000] brd: module loaded
[    0.000000] Freeing unused kernel memory: 1464K (ffffffff81000000 - ffffffff8116e000)
[    0.000000] This architecture does not have kernel memory protection.
init: cannot set terminal process group (-1): Inappropriate ioctl for device
init: no job control in this shell
init-4.3#