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

Generate DTS with XIP support for running Zephyr from flash #1748

Closed

Conversation

josuah
Copy link
Contributor

@josuah josuah commented Aug 18, 2023

This incidentally remove the -DCONFIG_SPI_LITESPI=y flag altogether, which I can add back in another commit to this pull request. Should there be some extra command line flag to choose if the SPI flash should be used for XIP or for user data storage like a filesystem? Or support both by default/

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 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
@josuah
Copy link
Contributor Author

josuah commented Sep 14, 2023

I notice that this can be configured from the Zephyr application and LiteX SoC entirely.
The XIP support becomes completely optional.

It is a matter of choice whether we want spiflash to always be used for Zephyr (implying CONFIG_XIP).

Also, it is necessary to overwrite that setup if we want to use a different flash address anyway, such as including an offset for the bitstream.

I am therefore closing this, as the most common use-case requires customization anyway.

@josuah
Copy link
Contributor Author

josuah commented Sep 14, 2023

Zephyr-side:

app.overlay:

/ {
    chosen {
        zephyr,flash = &flash0;
    };

    # This is the flash address space  + 0x0010_0000 to have Zephyr after the bitstream
    # Zephyr's linker script will follow this nicely.
    flash0: flash@20100000 {
        reg = <0x20100000 0x100000>;
        compatible = "soc-nv-flash";
    };
};

prj.conf:

CONFIG_XIP=y

CMakeLists.txt:

cmake_minimum_required(VERSION 3.20.0)

set(CONF_FILE prj.conf litex.conf)
set(DTC_OVERLAY_FILE app.overlay litex.overlay)
set(BOARD litex_vexriscv)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(example_litex_project)
add_subdirectory(drivers)

target_sources(app PRIVATE src/main.c)

LiteX-side:

Add the SPI flash, in whichever way work for you, I went down the route of specifying soc.spi_flash_module = ... from the board, and use it from add_spi_flash() on ZephyrSoC, to allow per-board customization reflect on ZephyrSoC:

https://github.com/josuah/zephyr-on-litex-vexriscv/blob/master/make.py#L217-L218
https://github.com/josuah/zephyr-on-litex-vexriscv/blob/master/soc_zephyr.py#L87-L89

@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