cfriedt / greybus-for-zephyr

Greybus Module for the Zephyr Real-Time Operating System
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

test: greybus: gpio: fix gpio on qemu #49

Closed cfriedt closed 3 years ago

cfriedt commented 3 years ago

This change allows the gpio test to work in qemu_cortex_m3, which is a necessary but separable step to get TLS working because neither native_posix_64 nor Linux support Zephyr's TLS extensions for the standard sockets API.

Fixes #48

cfriedt commented 3 years ago

It looks as though there are alignment issues with x86_64 because I just ran into this problem in qemu_x86_64. Zephyr might have some additional work to do to clean up that architecture. Also, happens on native_posix_64 when on an x86_64 machine but not on an aarch64 machine.

ASSERTION FAIL [(addr & (0x1000 - 1)) == 0U] @ WEST_TOPDIR/zephyr/arch/x86/core/x86_mmu.c:423
        unaligned address 0x13bdd0
E: RAX: 0x0000000000000004 RBX: 0x0000000000001000 RCX: 0x0000000000000001 RDX: 0x0000000000000046
E: RSI: 0x00000000000001a7 RDI: 0x0000000000131138 RBP: 0x000000000013bdd0 RSP: 0x0000000000183d08
E:  R8: 0x0000000000000001  R9: 0x0000000000183b00 R10: 0x00000000ffffffff R11: 0x0000000000000031
E: R12: 0x0000000000000000 R13: 0x0000000000000000 R14: 0x000000000010ac60 R15: 0x000000000013bdd0
E: RSP: 0x0000000000183d08 RFLAGS: 0x0000000000000002 CS: 0x0018 CR3: 0x000000000019b000
E: RIP: 0x0000000000103629
E: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
E: Current thread: 0x13b200 (main)
E: Halting system
cfriedt commented 3 years ago

For now, I might just use qemu_cortex_m3 to run the regular GPIO unit tests as well.

cfriedt commented 3 years ago

This is brutal. I was hoping it would be relatively easy to run tests via qemu_cortex_m3, but it really is not easy at all. The process hangs on failure and it hangs on success. It also needs a unix domain socket setup for emulating the serial as well when running with west.

I'm wondering what effort Zephyr has gone to to simplify it. I guess they do have their sanitycheck / twister scripts but it is really heavyweight for simply running a single Qemu instance.

So native_posix_64 will suffice for testing plain-text GPIO, I2C, SPI, etc, due to the simple emulated hardware APIs, but when using TLS, there is absolutely no way to exercise the code paths under question. We need to run the Zephyr kernel inside of an emulator so that the Zephyr socket API is properly used.

This is incredibly frustrating, but I think having functional automated testing is important.

cfriedt commented 3 years ago

This works locally. Hopefully it also works in CI

twister -p qemu_cortex_m3 -T $GB/tests/subsys/greybus/gpio