1 ## Build IoT.js with NuttX
4 We work on STM32F4 board for NuttX and the detail of the reference board is well described at [STM32F4-discovery with BB](http://www.st.com/web/en/catalog/tools/FM116/SC959/SS1532/LN1199/PF255417).
6 ### Relation with STM board?
7 We do not have any business relation with STM board. It is selected because it has enough RAM and Flash ROM, so that development can be more comfortable. And it has lots of pins to play with.
9 When IoT.js is built up and optimized, it may work in devices having smaller resource.
12 ### 1. Prepare for prerequisite
16 $ sudo apt-get install autoconf libtool gperf flex bison autoconf2.13
17 $ sudo apt-get install cmake libncurses-dev libusb-1.0-0-dev
18 $ sudo apt-get install libsgutils2-dev gcc-arm-none-eabi minicom
21 To use menuconfig in NuttX, you may need to install kconfig frontend.
24 $ git clone https://github.com/jameswalmsley/kconfig-frontends.git
25 $ cd kconfig-frontends
27 $ ./configure --enable-mconf
35 * Install Xcode from the app store and run once Xcode to install components.
36 * Install Xcode command line tools.
38 $ xcode-select --install
40 * Install [Homebrew package manager](http://brew.sh/)
43 $ brew tap PX4/homebrew-px4
45 $ brew install cmake bash-completion pkg-config kconfig-frontends
46 $ brew install gcc-arm-none-eabi libusb minicom
49 ### 2. Build NuttX (For the first time)
51 To generate headers which are required to build IoT.js, for the first time, you need to build NuttX at least once. This time nuttx build will be failed. But don't worry at this time. After one execution, you don't need this sequence any more.
53 #### Supported Nuttx version
56 | nuttx | nuttx-7.19 |
59 We only guarantee that the specified version will work well. It is recommended to check out with the specified tag from a git repository.
62 #### Follow the instruction
63 * [STM32F4-discovery](../../targets/nuttx-stm32f4/README.md)
66 ### 3. Build IoT.js for NuttX
68 These options are needed.
72 --nuttx-home=/path/to/nuttx
73 --target-board=stm32f4dis
74 --jerry-heaplimit=[..]
80 --target-arch=arm --target-os=nuttx --nuttx-home=../nuttx \
81 --target-board=stm32f4dis --jerry-heaplimit=78
84 Library files will be generated like below when build is successful.
87 $ ls build/arm-nuttx/release/lib
88 libhttpparser.a libiotjs.a libjerrycore.a libtuv.a
93 This time make command for NuttX has to be successful unlike above.
95 #### Follow the instruction
96 * [STM32F4-discovery](../../targets/nuttx-stm32f4/README.md)
102 There are two USB Connections on the Target board. USB mini CN1 and USB micro CN5. Both USB ports need to be connected to your Host. CN1 is used for power and Flashing, but it will not appear as a device in Linux. CN5 is used for NSH and will appear as `/dev/ttyACM0(linux)` or `/dev/tty.usbmodem1(macOS)` when things work well.
108 $ minicom --device=/dev/ttyACM0
110 $ minicom --device=/dev/tty.usbmodem1
113 You may need to enable _Add Carriage Return_ option.
114 * Press <kbd>Ctrl-A</kbd> + <kbd>Z</kbd> + <kbd>U</kbd> for short in minicom screen. (For linux user)
115 * Press <kbd>[Meta](http://osxdaily.com/2013/02/01/use-option-as-meta-key-in-mac-os-x-terminal/)</kbd> + <kbd>Z</kbd> for short in minicom screen. (For macOS user)
117 Press _Enter_ key several times to trigger NuttShell to start.
119 If micro SD is enabled, you can copy any script file to it and run with _nsh_, for example;
122 nsh> mount -t vfat /dev/mmcsd0 /mnt/sdcard
123 nsh> iotjs /mnt/sdcard/path_to_file.js
128 +-----------------------------+
130 | Cannot open /dev/ttyACM0! |
132 +-----------------------------+
134 and it stays on the screen, something is wrong. Blue LED may blink if NuttX is in abnormal state. Press black(reset) button on the board and try again. If you still see this warning message, begin with original NuttX code and check your board, USB line and other softwares.