GithubHelp home page GithubHelp logo

icebreaker-fpga / icebreaker-litex-examples Goto Github PK

View Code? Open in Web Editor NEW
65.0 65.0 17.0 327 KB

Example litex Risc-V SOC and some example code projects in multiple languages.

Makefile 6.21% C 37.08% Assembly 1.93% Python 46.20% Shell 0.18% Rust 8.40%

icebreaker-litex-examples's People

Contributors

disasm avatar esden avatar gregdavill avatar mithro avatar securelyfitz avatar xobs avatar zottel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

icebreaker-litex-examples's Issues

icebreaker.py error

After cloning, I run the icebreaker.py script in the soc folder with both --debug and --flash option, then with either and with none. I get the following error on Ubuntu 18.04

Warning: Wire top.uartwishbonebridge_state has an unprocessed 'init' attribute.
Warning: Wire top.wb2csr_next_state has an unprocessed 'init' attribute.
unrecognised option '--pre-pack'
Traceback (most recent call last):
File "./icebreaker.py", line 243, in
main()
File "./icebreaker.py", line 234, in main
builder.build()
File "/home/unix/icebreaker-litex-examples/soc/deps/litex/litex/soc/integration/builder.py", line 204, in build
vns = self.soc.build(build_dir=self.gateware_dir, **kwargs)
File "/home/unix/icebreaker-litex-examples/soc/deps/litex/litex/soc/integration/soc.py", line 897, in build
return self.platform.build(self, *args, **kwargs)
File "/home/unix/icebreaker-litex-examples/soc/deps/litex/litex/build/lattice/platform.py", line 34, in build
return self.toolchain.build(self, *args, **kwargs)
File "/home/unix/icebreaker-litex-examples/soc/deps/litex/litex/build/lattice/icestorm.py", line 194, in build
_run_script(script)
File "/home/unix/icebreaker-litex-examples/soc/deps/litex/litex/build/lattice/icestorm.py", line 127, in _run_script
raise OSError("Subprocess failed")
OSError: Subprocess failed

Can anyone please help me figure this out? Efforts are greatly appreciated!

gdb breakpoints for c-riscv-blink

I managed to build and set up the toolchain for the c-riscv-blink program. I also managed to connect a gdb server over the wishbone tool, which seems to work in principle. I can step through the program, display the value of variables, etc. However, when I try to set a breakpoint, the execution does not stop. Is it something I am doing wrong or does this not work? Where should I start to investigate?

Steps to reproduce:

  • Generate and flash soc with following command from the soc directory:
    • ./icebreaker.py --debug --csr-csv build/csr.csv
    • apply the fix from Issue 7: #7 (comment)
    • ./icebreaker.py --debug --csr-csv build/csr.csv --flash
  • build and program binary from the c-riscv-blink directory:
    • make
    • make prog
  • connect terminal and gdb server from the soc directory:
    • wishbone-tool --uart /dev/ttyUSB1 -s terminal -s gdb --csr-csv build/csr.csv
  • attach debugger from c-riscv-blink directory:
    • riscv64-unknown-elf-gdb riscv-blink.elf -ex 'target remote localhost:3333'

If set a breakpoint or hardware breakpoint (gdb command b or hb respectively) for example on line 29 in main on the uart_rxtx_write call and continue execution, I can still type in the terminal, the characters are echoed back and the LEDs toggle without the breakpoint ever stopping the execution.

Any help would be appreciated.

Rust binary (after objcopy) too large

Abstract

The binary that is flashed via the rust example is over 250MB large, too large for the target system. The C example does NOT suffer from this issue.

Reproduction

  1. Get Rust version 1.45.0
  2. cd r-riscv-blink
  3. cargo build --release (although the issue also exists w/o the release flag)

Technical Details

$ cd target/riscv32i-unknown-none-elf/release/
$ ls -lh r-riscv-blink{,.bin}
-rwxr-xr-x 2 foo bar 456K Jul 25 16:08 r-riscv-blink
-rwxr-xr-x 1 foo bar 257M Jul 25 16:08 r-riscv-blink.bin

So while the input ELF (r-riscv-blink) has a somewhat expected size for an unstripped Rust program, the output binary (r-riscv-blink.bin) is just huge. If we look at the ELF file:

