From 6e5405d6fc28dc765fab755d455dfc2344382253 Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Fri, 19 Apr 2019 21:44:04 +0200 Subject: [PATCH] nuttx: Add Minimal support for stm32f7nucleo So far, Only console, http module has been tested. Config file is generated using defconfig, and contains those mandatory options: ``` CONFIG_NET_LOCAL=y CONFIG_NET_TCPBACKLOG=y CONFIG_PTHREAD_MUTEX_TYPES=y CONFIG_RR_INTERVAL=100 CONFIG_SCHED_LPWORKPRIORITY=176 ``` Build flags are relying on mcpu flags. More IO modules to be supported next. Relate-to: https://github.com/rzr/webthing-iotjs/issues/3 Change-Id: Ib44227e33c6b7d07f11687385d788017350e3827 IoT.js-DCO-1.0-Signed-off-by: Philippe Coval p.coval@samsung.com --- CMakeLists.txt | 3 + config/nuttx/stm32f7nucleo/config.default | 93 +++++++++++++++++++ src/modules.json | 9 ++ src/modules/iotjs_module_stm32f7nucleo.c | 24 +++++ src/modules/iotjs_module_stm32f7nucleo.h | 20 ++++ .../nuttx/iotjs_module_stm32f7nucleo-nuttx.c | 22 +++++ tools/build.py | 5 +- 7 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 config/nuttx/stm32f7nucleo/config.default create mode 100644 src/modules/iotjs_module_stm32f7nucleo.c create mode 100644 src/modules/iotjs_module_stm32f7nucleo.h create mode 100644 src/modules/nuttx/iotjs_module_stm32f7nucleo-nuttx.c diff --git a/CMakeLists.txt b/CMakeLists.txt index f15cc0d350..8d37d6dcc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/config/nuttx/stm32f7nucleo/config.default b/config/nuttx/stm32f7nucleo/config.default new file mode 100644 index 0000000000..dd54ca16e9 --- /dev/null +++ b/config/nuttx/stm32f7nucleo/config.default @@ -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 diff --git a/src/modules.json b/src/modules.json index 53ca1f3e04..c03c64f55f 100644 --- a/src/modules.json +++ b/src/modules.json @@ -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", diff --git a/src/modules/iotjs_module_stm32f7nucleo.c b/src/modules/iotjs_module_stm32f7nucleo.c new file mode 100644 index 0000000000..dfa2c8a723 --- /dev/null +++ b/src/modules/iotjs_module_stm32f7nucleo.c @@ -0,0 +1,24 @@ +/* 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() { + jerry_value_t stm32f7nucleo = jerry_create_object(); + + return stm32f7nucleo; +} diff --git a/src/modules/iotjs_module_stm32f7nucleo.h b/src/modules/iotjs_module_stm32f7nucleo.h new file mode 100644 index 0000000000..c70445f61e --- /dev/null +++ b/src/modules/iotjs_module_stm32f7nucleo.h @@ -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 */ diff --git a/src/modules/nuttx/iotjs_module_stm32f7nucleo-nuttx.c b/src/modules/nuttx/iotjs_module_stm32f7nucleo-nuttx.c new file mode 100644 index 0000000000..4f517219b2 --- /dev/null +++ b/src/modules/nuttx/iotjs_module_stm32f7nucleo-nuttx.c @@ -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__ diff --git a/tools/build.py b/tools/build.py index 38c57b8e49..3b596c6ca9 100755 --- a/tools/build.py +++ b/tools/build.py @@ -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', @@ -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)