Advertisement
djazz

NBC/NXC compiler for the Raspberry Pi (Lego Mindstorms NXT)

Sep 7th, 2012
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1.  
  2. HOW-TO GET THE NBC/NXC COMPILER ON THE RASPBERRY PI
  3. ===================================================
  4.  
  5. I assume you are using Raspbian.
  6.  
  7.  
  8. $ cd ~/path/where/i/want/to/install/nbc
  9.  
  10.  
  11.  
  12. Folder to hold the sourcecode:
  13.  
  14. $ mkdir nbc_src
  15.  
  16. $ cd nbc_src
  17.  
  18.  
  19.  
  20. Download the source code:
  21.  
  22. $ wget http://freefr.dl.sourceforge.net/project/bricxcc/NBC_NXC/NBC%20release%201.2.1%20r4/nbc-1.2.1.r4.src.tgz
  23.  
  24. If that don't work, download the nbc source code from this site:
  25. http://sourceforge.net/projects/bricxcc/files/NBC_NXC/NBC%20release%201.2.1%20r4/nbc-1.2.1.r4.src.tgz/download
  26.  
  27. Make sure you are downloading the latest version of NBC. See all versions here:
  28. http://sourceforge.net/projects/bricxcc/files/NBC_NXC/
  29.  
  30.  
  31.  
  32. Extract in current directory, make sure filename is correct
  33.  
  34. $ tar xvzf nbc-1.2.1.r4.src.tgz
  35.  
  36.  
  37.  
  38. Go to the newly created "NXT" directory
  39.  
  40. $ cd NXT
  41.  
  42.  
  43.  
  44. Now you need to install the FreePascal compiler and USB support, for transferring programs to the NXT
  45.  
  46. $ sudo apt-get install fp-compiler fp-units-fcl libusb-dev
  47.  
  48.  
  49.  
  50. Start compiling/assembling
  51.  
  52. $ make -f nbcunix.mak
  53.  
  54.  
  55.  
  56. Copy the executable from the source folder to the parent, and leave the source folder.
  57.  
  58. $ cp nbc ../../nbc
  59.  
  60. $ cd ../../
  61.  
  62. If you want you can delete the source folder:
  63.  
  64. $ rm -rf nbc_src
  65.  
  66.  
  67.  
  68. You can try to see of NBC is working by typing
  69.  
  70. $ ./nbc -help
  71.  
  72. You should see the help about the tool
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80. Now let's fix USB support, so you can upload the programs to the NXT directly
  81. I like using nano, but you can use leafpad or any other text editor
  82.  
  83. $ sudo nano /etc/udev/rules.d/71-lego.rules
  84.  
  85. Paste the following in that file:
  86.  
  87.  
  88.  
  89. # USB - Lego Mindstorms NXT
  90. SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="0694", ATTR{idProduct}=="0002", MODE:="0666"
  91. SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="03eb", ATTR{idProduct}=="6124", MODE:="0666"
  92.  
  93.  
  94.  
  95.  
  96. Press Ctrl+X, write Y (for english) and hit enter. The file is now saved.
  97.  
  98. Now run this command to reload the udev rules:
  99.  
  100. $ sudo udevadm control --reload-rules
  101.  
  102.  
  103.  
  104.  
  105. You can now connect the NXT and start write programs!!
  106.  
  107.  
  108.  
  109. Example program:
  110.  
  111.  
  112. task main() {
  113. ClearScreen();
  114. TextOut(0, LCD_LINE4, "Hello, Raspberry");
  115.  
  116. while(1) {}
  117. }
  118.  
  119.  
  120.  
  121.  
  122. To compile a program and run it:
  123.  
  124. $ ./nbc myProgram.nxc -r
  125.  
  126.  
  127.  
  128. Enjoy!
  129.  
  130. Please tell me if I missed a step
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement