3 This directory contains files to run IoT.js on
4 [STM32F4-Discovery board](http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-discovery-kits/stm32f4discovery.html) with [NuttX](http://nuttx.org/)
8 #### 1. Set up the build environment for STM32F4-Discovery board
10 Clone IoT.js and NuttX into iotjs-nuttx directory
15 $ git clone https://github.com/Samsung/iotjs.git
16 $ git clone https://bitbucket.org/nuttx/nuttx.git --branch nuttx-7.19
17 $ git clone https://bitbucket.org/nuttx/apps.git --branch nuttx-7.19
18 $ git clone https://github.com/texane/stlink.git
21 Note that we only support the specified git tag from nuttx repository
23 The following directory structure is created after these commands
35 #### 2. Add IoT.js as a builtin application for NuttX
40 $ cp ../../iotjs/targets/nuttx-stm32f4/app/* ./iotjs/
43 #### 3. Configure NuttX
46 # assuming you are in iotjs-nuttx folder
49 # configure NuttX USB console shell
50 $ ./configure.sh stm32f4discovery/usbnsh
53 Now you can configure nuttx like either of below. For convenience, we provide built-in configure file for you. (This configure file is equipped with modules specified as `always`. For `optional` modules, you might follow instructions below.)
56 $ cp ../iotjs/targets/nuttx-stm32f4/nuttx/.config.default .config
59 Or if you want to configure yourself, you can follow guide below.
62 # might require to run "make menuconfig" twice
66 Followings are the options to set:
69 * Change `Build Setup -> Build Host Platform` from _Windows_ to [_Linux_|_OSX_]
70 * Enable `System Type -> FPU support`
71 * Enable `System Type -> STM32 Peripheral Support -> SDIO`
72 * Enable `RTOS Features -> Clocks and Timers -> Support CLOCK_MONOTONIC`
73 * Enable `RTOS Features -> Pthread Options -> Enable mutex types`
74 * Enable `RTOS Features -> Files and I/O -> Enable /dev/console`
75 * Enable `RTOS Features -> Work queue support -> High priority (kernel) worker thread`
76 * Disable `Device Drivers -> Disable driver poll interfaces`
77 * Enable `Device Drivers -> MMC/SD Driver Support`
78 * Enable `Device Drivers -> MMC/SD Driver Support -> MMC/SD SDIO transfer support`
79 * Enable `Networking Support -> Networking Support`
80 * Enable `Networking Support -> Socket Support -> Socket options`
81 * Enable `Networking Support -> Unix Domain Socket Support`
82 * Enable `Networking Support -> TCP/IP Networking`
83 * Enable `Networking Support -> TCP/IP Networking -> Enable TCP/IP write buffering`
84 * Enable `File Systems -> FAT file system`
85 * Enable `File Systems -> FAT file system -> FAT upper/lower names`
86 * Enable `File Systems -> FAT file system -> FAT long file names`
87 * Enable `Device Drivers -> Network Device/PHY Support -> Late driver initialization`
88 * Enable `Library Routines -> Standard Math library`
89 * Enable `Application Configuration -> System Libraries and NSH Add-ons -> IoT.js`
90 * Enable all children of `Application Configuration -> System Libraries and NSH Add-ons -> readline() Support` (for those who wants to use readline)
93 * Enable `System Type -> STM32 Peripheral Support -> Ethernet MAC`
94 * Disable `System Type -> STM32 Peripheral Support -> USART2`
95 * Enable `System Type -> STM32 Peripheral Support -> USART6`
96 * Set `System Type -> Ethernet MAC configuration -> PHY address` to `0`
97 * Set `System Type -> Ethernet MAC configuration -> PHY Status Register Address (decimal)` to `31`
98 * Enable `System Type -> Ethernet MAC configuration -> PHY Status Alternate Bit Layout`
99 * Set `System Type -> Ethernet MAC configuration -> PHY Mode Mask` to `0x001c`
100 * Set `System Type -> Ethernet MAC configuration -> 10MBase-T Half Duplex Value` to `0x0004`
101 * Set `System Type -> Ethernet MAC configuration -> 100Base-T Half Duplex Value` to `0x0008`
102 * Set `System Type -> Ethernet MAC configuration -> 10Base-T Full Duplex Value` to `0x0014`
103 * Set `System Type -> Ethernet MAC configuration -> 10MBase-T Full Duplex Value` to `0x0018`
104 * Set `System Type -> Ethernet MAC configuration -> RMII clock configuration` to `External RMII clock`
105 * Enable `Board Selection -> STM32F4DIS-BB base board`
106 * Set `Device Drivers -> Network Device/PHY Support -> Board PHY Selection` to `SMSC LAN8720 PHY`
107 * Enable `Networking Support -> Data link support -> Local loopback`
108 * Enable `Networking Support -> TCP/IP Networking -> TCP/IP backlog support`
109 * Enable `Networking Support -> ARP Configuration -> ARP send`
112 * Enable `Networking Support > UDP Networking`
115 * Enable `System Type -> STM32 Peripheral Support -> TIM(N)`
116 * Enable `System Type -> Timer Configuration -> TIM(N) PWM`
117 * Set `System Type -> Timer Configuration -> TIM(N) PWM -> TIM(n) PWM Output Channel` to channel number you want
118 * Enable `Device Drivers -> PWM Driver Support`
121 * Enable `System Type -> STM32 Peripheral Support -> ADC(N)`
122 * Enable `System Type -> STM32 Peripheral Support -> TIM(M)`
123 * Enable `System Type -> Timer Configuration -> TIM(M) ADC`
124 * Enable `Device Drivers -> Analog Device(ADC/DAC) Support`
125 * Enable `Device Drivers -> Analog Device(ADC/DAC) Support -> Analog-to-Digital Conversion`
128 * Enable `System Type -> STM32 Peripheral Support -> U[S]ART(N)`
130 #### 4. Build IoT.js for NuttX
132 ##### Follow the instruction
133 * [Build-for-NuttX](../../docs/build/Build-for-NuttX.md)
138 # assuming you are in iotjs-nuttx folder
142 For release version, you can type R=1 make on the command shell.
146 Connect Mini-USB for power supply and connect Micro-USB for `NSH` console.
148 To configure `stlink` utility for flashing, follow the instructions [here](https://github.com/texane/stlink#build-from-sources).
152 # assuming you are in nuttx folder
153 $ sudo ../stlink/build/st-flash write nuttx.bin 0x8000000