buserror / simavr

simavr is a lean, mean and hackable AVR simulator for linux & OSX
GNU General Public License v3.0
1.56k stars 365 forks source link

UART broken #31

Closed Traumflug closed 9 years ago

Traumflug commented 10 years ago

I tried to replace the version of simavr coming with simreprap with the current one by replacing the entire directory of simreprap/shared/simavr with this repository. Hint: you have to replace all occurrences of SIMAVR in simrepraps' top Makefile with something like SIMAVR_DIR to get this working.

It worked when spooling simavr back to tag v1.0, but not with v1.1 or current master. When not working, the firmware (the one coming with simreprap) would simply not accept characters on the serial connection. Connecting with a G-code sender like Pronterface doesn't allow to establish a connection (Pronterface looks for the word "start" or "ok" on the serial line to recognize the connection).

Bisecting pointed to commit 890c3dcba764925a99b60c05b73365d3c3678435, which brings in the broken behaviour.

bsekisser commented 10 years ago

I noticed the instruction and timing tests did not work with the recent builds of simavr and last known working version was at 1.0... on a whim tried running with run_avr -v -v and found that works... Try the same with your situation and see if that works... if so could just be coincidence with something else needing to be looked at. Please let us know what you find.

Michael.

... I think I am on to something... console the output line is currently implimented as logging... looking back to see when it changed.

bsekisser commented 10 years ago

It looks to be the statement on line 167 if function avr_uart_write in sim_uart.c:

    printf( FONT_GREEN "%s\n" FONT_DEFAULT, p->stdio_out);

was replaced with:

    AVR_LOG(avr, LOG_TRACE, FONT_GREEN "%s\n" FONT_DEFAULT, p->stdio_out);

during the switch to the logger functions... looked at the history and it seems to have fluxed a bit with the changes being commited and reverted a few times but.. don't know much more than that.

did a quick switch, compile and run... works. I'll be submitting for review.

bsekisser commented 10 years ago

Scratch that... The line concerning console output is/was only one part of the problem, the line (195/196) in function avr_uart_write doing the write:

            // required for u2x (double uart transmission speed)
    avr_core_watch_write(avr, addr, v);

as reported found by Traumflug during the bisect seems to be the other half...

bsekisser commented 10 years ago

think I found other part of the issue... writing for u2x inappropriately clears the UDRE read-only flag thus transmit functions never see the transmitter as being ready for data.

putting together a fix.