From: E. W. <er...@ev...> - 2004-12-14 16:33:38
|
Jan Humpl wrote: > > > E. Weddington wrote: > >> On 14 Dec 2004 at 12:13, Jan Humpl wrote: >> >> >>> Hi, I'm tring to use bootloader in C, I follow >>> avr-libc-user-manual-1.0.4 manual - so I add "BOOTLOADER_SECTION" to >>> my boot function, but I can't link that code... :( (I try some >>> changes in makefile, but not sucefully. Libc manual should be more >>> concrete :) There is output from linking: >>> >>> Linking: main.elf >>> avr-gcc -mmcu=atmega16 -I. -gstabs -Os -funsigned-char >>> -funsigned-bitfields -fpack-struct -fshort-enums -Wall >>> -Wstrict-prototypes -Wa,-adhlns=main.o -std=gnu99 -mcall-prologues >>> -Wp,-M,-MP,-MT,main.o,-MF,.dep/main.elf.d main.o bootloader.o >>> registers.o signals.o init.o uart.o systimer.o modbus.o spi.o crc.o >>> --output main.elf -Wl,-Map=main.map,--cref -lm >>> C:\Program >>> Files\WinAVR\bin\..\lib\gcc\avr\3.4.1\..\..\..\..\avr\bin\ld.exe: >>> section .bootloader [0000125a -> 00001271] overlaps section .data >>> [0000125a -> 00001459] >>> make: *** [main.elf] Error 1 >>> >>> >>> Has anyone experience with bootloader or how to specify memory >>> location for some function? Some running code example is helpfull >>> :). Thanks. >>> >> >> >> You now need to relocate the .bootloader section to the correct >> address. See the avr-libc FAQ. There is an item in there about how to >> relocate a custom section, using a bootloader section as an example. >> >> You can also search the AVR GCC Forum at AVR Freaks >> (www.avrfreaks.net) for a lot more info. >> >> > > I foud that I must add: > > BOOTLOADER_START_128 = 0x1F80 > BOOTLOADER_START_256 = 0x1F00 > BOOTLOADER_START_512 = 0x1E00 > BOOTLOADER_START_1024 = 0x1C00 > BOOTLOADER_START = $(BOOTLOADER_START_128) > > LDFLAGS += -Wl,--section-start=.bootloader=$(BOOTLOADER_START) > > to makefile (atmega16). (why this isn't documented in avr-libc manual?) Yes unfortunately, this info is found in the FAQ, not with the rest of the bootloader info. Sorry for the hassle. > But I still have a problem :) Function marked as 'BOOTLOADER_SECTION" > is compilled into right adress, but mcu don't jump into it after reset. I I'm not familiar with the mega16, but one big hangup that gets people is that Atmel lists the starting address of the boot sections as WORD addresses. The toolset does everything in BYTE addresses. When I calculate 0x1F80 (from above), this equals 8064 decimal, which is nowhere near the top of the 16K flash. If you multiply it by 2 (to convert a WORD address to a BYTE address), then I get 16128, which is 256 bytes away from the top of the 16K flash. So those addresses you have are WORD addresses and should be changed to BYTE addresses. HTH Eric |