Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuttx: Add Minimal support for stm32f7nucleo #1869

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ elseif("${TARGET_BOARD}" STREQUAL "rpi3")
elseif("${TARGET_BOARD}" STREQUAL "stm32f4dis")
iotjs_add_compile_flags(-mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16)
iotjs_add_compile_flags(-mfloat-abi=hard)
elseif("${TARGET_BOARD}" STREQUAL "stm32f7nucleo")
iotjs_add_compile_flags(-mcpu=cortex-m7)
iotjs_add_compile_flags(-mfloat-abi=hard)
endif()

# Add os-dependant flags
Expand Down
93 changes: 93 additions & 0 deletions config/nuttx/stm32f7nucleo/config.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="nucleo-144"
CONFIG_ARCH_BOARD_NUCLEO_144=y
CONFIG_ARCH_BUTTONS=y
CONFIG_ARCH_CHIP_STM32F767ZI=y
CONFIG_ARCH_CHIP_STM32F7=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_DCACHE=y
CONFIG_ARMV7M_DCACHE_WRITETHROUGH=y
CONFIG_ARMV7M_DTCM=y
CONFIG_ARMV7M_ICACHE=y
CONFIG_BOARD_LOOPSPERMSEC=43103
CONFIG_BUILTIN=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_ETH0_PHY_LAN8742A=y
CONFIG_FS_PROCFS=y
CONFIG_FS_PROCFS_REGISTER=y
CONFIG_FS_TMPFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_IOTJS=y
CONFIG_LIB_HOSTNAME="stntest"
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=3
CONFIG_NET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETUTILS_DISCOVER=y
CONFIG_NETUTILS_WEBCLIENT=y
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1500
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_IGMP=y
CONFIG_NET_LOCAL=y
CONFIG_NET_LOOPBACK=y
CONFIG_NET_ROUTE=y
CONFIG_NET_SOLINGER=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_NUCLEO_CONSOLE_VIRTUAL=y
CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_PREALLOC_TIMERS=4
CONFIG_PREALLOC_WDOGS=4
CONFIG_PTHREAD_MUTEX_TYPES=y
CONFIG_RAM_SIZE=245760
CONFIG_RAM_START=0x20010000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=100
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_LPWORKPRIORITY=176
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_SPI=y
CONFIG_STACK_COLORATION=y
CONFIG_START_DAY=30
CONFIG_START_MONTH=11
CONFIG_START_YEAR=2015
CONFIG_STM32F7_ETHMAC=y
CONFIG_STM32F7_PHYADDR=0
CONFIG_STM32F7_PHYSR=31
CONFIG_STM32F7_PHYSR_100FD=0x0018
CONFIG_STM32F7_PHYSR_100HD=0x0008
CONFIG_STM32F7_PHYSR_10FD=0x0014
CONFIG_STM32F7_PHYSR_10HD=0x0004
CONFIG_STM32F7_PHYSR_ALTCONFIG=y
CONFIG_STM32F7_PHYSR_ALTMODE=0x001c
CONFIG_SYSTEM_DHCPC_RENEW=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_PING=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART3_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WDOG_INTRESERVE=0
99 changes: 99 additions & 0 deletions docs/build/Build-for-STM32F4-NuttX.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,102 @@ If you see
+-----------------------------+
```
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.


## EXTRA STM32 SUPPORT

While STM32F4-Discovery is the reference target,
IoT.js can be built for other based STM32 boards:

* [Nucleo-F767zi](https://www.st.com/en/evaluation-tools/nucleo-f767zi.html)

The procedure is similar to STM32F4, so only specific info will be explained in following chapters:

## NUCLEO-F767ZI

### 1. Prepare for prerequisite

See general instructions for STM32F4 in related chapter.

### 2. Set up the build environment for STM32F7-Nucleo board

#### Supported Nuttx version for NUCLEO-F767ZI

Since development is still in progress, master branch of NuttX will be used
until a version is released with relevant STM32F7 support.

#### Clone repository for NUCLEO-F767ZI

Clone IoT.js and NuttX into iotjs-nuttx directory:

```bash
$ mkdir iotjs-nuttx
$ cd iotjs-nuttx
$ git clone https://github.com/pando-project/iotjs.git
$ git clone https://bitbucket.org/nuttx/nuttx.git --branch master
$ git clone https://bitbucket.org/nuttx/apps.git --branch master
```
### 3. Build NuttX (For the first time) for NUCLEO-F767ZI

See general instructions for STM32F4 in related chapter.

#### Add IoT.js as a builtin application for NuttX for NUCLEO-F767ZI

See general instructions for STM32F4 in related chapter.

##### Configure NuttX for NUCLEO-F767ZI

See general instructions for STM32F4 in related chapter. but instead of configuring for discovery in STM32F4:

```bash
$ ./configure.sh stm32f4discovery/usbnsh
```

Nucleo-144 board configuration will be needed with STM32F7 MCU (with Network Controller support):

```bash
$ ./configure.sh nucleo-144/f767-netnsh
```

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.)
```bash
$ cd ..
$ cp ../iotjs/config/nuttx/stm32f7nucleo/config.default .config
```

### 4. Build IoT.js for NuttX for NUCLEO-F767ZI


These options are needed.
```bash
--target-arch=arm
--target-os=nuttx
--nuttx-home=/path/to/nuttx
--target-board=stm32f7nucleo
--jerry-heaplimit=[..]
```

For example,
```bash
$ ./tools/build.py \
--target-arch=arm --target-os=nuttx --nuttx-home=../nuttx \
--target-board=stm32f7nucleo --jerry-heaplimit=78
```
Library files will be generated like below when build is successful, at least expect to find:

```bash
$ ls build/arm-nuttx/*/lib
libhttpparser.a libiotjs.a libjerrycore.a libtuv.a
```

### 5. Build NuttX for NUCLEO-F767ZI

See general instructions for STM32F4 in related chapter.

### 6. Flashing for NUCLEO-F767ZI

See general instructions for STM32F4 in related chapter.

### 7. Run IoT.js for NUCLEO-F767ZI

See general instructions for STM32F4 in related chapter.
9 changes: 9 additions & 0 deletions src/modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,15 @@
"native_files": ["modules/iotjs_module_stm32f4dis.c"],
"init": "InitStm32f4dis"
},
"stm32f7nucleo": {
"platforms": {
"nuttx": {
"native_files": ["modules/nuttx/iotjs_module_stm32f7nucleo-nuttx.c"]
}
},
"native_files": ["modules/iotjs_module_stm32f7nucleo.c"],
"init": "InitStm32f7nucleo"
},
"stream": {
"js_file": "js/stream.js",
"require": ["stream_duplex", "stream_internal", "stream_readable",
Expand Down
25 changes: 25 additions & 0 deletions src/modules/iotjs_module_stm32f7nucleo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* Copyright 2019-present Samsung Electronics Co., Ltd. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "iotjs_def.h"
#include "iotjs_module_stm32f7nucleo.h"


jerry_value_t InitStm32f7nucleo() {
LaszloLango marked this conversation as resolved.
Show resolved Hide resolved
jerry_value_t stm32f7nucleo = jerry_create_object();
/* Hardware support in progress, do initialization here */

return stm32f7nucleo;
}
20 changes: 20 additions & 0 deletions src/modules/iotjs_module_stm32f7nucleo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* Copyright 2019-present Samsung Electronics Co., Ltd. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef IOTJS_MODULE_STM32F4DIS_H
#define IOTJS_MODULE_STM32F4DIS_H


#endif /* IOTJS_MODULE_STM32F4DIS_H */
22 changes: 22 additions & 0 deletions src/modules/nuttx/iotjs_module_stm32f7nucleo-nuttx.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Copyright 2019-present Samsung Electronics Co., Ltd. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#if defined(__NUTTX__) && (TARGET_BOARD == stm32f7nucleo)


#include "iotjs_def.h"
#include "modules/iotjs_module_stm32f7nucleo.h"

#endif // __NUTTX__
5 changes: 4 additions & 1 deletion tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ def init_options():
default=platform.arch(),
help='Specify the target architecture (default: %(default)s).')
iotjs_group.add_argument('--target-board',
choices=[None, 'artik10', 'stm32f4dis', 'rpi2', 'rpi3', 'artik05x'],
choices=[None, 'artik10', 'stm32f4dis', 'stm32f7nucleo',
'rpi2', 'rpi3', 'artik05x'],
default=None, help='Specify the target board (default: %(default)s).')
iotjs_group.add_argument('--target-os',
choices=['linux', 'darwin', 'osx', 'mock', 'nuttx', 'tizen', 'tizenrt',
Expand Down Expand Up @@ -282,6 +283,8 @@ def build_cmake_args(options):
include_dirs.append('%s/include' % options.sysroot)
if options.target_board == 'stm32f4dis':
include_dirs.append('%s/arch/arm/src/stm32' % options.sysroot)
elif options.target_board == 'stm32f7nucleo':
include_dirs.append('%s/arch/arm/src/stm32f7' % options.sysroot)

if options.target_os == 'tizenrt':
include_dirs.append('%s/../framework/include/iotbus' % options.sysroot)
Expand Down