From da8934180ab499fda8874a9e6932dc1596b2d159 Mon Sep 17 00:00:00 2001 From: Rodrigo Sim Date: Thu, 11 Jul 2024 18:38:26 -0300 Subject: [PATCH] board/stm32f401rc-rs485: Add support to Device Configuration over Telnet Signed-off-by: Rodrigo Sim rcsim10@gmail.com --- .../boards/stm32f401rc-rs485/index.rst | 34 +++++++ .../configs/telnetd/defconfig | 93 +++++++++++++++++++ .../stm32f401rc-rs485/src/CMakeLists.txt | 3 + .../arm/stm32/stm32f401rc-rs485/src/Make.defs | 3 + .../stm32/stm32f401rc-rs485/src/stm32_reset.c | 62 +++++++++++++ 5 files changed, 195 insertions(+) create mode 100644 boards/arm/stm32/stm32f401rc-rs485/configs/telnetd/defconfig create mode 100644 boards/arm/stm32/stm32f401rc-rs485/src/stm32_reset.c diff --git a/Documentation/platforms/arm/stm32f4/boards/stm32f401rc-rs485/index.rst b/Documentation/platforms/arm/stm32f4/boards/stm32f401rc-rs485/index.rst index 8bc84c461d42b..6eb45f87b0438 100644 --- a/Documentation/platforms/arm/stm32f4/boards/stm32f401rc-rs485/index.rst +++ b/Documentation/platforms/arm/stm32f4/boards/stm32f401rc-rs485/index.rst @@ -501,6 +501,7 @@ rndis Configures the NuttShell (nsh), enables a serial console on USART6 and enables RNDIS over USB. NSH commands:: + nsh> mount -t procfs /proc nsh> ping -h Usage: ping [-c ] [-i ] [-W ] [-s ] @@ -598,3 +599,36 @@ The board profile configures the NSH over USB and you can use the fb command to 5: ( 55, 25) ( 18, 14) Test finished nsh> + +telnetd +------- + +Configures the NuttShell (nsh), enables a serial console on USART6, enables RNDIS over USB and +enables Device Configuration over Telnet. +NSH commands:: + + nsh> mount -t procfs /proc + nsh> ifcong + +Get the ip address assigned to eth0 and convert to hexadecimal, for example 192.168.1.2 +becomes 0xC0A80102, than configure CONFIG_NETINIT_IPADDR and CONFIG_EXAMPLES_TELNETD_IPADDR, +also configure the router address, in this example it woukd be 0xC0A80101. After theses changes +rebuild and load the new firmware on your board:: + + nsh> mount -t procfs /proc + nsh> telnetd + +At your host PC, telnet to IP address for the board:: + + $ telnet 192.168.01.02 + +Now you will be able to access the Device Configuration over Telnet:: + + Device Configuration over Telnet + You can add functions to setup your device + Type '?' and press for help + cfg> ? + Available commands: + help, ? - show help + reset - reset the board + exit - exit shell diff --git a/boards/arm/stm32/stm32f401rc-rs485/configs/telnetd/defconfig b/boards/arm/stm32/stm32f401rc-rs485/configs/telnetd/defconfig new file mode 100644 index 0000000000000..151a77adc6d71 --- /dev/null +++ b/boards/arm/stm32/stm32f401rc-rs485/configs/telnetd/defconfig @@ -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_FPU is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +# CONFIG_SYSTEM_TELNETD is not set +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="stm32f401rc-rs485" +CONFIG_ARCH_BOARD_STM32F401RC_RS485=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_CHIP="stm32" +CONFIG_ARCH_CHIP_STM32=y +CONFIG_ARCH_CHIP_STM32F401RC=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_IRQBUTTONS=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARDCTL_USBDEVCTRL=y +CONFIG_BOARD_LOOPSPERMSEC=8499 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_EXAMPLES_BUTTONS=y +CONFIG_EXAMPLES_BUTTONS_NAME0="SW3" +CONFIG_EXAMPLES_BUTTONS_NAME1="SW4" +CONFIG_EXAMPLES_BUTTONS_NAME2="SW5" +CONFIG_EXAMPLES_BUTTONS_NAMES=y +CONFIG_EXAMPLES_BUTTONS_QTD=3 +CONFIG_EXAMPLES_TELNETD=y +CONFIG_EXAMPLES_TELNETD_DRIPADDR=0xC0A80101 +CONFIG_EXAMPLES_TELNETD_IPADDR=0xC0A80102 +CONFIG_FS_PROCFS=y +CONFIG_FS_TMPFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INPUT=y +CONFIG_INPUT_BUTTONS=y +CONFIG_INPUT_BUTTONS_LOWER=y +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_MEMFD_ERROR=y +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x0 +CONFIG_NETDEV_LATEINIT=y +CONFIG_NETINIT_DRIPADDR=0xC0A80101 +CONFIG_NETINIT_IPADDR=0xC0A80102 +CONFIG_NETINIT_NETMASK=0xFFFFFF00 +CONFIG_NETINIT_NOMAC=y +CONFIG_NETINIT_THREAD=y +CONFIG_NETUTILS_DHCPC=y +CONFIG_NETUTILS_TELNETD=y +CONFIG_NETUTILS_WEBCLIENT=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_ICMP=y +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_LOOPBACK=y +CONFIG_NET_STATISTICS=y +CONFIG_NET_TCP=y +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_UDP=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_DISABLE_IFUPDOWN=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=98304 +CONFIG_RAM_START=0x20000000 +CONFIG_RAW_BINARY=y +CONFIG_RNDIS=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_SPI=y +CONFIG_START_DAY=5 +CONFIG_START_MONTH=5 +CONFIG_START_YEAR=2014 +CONFIG_STM32_JTAG_SW_ENABLE=y +CONFIG_STM32_OTGFS=y +CONFIG_STM32_PWR=y +CONFIG_STM32_USART6=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_PING=y +CONFIG_TASK_NAME_SIZE=0 +CONFIG_USART6_SERIAL_CONSOLE=y +CONFIG_USBDEV=y diff --git a/boards/arm/stm32/stm32f401rc-rs485/src/CMakeLists.txt b/boards/arm/stm32/stm32f401rc-rs485/src/CMakeLists.txt index ac84ab514ea3d..ae438a4f62b09 100644 --- a/boards/arm/stm32/stm32f401rc-rs485/src/CMakeLists.txt +++ b/boards/arm/stm32/stm32f401rc-rs485/src/CMakeLists.txt @@ -30,6 +30,9 @@ endif() if(CONFIG_BOARDCTL) list(APPEND SRCS stm32_appinit.c) + if(CONFIG_BOARDCTL_RESET) + list(APPEND SRCS stm32_reset.c) + endif() endif() if(CONFIG_ARCH_BUTTONS) diff --git a/boards/arm/stm32/stm32f401rc-rs485/src/Make.defs b/boards/arm/stm32/stm32f401rc-rs485/src/Make.defs index c482c747a1af0..ea4b7f10dfee8 100644 --- a/boards/arm/stm32/stm32f401rc-rs485/src/Make.defs +++ b/boards/arm/stm32/stm32f401rc-rs485/src/Make.defs @@ -38,6 +38,9 @@ endif ifeq ($(CONFIG_BOARDCTL),y) CSRCS += stm32_appinit.c +ifeq ($(CONFIG_BOARDCTL_RESET),y) +CSRCS += stm32_reset.c +endif endif ifeq ($(CONFIG_ARCH_BUTTONS),y) diff --git a/boards/arm/stm32/stm32f401rc-rs485/src/stm32_reset.c b/boards/arm/stm32/stm32f401rc-rs485/src/stm32_reset.c new file mode 100644 index 0000000000000..6e1501dde86e9 --- /dev/null +++ b/boards/arm/stm32/stm32f401rc-rs485/src/stm32_reset.c @@ -0,0 +1,62 @@ +/**************************************************************************** + * boards/arm/stm32/stm32f401rc-rs485/src/stm32_reset.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#ifdef CONFIG_BOARDCTL_RESET + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value int this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +int board_reset(int status) +{ + up_systemreset(); + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */