NXT Emulator, how hard would it be?

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
tcwan
Posts: 186
Joined: 30 Sep 2010, 07:39

Re: NXT Emulator, how hard would it be?

Post by tcwan »

afanofosc wrote:It would be relatively easy to write an emulator that only emulated touch sensors, nxt buttons, and the nxt lcd screen. What should this emulator do when you run an RXE that tries to use hardware/firmware features other than simple touch sensors, buttons, and the LCD screen?

John Hansen
To me, the basic modules would be:
- Flash storage emulation
- LCD screen emulation
- Buttons emulation
- minimal AVR co-processor emulation (to boot the NXT firmware).

This would at least get a simple CPU-bound RXE program up and running.
The rest can be tackled later.
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: NXT Emulator, how hard would it be?

Post by nxtboyiii »

So why not take a shot at it? I mean, once you have the very basic stuff, you could just add on to it.
Thanks, and have a nice day,
nxtboy III

programnxt.com
mcsummation
Posts: 220
Joined: 23 Jan 2012, 17:07
Location: Round Rock, TX

Re: NXT Emulator, how hard would it be?

Post by mcsummation »

So, are you proposing emulating at the ARM7 or FW level?

ARM7 emulators already exist, so you could just load the actual FW into that and go from there. All that would need to be added is the actual sensor hardware emulation, which for the pushbutton sensors would be easy. I think the LCD would be easy, also, as you would be fed a bit map. (I did a "screen emulation" back in 1967 as a method of learning assembler language for the System 360/75 that NASA was getting.)

If you want to do it at the FW/NBC level, you would need to duplicate what the FW already does. Seems to me like adding onto an ARM7 might be easier.

I agree, sounds like a fun project. This could even be done as a "group project".
tcwan
Posts: 186
Joined: 30 Sep 2010, 07:39

Re: NXT Emulator, how hard would it be?

Post by tcwan »

nxtboyiii wrote:So why not take a shot at it? I mean, once you have the very basic stuff, you could just add on to it.
I guess it depends on whether you have any experience working with emulators, etc.
While the modules I mentioned are a basic requirements, they are not trivial to implement.

As I mentioned in an earlier post, virtualized drivers would be easier to develop but requires hacking the NXT firmware.
So to get into this project, you'd need to learn up on the following:
- C language programming & Linux environment (probably easiest for development)
- NXT firmware compilation and hacking
- QEMU emulator hacking
- AT91SAM7 microcontroller peripheral details (available from ATMEL website), on at least the Flash controller and other setup bits.
- LEGO NXT Hardware SDK (at least, some details on how to interface to the hardware devices such as the AVR co-processor and LCD controller)
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: NXT Emulator, how hard would it be?

Post by nxtboyiii »

Wow, that's a lot of stuff. :P
Thanks, and have a nice day,
nxtboy III

programnxt.com
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXT Emulator, how hard would it be?

Post by afanofosc »

To emulate a subset of the NXT firmware functionality you definitely do not need anything related to ARM processor emulation. And if all you want to do is emulate the virtual machine portion of the firmware then you need hardly anything at all. I ported large portions of the VM to Delphi a few weeks after the 1.04 firmware source code was made available, i.e., years ago. I used it to test the validity of RXEs generated by the NBC compiler. I think it would be a lot easier to compile portions of the firmware source code into an executable that lets you run RXEs than it would be to mess around with an ARM emulator and trying to implement hardware layer emulation so that you could take an NXT firmware image and use it unchanged in an emulation environment.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
tcwan
Posts: 186
Joined: 30 Sep 2010, 07:39

Re: NXT Emulator, how hard would it be?

Post by tcwan »

afanofosc wrote:To emulate a subset of the NXT firmware functionality you definitely do not need anything related to ARM processor emulation. And if all you want to do is emulate the virtual machine portion of the firmware then you need hardly anything at all. I ported large portions of the VM to Delphi a few weeks after the 1.04 firmware source code was made available, i.e., years ago. I used it to test the validity of RXEs generated by the NBC compiler. I think it would be a lot easier to compile portions of the firmware source code into an executable that lets you run RXEs than it would be to mess around with an ARM emulator and trying to implement hardware layer emulation so that you could take an NXT firmware image and use it unchanged in an emulation environment.

John Hansen
I don't know the firmware code in detail, but basically your suggestion is to (re)implement a NXT Byte Code Virtual Machine, or at least enough of it to make common NBC instructions work. I suppose that is analogous to the virtualized driver approach I've suggested, except that all the I/O routines in the firmware are rewritten to target a PC host rather than the NXT brick.

That way, QEMU is removed from the list of pre-requisites, and it becomes:
- C language programming & Linux environment (probably easiest for development)
- NXT firmware compilation and hacking
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: NXT Emulator, how hard would it be?

Post by nxtboyiii »

So.... Why not make it??
Thanks, and have a nice day,
nxtboy III

programnxt.com
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXT Emulator, how hard would it be?

Post by afanofosc »

Frank Knefel has created something like what you are looking for.

http://nxceditor.sourceforge.net/

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
tcwan
Posts: 186
Joined: 30 Sep 2010, 07:39

Re: NXT Emulator, how hard would it be?

Post by tcwan »

afanofosc wrote:Frank Knefel has created something like what you are looking for.

http://nxceditor.sourceforge.net/

John Hansen
That's pretty cool!
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest