Welcome! Log In Create A New Profile

Advanced

Gen 7 sending serial data crashes the system

Posted by Grumpy Mike 
Gen 7 sending serial data crashes the system
July 20, 2011 01:31PM
I have built a Gen 7 electronics board with a 20MHz ATmega644. I have burned a boot loader on it with the arduino ISP and I can load in software to make LEDs blink and read the values back from the limit switches. It talks to me using Serial.print().

However, when I send it anything down the serial port the whole system freezes. I am not even reading the data, just sending it one single byte.

I installed the Gen 7 support as described in the install file and apart from having to add some boot loader files for the arduino ISP to use everything worked fine.

Is this a known problem and is there a cure? My newly built Prusa is just siting on my bench, looking, as my wife put it, "like some strange gymnastic equipment for mice".
Re: Gen 7 sending serial data crashes the system
July 20, 2011 05:05PM
Quote

However, when I send it anything down the serial port the whole system freezes.

Which system freezes? Your PC?

Quote

Is this a known problem and is there a cure?

Assuming it's your PC, your operating system shouldn't freeze just because there's a byte in the serial line stuck. But that's obviously ho it works.

This SetupTest firmware doesn't read from the serial line, so sending something is pointless. To get your Prusa working, you should upload a firmware like FiveD, Teacup or Sprinter, obviously.


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Re: Gen 7 sending serial data crashes the system
July 21, 2011 02:01AM
No it is the 644 system that freezes, there must be some error in the serial input ISR. Hence any reprap controlling firmware will not work.

Edited 1 time(s). Last edit at 07/21/2011 11:14AM by Grumpy Mike.
Re: Gen 7 sending serial data crashes the system
July 21, 2011 04:11AM
Quote

No it is the 644 system that freezes, there must be some error in the serial input ISR.

There is no serial input ISR in SetupTest.pde.


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Re: Gen 7 sending serial data crashes the system
July 21, 2011 11:09AM
Sorry I am not making myself clear. I know from my other forums that it is difficult to tell the competency level of posters. Let me say that while I am completely new to 3D printing I have some experience with arduinos. Please see:-
some of my projects here

The ISR I refer to is in the support package for the arduino itself. Let me explain in more detail what has happened.

I built a Gen 7 electronics system on strip board, using a 644 ruing at 20MHz. I added the Gen7+Arduino+IDE+support to my arduino system and burnt a boot loader. My board could now be uploaded with code, I uploaded a few test programs that flashed LEDs and sent messages back to the computer using Serial.print() and all was fine. I up loaded the Tonkip firmware after changing pin assignments and the like to match my system. However, after the initial "starting" message I could get no response from it. So I put in some debug print statements in it and I found that everything worked fine until the instance when I sent a single character to it from the monitor when it froze.
I then wrote a simple blinking LED sketch and up loaded that. Again it worked well until I sent it data on the serial port, then the LED stopped blinking and only a hardware reset would bring it back.

As I can upload code there is nothing wrong with the physical connection to the input serial port. As I can see print messages coming back from my board there is nothing wrong with the baud rate or the serial output port. However, the instant I send something the board freezes.

There is an ISR that takes a byte from the serial port and puts it in the buffer, this is part of the Arduino infrastructure and is defined in the Gen7+Arduino+IDE+support files. It is these files that I believe might be in error and causing this crashing, although it might be the compiler. Either way it is quite useless for controlling a RepRap as you can never receive anything.

I am using release 22 of the arduino on a MacBook Pro running OSX 10.6.7

I take it from your reply that no one else has reported this but basically I think your Gen 7 support package for the 644 is broken.

Edited 1 time(s). Last edit at 07/21/2011 11:17AM by Grumpy Mike.
Re: Gen 7 sending serial data crashes the system
July 21, 2011 02:54PM
Tonokip is an old, no longer maintained version of Sprinter - you should either start with Sprinter, or with the 5D firmware from sourceforge/reprap.
Re: Gen 7 sending serial data crashes the system
July 21, 2011 06:33PM
Quote

I take it from your reply that no one else has reported this ...

About 50 Gen7s are running with this package. Except for the bootloader, all the arduino support files were taken over from Sanguino / Gen3. Thousands more users. So at least it basically works.

Quote

... but basically I think your Gen 7 support package for the 644 is broken.

That said, it's quite possible there's room for enhancement. Can you suggest a patch? Ideally one which doesn't require me to dive into the issue smiling smiley


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Re: Gen 7 sending serial data crashes the system
July 22, 2011 04:18AM
Quote

About 50 Gen7s are running with this package....... So at least it basically works.
Yes but how many of those people were using a 664P processor, I was using a 644.

I tracked down the problem to this code in the HardwareSerial.cpp file:-
#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1280__)
ISR(USART0_RX_vect)
{
unsigned char c = UDR0;
store_char(c, &rx_buffer);
}
Which only defined the ISR receive vector for the 644P and the 1280. As I had only a 644 this vector was never being defined hence the crash when it was called.

I went to the site with the Gen 7 support and discovered that the current download had files created on the 12th May 2011, where as the files I was using were created on 27th March. Doing a diff on the two sets showed that the HardwareSerial.cpp file had been altered so that a vector was defined for my processor.

It would really help if there was a version number or build number in the readme file that indicated there had been a change.

So the upshot is that it now no longer crashes when receiving serial data.

@raldrich
Thanks for the heads up on that, I was finding once this problem was fixed that the Tonokip firmware was not reading the input buffers correctly anyway under all circumstance and so would require a bit of work. I will look at Sprinter like you suggested.
Re: Gen 7 sending serial data crashes the system
July 23, 2011 06:16AM
Glad you could resolve it, Grumpy Mike. When experiencing bugs it's always a good idea to pull the latest Git revision, or at least the latest release, of course.


Generation 7 Electronics Teacup Firmware RepRap DIY
     
Sorry, only registered users may post in this forum.

Click here to login