Closed 4ntoine closed 8 years ago
What can i check?
hex size seems to be reasonable: MBA-Anton:bin asmirnov$ ls -l /tmp/arduino_test1/Blink.cpp.hex.txt -rw-r--r-- 1 asmirnov wheel 3879 1 окт 11:22 /tmp/arduino_test1/Blink.cpp.hex.txt
HardwareSerial
probably uses interrupts under the hood, and due to #162, the interrupt signal routine table is incorrectly generated.
This is probably related.
yes it does use interrupts:
// Actual interrupt handlers //////////////////////////////////////////////////////////////
void HardwareSerial::_tx_udr_empty_irq(void)
{
// If interrupts are enabled, there must be more data in the output
// buffer. Send the next byte
unsigned char c = _tx_buffer[_tx_buffer_tail];
_tx_buffer_tail = (_tx_buffer_tail + 1) % SERIAL_TX_BUFFER_SIZE;
*_udr = c;
// clear the TXC bit -- "can be cleared by writing a one to its bit
// location". This makes sure flush() won't return until the bytes
// actually got written
sbi(*_ucsra, TXC0);
if (_tx_buffer_head == _tx_buffer_tail) {
// Buffer empty, so disable interrupts
cbi(*_ucsrb, UDRIE0);
}
}
This is pretty important issue as Arduino does not have debugger and serial is the only way to debug or interact with a board. For now it blocks arduino..
i've tried to:
// 4ntoine : for now we can't use Serial because of https://github.com/avr-llvm/llvm/issues/167
#ifndef NO_SERIAL
#include "HardwareSerial.h"
#include "USBAPI.h"
#endif
-DNO_SERIAL=1
main.cpp
in order to skip serialRun
:// 4ntoine
#ifndef NO_SERIAL
for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
#endif
So i was able to compile Blink.hex:
-rw-r--r-- 1 asmirnov wheel 1989 12 окт 09:36 /tmp/arduino_test1/Blink.cpp.hex
Anyway i'm still having this issue: L (pin 13) is constantly lighting and TX is constantly lighting too.
oh, i've noted i used
#ifndef NO_SERIAL
for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
#endif
but i should use:
for (;;) {
loop();
#ifndef NO_SERIAL
if (serialEventRun) serialEventRun();
#endif
}
now blink is larger:
-rw-r--r-- 1 asmirnov wheel 3793 12 окт 09:43 /tmp/arduino_test1/Blink.cpp.hex
and it's having slightely different behaviour:
Closing as this is a dupe of #192.
not sure it's duplicate. in #192 you can't compile avr-llvm but in this task you can compile avr-llvm, but compiled files work incorrectly. consider reopening
Sorry, I meant #162.
after complining and uploading simple Blink sketch TX LED is constantly lighting, no LED on pin 13 blinking.
I had to add
serialEventRun
function to override wrong behaviour initialied by weak issue: https://github.com/avr-llvm/clang/issues/9Blink.cpp:
Then i compiled all the .cpp:
and packed into .a:
created archive index:
linked:
and prepared hex:
After flashing with avrdude i'm getting described behaviour.