Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] litex_sim: move most code from main() to SimSoC() #1764

Closed
wants to merge 4 commits into from

Conversation

josuah
Copy link
Contributor

@josuah josuah commented Sep 3, 2023

I was on my way to bring support for the simulator on Zephyr-on-LitexVexriscv, then I saw this: https://github.com/litex-hub/linux-on-litex-vexriscv/blob/master/sim.py#L70

This means that currently, ./make.py has nothing to do with ./sim.py, and any pull request to ./make.py needs maintainers to always update ./sim.py... time-consuming for little added-value?

So why not allow the simulator to be configured as a regular boards? import litex.tools.litex_sim

Supersedes litex-hub/litex-boards#525

@@ -545,7 +542,7 @@ def pre_run_callback(vns):

builder = Builder(soc, **parser.builder_argdict)
builder.build(
sim_config = sim_config,
sim_config = soc.sim_config,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because sim_config needs to be passed to the builder but is not in main() anymore, SimSoC() exposes it as self.sim_config.

This is a fix for this error:

    $ xargs <overlay.config west build -p -b litex_vexriscv zephyr/samples/subsys/shell/shell_module -- -DDTC_OVERLAY_FILE="$PWD/overlay.dts"
    [...]
    -- Found devicetree overlay: /home/zephyr/overlay.dts
    devicetree error: /home/zephyr/overlay.dts:49 (column 1): parse error: undefined node label 'sdcard_block2mem'
    -- In: /home/zephyr/build/zephyr, command: /home/zephyr/.venv/bin/python3.11;/home/zephyr/zephyr/scripts/dts/gen_defines.py;--dts;/home/zephyr/build/zephyr/zephyr.dts.pre;--dtc-flags;'';--bindings-dirs;/home/zephyr/zephyr/dts/bindings;--header-out;/home/zephyr/build/zephyr/include/generated/devicetree_generated.h.new;--dts-out;/home/zephyr/build/zephyr/zephyr.dts.new;--edt-pickle-out;/home/zephyr/build/zephyr/edt.pickle;--vendor-prefixes;/home/zephyr/zephyr/dts/bindings/vendor-prefixes.txt
    CMake Error at /home/zephyr/zephyr/cmake/modules/dts.cmake:276 (message):
      gen_defines.py failed with return code: 1
    Call Stack (most recent call first):
      /home/zephyr/zephyr/cmake/modules/zephyr_default.cmake:115 (include)
      /home/zephyr/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      /home/zephyr/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:4 (find_package)
    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: /usr/bin/cmake -DWEST_PYTHON=/home/zephyr/.venv/bin/python3.11 -B/home/zephyr/build -GNinja -DBOARD=litex_vexriscv -DDTC_OVERLAY_FILE=/home/zephyr/overlay.dts -DCONFIG_UART_LITEUART=y -DCONFIG_LITEX_TIMER=y -DCONFIG_ETH_LITEETH=n -DCONFIG_SPI_LITESPI=n -DCONFIG_SD_LITESD=n -DCONFIG_SD_LITESD=n -DCONFIG_SD_LITESD=n -DCONFIG_SD_LITESD=n -DCONFIG_SD_LITESD=n -DCONFIG_I2C_LITEX=n -DCONFIG_I2S_LITEX=n -DCONFIG_I2S_LITEX=n -DCONFIG_CLOCK_CONTROL_LITEX=n -DCONFIG_LITEX_CSR_DATA_WIDTH=32 -S/home/zephyr/zephyr/samples/subsys/shell/shell_module
    $
This allows to execute a firmware loaded in the SPI flash.

No support for partitions yet: this does not yet support cohabitating the
bitstream and firmware yet, so the bitstream has to be loaded to CRAM
directly for now (default for --load).

This allows loading larger Zephyr examples, and was required to fit
the shell on the Crosslink-NX board.

See litex-hub/zephyr-on-litex-vexriscv#13
This aims to turn litex.tools.litex_sim.SimSoC into something
useable as a litex_board.targets. The result is to reduce the
amount of boilerplate code, and consider the simulator like a
regular board, in hope to reduce hardware/simulation mismatch
for Linux-on-LitexVexriscv, Zephyr-on-LitexVexriscv, etc.
@josuah
Copy link
Contributor Author

josuah commented Sep 4, 2023

Required by litex-hub/zephyr-on-litex-vexriscv#18

I can change #18 so that it does not rely on it and close this if there were other plans for it.

@josuah josuah changed the title litex/tools/litex_sim: move most code from main() to SimSoC() [RFC] litex_sim: move most code from main() to SimSoC() Sep 5, 2023
@josuah
Copy link
Contributor Author

josuah commented Sep 14, 2023

I am closing this to let Enjoy-Digital perform refactoring freely on the Zephyr-on-LiteX-Vexriscv, as well as Linux-on-LiteX-Vexriscv, which will might happen everywhere else before here.

@josuah josuah closed this Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant