This is a step-by-step tutorial explaining how to compile and install NuttX on Infineon XMC4500-Relax board.
These steps where tested on Ubuntu 16.04 LTS (Long Term Support).
Open the Linux terminal and install the dependence packages using this command:
$ sudo apt-get install automake bison build-essential flex gcc-arm-none-eabi gperf git libncurses5-dev libtool libusb-dev libusb-1.0.0-dev pkg-config
Create the nuttx workspace:
mkdir ~/nuttxspace cd ~/nuttxspace
Clone and compile the OpenOCD (it is used to flash the firmware in the board).
$ git clone http://repo.or.cz/r/openocd.git $ cd ~/nuttxspace/openocd $ ./bootstrap $ ./configure --enable-internal-jimtcl --enable-maintainer-mode --disable-werror --disable-shared --enable-stlink --enable-jlink --enable-rlink --enable-vslink --enable-ti-icdi --enable-remote-bitbang --enable-usb-blaster --enable-presto --enable-osbdm $ make $ sudo make install
Copy the OpenOCD udev rules and update it:
$ cd contrib $ sudo cp 60-openocd.rules /etc/udev/rules.d/ $ sudo udevadm trigger
Clone the NuttX repositories:
$ cd ~/nuttxspace $ git clone https://bitbucket.org/nuttx/nuttx $ git clone https://bitbucket.org/nuttx/apps $ git clone https://bitbucket.org/nuttx/tools
Configure, compile and install the Kconfig-Frontends (needed by NuttX’s menuconfig)
$ cd ~/nuttxspace $ cd tools/kconfig-frontends/ $ ./configure $ make $ sudo make install $ sudo ldconfig
Now we can compile NuttX for XMC4-Relax board!
Run the configure script:
$ cd ~/nuttxspace $ cd nuttx $ ./tools/configure.sh xmc4500-relax/nsh
Run menuconfig and change the build to Linux and UART3 as serial console:
$ make menuconfig Build Setup ---> Build Host Platform (Linux) System Type ---> XMC4xxx Peripheral Support ---> [ ] USIC0 [*] USIC1 (press SPACE to select) [ ] USIC2 XMC4xxx USIC Configuration ---> USIC1 Channel 0 Configuration (Not used) ---> USIC1 Channel 1 Configuration (UART3) ---> Device Drivers ---> [*] Serial Driver Support ---> Serial console (UART3) --->
Time to compile it:
$ make
If everything compiled correctly you get a nuttx.bin:
$ ls -l nuttx.bin -rwxrwxr-x 1 alan alan 79804 Jan 8 12:25 nuttx.bin
Plug the USB cable on you computer and on XMC4500-Relax board and use OpenOCD to flash it:
$ sudo openocd -f board/xmc4500-relax.cfg -c init -c "reset halt" -c "flash write_image erase nuttx.bin 0x0c000000"
You should see these messages:
$ sudo openocd -f board/xmc4500-relax.cfg -c init -c "reset halt" -c "flash write_image erase nuttx.bin 0x0c000000" Open On-Chip Debugger 0.10.0+dev-00172-g7719e96 (2017-11-12-09:13) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html adapter speed: 4000 kHz cortex_m reset_config sysresetreq adapter speed: 1000 kHz Info : No device selected, using first device. Info : J-Link Lite-XMC4000 Rev.1 compiled Apr 2 2015 18:25:20 Info : Hardware version: 1.00 Info : VTarget = 3.300 V Info : clock speed 1000 kHz Info : SWD DPIDR 0x2ba01477 Info : xmc4500.cpu: hardware has 6 breakpoints, 4 watchpoints target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x08000200 msp: 0x20001e84 auto erase enabled Info : Clearing flash status Info : Clearing flash status wrote 81920 bytes from file nuttx.bin in 19.998228s (4.000 KiB/s)
Configure your Linux machine to let your user to have access to serial port:
$ sudo usermod -a -G dialout alan
You just replace ‘alan’ with your username.
You need a USB/Serial adapter that works to 3.3V, like FDTI dongle or Silabs CP2102.
Connect the USB/Serial RXD to XMC4500-Relax board P0.1 (Header pin X1 pin 34), connect TXD to P0.0 (Header pin X1 pin 36) and connect the GND to board GND (Header pin X1 pin 1, 2, 3 or 4).
Configure minicom to use your USB/Serial adapter (i.e. at /dev/ttyUSB0) to 115200 8n1:
$ sudo minicom -s Serial port setup A - Serial Device : /dev/ttyUSB0 E - Bps/Par/Bits : 115200 8N1 F - Hardware Flow Control : No G - Software Flow Control : No Save setup as dfl Exit
Press the XMC4500 Reset button and you should see:
NuttShell (NSH) nsh>
Type ‘help’ or ‘?’ to the the listing of enabled commands:
nsh> help help usage: help [-v] [] [ dirname help mh set unset ? dd hexdump mount sh usleep basename df kill mv sleep xd break echo ls mw test cat exec mb ps time cd exit mkdir pwd true cp false mkfatfs rm uname cmp free mkrd rmdir umount Builtin Apps: i2c ramtest nsh>