Skip to content

Fails tests/drivers/display/display_read_write on SDL display driver #88714

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

Open
soburi opened this issue Apr 16, 2025 · 9 comments · Fixed by #89267
Open

Fails tests/drivers/display/display_read_write on SDL display driver #88714

soburi opened this issue Apr 16, 2025 · 9 comments · Fixed by #89267
Assignees
Labels
area: Display area: native port Host native arch port (native_sim) bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@soburi
Copy link
Member

soburi commented Apr 16, 2025

Describe the bug

Fails tests/drivers/display/display_read_write on SDL display driver.

At a glance, the #81184 change seems

display_read() behavior.

To Reproduce

 west twister -p native_sim -T tests/drivers/display/display_read_write/ 

Note: Currently, the test is disabled by the harness: display line.
To run the test, we need to remove this line from
tests/drivers/display/display_read_write/testcase.yaml

Expected behavior
Pass the test.

@soburi soburi added the bug The issue is a bug, or the PR is fixing a bug label Apr 16, 2025
@JarmouniA JarmouniA added area: native port Host native arch port (native_sim) area: Display labels Apr 16, 2025
@aescolar
Copy link
Member

@Finomnis
Copy link
Contributor

What's the error?

@soburi
Copy link
Member Author

soburi commented Apr 20, 2025

@Finomnis

What's the error?

As mentioned above, to run the tests/drivers/display/display_read_write/ test, you must modify the testcase.yaml. However, two errors will occur if you do so and run the tests. One is an error where the thread priority is inappropriate and the test stops with an assert.

ASSERTION FAIL [((((prio)) == 15 && z_is_idle_thread_entry((entry))) || (((15 - 1) >= ((-16))) && ((prio)) >= ((-16)) && ((prio)) <= (15 - 1)))] @ WEST_TOPDIR/zephyr/kernel/thread.c:517
 invalid priority (15); allowed range: 14 to -16
@WEST_TOPDIR/zephyr/lib/os/assert.c:43
[00:00:00.000,000] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
[00:00:00.000,000] <err> os: Current thread: 0x8140dc0 (main)
[00:00:00.000,000] <err> os: Halting system

This can be avoided by adjusting CONFIG_SDL_DISPLAY_THREAD_PRIORITY.
But I have no idea how to fix it properly at this point.

And if I work around it, the test will fail.
This test reads data written in the framebuffer memory and checks whether it is the expected content.
I think the reading behavior has probably changed.

The test passed in versions before 02d562e.
The fix in 02d562e
adds support for transparent colors, but it still affects settings other than ARGB8888. It seems strange.

*** Booting Zephyr OS build v4.1.0-2646-ge41909a32ce9 ***
Running TESTSUITE display_read_write
====================================================================
START - test_clear

 Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/display/display_read_write/src/main.c:88: verify_background_color: (buf32[i] not equal to color)
@0
 FAIL - test_clear in 0.000 seconds
====================================================================
START - test_read_does_not_clear_existing_buffer

 Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/display/display_read_write/src/main.c:64: verify_bytes_of_area: data not equal to disp_buffer

 FAIL - test_read_does_not_clear_existing_buffer in 0.000 seconds
====================================================================
START - test_write_to_buffer_head

 Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/display/display_read_write/src/main.c:64: verify_bytes_of_area: data not equal to disp_buffer

 FAIL - test_write_to_buffer_head in 0.000 seconds
====================================================================
START - test_write_to_buffer_tail

 Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/display/display_read_write/src/main.c:210: display_read_write_test_write_to_buffer_tail: data not equal to disp_buffer + (display_width * display_height * bpp - buf_size)

 FAIL - test_write_to_buffer_tail in 0.000 seconds
====================================================================
TESTSUITE display_read_write failed.

@Finomnis
Copy link
Contributor

Finomnis commented Apr 20, 2025

The thread priority issue is probably related to #87883.

@faxe1008

@aescolar aescolar assigned Finomnis and faxe1008 and unassigned aescolar Apr 22, 2025
@faxe1008
Copy link
Collaborator

faxe1008 commented Apr 22, 2025

@soburi @Finomnis changing the priority to 8 I get:

*** Booting Zephyr OS build v4.1.0-2705-g76c266c0a70d ***
Running TESTSUITE display_read_write
===================================================================
START - test_clear

    Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/display/display_read_write/src/main.c:106: verify_background_color: (!!(*tptr & BIT(i % 8)) not equal to !!(color))
@0
 FAIL - test_clear in 0.000 seconds
===================================================================
START - test_read_does_not_clear_existing_buffer
ASSERTION FAIL [(desc->height % 8) == 0U] @ WEST_TOPDIR/zephyr/drivers/display/display_sdl.c:273
	Input buffer height not aligned per 8 pixels
@ WEST_TOPDIR/zephyr/lib/os/assert.c:43
[00:00:00.000,000] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
[00:00:00.000,000] <err> os: Current thread: 0x464500 (test_read_does_not_clear_existi)
[00:00:00.000,000] <err> os: Halting system

If I change the value to 0 I get the same output as you did.

@Finomnis
Copy link
Contributor

I probably won't be about to contribute much, I have very little time right now

@danieldegrasse danieldegrasse added the priority: low Low impact/importance bug label Apr 22, 2025
@Finomnis
Copy link
Contributor

Finomnis commented Apr 29, 2025

I debugged into tests/drivers/display/display_read_write/drivers.display.read_write.sdl.argb8888, function test_write_to_buffer_head and found the following:

  • We write [0xfa, 0xaf, 0x9f, 0xfa] to the display
  • We read [0xf4, 0xaa, 0x9b, 0xfe] from the display, whilst according to the test, it should be identical.

The reason this fails is indeed because of the transparency handling. We added a checkerboard pattern to the background, which shows is most likely visible here, because the written color value does have some degree of transparency.

For this test, we should probably remove the transparency from this pixel.

The other issue was that the background was initialized with [0x0, 0x0, 0x0, 0x0], which is transparent and hence invisible. That one might be a bug in display_sdl_read, though.

@Finomnis
Copy link
Contributor

Finomnis commented Apr 29, 2025

Actually, scratch that, I think both are based on a real bug in display_sdl_read. The display API didn't change, so the SDL driver should still run those tests successfully. Everything else should be considered a bug in the SDL driver.

Will create a fix PR soon.

@Finomnis
Copy link
Contributor

Finomnis commented Apr 29, 2025

#89267 is the part that I can fix, but the mono01 and mono10 errors I am unsure about.

It is probably something I need @faxe1008 for.

The errors are:

ASSERTION FAIL [(desc->height % 8) == 0U] @ WEST_TOPDIR/zephyr/drivers/display/display_sdl.c:278
	Input buffer height not aligned per 8 pixels

and

Assertion failed at WEST_TOPDIR/zephyr/tests/drivers/display/display_read_write/src/main.c:119: verify_background_color: (!!(*tptr & BIT(i % 8)) not equal to !!(color))

where it expects background color 0, but gets 1. Again, the whole mono bit packing code is confusing to me, so I don't know.

Also, some test_write_to_buffer_head and test_write_to_buffer_tail fail.

All other color modes except the mono ones seem to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Display area: native port Host native arch port (native_sim) bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants