Board:emulation/spike-riscv
Jump to navigation
Jump to search
The wiki is being retired!
Documentation is now handled by the same processes we use for code: Add something to the Documentation/ directory in the coreboot repo, and it will be rendered to https://doc.coreboot.org/. Contributions welcome!
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
- clone the coreboot git repository
- download and apply the following patches:
- run
make crossgcc-riscv
and a have a cup of $BEVERAGE
Building spike
- download Spike from https://github.com/riscv/riscv-isa-sim
- download and apply this patch that implements an 8250 UART
- TODO: fesvr: patch device_list_t::handle_command to ignore HTIF writes
- Edit riscv/processor.cc, processor_t::get_csr(), and add "case CSR_TIME: return 0;"
- run make
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 prefixmake 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 themake-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#