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

add litei2c #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,50 +47,55 @@ jobs:
./overlay.config

Zephyr-build:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
needs: Bitstream-build
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: Bitstream-build

- name: Install dependencies
run: |
sudo apt update
sudo apt-get install -y --no-install-recommends ninja-build gperf ccache dfu-util device-tree-compiler libssl-dev gcc g++ python3-dev python3-pip
sudo apt update
sudo apt-get install -y --no-install-recommends python3-setuptools python3-tk python3-wheel xz-utils file make gcc gcc-multilib g++-multilib libmagic1 libsdl2-dev
sudo apt-get install -y --no-install-recommends git cmake ninja-build gperf \
ccache dfu-util device-tree-compiler wget \
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 python3-venv

- name: Download Zephyr SDK
- name: Create Python virtual environment
run: |
wget -q -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/zephyr-sdk-0.16.8_linux-x86_64.tar.xz | tar -J -xf -
python3 -m venv .venv
source .venv/bin/activate
echo "VIRTUAL_ENV=${VIRTUAL_ENV}" >> $GITHUB_ENV
echo "${VIRTUAL_ENV}/bin" >> $GITHUB_PATH
shell: bash

- name: Prepare Zephyr
run: |
pip3 install west
pip install west
west init zephyrproject
cd zephyrproject/
west config manifest.group-filter -- -hal,-tools,-bootloader,-babblesim
west config manifest.project-filter -- -nrf_hw_models
west config --global update.narrow true
west update
west zephyr-export
pip3 install -r zephyr/scripts/requirements.txt
west packages pip --install
cd ..

- name: Install Zephyr SDK
run: |
cd zephyr-sdk-*
./setup.sh -h -t riscv64-zephyr-elf
cd ../
cd zephyrproject/zephyr
west sdk install -H -t riscv64-zephyr-elf
cd ../../

- name: Build Zephyr App
run: |
export ZEPHYR_SDK_INSTALL_DIR=$PWD
cd zephyrproject/zephyr
cat ../../Bitstream-build/overlay.config | xargs west build -b litex_vexriscv samples/philosophers/ -- -DDTC_OVERLAY_FILE= ../../Bitstream-build/overlay.dts
cd ../../

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{github.job}}
path: ./zephyrproject/zephyr/build/zephyr/zephyr.bin
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@
[submodule "third_party/pythondata-software-picolibc"]
path = third_party/pythondata-software-picolibc
url = https://github.com/litex-hub/pythondata-software-picolibc.git
[submodule "third_party/litei2c"]
path = third_party/litei2c
url = https://github.com/litex-hub/litei2c
2 changes: 1 addition & 1 deletion init
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export PATH="${PWD}/third_party/litex/litex/tools:$PATH"
export PATH="${PWD}/tools/conda/bin:$PATH"

directories=(litedram liteeth liteiclink litepcie litespi litesata litescope litevideo litex litex-boards litex-renode migen nmigen pythondata-cpu-vexriscv pythondata-software-compiler_rt pythondata-software-picolibc)
directories=(litedram liteeth litei2c liteiclink litepcie litespi litesata litescope litevideo litex litex-boards litex-renode migen nmigen pythondata-cpu-vexriscv pythondata-software-compiler_rt pythondata-software-picolibc)

for directory in "${directories[@]}";
do
Expand Down
3 changes: 3 additions & 0 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def main():
parser.add_argument("--with_spi", action="store_true", help="Enable spi (Arty target only)")
parser.add_argument("--with_spi_flash", action="store_true", help="Enable spi flash (Arty target only)")
parser.add_argument("--with_i2c", action="store_true", help="Enable i2c (Arty target only)")
parser.add_argument("--with_litei2c", action="store_true", help="Enable i2c via litei2c (Arty target only)")
parser.add_argument("--with_pwm", action="store_true", help="Enable pwm (Arty target only)")
parser.add_argument("--spi-data-width", type=int, default=8, help="SPI data width (maximum transfered bits per xfer, Arty target only)")
parser.add_argument("--spi-clk-freq", type=int, default=1e6, help="SPI clock frequency (Arty target only)")
Expand Down Expand Up @@ -154,6 +155,8 @@ def main():
soc.add_spi_flash(mode="4x", module=S25FL128L(Codes.READ_1_1_4), rate=args.spi_flash_rate, with_master=True)
if args.with_i2c:
soc.add_i2c()
if args.with_litei2c:
soc.add_litei2c()
if args.with_i2s:
if not args.with_mmcm:
print("Adding mmcm implicitly, cause i2s core needs special clk signals")
Expand Down
9 changes: 9 additions & 0 deletions soc_zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

from liteeth.phy.mii import LiteEthPHYMII

from litei2c import LiteI2C

# Helpers ------------------------------------------------------------------------------------------

def platform_request_all(platform, name):
Expand Down Expand Up @@ -52,6 +54,7 @@ class _SoCZephyr(soc_cls):
"spiflash_core": 24, # addr: 0xe000c000
"spiflash_phy": 25, # addr: 0xe000c800
"watchdog0": 26, # addr: 0xe000d000
"litei2c": 27, # addr: 0xe000d800
}}

