Closed teackot closed 1 year ago
I could not reproduce this issue with simavr master (7003af00df0f89a38898896fe536c5f15ae4ef1a). I get instead:
Loaded 82 bytes at 0
avr_gdb_init listening on port 1234
However, this line you showed looks suspicious:
Loaded 1204 .text at address 0x0
This cannot fit in an ATtiny13, and is also way too big for such a simple program. Did you forget to enable optimizations? If so, you should have seen this compiler message:
warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed" [-Wcpp]
If I attempt to load the unoptimized program (which is too large) with simavr, I get
Loaded 1090 bytes at 0
Aborted
It works well for me also. I can even see a lamp flashing:
If the size of the flash segment is the problem, adding option "-v" to the command will confirm it, as there is a error message for the problem. (There is a plausible PR to show error messages by default.) I think that is the right explanation, as "IOT instruction" is probably some shell's anachronistic way of saying "Aborted". (SIGIOT and SIGABRT are the same thing. I think it was the PDP-11 that actually had an IOT instruction!)
When I tried to compile without optimisation, the oversized flash was reported, with no output file:
In file included from attiny13_510.c:6:0: /usr/lib/avr/include/util/delay.h:112:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed" [-Wcpp]
/usr/lib/gcc/avr/5.4.0/../../../avr/bin/ld: attiny13_510.axf section .text' will not fit in region
text'
collect2: error: ld returned 1 exit status
Building for an Atmega, then running on the Tiny13 fixed that, and I also saw "Aborted" and the message with "-v".
Sorry for the late answer.
Did you forget to enable optimizations
Yes, this was the problem. Enabling optimizations reduced the output size from 1204 B to 44 B and it now fits in ATtiny13
If the size of the flash segment is the problem, adding option "-v" to the command will confirm it
Now with -v it shows an actual error message: avr_loadcode(): Attempted to load code of size 1204 but flash size is only 1024.
A simple program with 2 delays:
Launched with:
Gives:
However, if you leave only one _delay_ms or compile for another MCU (I tried ATMega328), program runs fine