Society of Robots - Robot Forum

Software => Software => Topic started by: ratcateme on August 22, 2008, 10:39:41 PM

Title: bootloader recover from CRC-Error
Post by: ratcateme on August 22, 2008, 10:39:41 PM
I am programing the axon using the bootloader and i uploaded some code that had a warning in it a compile time now when i uploaded it i get a "CRC-Error"(see screen dump)
that is alright i found the problem in my code and fixed it but my problem is that in order to upload the fixed code i have to restart my pc because it tells me it can't open COM3.
and i have to restart to fix the problem. how can i get it working again without restarting.
or do i just have to make sure the code is absolutely fine when i put it on so i don't get these errors

Scott.
Title: Re: bootloader recover from CRC-Error
Post by: ratcateme on August 22, 2008, 10:41:55 PM
sorry forgot the image
Title: Re: bootloader recover from CRC-Error
Post by: Admin on August 22, 2008, 10:51:49 PM
Hmmm I've never seen that error before, but I'm willing to bet it's a bug in the bootloader itself. Mostly because google found half a million results for it . . .
http://www.google.com/search?q=%22CRC--error%22


Can you explain exactly what your code does, file size, if you changed any fuses, if this error keeps happening or not, etc.

Basically, enough info to figure out whats causing it.

Also, can you upload your Axon.hex file here?

It almost sounds like your com port isn't closing properly. Try going to Device Manager and change the com port of your USB the next time the error happens, and let us know.

Control Panel->System Properties->Hardware tab->Device Manager->right click the Axon USB->Port Settings tab->Advanced...->COM Port Number
Title: Re: bootloader recover from CRC-Error
Post by: ratcateme on August 23, 2008, 01:01:10 AM
it came from a script similar to this
Code: [Select]
char get_usb_chr(void)
{
char temp=uart1GetByte();
int tempa = temp; //convert to ascii  line 31
while(tempa == 255) //invalid byte get a new one
{
delay_ms(200);
temp=uart1GetByte();
int tempa = temp;//convert to ascii
}
rprintf("\r\n"); //create a new line on users screen
return temp;
}
void control(void)
{
while(1)
{
char data = get_usb_chr(); //line 40
rprintf("you typed %c\r\n");
}

}
it gives me these errors in AVR Studio
Code: [Select]
control.c: In function 'get_usb_chr':
control.c:31: warning: unused variable 'tempa'
control.c: In function 'control':
control.c:40: warning: unused variable 'data'
the same errors as the code that gave me the CRC error but this time it says CRC o.k.
i have lost the code that gave me the CRC error but if i fund some that will give me one ill post it here

Scott.
Title: Re: bootloader recover from CRC-Error
Post by: Admin on August 23, 2008, 06:41:12 AM
So the CRC error only occurred once?


As for those warnings, they shouldn't hurt anything.
Title: Re: bootloader recover from CRC-Error
Post by: ratcateme on August 23, 2008, 01:16:39 PM
i got it a couple of times with some code that had those warnings about unused variable's. i thought they were harmless so i uploaded the code anyway.
and i got that CRC-Error 2 or 3 times. i have to go away today but i will see about recreating the code that created the error tomorrow

Scott.
Title: Re: bootloader recover from CRC-Error
Post by: mbateman on October 12, 2008, 07:48:27 AM
I am having the same issue. Any error the bootloader encounters hangs the USB port so nothing can use it. The only way I have found to recover is to reboot the PC. It would be nice if the bootloader handled errors more gracefully.
Title: Re: bootloader recover from CRC-Error
Post by: ratcateme on October 12, 2008, 12:30:28 PM
can you post the code i tried to recreate my code but i couldn't make it happen.

Scott.
Title: Re: bootloader recover from CRC-Error
Post by: BuddingContraptionist on October 13, 2008, 05:37:23 PM
I just got the same thing.  I uncommented my numerous global unused variables, and it fixed itself.

A CRC check is just a method of summing the number of bytes (in the object code), so that when the copy occurs the receiving end can calculate a CRC of its own using the same method and come to the same sum (and therefore verify that it received all the data correctly).  Since it happened arbitrarily to me, after i added one too many variables, it might have to do with the way the compiler packs the variables for byte-alignment vs how the 8-bit atmega640 does it
Title: Re: bootloader recover from CRC-Error
Post by: BuddingContraptionist on October 14, 2008, 12:35:50 PM
show me how i can make my own programmer and i will look at the bootloader code
Title: Re: bootloader recover from CRC-Error
Post by: Dscrimager on December 03, 2008, 09:03:34 PM
Anyone else have any ideas,... I'm getting the same thing every time now that I program and it borks my whole system since I have to reboot to get back to an open com port.

Even after I reboot it's not working until I plug in the USB cable to the Axon at least once, believe it or not,...

I can post code if it makes a difference...just got the board today and have been working fine for hours...

I've uninstalled and re-installed the drivers. I've moved to a different USB port. I've changed cables.

My first post BTW!

Help!!!!

Title: Re: bootloader recover from CRC-Error
Post by: airman00 on December 03, 2008, 09:42:21 PM
is there a better bootloader out there that we should switch to?
Title: Re: bootloader recover from CRC-Error
Post by: Admin on December 03, 2008, 09:54:03 PM
Anyone tried out the new bootloader version yet to see if it fixes the problem?
http://www.societyofrobots.com/robotforum/index.php?topic=5932.0

