iman-30 / optiboot

Automatically exported from code.google.com/p/optiboot
0 stars 0 forks source link

Makefile builds images that are invalid #29

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
$ gmake atmega328
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types 
-mshort-calls -mmcu=atmega328p -DF_CPU=16000000L  '-DLED_START_FLASHES=3' 
'-DBAUD_RATE=57600'   -c -o optiboot.o optiboot.c
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types 
-mshort-calls -mmcu=atmega328p -DF_CPU=16000000L  '-DLED_START_FLASHES=3' 
'-DBAUD_RATE=57600' -Wl,--section-start=.text=0x7e00 -Wl,--relax -nostartfiles 
-o optiboot_atmega328.elf optiboot.o 
avr-objcopy -j .text -j .data -O ihex optiboot_atmega328.elf 
optiboot_atmega328.hex
avr-objdump -h -S optiboot_atmega328.elf > optiboot_atmega328.lst
rm optiboot.o optiboot_atmega328.elf

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file 
"optiboot/bootloaders/optiboot/optiboot_atmega328.hex"
avrdude: input file optiboot/bootloaders/optiboot/optiboot_atmega328.hex auto 
detected as Intel Hex
avrdude: ERROR: address 0x8010 out of range at line 33 of 
optiboot/bootloaders/optiboot/optiboot_atmega328.hex
avrdude: write to file 'optiboot/bootloaders/optiboot/optiboot_atmega328.hex' 
failed

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Original issue reported on code.google.com by Alan.Bur...@gmail.com on 9 Jan 2011 at 5:16

GoogleCodeExporter commented 8 years ago
Here's the hex file: The contents are completely different from the one 
downloaded from the optiboot website and the 3rd from last line is the one 
that's causing the problem:

:107E000011E0A0E0B1E0E0E1F0E802C005900D92E1
:107E1000A030B107D9F711E0A0E0B1E001C01D9298
:107E2000A030B107E1F785E08093810082E0809384
:107E3000C00088E18093C10086E08093C20082E2A6
:107E40008093C40084B714BE81FFCFD08DE0C7D02B
:107E5000259A86E020E33CEF91E030938500209363
:107E6000840096BBB09BFECF1D9AA8958150A9F7C0
:107E7000DD24D394A5E0EA2EF1E1FF2EA3D08134D6
:107E800021F481E0BDD083E024C0823411F484E188
:107E900003C0853419F485E0B3D089C08535A1F4D9
:107EA00091D0082F10E010930102009300028AD0B5
:107EB00090E0982F8827802B912B880F991F909303
:107EC00001028093000272C0863529F484E098D0C4
:107ED00080E070D06CC0843609F042C07BD0E09165
:107EE0000002F091010283E080935700E895C0E022
:107EF000D1E068D089938091020281508093020280
:107F00008823B9F777D007B600FCFDCF4091000277
:107F100050910102A0E0B1E02C9130E0FD0181819F
:107F200090E0982F8827822B932B1296FA010C0150
:107F3000D0925700E89511244E5F5F4FF1E0A038D2
:107F4000BF0751F7E0910002F0910102E092570063
:107F5000E89507B600FCFDCFF0925700E89527C0E2
:107F60008437B9F437D046D0E0910002F091010295
:107F70003196F0930102E09300023197E4918E2F45
:107F800019D080910202815080930202882361F708
:107F90000EC0853739F42ED08EE10CD085E90AD099
:107FA0008FE097CF813511F488E019D023D080E19C
:107FB00001D064CF982F8091C00085FFFCCF9093B3
:107FC000C6000895A8958091C00087FFFCCF8091DE
:107FD000C6000895F7DFF6DF80930202F3CFE0E6F4
:107FE000F0E098E190838083089580E0F8DFEE2749
:107FF000FF270994E7DF803209F0F7DF84E1DACF69
:108000001F93182FDFDF1150E9F7F4DF1F91089558
:0400000300007E007B
:00000001FF

If I delete the errant line the image uploads but doesn't actually work.

At a guess it would seem that optiboot is dependent on the quirks of the 
particular compiler version that it is built with, in my case I'm using gcc 
4.3.5.

Original comment by Alan.Bur...@gmail.com on 9 Jan 2011 at 5:30

GoogleCodeExporter commented 8 years ago
Is this the same as "issue 1" ?
http://code.google.com/p/optiboot/issues/detail?id=1&can=1

Original comment by wes...@gmail.com on 16 Jan 2011 at 12:34

GoogleCodeExporter commented 8 years ago
Possibly, I can investigate if the -nostdlib flag makes a difference.

Original comment by Alan.Bur...@gmail.com on 16 Jan 2011 at 12:53

