Page 1 of 1

GCC nxt makefile

Posted: 04 Nov 2012, 22:00
by sega16
I have tried nxc before but well... it is not exactly c meaning that it does not support everything that c supports mainly pointers. I want to write a mod player for the nxt and to do that you need pointers to access the sound hardware directly. Does anybody have a makefile template that I could use to program the lego nxt robot with gcc I am running Debian gnu/linux right now.

Re: GCC nxt makefile

Posted: 05 Nov 2012, 14:23
by hassenplug
I don't think it's quite that easy. The compiler needs to have knowledge about the target, in more ways that just that.

Also, the target would be the NXT, which means you'll need to replace ALL the software/firmware in the NXT, not just writing a simple program to run on the existing firmware (because it may be the firmware that has that limitation)

Steve

Re: GCC nxt makefile

Posted: 06 Nov 2012, 02:25
by sega16
hassenplug wrote:I don't think it's quite that easy. The compiler needs to have knowledge about the target, in more ways that just that.
That is why I wanted a ready made makefile because I am not sure of the executable format that the nxt uses.
hassenplug wrote: Also, the target would be the NXT, which means you'll need to replace ALL the software/firmware in the NXT, not just writing a simple program to run on the existing firmware (because it may be the firmware that has that limitation)

Steve
I do not understand why the firmware could be a limitation does it not just jump to the program address or is there more or could the programs be run-time interpreted like java and not native arm code.

Re: GCC nxt makefile

Posted: 06 Nov 2012, 04:40
by mattallen37
The Lego NXT FW runs programs with the .rxe extension (very specific to the NXT).

The FW is not just a boot-loader with a menu. It's a VM that runs the VM OP codes of the user program (.rxe file). The FW VM takes care of user-code multitasking, as well as it's own tasks (updating the LCD, talking with the co-processor, etc.).

At the request of Sivan Toledo, John Hansen has added FW functionality for what you seem to want (in the NBC/NXC Enhanced FW); see here. A normal .rxe file header starts with "MindstormsNXT", but if it starts with "NXTBINARY" instead, then the FW jumps to the function specified, and totally abandons everything else. That means that the user program is now responsible for everything! The user program now needs to take care of any multitasking, LCD updates, co-processor updates, etc. Simply restarting the NXT will boot the FW as usual. From the directions provided, I wasn't able to gather enough details to actually make it work, and Sivan didn't answer an email I sent him requesting assistance. If you get anywhere, please tell us about it!

Re: GCC nxt makefile

Posted: 06 Nov 2012, 11:04
by pbenco
Hello

Once again, google is your friend!!!

for compiling with NXT GCC ELF program: http://www.jstuber.net/lego/nxt-program ... chain.html
for building GCC ARM EABI toolchain : http://nxt-firmware.ni.fr.eu.org/build/gcc/

Hope this help
Ben

Re: GCC nxt makefile

Posted: 08 Nov 2012, 21:45
by sega16
Thank you everyone I will be reading up on these links that you guys posted and I will certainly have something working sooner or later.

Re: GCC nxt makefile

Posted: 09 Nov 2012, 06:57
by tcwan
sega16 wrote:Thank you everyone I will be reading up on these links that you guys posted and I will certainly have something working sooner or later.
If you want to program native C on the NXT, there are three free options available:

NXT Native http://www.tau.ac.il/~stoledo/lego/nxt-native/ (This is quite bare-bones, just enough to configure the hardware)
NxOS-Armdebug https://github.com/tcwan/nxos-armdebug (uses same mechanism as Sivan Toledo's approach to download and run executables on the NXT)
nxtOSEK http://lejos-osek.sourceforge.net/

Disclaimer: I'm the current maintainer for NxOS-Armdebug.