Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
compiling-v2-dev [2017/02/10 09:36]
93.7.26.177
compiling-v2-dev [2017/09/03 21:02] (current)
51.6.19.28 [Toolchain installation]
Line 25: Line 25:
 Then we need to install the ARM GCC Toolchain. ​ Then we need to install the ARM GCC Toolchain. ​
  
-For this you can use the classic Smoothie method, or the repositories :  +For this you use the repositories :  
 +We want a version >= gcc version 6.3.1 20170620
 === From the repositories === From the repositories
  
Line 35: Line 35:
 </​code>​ </​code>​
  
-=== Using the Smoothie script 
- 
-Smoothie has a script to grab the toolchain you might be used to ( see [[http://​smoothieware.org/​compiling-smoothie|compiling smoothie]] ), here is how to use it :  
- 
-<​code>​ 
-wget https://​raw.githubusercontent.com/​Smoothieware/​Smoothieware/​edge/​linux_install 
-chmod +x linux_install 
-./​linux_install 
-./​BuildShell 
-</​code>​ 
  
 == Cloning NuttX == Cloning NuttX
Line 87: Line 77:
 Here is a list of different methods you can use to flash the board, mostly depending on the hardware available to you :  Here is a list of different methods you can use to flash the board, mostly depending on the hardware available to you : 
  
-=== Using a ST-Link v2+=== Using a STLink-v2 with OpenOCD 
 + 
 +**Note: You will need to use the OpenOCD version 0.10 or newer from repository. OpenOCD 0.9 from Ubuntu repository doesn'​t work.**
  
 In order to flash the firmware (nuttx.bin) inside the board using a ST-Link v2, you need to connect the JTAG/SWD programmer in the J5 connector of the board. In order to flash the firmware (nuttx.bin) inside the board using a ST-Link v2, you need to connect the JTAG/SWD programmer in the J5 connector of the board.
Line 100: Line 92:
  
 Just connect the USB/Serial board to Slot/​Connector 5 and use some serial console terminal like "​minicom"​ configured to 115200 8n1 to get access to NuttX prompt. Just connect the USB/Serial board to Slot/​Connector 5 and use some serial console terminal like "​minicom"​ configured to 115200 8n1 to get access to NuttX prompt.
 +
 +=== Using JLink with OpenOCD
 +
 +**Note: You will need to use the OpenOCD version 0.10 or newer from repository. OpenOCD 0.9 from Ubuntu repository doesn'​t work.**
 +
 +To use JLink programmer to flash the Bambino board you need edit the jlink.cfg to use the SWD instead of JTAG:
 +
 +<​code>​
 +$ sudo vi /​usr/​local/​share/​openocd/​scripts/​interface/​jlink.cfg ​
 +</​code>​
 +
 +Then add this line at end of file:
 +
 +<​code>​
 +transport select swd
 +</​code>​
 +
 +Now you can use the same command line that was used with STLink-V2 programmer:
 +<​code>​
 +$ sudo openocd -f interface/​jlink.cfg -f target/​lpc4350.cfg -c init -c "reset halt" -c "flash write_image erase nuttx.bin 0x14000000"​
 +</​code>​
 +
 +If this command doesn'​t work for you, try it instead:
 +
 +<​code>​
 +$ sudo openocd -f interface/​jlink.cfg -f board/​lpc4350_spifi_generic.cfg -c init -c "reset halt" -c "flash write_image erase nuttx.bin 0x14000000"​
 +</​code>​
 +
 +We should see this message:
 +<​code>​
 +Open On-Chip Debugger 0.10.0-dev-00371-g81631e4 (2016-09-26-12:​35)
 +Licensed under GNU GPL v2
 +For bug reports, read
 + http://​openocd.org/​doc/​doxygen/​bugs.html
 +swd
 +adapter speed: 500 kHz
 +cortex_m reset_config vectreset
 +Info : No device selected, using first device.
 +Info : J-Link ARM V8 compiled Nov 28 2014 13:44:46
 +Info : Hardware version: 8.00
 +Info : VTarget = 3.313 V
 +Info : clock speed 500 kHz
 +Info : SWD DPIDR 0x2ba01477
 +Info : lpc4350.m4: hardware has 6 breakpoints,​ 4 watchpoints
 +Warn : Only resetting the Cortex-M core, use a reset-init event handler to reset any peripherals or configure hardware srst support.
 +lpc4350.m4: target state: halted
 +target halted due to debug-request,​ current mode: Thread ​
 +xPSR: 0x01000000 pc: 0x10402c40 msp: 0x10087ff0
 +auto erase enabled
 +Info : Found flash device 'win w25q64cv'​ (ID 0x001740ef)
 +wrote 131072 bytes from file nuttx.bin in 5.381125s (23.787 KiB/s)
 +</​code>​
  
 === Using lpc21isp === Using lpc21isp
Line 168: Line 212:
  
 <​code>​ <​code>​
-JLinkGDBServer -device ​LPC4337_M4 ​-endian little -if JTAG -speed 10000 -localhostonly+JLinkGDBServer -device ​LPC4330_M4 ​-endian little -if JTAG -speed 10000 -localhostonly
 arm-none-eabi-gdb -ex "set target-charset ASCII" -ex "set print pretty on" -ex "​target remote :2331" -ex "set mem inaccessible-by-default off" nuttx arm-none-eabi-gdb -ex "set target-charset ASCII" -ex "set print pretty on" -ex "​target remote :2331" -ex "set mem inaccessible-by-default off" nuttx
 </​code>​ </​code>​
Line 175: Line 219:
 * arm-none-eabi-gdb connects to JLinkGDBServer via a TCP/IP socket on port 2331. It can then be used in a fashion similar to how MRI has been used to debug Smoothie firmware in the past. * arm-none-eabi-gdb connects to JLinkGDBServer via a TCP/IP socket on port 2331. It can then be used in a fashion similar to how MRI has been used to debug Smoothie firmware in the past.
  
-It is possible to use GDB and the JLinkGDBServer to upload code into the LPC4337 ​via JTAG. I see upload speeds of >​1MiB/​sec when using this method.+It is possible to use GDB and the JLinkGDBServer to upload code into the LPC4330 ​via JTAG. I see upload speeds of >​1MiB/​sec when using this method.
  
 From within GDB, you can issue the following commands to upload the binary contents of the specified .elf file into the microcontroller and start it executing again from a clean reset. From within GDB, you can issue the following commands to upload the binary contents of the specified .elf file into the microcontroller and start it executing again from a clean reset.
Line 184: Line 228:
 monitor reset monitor reset
 continue continue
 +</​code>​
 +
 +=== Using LPCScrypt
 +
 +First off download the User Guide PDF [[http://​www.nxp.com/​products/​software-and-tools/​software-development-tools/​software-tools/​lpc-microcontroller-utilities/​lpcscrypt-v1.8.0:​LPCSCRYPT?​tab=Documentation_Tab|here]].
 +
 +In particular, read section 3.2 and 3.3 about what needs to be installed before LPCScrypt can run.
 +
 +Here is a brief summary of what is required for Ubuntu platforms:
 +
 +* LPCScrypt installs 32-bit binaries so 64-bit Ubuntu installs will need additional 32-bit library support:
 +** Ubuntu 13.04 of earlier: ''​sudo apt-get install linux32 ia32-libs''​
 +** Ubuntu 13.10 and later: ''​sudo apt-get install libc6:i386 libusb-dev:​i386 uuid-dev:​i386 libgtk2.0-0:​i386 gtk2-engines-murrine:​i386''​
 +* It can be nice to have the USB based serial ports exposed by the LPCScrypt second stage boot loader accessible from user mode:
 +* ''​sudo scripts/​install_udev_rules''​
 +
 +Then, download LPCScript from [[http://​www.nxp.com/​products/​software-and-tools/​software-development-tools/​software-tools/​lpc-microcontroller-utilities/​lpcscrypt-v1.8.0:​LPCSCRYPT?​tab=Design_Tools_Tab|here]] and install it.
 +
 +You then need to enter bootloader mode : 
 +
 +* Press and hold down the ISP button.
 +* Press and release the RESET button.
 +* Release the ISP button.
 +
 +This is the same as the procedure for [[http://​smoothieware.org/​flashing-the-bootloader|flashing the v1 bootloader]].
 +
 +You can then use LPCScrypt to flash your firmware : 
 +
 +<​code>​
 +./​scripts/​boot_lpcscrypt ​
 +./​bin/​lpcscrypt program +c /​path/​to/​nuttx/​nuttx.bin BankA
 +./​bin/​lpcscrypt resetCore
 +</​code>​
 +
 +Alternatively this has been known to work : 
 +
 +<​code>​
 +sleep 1
 +./​bin/​lpcscrypt -d /​dev/​ttyACM0 program +c LPC4330_M4/​Smoothie2.bin SPIFI
 +sleep 1
 +./​bin/​lpcscrypt -d /​dev/​ttyACM0 resetCore
 +</​code>​
 +
 +== Verifying NuttX Initialization ==
 +
 +You flashed the nuttx.bin firmware inside Bambino 200E board, now you can see the NuttX initialization over serial.
 +
 +Just connect the USB/Serial board to Gadgeteer Slot 5 (label: "​KU ​  ​X"​) and use some serial console terminal like "​minicom"​ with the USB/Serial device file detected by Linux (use dmesg to see it, normall will be /​dev/​ttyUSB0) and configure it to 115200 8n1 to get access to NuttX prompt.
 +
 +Press the "​RESET"​ button near USB1 connector and you will see the NuttX initialization:​
 +
 +<​code>​
 +NuttShell (NSH)                                                                    ​
 +nsh>
 +</​code>​
 +
 +Type "​help"​ or "?"​ to see the available commands:
 +
 +<​code>​
 +nsh> ?
 +help usage: ​ help [-v] [<​cmd>​] ​                                              
 +                                        ​
 +  [           ​cmp ​        ​false ​      ​mkdir ​      ​rm ​         true        ​
 +  ?           ​dirname ​    ​free ​       mh          rmdir       ​uname ​      
 +  basename ​   dd          help        mount       ​set ​        ​umount ​     ​
 +  break       ​df ​         hexdump ​    ​mv ​         sh          unset       
 +  cat         ​echo ​       kill        mw          sleep       ​usleep ​     ​
 +  cd          exec        ls          ps          test        xd          ​
 +  cp          exit        mb          pwd         ​time ​       ​
 +
 +Builtin Apps:
 +nsh>
 </​code>​ </​code>​
  
Line 207: Line 323:
  
 == Testing USB == Testing USB
 +
 +You can test USB on Bambino board using these steps:
 +
 +<​code>​
 +cd ~/​nuttxspace/​nuttx/​tools
 +./​configure.sh bambino-200e/​usbnsh
 +cd ..
 +make
 +</​code>​
 +
 +Flash the nuttx.bin firmware as explained before and connect a USB cable on USB0 port and to your PC.
 +
 +Reset the board, you will see in the "​dmesg"​ of Linux that it created the USB/Serial device as ttyACM0. Configure the minicom to use /​dev/​ttyACM0 115200 8N1.
 +
 +Press Enter three times in the minicom to start the NuttX Shell.
 +
 +== Testing SD Card ==
  
 TODO TODO