zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.99k stars 6.69k forks source link

litex_vexriscv: k_msleep() never returns (deadlock?) #39298

Closed mckaymatthew closed 2 years ago

mckaymatthew commented 3 years ago

Describe the bug Calling k_msleep never returns on litex_vexriscv hardware using colorlighti5 Lattice board.

To Reproduce Steps to reproduce the behavior:

  1. Modify samples/HelloWorld/main.c uint32_t ctr = 0; while(1) { printk("Hello World! %u\n",ctr++); k_msleep(1); }
  2. Build litex: python3 ./colorlight_i5.py --build --csr-csv test/csr.csv --csr-json test/csr.json
  3. Generate dts overlay: litex/litex/tools/litex_json2dts_zephyr.py --dts overlay.dts --config overlay.config csr.json
  4. Build HelloWorld: west build -b litex_vexriscv samples/hello_world --pristine -DDTC_OVERLAY_FILE=/Users/user/project/litex/litex-boards/litex_boards/targets/test/overlay.dts -DCONFIG_UART_LITEUART=y -DCONFIG_LITEX_TIMER=y -DCONFIG_ETH_LITEETH=n -DCONFIG_SPI_LITESPI=n -DCONFIG_I2C_LITEX=n
  5. Load bitstream ecpdap program --freq 5000 colorlight_i5/gateware/colorlight_i5.bit
  6. Load kernel onto platform ./litex_term.py --serial-boot --kernel /Users/user/project/zephyrproject/zephyr/build/zephyr/zephyr.bin /dev/cu.usbmodem142401
  7. Observe never return from k_msleep

Expected behavior A clear and concise description of what you expected to happen.

Impact Showstopper.

Logs and console output Adding some printk debugging, arch_swap is never returning when called in z_swap_irqlock

Zephyr console On main/head

--============= Liftoff! ===============--
*** Booting Zephyr OS build v2.7.99-414-g41833951b0f4  ***
Hello World! 0

On 2.7.0-rc1

--============= Liftoff! ===============--
*** Booting Zephyr OS build v2.7.0-rc1  ***
Hello World! 0

Build logs from zephyr:

west build  -b litex_vexriscv samples/hello_world --pristine   -DDTC_OVERLAY_FILE=/Users/user/project/litex/litex-boards/litex_boards/targets/test/overlay.dts  -DCONFIG_UART_LITEUART=y -DCONFIG_LITEX_TIMER=y -DCONFIG_ETH_LITEETH=n -DCONFIG_SPI_LITESPI=n -DCONFIG_I2C_LITEX=n
-- west build: making build dir /Users/user/project/zephyrproject/zephyr/build pristine
-- west build: generating a build system
Including boilerplate (Zephyr base): /Users/user/project/zephyrproject/zephyr/cmake/app/boilerplate.cmake
-- Application: /Users/user/project/zephyrproject/zephyr/samples/hello_world
-- Zephyr version: 2.7.99 (/Users/user/project/zephyrproject/zephyr), build: v2.7.99-414-g41833951b0f4
-- Found Python3: /usr/local/opt/python@3.9/bin/python3.9 (found suitable exact version "3.9.7") found components: Interpreter 
-- Found west (found suitable version "0.11.1", minimum required is "0.7.1")
-- Board: litex_vexriscv
-- Cache files will be written to: /Users/user/Library/Caches/zephyr
-- Found dtc: /usr/local/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6")
-- Found toolchain: cross-compile (/Users/user/project/litex/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-apple-darwin/bin/riscv64-unknown-elf-)
-- Found BOARD.dts: /Users/user/project/zephyrproject/zephyr/boards/riscv/litex_vexriscv/litex_vexriscv.dts
-- Found devicetree overlay: /Users/user/project/litex/litex-boards/litex_boards/targets/test/overlay.dts
litex_vexriscv.dts.pre.tmp:28.35-35.5: Warning (interrupt_provider): /soc/interrupt-controller@bc0: Missing #address-cells in interrupt provider
unit address and first address in 'reg' (0xf0003800) don't match for /soc/serial@e0001800
unit address and first address in 'reg' (0xf0003000) don't match for /soc/timer@e0002800
unit address and first address in 'reg' (0xf0000800) don't match for /soc/dna@e0003800
-- Generated zephyr.dts: /Users/user/project/zephyrproject/zephyr/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /Users/user/project/zephyrproject/zephyr/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: /Users/user/project/zephyrproject/zephyr/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: /Users/user/project/zephyrproject/zephyr/build/zephyr/dts.cmake

warning: ETH_LITEETH_0 (defined at drivers/ethernet/Kconfig.liteeth:7) was assigned the value 'y'
but got the value 'n'. Check these unsatisfied dependencies: ETH_LITEETH (=n). See
http://docs.zephyrproject.org/latest/reference/kconfig/CONFIG_ETH_LITEETH_0.html and/or look up
ETH_LITEETH_0 in the menuconfig/guiconfig interface. The Application Development Primer, Setting
Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
too.

Parsing /Users/user/project/zephyrproject/zephyr/Kconfig
Loaded configuration '/Users/user/project/zephyrproject/zephyr/boards/riscv/litex_vexriscv/litex_vexriscv_defconfig'
Merged configuration '/Users/user/project/zephyrproject/zephyr/samples/hello_world/prj.conf'
Merged configuration '/Users/user/project/zephyrproject/zephyr/build/zephyr/misc/generated/extra_kconfig_options.conf'
Configuration saved to '/Users/user/project/zephyrproject/zephyr/build/zephyr/.config'
Kconfig header saved to '/Users/user/project/zephyrproject/zephyr/build/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- The ASM compiler identification is GNU
-- Found assembler: /Users/user/project/litex/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-apple-darwin/bin/riscv64-unknown-elf-gcc
CMake Warning at /Users/user/project/zephyrproject/zephyr/CMakeLists.txt:730 (message):
  No SOURCES given to Zephyr library: drivers__spi

  Excluding target from build.

CMake Warning at /Users/user/project/zephyrproject/zephyr/CMakeLists.txt:730 (message):
  No SOURCES given to Zephyr library: drivers__ethernet

  Excluding target from build.

-- Configuring done
-- Generating done
-- Build files have been written to: /Users/user/project/zephyrproject/zephyr/build
-- west build: building application
[1/156] Preparing syscall dependency handling

[149/156] Linking C executable zephyr/zephyr_prebuilt.elf

[156/156] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
             RAM:      107612 B         8 MB      1.28%
        IDT_LIST:          0 GB         2 KB      0.00%

Environment (please complete the following information):

mckaymatthew commented 3 years ago

Update: It appears the register definitions in litex_timer.c are incorrect, and the system is never getting a sys_clock_announce.

mckaymatthew commented 3 years ago

Register definition errors are present in eth_litex.c as well

github-actions[bot] commented 2 years ago

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.