(you'd need a hardware uploader to upload any new bootloader)
Title: Re: bootloader recover from CRC-Error
Post by: Dscrimager on December 03, 2008, 10:07:19 PM
I commented out a bunch of code and now the problem has gone away.
Quite frustrating.
I have no hardware programmer so no new bootloader tests from me.

Title: Re: bootloader recover from CRC-Error
Post by: Admin on December 04, 2008, 12:19:52 AM
Dscrimager, can you post the code here that you commented out? Also, can you (or anyone) upload your compiled .hex file that is guaranteed to cause the problem?

This will help me narrow down the problem, and also let me test the new bootloader on it myself.
Title: Re: bootloader recover from CRC-Error
Post by: Dscrimager on December 04, 2008, 07:01:07 PM
Unfortunately I kept trying things and did not save that version. If it happens again I will save it and send it on for sure.

I'm going to speculate here for a minute as well. I am very quick to shut off the axon and attempt to reprogram. Looking at that big ol' cap sitting on that board and watching that LED fade away sloooowly, I think not letting board discharge might have been contributing some to the problem.

I also notice note that I need to plug and unplug the axon occasionally from the USB for it to be 'openable' again on my com port.

Finally, it seems like I need to let the bootloader spinner cycle a few more times before I power the axon on. Definitely have to have the axon hooked to the bootloader for it to open the com port through the drivers....

I'm going to slow down a bit and see if I encounter more problems.

Now to slowly start adding back in the features that I want....
Title: Re: bootloader recover from CRC-Error
Post by: Admin on December 04, 2008, 11:42:20 PM
Dscrimager, once you start adding on external hardware (servos, sensors, etc) that LED won't take so long to fade away :P

Quote
I also notice note that I need to plug and unplug the axon occasionally from the USB for it to be 'openable' again on my com port.
This has never happened on my Dell with XP . . . strange! Sounds like windoze isnt closing the COM port properly . . .
Title: Re: bootloader recover from CRC-Error
Post by: Dscrimager on December 07, 2008, 05:25:38 PM
One last update..

For me all problems have gone away with regard to this thread. I now turn off the AXON and let it sit about 5 seconds before doing anything else. Then I am able to reprogram pretty much at will. I really think this was related to powering off and then trying to reprogram to fast.

Since I got the axon a few days ago I now have working:
- continuous rotation servos fro driving with forward/backward/stop (with PWM on a timer-sweet!)
- light sensor
- sensors being checking with an interrupt on a timer
partially working:
- 3-axis accelerometer (still trying to udnerstand output)
upcoming
- PIR meter

So, point being I have reprogrammed like 200 times successfully with no problems and I am cranking along on my first all custom robot in a few days! The AXON is great!
Title: Re: bootloader recover from CRC-Error
Post by: Admin on December 09, 2008, 10:08:12 PM
A 5 or 10 second (http://www.societyofrobots.com/robotforum/index.php?topic=6089.0) delay is unacceptable to me, and I'd like to shorten that time for you.

Do you find having servos connected to the power bus shortens that time? I'm debating if the Axon is resetting too slowly because of that big cap isn't draining fast enough. It needs to reset for the bootloader to work.
Title: Re: bootloader recover from CRC-Error
Post by: Dscrimager on December 11, 2008, 06:45:08 PM
Well maybe I overstate. 5 seconds is really fine I think. Its a great board I love it....
Since it takes a few seconds to make a program change and rebuild it I just turn off the AXON first, then make some program changes and it reprograms just fine.

Let me say to anyone considering the AXON, it's really NICE! The small delay to drain off the cap is NOT a problem from my perspective.

Doug
Title: Re: bootloader recover from CRC-Error
Post by: OperationIvy on December 16, 2008, 05:23:00 PM
I believe that was my problem also. I just make sure the axon is off for several seconds before I try to reprogram it and I haven't had a C.R.C. error since. :)
Title: Re: bootloader recover from CRC-Error
Post by: Admin on December 17, 2008, 08:51:43 AM
I've been completely unable to reproduce this bug - even with nothing draining the cap on my Axons. I suspect its a problem on only certain PC's or specific hardware.

I've updated the Axon FAQ (http://www.societyofrobots.com/axon/axon_FAQ.shtml) with the 5 sec delay solution.
Title: Re: bootloader recover from CRC-Error
Post by: mbateman on December 17, 2008, 09:50:15 AM
Back to the original topic of this thread, if I have any warnings about an unused variable, but load the .hex anyway, it will give me a CRC error, and the USB/COM port will hang. Once in that state, it appears that it thinks the port is still open, so no other application can attach to it either (i.e. Hyperterm). The only way I have found to clear it is to reboot.
Title: Re: bootloader recover from CRC-Error
Post by: klims on April 15, 2009, 08:06:56 PM
Here is a .hex file that consistently gives me a CRC-Error no matter how long I wait for the Axon

I should probably mention that my program was working a treat until I commented out a delay_ms().
As far as I can tell the delay_ms() function seems to be responsible for a lot of my errors.....