u-boot not retrying after timeout - u-boot

I have u-boot configured to use tftpboot to grab the linux image over the ethernet network. If the tftp server on an external device is already setup and running, everything works fine. However, if my device powers on before the server is ready, it will timeout. Once it times out, it will no longer attempt to connect to the server to get the file.:
Filename 'image.ub'.
Load address: 0x10000000
Loading: T T T T T T T T T T
Retry count exceeded; starting again
Zynq>
Even though it says "starting again", nothing actually restarts. Once the server finally becomes ready, there is no communications to get the linux image. Note that I can use the serial port to manually restart the tftpboot, but I need it to retry automatically.
Is there some option that will make a retry actually occur? Here is some environmental variables:
> echo $default_bootcmd
run uenvboot; run cp_kernel2ram && bootm 0x10000000; run netboot
> echo $netboot
tftpboot ${netstart} ${kernel_img} && bootm
> echo $uenvboot
if run sd_uEnvtxt_existence_test; then run loadbootenv; echo Loaded environment from ${bootenv}; run importbootenv; fi; if test -n $uenvcmd; then echo Running uenvcmd ...; run uenvcmd; fi

The last message that is output by U-Boot,
Retry count exceeded; starting again
originates from tftp_timeout_handler() and restart(), which then calls net_start_again().
Is there some option that will make a retry actually occur?
The U-Boot routine net_start_again() indicates that the environment variable netretry determines the local variables retrycnt and retry_forever.
Try defining the environment variable netretry with value yes, i.e.
setenv netretry yes
When variable netretry does not exist in the environment, the code indicates that no retry would be attempted (per this patch), as you experienced.

Related

system() not working as expected with %ERRORLEVEL%

I was trying to find a way to see if a host is alive in C on Windows so I ran system with a ping command and then ran system checking %ERRORLEVEL% but it was always showing 0 even if the host was not reachable.
system("ping -w 1000 -n 1 192.168.0.4 | findstr /r /c:\"[0-9] *ms\"");
system("echo %ERRORLEVEL%");
Furthermore even I system call something that will defintely fail like:
system("call dir");
system("echo %ERRORLEVEL%");
%ERRORLEVEL% will still print a 0. Even after the call command failed with:
"'poop' is not recognized as an internal or external command,
operable program or batch file".
Moreover I noticed some strange behavior that if I tried to see the %ERRORLEVEL% on the same command as the ping in cmd:
ping -n 1 192.168.0.1 | findstr /r /c:"[0-9] *ms" & echo %ERRORLEVEL%
it would always return the previous %ERRORLEVEL%. For example if i pinged 192.168.0.1 which is reachable I would 1 or 0 depending on my last command. But if I ran the command again I would get 0. Now if I checked 192.168.0.4 which is not reachable I would get 0. But if I checked it again I would get 1.
Can anyone help me possibly find a better way to see if hosts are available or find out what im doing wrong with %ERRORLEVEL% and system()?
Each call to system() spawns a new instance of cmd.exe, that is why you are losing the error info. The return value of system() is defined as an "implementation-defined value", but it is usually the exit code of the spawned process.
Or, you can use CreateProcess() to run ping directly, and use GetExitCodeProcess() to get its exit code.
Or, simply don't run ping at all. You can use IcmpSendEcho() (or related function) instead.
With each system call you spawn a new cmd shell. So the exit value of a program run in a previous shell (system call) is not available in the next one.
To get the exit value and use it, make a batch job that you run with the system command. All commands in the batch job (.bat) are executed in the same shell so the exit value of the previous command is available for your echo.
The WinAPI function IcmpSendEcho will check if a host is alive. You can see if the host received the request when IcmpSendEcho is finished and the response is stored in the ICMP_ECHO_REPLY structure. Check the Status member for details about the request.

WMIC: Run Batch Script Remotely

I've been trying to get a Jenkins deploy job to work by running a batch script to do the install of an msi from the Jenkins build machine itself. I've given the appropriate access rights, but still am not able to run the following command remotely, using WMIC
wmic /node:myServerIp /user:"clientpc\my-user" /password:"my-password" process call create "D:\someDir\someOtherDir\test.bat"
The follow response from the above command:
Executing (Win32_Process)->Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
ReturnValue = 9;
};
After some research, it looks like return value of '9' is 'Path not found' according to https://msdn.microsoft.com/en-us/library/aa389388(v=vs.85).aspx, but I've verified that the path exists on the remote server.
The test.bat file that I'm trying to run is very simple, and should just write to a text file.
#echo This is a test.> test.txt
I've verified that both files exist on the server, and have granted 'EVERYONE' to the shared folder 'someDir'.
I have tried prefixing 'cmd.exe /c' to the path called:
wmic /node:myServerIp /user:"clientpc\my-user" /password:"my-password" process call create "cmd.exe /c D:\someDir\someOtherDir\test.bat"
...for which I receive:
Invalid Verb Switch.
I've verified that the user access is correct by providing a bad password, in which case permission is denied.
EDIT:
Changed the path from D:\someDir\someOtherDir\test.bat to D:\\someDir\\someOtherDir\\test.bat but now receive the following error:
ERROR:
Description = The RPC server is unavailable.
EDIT 2:
Looks like the RPC user I was using was the cause for the error. Still troubleshooting, but when I use my AD user, as opposed to the administrator I created to run this, I get the following AGAIN...
Executing (Win32_Process)->Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
ReturnValue = 9;
};
I was able to get the following to work on an Active Directory domain.
Wmic /node:"ComputerName" process call create "cmd.exe /c (net use o: /delete /y & net use o: \\Server\share /user:Domain\Administrator Password & o:\Dir\Subdir\test.cmd) >> c:\users\MyUser\testout2.txt"
The very simple contents of test.cmd:
echo Just a test >> c:\users\MyUser\testout.txt
date /t >> c:\users\MyUser\testout.txt
time /t >> c:\users\MyUser\testout.txt
The "job" is being sent to "ComputerName" on the domain. The batch/script file the job runs is on a network share. The job running on "ComputerName" will not see any mapped drives, so I delete and map a drive. I don't believe it is ever necessary to delete the drive, but I added that for completeness sake.
After execution, testout2.txt shows the batch file executing the commands and
testout.txt contains the results of the batch file commands as expected.
Things to watch out for:
As mentioned, mapped drives are not visible from the remote job
You are executing in the target machine's environment - drive letters need to make sense to that machine
Internal commands such as 'echo' require the job starts with 'CMD.EXE /c'
Group multiple commands inside parentheses and separate with ampersands (&)
Don't collide file access. I use testout.txt and testout2.txt files. If I had given them the same name, one set of outputs would have been lost.
Nothing you do this way will ever be visible to the user; the job is run in such a way that it can not display on the user's screen.
Sending a password in clear text as I show in the example is a security hazard and should be avoided. I'm not sure of a better way to map drives in this context however.

