exit(-1) function in U-Boot
Hi all,
I am having hard time to find exit() function in U-Boot, so I can exit from a application at any function when something goes wrong.
Is there some alternative? I just want to break program execution, printf message on the screen and regain the prompt.
Salut,
Drasko
Dear Drasko,
Quoted 3 lines · In message <[email protected]> you…
I am having hard time to find
exit()function in U-Boot, so I can exit from a application at any function when something goes wrong.
U-Boot itself has no exit, obviously.
But you mention "application", so I guess you are referring to stand- alone applications; these terminate when you return from the top level function. How you arrange for that is up to you. setjmp / long- jmp are usually trivial to implement / use.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de No one can guarantee the actions of another. -- Spock, "Day of the Dove", stardate unknown
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 42 lines · Drasko DRASKOVIC
Actually, I ment U-boot itself. When I said application, I was wrong. I ment for example command, which is part of U-Boot. If I want to exit when something is wrong within TFTP for example, I cannnot break execution and regain U-Boot shell? (Otherwise, I have to go back to calling functions in
net.c, etc..., which is not what I want. I want to stop on the place error happened.)BR,
DraskoQuoted 27 lines · Wolfgang Denk
Dear Drasko,
In message <[email protected]>
Quoted 2 lines · you
I am having hard time to find
exit()function in U-Boot, so I can exitfrom
Quoted 1 line
a application at any function when something goes wrong.
U-Boot itself has no exit, obviously.
But you mention "application", so I guess you are referring to stand- alone applications; these terminate when you return from the top level function. How you arrange for that is up to you. setjmp / long- jmp are usually trivial to implement / use.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de No one can guarantee the actions of another.
-- Spock, "Day of the Dove", stardate unknown
Dear Drasko DRASKOVIC,
please keep discussion on the mailing list.
And please don;t top-post / full-quote. Make sure to read
http://www.netmeister.org/news/learn2quote.html
Quoted 7 lines · In message <[email protected]> you…
Actually, I ment U-boot itself. When I said application, I was wrong. I ment for example command, which is part of U-Boot. If I want to exit when something is wrong within TFTP for example, I cannnot break execution and regain U-Boot shell? (Otherwise, I have to go back to calling functions in
net.c, etc..., which is not what I want. I want to stop on the place error happened.)
When "something is wrong within TFTP", the respective function returns an error code, which propagates upward and causes the running command to terminate, so you automatically end up back in the U-Boot shell.
Maybe you should explain what exactly you are trying to do. I have the feeling that your question does not describe your actual problem, and that your actual problem might be either be based on a misunder- standing or inappropriate use.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de ATTENTION: Despite Any Other Listing of Product Contents Found Here- on, the Consumer is Advised That, in Actuality, This Product Consists Of 99.9999999999% Empty Space.
Hi Wolfgang,
Quoted 4 lines
When "something is wrong within TFTP", the respective function returns an error code, which propagates upward and causes the running command to terminate, so you automatically end up back in the U-Boot shell.
Yes, I agree but the caller might do something else before exits the command, or not exit the command at all (maybe take another path, because function return sucess), and it begins difficult for me to follow where the error happened in the past. I am trying to avoid use of debugger for the moment, so I hoped to set a few conditions like
if (error)
{
perror ("error1");
exit(-1);
}
Quite simple, so I can see where it breaks. Some kind of assert. (Is there an assert in U-Boot?)
Letting it propagate upwards severall call on the stack... uh... I will be lost where the error came from.
Thanks,
Drasko
Dear Drasko DRASKOVIC,
Quoted 3 lines · In message <[email protected]> you…
Quite simple, so I can see where it breaks. Some kind of assert. (Is there an assert in U-Boot?)
Instead of vague descriptions like "something is wrong within TFTP" or "it breaks" you could try and post the exact commands you're trying and the exact error messages you are seing, including infor- mation which version of U-Boot you are running and on which platform. That would really be helpful.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Ninety-Ninety Rule of Project Schedules:
The first ninety percent of the task takes ninety percent of
the time, and the last ten percent takes the other ninety percent.Hi Wolfgang,
Quoted 3 lines
Instead of vague descriptions like "something is wrong within TFTP" or "it breaks" you could try and post the exact commands you're trying and the exact error messages you are seing,
I am sorry for being vague, I hope this example will make it a bit more clear:
static void
TftpTimeout (void)
{
if (++TftpTimeoutCount > TIMEOUT_COUNT) {
puts ("\nRetry count exceeded; timeout error\n");
if (image_valid == 0)
{
/*
* We have no valid Linux image anymore!
* We must start update again!
*/
NetStartAgain ();
}
* else /* last image is not corrupted, I want to boot it */
{
/* LET ME OUT! I do not want to go back to net.c caller,
bacause I do not know how to tell him it was TIMEOUT.
All I can do is NetState = NETLOOP_FAIL. Not much of an
info. */
printf("TIMEOUT error\n");
exit (-1);
}*
} else {
puts ("T ");
NetSetTimeout (TIMEOUT * CFG_HZ, TftpTimeout);
TftpSend ();
}
}Quoted 1 line
including information which version of U-Boot you are running
u-boot-1.1.6
Quoted 1 line
and on which platform.
ARM9
Best regards,
Drasko
Dear Drasko DRASKOVIC,
Quoted 24 lines · In message <[email protected]> you…
I am sorry for being vague, I hope this example will make it a bit more clear:
static void
TftpTimeout (void){ if (++TftpTimeoutCount > TIMEOUT_COUNT) { puts ("\nRetry count exceeded; timeout error\n"); if (image_valid == 0) { /* * We have no valid Linux image anymore! * We must start update again! */ NetStartAgain (); } * else /* last image is not corrupted, I want to boot it */ { /* LET ME OUT! I do not want to go back to net.c caller, bacause I do not know how to tell him it was TIMEOUT. All I can do is NetState = NETLOOP_FAIL. Not much of an info. */ printf("TIMEOUT error\n");
Quoted 8 lines
exit (-1);
}*
} else {
puts ("T ");
NetSetTimeout (TIMEOUT * CFG_HZ, TftpTimeout);
TftpSend ();
}
}What you are doing here makes no sense.
Image handling has no place in the networking code.
If you need image download with error handling, then implement this on the command level as a command sequence in an environment variable, or as a shell script.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de God is real, unless declared integer.