[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Stuckness with ATTiny15 program and avr-gcc
From: |
Bruce D. Lightner |
Subject: |
Re: [avr-gcc-list] Stuckness with ATTiny15 program and avr-gcc |
Date: |
Fri, 07 Jan 2005 16:04:24 -0800 |
User-agent: |
Mozilla Thunderbird 0.5 (Windows/20040207) |
Ned Konz wrote:
Hi folks,
I'm trying to get my workflow, header files, etc. set up for programming the
ATTiny15L using avr-gcc. I'm going to publish a HOWTO on my site once I get
things working fairly well.
So far, the code generation looks good, and I'm using Bruce Lightner's Perl
program to help look for potential problems (like use of RAM). I've written
several header files for the attiny15; I'm only using the inttypes.h header
from avr-libc (this will go away as well when I put those definitions into my
headers).
However, I'm stuck on this project, unable to get my code working properly on
a real device. I've run other code compiled from avr-gcc and programmed into
the device the same way without problems on the same hardware.
The programming works fine, complete with verification.
I'm setting the fuses so that RSTDISABL is programmed (I'm using the RESET/PB5
line to drive a LED). I have tried both settings of the BOD fuse.
I'm not using the watchdog.
It works fine in the simulator, doing just what I expect it to.
It does not work just fine in the real device.
In fact, it's not even getting to the point where the LED is turned on (in the
initialization in main()), or where the ADC reference voltage is connected to
the external capacitor.
If I look at the pins on the device (which programs and verifies just fine
using AvrStudio4 and an STK500 board), I see Vcc and pin 1 (RESET/PB5) going
high. Of course, they're both pulled up by external circuitry. The AREF pin
stays hi-Z, as do all the other pins.
So I figure that rules out (say) going excessively deep in the stack. Not that
that should happen; the maximum call depth is 2, leaving 1 for the interrupt
handler.
I've read over the listing and I don't see anything strange.
I've put a zip on my site, with the C code, the headers, and a listing file.
There is a schematic in PNG form in the zip too.
If you're interested in looking at this, my code and schematic is available at
http://bike-nomad.com/misc/tiny15Regulator.zip
If you can figure out why it doesn't work, I'd appreciate it.
I'd be glad to trade my time analyzing your programming problem later on.
Thanks,
One problem that I see after looking at your mixed listing (i.e.,
"regulator.lss") is that you have linked with the standard avr-gcc
"startup code", which assumes that you have RAM memory with .data and .bss
sections. This is likely causing problems.
Although I did not go through your "Makefile" in detail, it looks like you
are using the "generic" avr-gcc Makefile, which therefore probably uses
the default liker script. That also is likely to cause problems.
Here's the assembly language "startup" code I use for the ATtiny15L
("init.s")...
; init.s
.section reset
.global my_reset
my_reset:
clr r1 ; r1=0 for avr-gcc
; initialize SP to top of SRAM.
.equ SPH ,0x3E
.equ SPL ,0x3D
ldi r24,0xff ; trick AT90S8515 emulator
out SPL,r24 ; set SP = 0xff
out SPH,r1
rjmp main ; call C routine
I also use the linker option "--script tinyker.lds" which causes the
linker to use the following special script...
/* linker script for ATtiny15 */
OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
OUTPUT_ARCH(avr:2)
MEMORY
{
text (rx) : ORIGIN = 0, LENGTH = 1K
data (rw!x) : ORIGIN = 0x60, LENGTH = 0
eeprom (rw!x) : ORIGIN = 0, LENGTH = 512
undefined_section (rw!x) : ORIGIN = 0, LENGTH = 0K
symbol_references (rw!x) : ORIGIN = 0, LENGTH = 0K
}
SECTIONS
{
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text :
{
*(.rel.text)
*(.rel.text.*)
*(.rel.gnu.linkonce.t*)
}
.rela.text :
{
*(.rela.text)
*(.rela.text.*)
*(.rela.gnu.linkonce.t*)
}
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata :
{
*(.rel.rodata)
*(.rel.rodata.*)
*(.rel.gnu.linkonce.r*)
}
.rela.rodata :
{
*(.rela.rodata)
*(.rela.rodata.*)
*(.rela.gnu.linkonce.r*)
}
.rel.data :
{
*(.rel.data)
*(.rel.data.*)
*(.rel.gnu.linkonce.d*)
}
.rela.data :
{
*(.rela.data)
*(.rela.data.*)
*(.rela.gnu.linkonce.d*)
}
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.text :
{
*(vectors)
*(imports)
*(reset_start)
*(reset_io)
*(load_sram_eeprom)
*(reset_00)
*(reset_01)
*(reset_network)
*(reset_02)
*(reset_03)
*(reset)
*(reset_end)
*(.progmem.gcc*)
*(.progmem*)
*(strings)
. = ALIGN(2);
*(.text)
. = ALIGN(2);
*(.text.*)
. = ALIGN(2);
*(.fini)
_etext = . ;
} > text
.data : AT (ADDR (.text) + SIZEOF (.text))
{
*(.data)
*(.gnu.linkonce.d*)
. = ALIGN(2);
_edata = . ;
} > data
.bss SIZEOF(.data) + ADDR(.data) :
AT (ADDR (.text) + SIZEOF (.text) + SIZEOF (.data))
{
PROVIDE (__bss_start = .) ;
*(.bss)
*(COMMON)
PROVIDE (__bss_end = .) ;
*(uninitialized_data)
_end = . ;
} > data
.eeprom :
{
*(eeprom_reserved)
*(eeprom*)
*(.eeprom*)
__eeprom_end = . ;
} > eeprom
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
PROVIDE (__ddf = 0x25f);
symbol_references : {
*(symbol_references)
} >symbol_references
undefined_section : {
*(*)
. = 0 ;
} >undefined_section
}
Take a look at...
http://lightner.net/avr/ATtinyAvrGcc.html
...for more details.
Best regards,
Bruce
--
Bruce D. Lightner
Lightner Engineering
La Jolla, California
Voice: +1-858-551-4011
FAX: +1-858-551-0777
Email: address@hidden
URL: http://www.lightner.net/lightner/bruce/
Re: [avr-gcc-list] Stuckness with ATTiny15 program and avr-gcc, Bob Paddock, 2005/01/08