diff --git a/docs/MCU_based_host/Getting_started.md b/docs/MCU_based_host/Getting_started.md index ec83259611..5c39f223eb 100644 --- a/docs/MCU_based_host/Getting_started.md +++ b/docs/MCU_based_host/Getting_started.md @@ -34,12 +34,23 @@ We have tested project with STM32F469I-Discovery board. If other than STM32F469I 1) Create a workspace_directory outside of `ESP-Hosted` git cloned directory. 2) Browse and Open Workspace directory in STM32CubeIDE. It will take few seconds to open STM32CubeIDE. -3) From `Information Center` tab select Start new project from existing STM32CubeMX configuration file, i.e. ioc file option. It will take few seconds to open dialog box. In STM32CubeMX .ioc file field, browse to `/path/to/esp_hosted/host/stm32/proj/stm_spi_host.ioc -> Open` and click on `finish` icon. New dialog box will open as Open Associated Perspective, click on `Yes`. It may take 2-3 minutes to open. +3) From `Information Center` tab select Start new project from existing STM32CubeMX configuration file, i.e. ioc file option. It will take few seconds to open dialog box. In STM32CubeMX .ioc file field, browse to `/host/stm32/proj/stm_spi_host.ioc -> Open` and click on `finish` icon. New dialog box will open as Open Associated Perspective, click on `Yes`. It may take 2-3 minutes to open. 4) Close `stm_spi_host.ioc` tab then close STM32CubeIDE and click on `exit`. -5) Copy .project and.cproject from `/host/stm32/proj/`files to `/stm_spi_host/` directory forcefully. Please check hidden files for .project and .cproject for *nix based envirnments. +5) For Linux and Mac development hosts, In terminal, run +``` +$ cd /host/stm32/proj +$ bash ./prepare_project.sh +``` +For Windows based systems, open "cmd.exe" or Windows Power Shell and run - +``` +> cd \host\stm32\proj +> prepare_project.bat +``` +This will copy the project configuration files into workspace_directory + 6) Re-open STM32CubeIDE with workspace as workspace_directory. 7) Ignore all warnings under `Problems` tab if any. -8) Configure all build variables as mentioned in User configuration parameter section below. All parameters are mandatory to be filled. Please note that, every subsequent change in configuration parameter would need a clean build as mentioned ahead. +8) Configure all build variables as mentioned in [User configuration parameter](#user-configuration-parameter) section below. Variable CODE_BASE should already be populated. All parameters are mandatory to be filled. Please note that, every subsequent change in configuration parameter would need a clean build as mentioned ahead. 9) Uncheck `Build Automatically` from `menu -> Project` and Clean build the project as `Project menu -> Clean -> clean`. 10) Run application on stm32 board, please connect STM32 board to your machine if not already connected. In STM32CubeIDE, go to `Project Explorer`, right click on `stm_spi_host` project. Then `menu -> Run -> Run as -> STM32 Cortex-M C/C++ Application `. This will open Edit Configuration box, Click `OK`. `Debug as` option can also be alternatively used if debugging is desired. @@ -63,7 +74,7 @@ Shutting down... ``` $ minicom -D /dev/ttyACM0 ``` -Note: /dev/ttyACM0 is used for *nix based systems. For Windows please check used COM port. Baud rate used is 115200. Parity bits configuration is 8N1. +Note: /dev/ttyACM0 is used for For Linux, /dev/cu.usbmodemXXXXXX for Mac and COM port for Windows development host. Baud rate used is 115200. Parity bits configuration is 8N1. Expected output log on tera term or minicom similar to below one: ``` @@ -145,7 +156,9 @@ Build Variables are as follows: #### Note: All string parameters are expected to be enclosed in double quotes. -Also change `CODE_BASE` variable from `menu -> Project -> Properties -> Resource -> Linked Resources -> Path Variables -> CODE_BASE -> Edit -> -> OK -> Apply and Close`. +Verify that `CODE_BASE` variable from `menu -> Project -> Properties -> Resource -> Linked Resources -> Path Variables -> CODE_BASE` points to git cloned directory. + +In case there is a warning sign on folder icon, it means STM32CubeIDE has not correctly configured the variable. In that case, re-configure it using, `Edit -> Click On Folder -> -> Open -> OK`. The warning sign now should disappear. Now click on `Apply and Close`. ## ARP Testing : @@ -154,20 +167,19 @@ To install arping on ubuntu based system, please use ``` $ sudo apt-get install arping ``` -More details of arping could be found on [this link](https://devconnected.com/arping-command-on-linux-explained/). arping can easily be installed on other architectures. Once the connection or a control path is setup between STM32 and ESP32, ARP can be tested for that interface. +More details of arping could be found on [this link](https://devconnected.com/arping-command-on-linux-explained/). arping can easily be installed on other architectures. For Windows hosts, [check this link](https://elifulkerson.com/projects/arp-ping.php). Once the connection is setup between STM32 and ESP32, ARP can be tested for that interface. ### ARP Request orininated from STM32 For station mode, `INPUT_STATION_SRC_IP` is used as STM32 IPv4 address and `INPUT_STATION_ARP_DEST_IP` is considered as destination IPv4 address. This could be configured as IPv4 address of your machine. For softap mode, `INPUT_SOFTAP_SRC_IP` will be used as STM32 IPv4 address and `INPUT_SOFTAP_ARP_DEST_IP` used as destination IPv4 address. -Please note that, In case of softap mode, only static IPv4 addresses are supported currently. You can use your machine to connect to softap and assign static address as `INPUT_SOFTAP_ARP_DEST_IP`. + +Please note, +1. In case of softap mode, only static IPv4 addresses are supported currently. You can use your machine to connect to softap and assign static address as `INPUT_SOFTAP_ARP_DEST_IP`. +2. IP addresses configured are in same subnet for that interface. ARP request will be triggered around every one second for both softap and station network. ARP responses are displayed on receival. On minicom, typically should be printed like, ``` -ARP_RSP_RCVD: 42 bytes from 192.168.1.203 (58:a0:23:86:2a:c4) -ARP_RSP_RCVD: 42 bytes from 192.168.1.203 (58:a0:23:86:2a:c4) -ARP_RSP_RCVD: 42 bytes from 192.168.1.203 (58:a0:23:86:2a:c4) -ARP_RSP_RCVD: 42 bytes from 192.168.1.203 (58:a0:23:86:2a:c4) -ARP_RSP_RCVD: 42 bytes from 192.168.1.203 (58:a0:23:86:2a:c4) +ARP_RSP_RCVD: XX bytes from 192.168.1.203 (58:a0:23:86:2a:c4) ``` ### ARP Responses from STM32 @@ -181,11 +193,9 @@ sudo arping 192.168.2.1 ``` ARP request received in STM32 are displayed on minicom like, ``` -ARP_REQ_RCVD: 58 bytes from 192.168.1.205 (a0:88:b4:e5:d5:38) +ARP_REQ_RCVD: XX bytes from 192.168.1.205 (a0:88:b4:e5:d5:38) ``` ARP response is triggered for requests received. You should be able see ARP response on your machine as, ``` -58 bytes from 3c:71:bf:9a:bc:b8 (192.168.1.233): index=0 time=199.144 msec +XX bytes from 3c:71:bf:9a:bc:b8 (192.168.1.233): index=0 time=199.144 msec ``` - - diff --git a/host/stm32/proj/.cproject b/host/stm32/proj/.cproject index c9e1b8daa0..e839295059 100644 --- a/host/stm32/proj/.cproject +++ b/host/stm32/proj/.cproject @@ -4,7 +4,7 @@ - + diff --git a/host/stm32/proj/.project b/host/stm32/proj/.project index 88e1e4e92e..76ca2a1a0f 100644 --- a/host/stm32/proj/.project +++ b/host/stm32/proj/.project @@ -50,7 +50,7 @@ CODE_BASE - file:/my/abs/git/repo/path/of/hosted + file:CODE_BASE_PLACE_HOLDER diff --git a/host/stm32/proj/prepare_project.bat b/host/stm32/proj/prepare_project.bat new file mode 100755 index 0000000000..28b79db243 --- /dev/null +++ b/host/stm32/proj/prepare_project.bat @@ -0,0 +1,61 @@ +@echo off +rem ### This is windows platform script to copy the project files and +rem ### make them aligned to STM32CubeIDE needs + +set WORKSPACE=%1 +set PROJ_NAME=stm_spi_host +set CWD=%CD% + +rem ### Check argument passed ### +IF "%1"=="" ( +echo usage: %0 Workspace_directory_absolute_path +goto error +) + +rem ### store git repo base path### +cd ..\..\.. +set CODE_BASE=%CD% +cd %CWD% + +rem ### check workspace directory exist ### +IF not exist %WORKSPACE% ( +echo %WORKSPACE% does not exist +echo Please follow documentation to import STM project from stm_spi_host.ioc, if not already done +goto error + ) + +rem ### check project directory exist ### +IF not exist %WORKSPACE%\%PROJ_NAME% ( +echo %WORKSPACE%\%PROJ_NAME% does not exist +echo Either incorrect workspace directory or ioc project not imported +echo Please follow documentation to import STM project from stm_spi_host.ioc, if not already done +goto error + ) + +rem ### search and replace project files ### +DEL %WORKSPACE%\%PROJ_NAME%\.project 2>NUL +DEL %WORKSPACE%\%PROJ_NAME%\.cproject 2>NUL + +setLocal EnableDelayedExpansion +For /f "tokens=* delims= " %%a in (.project) do ( +Set str=%%a +set str=!str:CODE_BASE_PLACE_HOLDER=%CODE_BASE%! +echo !str!>> %WORKSPACE%\%PROJ_NAME%\.project +) +ENDLOCAL + + +setLocal EnableDelayedExpansion +For /f "tokens=* delims= " %%a in (.cproject) do ( +Set str=%%a +set str=!str:CODE_BASE_PLACE_HOLDER=%CODE_BASE%! +echo !str!>> %WORKSPACE%\%PROJ_NAME%\.cproject +) +ENDLOCAL + +rem ### touch .mxproject file ### +copy /b %WORKSPACE%\%PROJ_NAME%\.mxproject +,, >NUL + +echo success. Now open STM32CubeIDE with %WORKSPACE% +:error +EXIT /B 1 diff --git a/host/stm32/proj/prepare_project.sh b/host/stm32/proj/prepare_project.sh new file mode 100755 index 0000000000..a777272a21 --- /dev/null +++ b/host/stm32/proj/prepare_project.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# This script copies and touches the .project, .cproject and .mxproject files +# This is required to make STM32CubeIDE recognize the new project import + +PROJ_NAME=stm_spi_host +CODE_BASE= + +function usage() { + echo "$0 " +} + +function copy_and_touch_files() { + CWD=`pwd` + cd ../../../ + CODE_BASE=`pwd` + cd $CWD + cp ./.project $WORKSPACE/$PROJ_NAME/ + cp ./.cproject $WORKSPACE/$PROJ_NAME/ + sed -i.bak "s#CODE_BASE_PLACE_HOLDER#$CODE_BASE#" $WORKSPACE/$PROJ_NAME/.project + sed -i.bak "s#CODE_BASE_PLACE_HOLDER#$CODE_BASE#" $WORKSPACE/$PROJ_NAME/.cproject + touch $WORKSPACE/$PROJ_NAME/.mxproject + echo "success. Now, please open STM32CubeIDE with $WORKSPACE" +} + +if [ "$#" != "1" ] ; then + echo "Err: Workspace directory created for STM32CubeIDE to be passed as argument" + usage + exit 1; +else + WORKSPACE=$1 +fi + +if [ "$1" == '-h' ] || [ "$1" == '--help' ] ; then + usage + exit 0 +fi + + +if [ ! -d $WORKSPACE ]; then + echo "Err: $WORKSPACE directory not found. Please follow documentation to import STM project from stm_spi_host.ioc first" + usage + exit 1; +fi + +if [ ! -d $WORKSPACE/$PROJ_NAME ]; then + echo "Err: Either incorrect Workspace directory or ioc project not imported." + echo "Please follow documentation to import STM project from stm_spi_host.ioc if not already done" + usage + exit 1; +fi + +copy_and_touch_files