From 2a83ee55b38c81df04d7d3b83d6bf68ed72936e4 Mon Sep 17 00:00:00 2001 From: WestfW Date: Fri, 10 Jun 2011 17:47:47 -0700 Subject: Add a version number to the optiboot source and binary. http://code.google.com/p/arduino/issues/detail?id=554 end of flash memory where they can be read (at least in theory) by device programmers, hex-file examination, or application programs. This is done by putting the version number in a separate section (".version"), and using linker/objcopy magic to locate that section as appropriate for the target chip. (See http://lists.gnu.org/archive/html/avr-gcc-list/2011-02/msg00016.html for some discussion on the details.) Start the version at 4.1 (the last "packaged" version of optiboot was called version 3, so the "top of source" would be 4.0, and adding the version number makes 4.1) Refactor LDSECTION in the Makefile to LDSECTIONS so that multiple section start addresses can be defined. Change the _isp makefile definitions to make the bootloader section readable (but not writable) by the application section. (This would need to be done elsewhere as well to handle all bootloader programming techniques. Notably Arduino's boards.txt Note that this change does not change the "code" portion of optiboot at all. The only diffs in the .hex files are the added version word at the end of flash memory. --- bootloaders/optiboot/optiboot_atmega328.lst | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'bootloaders/optiboot/optiboot_atmega328.lst') diff --git a/bootloaders/optiboot/optiboot_atmega328.lst b/bootloaders/optiboot/optiboot_atmega328.lst index 1af4a3c..0da8aaf 100644 --- a/bootloaders/optiboot/optiboot_atmega328.lst +++ b/bootloaders/optiboot/optiboot_atmega328.lst @@ -5,23 +5,25 @@ Sections: Idx Name Size VMA LMA File off Algn 0 .text 000001fc 00007e00 00007e00 00000054 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 1 .debug_aranges 00000028 00000000 00000000 00000250 2**0 + 1 .version 00000002 00007ffe 00007ffe 00000250 2**0 + CONTENTS, READONLY + 2 .debug_aranges 00000028 00000000 00000000 00000252 2**0 CONTENTS, READONLY, DEBUGGING - 2 .debug_pubnames 0000006a 00000000 00000000 00000278 2**0 + 3 .debug_pubnames 0000006a 00000000 00000000 0000027a 2**0 CONTENTS, READONLY, DEBUGGING - 3 .debug_info 00000284 00000000 00000000 000002e2 2**0 + 4 .debug_info 00000285 00000000 00000000 000002e4 2**0 CONTENTS, READONLY, DEBUGGING - 4 .debug_abbrev 000001ae 00000000 00000000 00000566 2**0 + 5 .debug_abbrev 0000019f 00000000 00000000 00000569 2**0 CONTENTS, READONLY, DEBUGGING - 5 .debug_line 00000450 00000000 00000000 00000714 2**0 + 6 .debug_line 00000453 00000000 00000000 00000708 2**0 CONTENTS, READONLY, DEBUGGING - 6 .debug_frame 00000090 00000000 00000000 00000b64 2**2 + 7 .debug_frame 00000090 00000000 00000000 00000b5c 2**2 CONTENTS, READONLY, DEBUGGING - 7 .debug_str 00000141 00000000 00000000 00000bf4 2**0 + 8 .debug_str 00000141 00000000 00000000 00000bec 2**0 CONTENTS, READONLY, DEBUGGING - 8 .debug_loc 000001e1 00000000 00000000 00000d35 2**0 + 9 .debug_loc 000001e1 00000000 00000000 00000d2d 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_ranges 00000068 00000000 00000000 00000f16 2**0 + 10 .debug_ranges 00000068 00000000 00000000 00000f0e 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: @@ -135,7 +137,7 @@ void watchdogReset() { __boot_page_fill_short((uint16_t)(void*)addrPtr,a); addrPtr += 2; } while (--ch); - + // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); 7e50: a5 e0 ldi r26, 0x05 ; 5 @@ -249,7 +251,7 @@ void watchdogReset() { 7ec6: e8 95 spm 7ec8: c0 e0 ldi r28, 0x00 ; 0 7eca: d1 e0 ldi r29, 0x01 ; 1 - + // While that is going on, read in page contents bufPtr = buff; do *bufPtr++ = getch(); @@ -278,7 +280,7 @@ void watchdogReset() { // Read command terminator, start reply verifySpace(); 7ef4: 75 d0 rcall .+234 ; 0x7fe0 - + // If only a partial page is to be programmed, the erase might not be complete. // So check that here boot_spm_busy_wait(); @@ -336,7 +338,7 @@ int main(void) { 7f2e: a0 38 cpi r26, 0x80 ; 128 7f30: bf 07 cpc r27, r31 7f32: 51 f7 brne .-44 ; 0x7f08 - + // Write from programming buffer __boot_page_write_short((uint16_t)(void*)address); 7f34: e0 91 00 02 lds r30, 0x0200 -- cgit v1.2.3-18-g5258