Skip to content

Add initial support for Nanox graphics backend for Lua#12

Open
toncho11 wants to merge 5 commits into
rafael2k:masterfrom
toncho11:master
Open

Add initial support for Nanox graphics backend for Lua#12
toncho11 wants to merge 5 commits into
rafael2k:masterfrom
toncho11:master

Conversation

@toncho11
Copy link
Copy Markdown
Collaborator

@toncho11 toncho11 commented May 25, 2026

Hi @rafael2k

The idea is to have 2 graphical backends: VGA and Nanox.
I would like to see my rotating cube running in Nano-X :)

How do we integrate the nanox lib file into the build?

And we add a flag into the makefile to switch to Nanox like this:

USE_NANOX_BACKEND ?= 0
NANOX_DIR ?= /root/microwindows
NANOX_LIB ?= $(NANOX_DIR)/lib/libnano-X.lib

?

It is work in progress.

@toncho11 toncho11 marked this pull request as draft May 25, 2026 20:45
@toncho11 toncho11 marked this pull request as ready for review May 26, 2026 15:03
@toncho11
Copy link
Copy Markdown
Collaborator Author

@rafael2k is the master branch the correct one to add new functionality and the one used by the ELKS' automatic builds?

@toncho11
Copy link
Copy Markdown
Collaborator Author

toncho11 commented May 26, 2026

@ghaerr I want to compile lua (which is compiled with owcc) together with libnano-X.a, but libnano-X.a is compiled with gcc ia 16. So is this actually possible?

@rafael2k
Copy link
Copy Markdown
Owner

@rafael2k is the master branch the correct one to add new functionality and the one used by the ELKS' automatic builds?

Very cool @toncho11 ! Yes, that is correct!

@ghaerr
Copy link
Copy Markdown

ghaerr commented May 27, 2026

I want to compile lua (which is compiled with owcc) together with libnano-X.a, but libnano-X.a is compiled with gcc ia 16. So is this actually possible?

Files compiled with OWCC can't be combined/linked with IA16 objects, and vice versa; the object files themselves as well as the function calling conventions are incompatible.

A few options might be either an OWCC version of the Nano-X client library (libnano-X.lib) or an ia16-elf-gcc version of LUA. The Nano-X client library communicates with the Nano-X server via a UNIX socket, so only the client library files (microwindows/src/nanox/{client.c,nxproto.c,nxutil.c,osdep.c) need to be compiled and linked with the application object files. This may not be a big deal, but would require changes to Makefile.elks on the Nano-X repo, or compiling those files along with the LUA build.

The other method would compiling LUA in small model using ia16-elf-gcc. Is there a reason why LUA must be compiled large model? It would seem the cubes demo itself shouldn't require more than 64K code or data, but I haven't looked at the LUA engine to determine that.

@rafael2k
Copy link
Copy Markdown
Owner

I want to compile lua (which is compiled with owcc) together with libnano-X.a, but libnano-X.a is compiled with gcc ia 16. So is this actually possible?

Files compiled with OWCC can't be combined/linked with IA16 objects, and vice versa; the object files themselves as well as the function calling conventions are incompatible.

A few options might be either an OWCC version of the Nano-X client library (libnano-X.lib) or an ia16-elf-gcc version of LUA. The Nano-X client library communicates with the Nano-X server via a UNIX socket, so only the client library files (microwindows/src/nanox/{client.c,nxproto.c,nxutil.c,osdep.c) need to be compiled and linked with the application object files. This may not be a big deal, but would require changes to Makefile.elks on the Nano-X repo, or compiling those files along with the LUA build.

The other method would compiling LUA in small model using ia16-elf-gcc. Is there a reason why LUA must be compiled large model? It would seem the cubes demo itself shouldn't require more than 64K code or data, but I haven't looked at the LUA engine to determine that.

Yes - I chose the large model for compiling Lua for a reason.
: )
Just "vendor" these files @ghaerr mentions inside the ELKS Lua repository, if things work / if owcc compiles cleanly the nanoX source, it is a good first step.

@toncho11
Copy link
Copy Markdown
Collaborator Author

So it did work!!!!!!!!!!!!!!!!!!!!!!!!! But there are also limitations ...

image

You need to set NANOX_DIR = in you Makefile.elks and we get the executable that supports Nano X.

Here are the details and limitations:

  • it only worked when I did /bin/nanox & /bin/lua /root/drawcube.lua
  • it did not work like this lua drawcube.lua, it gives an error that it can not open Nano-x
  • I started nxdsktop and nxterm and tried from there, but guess what - it gives "lua:out of memory".

hd32-minix.zip

@toncho11
Copy link
Copy Markdown
Collaborator Author

toncho11 commented May 30, 2026

Actually the idea was to have it working from nxdsktop as a nice demo. But progress is made!!!!!!!!!!!!!!!!!!!

@toncho11
Copy link
Copy Markdown
Collaborator Author

I reduced the speed between frames and I got a better screenshot

image

@toncho11
Copy link
Copy Markdown
Collaborator Author

@ghaerr I tried these in the Lua makefile:

DEFINES += -DAUTO_START_SERVER=1
DEFINES += -DBIN_NANOX='"/bin/nano-x"'

but it did not enable lua ./drawcube.lua.

Maybe the fork that is done when calling it like this lua ./drawcube.lua requires too much memory to start nano-x? While /bin/nanox & /bin/lua /root/drawcube.lua avoids this?

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

Successfully merging this pull request may close these issues.

3 participants