$ readelf -S r-riscv-blink
There are 23 section headers, starting at offset 0x71c18:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .text.dummy       PROGBITS        20000000 0000d4 040000 00   A  0   0  1
  [ 2] .text             PROGBITS        20040000 041000 000a14 00  AX  0   0  4
  [ 3] .rodata           PROGBITS        20040a14 041a14 000054 00   A  0   0  4
  [ 4] .data             PROGBITS        10000000 042000 000000 00   A  0   0  4
  [ 5] .bss              NOBITS          10000000 042000 000004 00  WA  0   0  1
  [ 6] .heap             PROGBITS        10000004 042000 000000 00  WA  0   0  1
  [ 7] .stack            PROGBITS        10000004 042000 01fffc 00  WA  0   0  1
  [ 8] .debug_line       PROGBITS        00000000 061ffc 0017e2 00      0   0  1
  [ 9] .debug_info       PROGBITS        00000000 0637de 00380b 00      0   0  1
  [10] .debug_abbrev     PROGBITS        00000000 066fe9 00051e 00      0   0  1
  [11] .debug_aranges    PROGBITS        00000000 067508 000030 00      0   0  8
  [12] .debug_str        PROGBITS        00000000 067538 003c21 01  MS  0   0  1
  [13] .debug_ranges     PROGBITS        00000000 06b160 0005f0 00      0   0  8
  [14] .riscv.attributes RISCV_ATTRIBUTE 00000000 06b750 00001a 00      0   0  1
  [15] .debug_loc        PROGBITS        00000000 06b76a 001362 00      0   0  1
  [16] .debug_pubnames   PROGBITS        00000000 06cacc 001267 00      0   0  1
  [17] .debug_pubtypes   PROGBITS        00000000 06dd33 0011c9 00      0   0  1
  [18] .debug_frame      PROGBITS        00000000 06eefc 000220 00      0   0  4
  [19] .comment          PROGBITS        00000000 06f11c 000013 01  MS  0   0  1
  [20] .symtab           SYMTAB          00000000 06f130 0023a0 10     22 527  4
  [21] .shstrtab         STRTAB          00000000 0714d0 0000ee 00      0   0  1
  [22] .strtab           STRTAB          00000000 0715be 00065a 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  p (processor specific)

Nothing too large here (largest is .text.dummy with 256kB). However, what is bizzare is the following:

$ riscv64-unknown-elf-objcopy -O binary -R .stack r-riscv-blink r-riscv-blink.bin
$ ls -lh r-riscv-blink{,.bin}
-rwxr-xr-x 2 tom tom 456K Jul 25 16:08 r-riscv-blink*
-rwxr-xr-x 1 tom tom 259K Jul 25 16:22 r-riscv-blink.bin*

This looks much better. Is the stack section somewhat broken? Version info:

$ riscv64-unknown-elf-objcopy --version
GNU objcopy (GNU Binutils) 2.34
Copyright (C) 2020 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

c-riscv-blink: wishbone error

c-riscv-blink/README.md:

pdp7@x1:~/dev/fpga/icebreaker-litex-examples/c-riscv-blink$ wishbone-tool --uart /dev/ttyUSB1 -s terminal
error: 'terminal' isn't a valid value for '--server <server-kind>'
	[possible values: gdb, random-test, wishbone]


USAGE:
    wishbone-tool <address> --baud <RATE> --bind-addr <IP_ADDRESS> --list --pid <USB_PID> --port <PORT_NUMBER> --serial <PORT> --server <server-kind>

For more information try --help

*pdp7@x1:~/dev/fpga/icebreaker-litex-examples/c-riscv-blink$ which wishbone-tool 
/home/pdp7/bin/wishbone-tool
pdp7@x1:~/dev/fpga/icebreaker-litex-examples/c-riscv-blink$ wishbone-tool --version
Wishbone Tool 0.4.7
pdp7@x1:~/dev/fpga/icebreaker-litex-examples/c-riscv-blink$ wishbone-tool --help
Wishbone Tool 0.4.7
Sean Cross <[email protected]>
Work with Wishbone devices over various bridges

USAGE:
    wishbone-tool [FLAGS] [OPTIONS] <address> --list --server <server-kind> [value]

FLAGS:
    -l, --list       List USB devices in the system
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -s, --server <server-kind>
            which server to run (if any) [possible values: gdb, wishbone, random-test]

    -a, --bind-addr <IP_ADDRESS>                 IP address to bind to [default: 127.0.0.1]
    -n, --port <PORT_NUMBER>                     port number to listen on [default: 1234]
    -p, --pid <USB_PID>                          USB PID to match [default: 0x5bf0]
    -v, --vid <USB_VID>                          USB VID to match
    -u, --serial <PORT>                          Serial port to use
    -b, --baud <RATE>                            Baudrate to use in serial mode [default: 115200]
    -g, --spi-pins <spi-pins>                    GPIO pins to use for MISO,MOSI,CLK,CS_N (e.g. 2,3,4,18)
        --csr-csv <csr-csv>                      csr.csv file containing register mappings
        --messible-address <messible-address>    address to use to get messible messages from
        --random-loops <random-loops>            number of loops to run when doing a random-test
        --random-address <random-address>        address to write to when doing a random-test
        --debug-offset <debug-offset>            

ARGS:
    <address>    address to read/write
    <value>      value to write

SoC Appears to no longer fit inside Ice40 FPGA

When I run: sudo ./icebreaker.py --debug --flash

