Revision 196

trunk/bootloader/reset_vect.c (revision 196)
1
/** 
2
 * Restore the reset vector to point to the end of ctors. This
3
 * is because we are stripping out the interrupt vector table
4
 * from the bootloader as we don't use it.
5
 */
6
void ResetVector (void) __attribute__((naked))
7
                        __attribute__((section(".reset")));
8
void ResetVector(void) {
9
    asm("rjmp __ctors_end");
10
}
trunk/bootloader/bootloader.c (revision 196)
1 1
#include "bootloader.h"
2 2

  
3 3
// Setup the default fuses
4
/*
4 5
FUSES = {
5 6
    .low = (FUSE_SUT0 & FUSE_CKSEL3 & FUSE_CKSEL2 & FUSE_CKSEL0),
6 7
    .high = (FUSE_EESAVE & FUSE_SPIEN),
7 8
    .extended = (FUSE_SELFPRGEN),
8
};
9
};*/
9 10

  
10 11

  
11 12

  
......
20 21
/**
21 22
 * Where we store the jump to user code. The jump address is in words
22 23
 * due to how the rjmp instruction works. It is 1 word below the bootloader
24
 * We declare it as noreturn to save some space since we will never return
25
 * to the bootloader unless we do a system reset
23 26
 */
24
void (*main_start)(void) = BOOT_START/2 - 1;
27
void (*main_start)(void) __attribute__((noreturn)) = BOOT_START/2 - 1;
25 28

  
26
/**
27
 * We declare main as naked so that there is no overhead for entering
28
 * and returning from this function since we don't really care about
29
 * what happens to it after we leave it
30
 */
31
int main(void) __attribute__ ((naked));
32

  
33 29
typedef union {
34 30
    uint8_t bytes[2];
35 31
    int16_t sword;
36 32
} rjump_t;
37 33

  
38
/** 
39
 * Restore the reset vector to point to the end of ctors. This
40
 * is because we are stripping out the interrupt vector table
41
 * from the bootloader as we don't use it.
42
 */
43
void ResetVector (void) __attribute__((naked))
44
                        __attribute__((section(".reset")));
45
void ResetVector(void) {
46
    asm("rjmp __ctors_end");
47
}
48 34

  
49

  
50 35
// SPM_PAGESIZE is set to 32 bytes
51 36
void onboard_program_write(uint16_t page, uint8_t *buf) {
52 37
  uint16_t i;
trunk/bootloader/Makefile (revision 196)
53 53
BOOTSTART = 0x400
54 54

  
55 55
# Location to place the jump table
56
JUMPSTART = 0x7E0
56
JUMPSTART = 0x7C0
57 57

  
58 58

  
59 59
# Output format. (can be srec, ihex, binary)
......
187 187
#    -Map:      create map file
188 188
#    --cref:    add cross reference to  map file
189 189
LDFLAGS = -Wl,--script=linker_script.x,-Map=$(TARGET).map,--cref,--section-start=.text=$(BOOTSTART),--section-start=.jumps=$(JUMPSTART),--undefined=_jumptable,--gc-sections
190
#LDFLAGS = -Wl,-Map=$(TARGET).map,--cref,--section-start=.text=$(BOOTSTART),--section-start=.jumps=$(JUMPSTART),--undefined=_jumptable
190 191
LDFLAGS += $(EXTMEMOPTS)
191 192
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
192 193

  
trunk/bootloader/linker_script.x (revision 196)
72 72
  /* Internal text space or external memory.  */
73 73
  .text :
74 74
  {
75
    bootloader.o(.reset)
75
    reset_vect.o(.reset)
76 76
    KEEP(*(.reset))
77 77
    *(.vectors)
78 78
    /*KEEP(*(.vectors))*/

Also available in: Unified diff