interrupt_map = {**soc_cls.interrupt_map, **{
Expand Down Expand Up @@ -90,6 +93,12 @@ def add_rgb_led(self):

def add_i2c(self):
self.submodules.i2c0 = I2CMaster(self.platform.request("i2c", 0))

def add_litei2c(self):
self.litei2c = LiteI2C(
sys_clk_freq=self.sys_clk_freq,
pads=self.platform.request("i2c", 0)
)

def add_i2s(self):
self.platform.add_extension(arty_platform._i2s_pmod_io)
Expand Down
1 change: 1 addition & 0 deletions third_party/litei2c
Submodule litei2c added at 31a9e1
2 changes: 1 addition & 1 deletion third_party/litesata
Submodule litesata updated 3 files
+2 −1 CONTRIBUTORS
+1 −1 LICENSE
+1 −1 README.md
2 changes: 1 addition & 1 deletion third_party/litescope
Submodule litescope updated 4 files
+1 −1 CONTRIBUTORS
+1 −1 LICENSE
+1 −1 README.md
+57 −38 litescope/core.py
2 changes: 1 addition & 1 deletion third_party/litex
Submodule litex updated 88 files
+39 −2 CHANGES.md
+29 −13 CONTRIBUTORS
+1 −1 LICENSE
+2 −2 README.md
+118 −1 litex/build/altera/common.py
+11 −0 litex/build/altera/platform.py
+40 −4 litex/build/altera/quartus.py
+1 −14 litex/build/colognechip/colognechip.py
+1 −0 litex/build/efinix/__init__.py
+292 −96 litex/build/efinix/common.py
+115 −24 litex/build/efinix/efinity.py
+70 −50 litex/build/efinix/ifacewriter.py
+108 −0 litex/build/efinix/ipmwriter.py
+57 −0 litex/build/efinix/platform.py
+5 −3 litex/build/generic_toolchain.py
+5 −0 litex/build/gowin/__init__.py
+75 −0 litex/build/gowin/apicula.py
+78 −12 litex/build/gowin/common.py
+56 −52 litex/build/gowin/gowin.py
+4 −2 litex/build/gowin/platform.py
+17 −11 litex/build/io.py
+21 −1 litex/build/lattice/common.py
+16 −0 litex/build/lattice/diamond.py
+14 −0 litex/build/lattice/platform.py
+4 −3 litex/build/nextpnr_wrapper.py
+4 −1 litex/build/openfpgaloader.py
+3 −2 litex/build/openocd.py
+5 −0 litex/build/sim/core/veril.cpp
+42 −4 litex/build/vhd2v_converter.py
+1 −1 litex/build/xilinx/common.py
+1 −1 litex/build/xilinx/platform.py
+52 −20 litex/build/xilinx/vivado.py
+1 −1 litex/gen/fhdl/hierarchy.py
+5 −0 litex/gen/fhdl/namer.py
+0 −0 litex/soc/cores/can/__init__.py
+175 −0 litex/soc/cores/can/ctu_can_fd.py
+88 −0 litex/soc/cores/can/rtl_lst.txt
+6 −3 litex/soc/cores/clock/colognechip.py
+19 −6 litex/soc/cores/clock/efinix.py
+1 −5 litex/soc/cores/clock/gowin_gw1n.py
+12 −3 litex/soc/cores/clock/lattice_nx.py
+65 −1 litex/soc/cores/clock/xilinx_usp.py
+4 −2 litex/soc/cores/cpu/naxriscv/core.py
+7 −2 litex/soc/cores/cpu/picorv32/core.py
+1 −0 litex/soc/cores/cpu/urv/__init__.py
+4 −0 litex/soc/cores/cpu/urv/boot-helper.S
+240 −0 litex/soc/cores/cpu/urv/core.py
+75 −0 litex/soc/cores/cpu/urv/crt0.S
+4 −0 litex/soc/cores/cpu/urv/irq.h
+19 −0 litex/soc/cores/cpu/urv/system.h
+118 −14 litex/soc/cores/cpu/vexiiriscv/core.py
+9 −0 litex/soc/cores/cpu/vexriscv_smp/core.py
+186 −15 litex/soc/cores/cpu/zynqmp/core.py
+72 −26 litex/soc/cores/dma.py
+608 −281 litex/soc/cores/hyperbus.py
+291 −0 litex/soc/cores/i2c.py
+6 −2 litex/soc/cores/jtag.py
+2 −1 litex/soc/cores/led.py
+2 −2 litex/soc/cores/ram/lattice_nx.py
+2 −2 litex/soc/cores/uart.py
+2 −0 litex/soc/cores/usb_ohci.py
+26 −5 litex/soc/cores/video.py
+3 −3 litex/soc/integration/builder.py
+157 −43 litex/soc/integration/soc.py
+3 −2 litex/soc/integration/soc_core.py
+1 −0 litex/soc/interconnect/axi/axi_lite.py
+1 −1 litex/soc/interconnect/packet.py
+39 −8 litex/soc/interconnect/stream.py
+34 −20 litex/soc/interconnect/wishbone.py
+3 −3 litex/soc/software/bios/boot.c
+10 −5 litex/soc/software/bios/helpers.c
+11 −81 litex/soc/software/bios/main.c
+2 −1 litex/soc/software/libbase/Makefile
+114 −0 litex/soc/software/libbase/hyperram.c
+68 −0 litex/soc/software/libbase/hyperram.h
+1 −1 litex/soc/software/liblitespi/Makefile
+14 −2 litex/soc/software/liblitespi/spiflash.c
+1 −0 litex/soc/software/liblitespi/spiflash.h
+150 −0 litex/soc/software/liblitespi/spiram.c
+17 −0 litex/soc/software/liblitespi/spiram.h
+19 −0 litex/tools/litex_json2dts_linux.py
+23 −27 litex/tools/litex_json2dts_zephyr.py
+45 −24 litex/tools/litex_sim.py
+9 −0 litex_setup.py
+1 −1 setup.py
+144 −108 test/test_hyperbus.py
+226 −0 test/test_i2c.py
+13 −8 test/test_led.py
2 changes: 1 addition & 1 deletion third_party/litex-boards
Submodule litex-boards updated 113 files
2 changes: 1 addition & 1 deletion third_party/migen