Re: [U-Boot] exit(-1) function in U-Boot

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
In message 5ec3d7930903170318r76f4786fsdf61ec1e2c11a04c@mail.gmail.com you wrote:
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

Hi Wolfgang,
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,
In message 5ec3d7930903170549sf6337c9l292d9ebef0fdf87a@mail.gmail.com you wrote:
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

Hi Wolfgang,
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 (); } }
including information which version of U-Boot you are running
u-boot-1.1.6
and on which platform.
ARM9
Best regards, Drasko

Dear Drasko DRASKOVIC,
In message 5ec3d7930903170638n7769e61anb30f5ce39d704f84@mail.gmail.com you wrote:
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 (); } }
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
participants (2)
-
Drasko DRASKOVIC
-
Wolfgang Denk