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

microwindows on 64bit ARM #80

Closed
uklatt opened this issue Nov 15, 2023 · 6 comments
Closed

microwindows on 64bit ARM #80

uklatt opened this issue Nov 15, 2023 · 6 comments

Comments

@uklatt
Copy link

uklatt commented Nov 15, 2023

I try to port an existing microwindows program from i.MX6 (32 Bit code, 16 Bit framebuffer) to i.MX8 (64 Bit code, 32 Bit framebuffer).

I can compile the libs and demo programs. When starting mdemo (or any other microwindows programs), the program crashes.

It looks like tbe initial erasing of the framebuffer is not working and there are writes outside of the allowed framebuffer memory.

Should the code work with a 64Bit compiler?

Uwe

@ghaerr
Copy link
Owner

ghaerr commented Nov 15, 2023

Hello @uklatt,

Should the code work with a 64Bit compiler?

Yes - Microwindows has been working on 64-bit systems for some time.

It looks like tbe initial erasing of the framebuffer is not working and there are writes outside of the allowed framebuffer memory.

Are you running the drivers/scr_fb.c framebuffer driver? It sounds like perhaps the framebuffer width, stride or overall length/height values might be improperly set. Another possibility is that your framebuffer requires 64-bit (not 32-bit) writes, or otherwise segfaults. If this is the case, then we'll have to look into rewriting whichever framebuffer sub driver you're using (likely drivers/fblin32.c) to use 64-bit moves when accessing the framebuffer. IIRC some of the upper-level routines may expect only 32-bit padding for images etc, which might also have to change.

Thank you!

@ghaerr
Copy link
Owner

ghaerr commented Nov 15, 2023

I try to port an existing microwindows program from i.MX6 (32 Bit code, 16 Bit framebuffer) to i.MX8 (64 Bit code, 32 Bit framebuffer).

Oops - I missed that! This means you can likely ignore my last comment about 64-bit framebuffer. Perhaps the issue then is that the scr_fb.c framebuffer driver is not picking up the fblin32.c 32-bit linear driver, or that the size (length in bytes) of the framebuffer is incorrect.

@uklatt
Copy link
Author

uklatt commented Nov 16, 2023

Hi @ghaerr
Thank you for the fast comment!
I checked with an older version 0.91 with some additions.
Now I am testing with the last 0.92 from http://www.microwindows.org/

With this version I have a different error:

Starting program: /home/root/mtest/mtest
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
1920x1080x32bpp linelen 7680 type 0 visual 2 colors 281470698520576 pixtype 3
createfont: (height == 0) found builtin font System (0)
createfont: (height == 0) found builtin font System (0)
createfont: (height == 0) found builtin font System (0)
Program received signal SIGSEGV, Segmentation fault.
0x0000aaaaaaaa973c in FillRect (hdc=0xaaaaaab1dde0, lprc=0xfffffffff568, hbr=0xaab103b8)
at /home/root/microwindows-0.92/src/mwin/wingdi.c:766
766 if(obr->style == BS_NULL)
(gdb) bt
#0 0x0000aaaaaaaa973c in FillRect (hdc=0xaaaaaab1dde0, lprc=0xfffffffff568, hbr=0xaab103b8)
at /home/root/microwindows-0.92/src/mwin/wingdi.c:766
#1 0x0000aaaaaaaaec2c in DefWindowProc (hwnd=0xaaaaaab1d970, msg=20, wParam=2863783280, lParam=0)
at /home/root/microwindows-0.92/src/mwin/windefw.c:366
#2 0x0000aaaaaaaa2be4 in wproc (hwnd=0xaaaaaab1d970, iMsg=20, wParam=2863783280, lParam=0)
at mtest.c:70
#3 0x0000aaaaaaaa439c in SendMessage (hwnd=0xaaaaaab1d970, Msg=20, wParam=2863783280, lParam=0)
at /home/root/microwindows-0.92/src/mwin/winuser.c:81
#4 0x0000aaaaaaaa83c4 in BeginPaint (hwnd=0xaaaaaab1d970, lpPaint=0xfffffffff820)
at /home/root/microwindows-0.92/src/mwin/wingdi.c:223
#5 0x0000aaaaaaaa2b7c in wproc (hwnd=0xaaaaaab1d970, iMsg=15, wParam=0, lParam=0) at mtest.c:60
#6 0x0000aaaaaaaa439c in SendMessage (hwnd=0xaaaaaab1d970, Msg=15, wParam=0, lParam=0)
at /home/root/microwindows-0.92/src/mwin/winuser.c:81
#7 0x0000aaaaaaaa5800 in UpdateWindow (hwnd=0xaaaaaab1d970)
at /home/root/microwindows-0.92/src/mwin/winuser.c:769
#8 0x0000aaaaaaaa2ad8 in WinMain (hInstance=0xaaaaaab1d670, hPrevInstance=0x0,
szCmdLine=0xaaaaaab1d6b0 "", iCmdShow=5) at mtest.c:41
#9 0x0000aaaaaaaa2c94 in main (ac=1, av=0xfffffffffb78)
at /home/root/microwindows-0.92/src/mwin/winmain.c:115
My framebuffer:

fbset -i
mode "1920x1080"
geometry 1920 1080 1920 1080 32
timings 0 0 0 0 0 0 0
accel true
rgba 8/16,8/8,8/0,0/0
endmode
Frame buffer device information:
Name : imx-drmdrmfb
Address : (nil)
Size : 8294400
Type : PACKED PIXELS
Visual : TRUECOLOR
XPanStep : 1
YPanStep : 1
YWrapStep : 0
LineLength : 7680
Accelerator : No

My config:
config.txt

@ghaerr
Copy link
Owner

ghaerr commented Nov 16, 2023

Looking at your stack trace, I can see the problem with v0.92 that you're running: the hbr HBRUSH is being truncated from 64 to 32 bits:

Program received signal SIGSEGV, Segmentation fault.
0x0000aaaaaaaa973c in FillRect (hdc=0xaaaaaab1dde0, lprc=0xfffffffff568, hbr=0xaab103b8)
at /home/root/microwindows-0.92/src/mwin/wingdi.c:766

Notice that the heap variables are all at addresses 0x0000aaaaaaaa.... while hbr above has its high 32 bits zero. This was fixed on 18 Dec 2018 in commit a3564f4 as can be seen in the "blame" report on src/mwin/windefw.c. Long story short - v0.92 is not 64-bit compiler clean and should not be used.

If you can produce a stack trace of the latest source code segfault I can probably help get this problem figured out.

Thank you!

@uklatt
Copy link
Author

uklatt commented Nov 17, 2023

Hi Greg,
many thanks for this tip!
I will try the last snapshot next week and report what happens...

@uklatt
Copy link
Author

uklatt commented Nov 21, 2023

@ghaerr
I was able to compile and run the last snapshot 0.94 with success!
Thank you for your help!

@uklatt uklatt closed this as completed Dec 6, 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

No branches or pull requests

2 participants