I get this error which seems to imply that the SoC no longer fits inside the Ice40 using the latest versions of LiteX and Yosys:
Info: Running main analytical placer, max placement attempts per cell = 3583164. ERROR: Failed to expand region (0, 0) |_> (25, 31) of 5311 ICESTORM_LCs 0 warnings, 1 error Traceback (most recent call last): File "./icebreaker.py", line 246, in <module> main() File "./icebreaker.py", line 236, in main builder.build() File "/home/meechy/Casino/icebreaker-litex-examples/soc/deps/litex/litex/soc/integration/builder.py", line 315, in build vns = self.soc.build(build_dir=self.gateware_dir, **kwargs) File "/home/meechy/Casino/icebreaker-litex-examples/soc/deps/litex/litex/soc/integration/soc.py", line 1131, in build return self.platform.build(self, *args, **kwargs) File "/home/meechy/Casino/icebreaker-litex-examples/soc/deps/litex/litex/build/lattice/platform.py", line 43, in build return self.toolchain.build(self, *args, **kwargs) File "/home/meechy/Casino/icebreaker-litex-examples/soc/deps/litex/litex/build/lattice/icestorm.py", line 207, in build _run_script(script) File "/home/meechy/Casino/icebreaker-litex-examples/soc/deps/litex/litex/build/lattice/icestorm.py", line 147, in _run_script raise OSError("Error occured during Yosys/Nextpnr's script execution.") OSError: Error occured during Yosys/Nextpnr's script execution.

LiteX submodule version points to unreachable URL

The submodule "litex @ fbadfa1" uses an outdated URL in .gitmodules:

[submodule "litex/soc/software/compiler_rt"]
	path = litex/soc/software/compiler_rt
	url = https://git.llvm.org/git/compiler-rt

The URL is not reachable anymore. It seems like llvm moved to https://github.com/llvm/llvm-project.
This leads to an error while installing submodules using the lxbuildenv.py scirpt.

Using the LiteX master branch instead seams to break some more things.

Warning: multiple conflicting drivers for icebreaker.\sys_rst:
    port O[0] of cell sys_rst_SB_LUT4_O (SB_LUT4)
    port Q[0] of cell SB_DFFS_1 (SB_DFFS)
ERROR: Net 'sys_rst' is multiply driven by cell ports SB_DFFS_1.Q and sys_rst_SB_LUT4_O.O
0 warnings, 1 error
Traceback (most recent call last):
  File "/home/___/Projects/Icebreaker/icebreaker-litex-examples/soc/icebreaker.py", line 243, in <module>
    main()
  File "/home/___/Projects/Icebreaker/icebreaker-litex-examples/soc/icebreaker.py", line 234, in main
    builder.build()
  File "/home/___/Projects/Icebreaker/icebreaker-litex-examples/soc/deps/litex/litex/soc/integration/builder.py", line 217, in build
    vns = self.soc.build(build_dir=self.gateware_dir, **kwargs)
  File "/home/___/Projects/Icebreaker/icebreaker-litex-examples/soc/deps/litex/litex/soc/integration/soc.py", line 1075, in build
    return self.platform.build(self, *args, **kwargs)
  File "/home/___/Projects/Icebreaker/icebreaker-litex-examples/soc/deps/litex/litex/build/lattice/platform.py", line 41, in build
    return self.toolchain.build(self, *args, **kwargs)
  File "/home/___/Projects/Icebreaker/icebreaker-litex-examples/soc/deps/litex/litex/build/lattice/icestorm.py", line 211, in build
    _run_script(script)
  File "/home/___/Projects/Icebreaker/icebreaker-litex-examples/soc/deps/litex/litex/build/lattice/icestorm.py", line 142, in _run_script
    raise OSError("Error occured during Yosys/Nextpnr's script execution.")
OSError: Error occured during Yosys/Nextpnr's script execution.

Does anyone have an ideas on how to fix this easily?

Attempting to run the SoC build script produces "name 'LiteXModule' is not defined`" error

When I run ./icebreaker.py --debug --flash I get the following error

jamesmeech@Jamess-MacBook-Pro-10 soc % ./icebreaker.py --debug --flash lxbuildenv: v2020.6.1.1 (run ./icebreaker.py --lx-help for help) Traceback (most recent call last): File "/Users/jamesmeech/Desktop/Casino/icebreaker-litex-examples/soc/./icebreaker.py", line 35, in <module> from litex_boards.platforms.icebreaker import Platform, break_off_pmod File "/Users/jamesmeech/Desktop/Casino/icebreaker-litex-examples/soc/deps/litex-boards/litex_boards/__init__.py", line 70, in <module> t = importlib.import_module(f"litex_boards.targets.{target}") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/Cellar/[email protected]/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/jamesmeech/Desktop/Casino/icebreaker-litex-examples/soc/deps/litex-boards/litex_boards/targets/numato_aller.py", line 28, in <module> from litepcie.phy.s7pciephy import S7PCIEPHY File "/Users/jamesmeech/Desktop/Casino/Enjoy_Digital/litepcie/litepcie/phy/s7pciephy.py", line 22, in <module> class S7PCIEPHY(LiteXModule): ^^^^^^^^^^^ NameError: name 'LiteXModule' is not defined

What is the best way to fix this?

wishbone-util hangs

Cloned a fresh copy of the project, uploaded to the board successfully following the README.md in the soc/, able to see my characters reflected using screen /dev/ttyUSB1 115200, but for some reason wishbone-tool --uart /dev/ttyUSB1 -s terminal is hanging / stalling the terminal. Maybe I haven't install things correctly?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.