GoogleCodeExporter commented 8 years ago
No, it isn't the same problem as issue#1, I've added the -nostdlib flag and the 
results are still different to the hex file in the distribution.  It's closer 
than it was, but still not the same.  Here's the hex so you can compare:

:107E000085E08093810082E08093C00088E18093C8
:107E1000C10086E08093C20080E18093C40084B7F3
:107E200014BE81FFCFD08DE0C7D0259A86E020E335
:107E30003CEF91E0309385002093840096BBB09B8B
:107E4000FECF1D9AA8958150A9F7DD24D394A5E013
:107E5000EA2EF1E1FF2EA3D0813421F481E0BDD0E0
:107E600083E024C0823411F484E103C0853419F422
:107E700085E0B3D089C08535A1F491D0082F10E0FA
:107E800010930102009300028AD090E0982F882777
:107E9000802B912B880F991F9093010280930002F1
:107EA00072C0863529F484E098D080E070D06CC030
:107EB000843609F042C07BD0E0910002F0910102CB
:107EC00083E080935700E895C0E0D1E068D08993C3
:107ED000809102028150809302028823B9F777D003
:107EE00007B600FCFDCF4091000250910102A0E0D6
:107EF000B1E02C9130E0FD01818190E0982F88273E
:107F0000822B932B1296FA010C01D0925700E89520
:107F100011244E5F5F4FF1E0A038BF0751F7E091A9
:107F20000002F0910102E0925700E89507B600FCCC
:107F3000FDCFF0925700E89527C08437B9F437D0C9
:107F400046D0E0910002F09101023196F0930102D7
:107F5000E09300023197E4918E2F19D080910202B4
:107F6000815080930202882361F70EC0853739F46F
:107F70002ED08EE10CD085E90AD08FE097CF8135E5
:107F800011F488E019D023D080E101D064CF982F7C
:107F90008091C00085FFFCCF9093C6000895A895FE
:107FA0008091C00087FFFCCF8091C6000895F7DF65
:107FB000F6DF80930202F3CFE0E6F0E098E19083F1
:107FC0008083089580E0F8DFEE27FF270994E7DF3C
:107FD000803209F0F7DF84E1DACF1F93182FDFDF5B
:0A7FE0001150E9F7F4DF1F91089536
:0400000300007E007B
:00000001FF

Original comment by Alan.Bur...@gmail.com on 17 Jan 2011 at 11:54

GoogleCodeExporter commented 8 years ago
HAving said that the image is different, it does appear to work, subject to the 
problems described in issue 28.

I think it's more or less certain that different compiler versions are going to 
produce slightly different output.  I suggest an additional step is added to 
the Makefile to check (via avr-size) that the output file is small enough to 
fit in 1K, and to abort the build if it doesn't.  That doesn't fully fix the 
problem but it will flag up errors at build time rather than at install time.

Original comment by Alan.Bur...@gmail.com on 19 Jan 2011 at 12:27

GoogleCodeExporter commented 8 years ago
I have just managed to compile Optiboot under Windows using the tools in the 
IDE.  Here's what I did:

- Copy the Arduino IDE to c:\tmp\arduino
- Download the current Optiboot source files into 
c:\tmp\arduino\hardware\arduino\bootloaders\optiboot-new
- Download WestfW's Makefile patch from 
<http://code.google.com/p/arduino/issues/detail?id=487>.  This patch adapts the 
file paths to allow the compiler toolchain to run under Windows.
- Patch the Makefile.  As it stands WestfW's diff file doesn't match the 
current version of the makefile, so it needs to be adapted slightly by hand.
- Add the '-nostdlib' as explained in Issue-1 
<http://code.google.com/p/optiboot/issues/detail?id=1>
- Compile:
@PATH=%PATH%;c:\tmp\arduino\hardware\tools\avr\utils\bin
make OS=windows ENV=arduino clean
make OS=windows ENV=arduino atmega328

The resulting file 'optiboot_atmega328.hex' matches perfectly the one in the 
source repository.

Original comment by tim...@gmail.com on 22 Mar 2011 at 1:39

GoogleCodeExporter commented 8 years ago
Note that slight compiler changes can cause dramatic differences in the 
apparent contents of the .hex file.  A size difference of one byte will cause 
jump instructions to have a different target address (for example), and even if 
it only changes by one, the whole line of the .hex file will diff diffferently.

Original comment by wes...@gmail.com on 30 Oct 2011 at 7:37

GoogleCodeExporter commented 8 years ago
Fixed as part of the great optiboot/Arduino sync-up
http://code.google.com/p/optiboot/source/detail?r=8559b64fd093d3976cae58778a1540
256cde5c8e

Original comment by wes...@gmail.com on 30 Oct 2011 at 8:19