Batch file to open server with port

I am trying to write a script to connect to a server on a specific port. I can get the script to open the browser with the server address as long as I don't include the port. If I try to include the port then I get an error saying:
There is no program associated to perform the requested action...
When I exclude the port it attempts to connect to the server in the browser, but this won't work without a port. Here's some of my code:
#ECHO off
SET serv=exampleserver.company.com
ECHO Server address is %serv%
SET /p port=Enter the port number
ECHO The port is %port%
SET addr=www.%serv%
ECHO Your full address is %addr%:%port%
START %addr%:%port%
PAUSE
EXIT
as you can test manually, while start www.stackoverflow.com will work, start stackoverflow.com won't, and neither start www.stackoverflow.com:80. I suspect that the recognition of "www." is a especially encoded exception.
To resolve this, use start http://<server>:<port>.
as an aside, if you surround your start parameter with quotes (required if it has a space or other separator), you need to put (empty) quotes before, like start "" "c:\program files\bla", since the first quoted argument will be interpreted as a window title.
xyz:abc is actually a valid filename under windows, where the second part names an alternate data stream (ADS).

BATCH - wait for executable to finish before starting next result

I'm pretty much a noob at this, so any help is appreciated.
I'm trying to run the video transcoding executable REDline on all .R3D files in a given folder. REDline only accepts single files, which is the issue. I finally got it to search recursively for the files I need, but my problem is the search function passes the next result to REDline before the first one is finished transcoding. I have the search results that need to run in a variable inside REDline.
Here's the code:
for /r D:\folder\ %%a in (*) do (
"C:/Program Files/REDCINE-X PRO 64-bit/REDLine.exe" --exportPreset "Prores_Intermediate" --i "%%~dpnxa" --useRSX 2 --masterRMDFolder "" -s 0 -e 95
)
After about .7 seconds, REDline reports 'received stop message from client'.
I don't think this is a REDline error, as I have been able to transcode single files successfully.
Thanks.
Try start /wait when running the executable.
If that does not help, the executable might start another executable which does the actual job. In that case identify the other executable using Process Monitor or Process Explorer. Check their command line parameter to see if you can run that executable directly.
If you can't run the other process yourself, you can wait until that process has exited. See Wait for executable to finish here on StackOverflow.
Im not familiar with that particular executable, but here are some suggestions you may try:
- Check the allowed parameters for REDLine.exe (documentation or possibly /?) to find out if there is any that might address your problem
- There are tools that allow you to check for the existance of a process (Microsoft Sysinternals, check the ones starting with PS*.exe) http://technet.microsoft.com/de-de/sysinternals/bb545021.aspx
Use this to improve your loop so that you check if the process is running first before continuing with the next loop - or loop without doing anything until the process has exited, you can do with repeatedly calling a ping to localhost inside your loop for a fixed time interval for example
- Check the errorcodes returned by programs to see if that helps you
- Put the code that starts your encoding inside its own batch file, and the check if the process is currently running as well
- Use the creation of a dummy file before starting and delete it once finished to discern if an instance of your batch is running
- Check the difference between calling a command directly from a batch file, and using the start command to run it at the same time

Batch file to monitor a processes RAM, CPU%, Network data, threads

I need to generate a report (periodic, say every 1 minute) that whilst run, generates the following in a txt file (or other):
For a given process...
Timestamp : RAM : CPU% : Network data sent/received for last second : Total network data sent/received : threads
I believe in Process Explorer the network data sent/received for last second is called the Delta.
Could you recommend how I might capture this using either a plain batch file, or relying on another tool if required? Such as power shell or PsList? Or at least, point me in the direction of the applicable tool that'll report all these things for a given process? And ideally, be able to report these from a process running on a remote machine if possible! Many thanks, knowledge gurus!
logman create counter cpu_mem_trh -c "\Processor(_Total)\% Processor Time" "\Memory\Pool Paged Bytes" "\Process(*)\Thread Count" -f csv -cf C:\PerfLogs\perflog.csv
logman update cpu_mem_trh -si 60 -v mmddhhmm
logman start cpu_mem_trh
to stop the performance counter use:
logman start cpu_mem_trh
Here are all available performance counters.
And here's the logman help.
For remote machine try with \\machine name prefix on each counter path or with -s option.Time intervals are set with -si option on the update verb. Path to the report is set with -cf option.

Resources