Well folks,
I am burning my fingers. @westfw has been giving me guidance but, I need some more help. At wesftw direction, I have installed WinAvr2010, and used it to compile optiboot.c, well almost. I added another procedure to support inplace self reprogramming, but the compiler is saying my procedure is defined but unused(.o generation), then in the next pass of avr-gcc (elf generation) It spits out undefined reference.
Here is the error from console:
C:\Users\user\Documents\GitHub\optiboot\optiboot\bootloaders\optiboot>make Targe
tV2
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
process_begin: CreateProcess(NULL, bash baudcheck.tmp.sh, ...) failed.
make (e=2): The system cannot find the file specified.
make: [baudcheck] Error 2 (ignored)
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega2560 -DF_CPU=1600
0000L -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -DBIGBOOT -DDOSELF -c -o
optiboot.o optiboot.c
optiboot.c:305:6: warning: #warning BAUD_RATE error greater than 2%
optiboot.c: In function 'do_self':
optiboot.c:1100: warning: cast from pointer to integer of different size
optiboot.c:1101: warning: cast from pointer to integer of different size
optiboot.c:1112: warning: cast from pointer to integer of different size
optiboot.c:1113: warning: cast from pointer to integer of different size
optiboot.c:1128: warning: cast from pointer to integer of different size
optiboot.c: At top level:
optiboot.c:1083: warning: 'do_self' defined but not used
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega2560 -DF_CPU=1600
0000L -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -DBIGBOOT -DDOSELF -Wl,--s
ection-start=.text=0x3fc00 -Wl,--section-start=.version=0x3fffe -Wl,--relax -nos
tartfiles -nostdlib -o optiboot_TargetV2.elf optiboot.o -lc
optiboot.o: In function `pre_main':
C:\Users\user\Documents\GitHub\optiboot\optiboot\bootloaders\optiboot/optiboot.c
:447: undefined reference to `do_self'
C:\Users\user\Documents\GitHub\optiboot\optiboot\bootloaders\optiboot/optiboot.c
:447: relocation truncated to fit: R_AVR_13_PCREL against undefined symbol `do_s
elf'
make: *** [optiboot_TargetV2.elf] Error 1
rm optiboot.o
C:\Users\user\Documents\GitHub\optiboot\optiboot\bootloaders\optiboot>
I am attaching my modified optiboot, and the MakeCustom
Chuck.
optiboot.c (40.5 KB)
Makefile.Custom.txt (1.11 KB)
Have you successfully compiled unmodified Optiboot?
That's what I would try first.
dmjlambert:
Have you successfully compiled unmodified Optiboot?
That's what I would try first.
Yes, I can compile optiboot. Here is an example compiling the bootloader for Lilypad.
C:\Users\user\Documents\GitHub\optiboot\optiboot\bootloaders\optiboot>make lilyp
ad
make atmega168 AVR_FREQ=8000000L LED_START_FLASHES=3
make[1]: Entering directory `C:/Users/user/Documents/GitHub/optiboot/optiboot/bo
otloaders/optiboot'
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
process_begin: CreateProcess(NULL, bash baudcheck.tmp.sh, ...) failed.
make (e=2): The system cannot find the file specified.
make[1]: [baudcheck] Error 2 (ignored)
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega168 -DF_CPU=80000
00L -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -c -o optiboot.o optiboot.c
optiboot.c:298:6: warning: #warning BAUD_RATE error greater than -2%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega168 -DF_CPU=80000
00L -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -Wl,--section-start=.text=0x3
e00 -Wl,--section-start=.version=0x3ffe -Wl,--relax -nostartfiles -nostdlib -o o
ptiboot_atmega168.elf optiboot.o -lc
avr-size optiboot_atmega168.elf
text data bss dec hex filename
492 0 0 492 1ec optiboot_atmega168.elf
avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,loa
d -O ihex optiboot_atmega168.elf optiboot_atmega168.hex
avr-objdump -h -S optiboot_atmega168.elf > optiboot_atmega168.lst
rm optiboot.o optiboot_atmega168.elf
make[1]: Leaving directory `C:/Users/user/Documents/GitHub/optiboot/optiboot/boo
tloaders/optiboot'
mv optiboot_atmega168.hex optiboot_lilypad.hex
mv optiboot_atmega168.lst optiboot_lilypad.lst
C:\Users\user\Documents\GitHub\optiboot\optiboot\bootloaders\optiboot>
any Ideas?
Chuck.
I just got it to compile, I had to add a dummy call after the appStart(ch); in Main(). It'll never actually reach it, but the compiler doesn't know!
Now to actually see if it works!

I'm going to have to increase the boot size, .text is 1334 bytes
C:\Users\user\Documents\GitHub\optiboot\optiboot\bootloaders\optiboot>make Targe
tV2
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
process_begin: CreateProcess(NULL, bash baudcheck.tmp.sh, ...) failed.
make (e=2): The system cannot find the file specified.
make: [baudcheck] Error 2 (ignored)
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega2560 -DF_CPU=1600
0000L -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -DBIGBOOT -DDOSELF -c -o
optiboot.o optiboot.c
optiboot.c:305:6: warning: #warning BAUD_RATE error greater than 2%
optiboot.c: In function 'do_self':
optiboot.c:1105: warning: cast from pointer to integer of different size
optiboot.c:1106: warning: cast from pointer to integer of different size
optiboot.c:1117: warning: cast from pointer to integer of different size
optiboot.c:1118: warning: cast from pointer to integer of different size
optiboot.c:1133: warning: cast from pointer to integer of different size
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega2560 -DF_CPU=1600
0000L -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -DBIGBOOT -DDOSELF -Wl,--s
ection-start=.text=0x3E000 -Wl,--section-start=.version=0x3fffe -Wl,--relax -nos
tartfiles -nostdlib -o optiboot_TargetV2.elf optiboot.o -lc
avr-size optiboot_TargetV2.elf
text data bss dec hex filename
1334 0 0 1334 536 optiboot_TargetV2.elf
avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,loa
d -O ihex optiboot_TargetV2.elf optiboot_TargetV2.hex
avr-objdump -h -S optiboot_TargetV2.elf > optiboot_TargetV2.lst
rm optiboot.o optiboot_TargetV2.elf
C:\Users\user\Documents\GitHub\optiboot\optiboot\bootloaders\optiboot>
Chuck
A bit above my skill level. Could you describe what the inplace self reprogramming is supposed to do?
dmjlambert:
A bit above my skill level. Could you describe what the inplace self reprogramming is supposed to do?
I have a network(RS485) of custom Mega2560 boards controlling equipment. It is a hassle to carry a laptop with an AVRISP to each one to download software updates. Each of these boards have SD cards and SPI Flash onboard.
This compilation success will allow remote reprogramming. Since I have been able to compile a custom bootloader. I will be able to use the SPM (Self Programming) feature of AVR processors. With my re-programming routine I can create application code that can successfully overwrite itself with new code.
The code I added to the bootloader will use an external FLASH chip as a source for the updated application code. I will be able to send a software update to each of my devices. The devices will store the software update in an external SPI Flash chip, a Winbond W25Q64F (8MB 8pin SPI Flash). Once the download is received and verified, the address of the image is passed to my re-programming routine. This routine re-flashes the Mega2560 IC. As long as the new code still supports the network and SPI Flash, I will be able to change the program in my custom Mega2560's without leaving my desk! 
The application code will also have the ability to read the SDcard. It can transfer updated code from the SDcard to the SPI Flash, then initiate the re-programming routine.
Life is looking good!
Chuck.