Skip to content

Commit

Permalink
Windows install updated and some fixes (#4)
Browse files Browse the repository at this point in the history
The windows install script has been made more resistant to possible
  interfering existing tool installations and faulty path variable.
New uart name parameter has been added to the do command. This can be used
  if the automatic detection of the XPLR-IOT-1 serial port fails.
The extFsFree function now return possible error code when applicable.
The socket example now has the correct echo server address.
  • Loading branch information
plerup authored Mar 10, 2023
1 parent 965453c commit 3e311cb
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 19 deletions.
7 changes: 7 additions & 0 deletions do
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def check_jlink():
#--------------------------------------------------------------------

def find_uart0():
if 'uart_name' in settings:
return settings['uart_name']
for port in list_ports.comports():
if re.search("CP210.+Interface 0", str(port)):
return port.device
Expand Down Expand Up @@ -420,6 +422,9 @@ if __name__ == "__main__":
parser.add_argument("-u", "--ubxlib-dir",
help="Ubxlib directory"
)
parser.add_argument("--uart-name",
help="Uart port name"
)
args = parser.parse_args()

if not args.operation[0] in locals():
Expand Down Expand Up @@ -448,6 +453,8 @@ if __name__ == "__main__":
if not args.example in examples:
error_exit(f"Invalid example \"{args.example}\"\nAvailable: {examples}")
settings['no_bootloader'] = args.no_bootloader
if args.uart_name != None:
settings['uart_name'] = args.uart_name
check_directories()
set_env()
state['example'] = args.example
Expand Down
4 changes: 0 additions & 4 deletions examples/ble_sps/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,4 @@ void main()
} else {
printf("* Failed to initiate the module: %d\n", errorCode);
}

while (1) {
uPortTaskBlock(1000);
}
}
11 changes: 6 additions & 5 deletions examples/common/ext_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ const char *extFsPath(const char *fileName)
return path;
}

unsigned long extFsFree()
int32_t extFsFree()
{
unsigned long free = 0;
int32_t errorOrSize;
struct fs_statvfs sbuf;
if (fs_statvfs(gMountPoint->mnt_point, &sbuf) == 0) {
free = sbuf.f_frsize * sbuf.f_bfree / 1024;
errorOrSize = fs_statvfs(gMountPoint->mnt_point, &sbuf);
if (errorOrSize == 0) {
errorOrSize = sbuf.f_frsize * sbuf.f_bfree / 1024;
}
return free;
return errorOrSize;
}

bool extFsFileExists(const char *fileName)
Expand Down
4 changes: 2 additions & 2 deletions examples/common/ext_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ const char *extFsPath(const char *fileName);

/**
* Get the size of the free space on the file system in kB.
* @return Actual free size.
* @return Actual free size or possible negative error code
*/
unsigned long extFsFree();
int32_t extFsFree();

/**
* Check if a file exists
Expand Down
2 changes: 1 addition & 1 deletion examples/socket/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void main()
if (errorCode == 0) {
// Send to and read back data from an echo server using ubxlib sockets
uSockAddress_t address;
uSockGetHostByName(deviceHandle, "ubxlib.it-sgn.u-blox.com",
uSockGetHostByName(deviceHandle, "ubxlib.redirectme.net",
&(address.ipAddress));
address.port = 5055;
int32_t sock = uSockCreate(deviceHandle,
Expand Down
22 changes: 15 additions & 7 deletions install/install_windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,20 @@ set ROOT_DIR=%USERPROFILE%\xplriot1
set ENV_DIR=%ROOT_DIR%\env
set GIT_ENV_DIR=%ENV_DIR:\=/%
set NCS_VERS=v2.1.0
set PIP_COM=pip3 --disable-pip-version-check install -q

echo Started at: %date% %time%

echo Installing packages...
"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass ^
-Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" ^
1>nul 2>%ERR_FILE% || (type %ERR_FILE% & exit /b 1)
set PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
set PATH=%ALLUSERSPROFILE%\chocolatey\bin;%PATH%
call :SilentCom "choco install -y --no-progress cmake --installargs 'ADD_CMAKE_TO_PATH=System'"
call :SilentCom "choco install -y --no-progress ninja gperf python3 git dtc-msys2 wget unzip nrfjprog tartool ccache"
call :SilentCom "choco install -y --no-progress ninja gperf python3 git dtc-msys2 wget curl unzip nrfjprog tartool ccache which"
call refreshenv >nul
pip3 install -q west
echo Installing west...
call :SilentCom "%PIP_COM% west"
set TarFile=newtmgr.tar.gz
curl -s https://archive.apache.org/dist/mynewt/apache-mynewt-1.4.1/apache-mynewt-newtmgr-bin-windows-1.4.1.tgz >%TarFile%
call tar -O -xf %TarFile% "*newtmgr.exe" >%ALLUSERSPROFILE%\chocolatey\bin\newtmgr.exe
Expand All @@ -49,9 +51,9 @@ call :SilentCom "west update"
call :SilentCom "west zephyr-export"

echo Installing additional Python requirements...
pip3 install -q -r zephyr/scripts/requirements.txt >nul 2>&1
pip3 install -q -r nrf/scripts/requirements.txt >nul 2>&1
pip3 install -q -r bootloader/mcuboot/scripts/requirements.txt >nul 2>&1
%PIP_COM% -r zephyr/scripts/requirements.txt >nul 2>&1
%PIP_COM% -r nrf/scripts/requirements.txt >nul 2>&1
%PIP_COM% -r bootloader/mcuboot/scripts/requirements.txt >nul 2>&1

echo Installing ARM compiler...
cd ..
Expand Down Expand Up @@ -96,7 +98,9 @@ cd ..
echo Getting the source code repositories...
call git clone --recursive -q https://github.com/u-blox/ubxlib_examples_xplr_iot
cd ubxlib_examples_xplr_iot
call python do -n %ENV_DIR%\ncs -t %ENV_DIR%\%GCCName% save
rem Make sure we use same python as pip3 (in case another installation exists)
for /F %%p in ('which pip3') do call :PythonPath %%p
call %_PYTHON_PATH%python do -n %ENV_DIR%\ncs -t %ENV_DIR%\%GCCName% save
rem Avoid owner protection problems as we have cloned as admin
call :SilentCom "takeown /r /f %ROOT_DIR%\ubxlib_examples_xplr_iot"
call git config --global --add safe.directory %GIT_ENV_DIR%/ncs/zephyr
Expand All @@ -110,4 +114,8 @@ goto:eof

:SilentCom
%~1 1>nul 2>%ERR_FILE% || (type %ERR_FILE% & exit /b 1)
exit /b 0

:PythonPath
set _PYTHON_PATH=%~dp1..\
exit /b 0

0 comments on commit 3e311cb

Please sign in to comment.