Project

General

Profile

Revision 89f527ad

ID89f527ad74f884b26429c0436fc0fbf0bdf39d17
Parent 6030b995
Child d88f80e5

Added by Thomas Mullins about 10 years ago

Added makefile magic to program bootloader in correct place

View differences:

scout_avr/bom/Makefile
12 12
SRC=bom.c tiny-twi.c
13 13
HDR=
14 14
FLAGS=-mmcu=$(MCU) -DF_CPU=$(F_CPU)UL -funsigned-char -Os -fpack-struct -Wall
15
BOOT_FLAGS=$(FLAGS) -Wl,-Ttext=0xA00
16
VECT_FLAGS=$(FLAGS) -nostartfiles
15 17

  
16 18
default: bom.hex
17 19

  
......
30 32
test.elf: test.c tiny-twi-sync.c tiny-twi-sync.h
31 33
	avr-g++ $(FLAGS) test.c tiny-twi-sync.c -o $@
32 34

  
35
bootloader.elf: bootloader.c tiny-twi-sync.c tiny-twi-sync.h
36
	avr-g++ $(BOOT_FLAGS) bootloader.c tiny-twi-sync.c -o $@
37

  
38
bootvectors.elf: bootvectors.S
39
	avr-g++ $(VECT_FLAGS) bootvectors.S -o $@
40

  
41
burn: bootloader.hex bootvectors.hex
42
	avrdude -p $(PART) -c $(PROG) -P usb -B 5 -U flash:w:bootloader.hex \
43
	  -U flash:w:bootvectors.hex
scout_avr/bom/bootloader.c
1 1
#include <inttypes.h>
2
#include <avr/boot.h>
2 3
#include <avr/interrupt.h>
3 4
#include <avr/pgmspace.h>
4 5
#include "tiny-twi-sync.h"
6
#include "bootloader.h"
5 7

  
6 8
uint32_t current_page;
7 9

  
......
32 34
  boot_page_write (page);     // Store buffer in flash page.
33 35
  boot_spm_busy_wait();       // Wait until the memory is written.
34 36

  
35
  // Reenable RWW-section again. We need this if we want to jump back
36
  // to the application after bootloading.
37

  
38
  boot_rww_enable ();
39

  
40 37
  // Re-enable interrupts (if they were ever enabled).
41 38

  
42 39
  SREG = sreg;
......
47 44
    if (current_page == 0) {
48 45
      uint16_t w = 0xC000 | ((START_ADDR >> 1) - 1);
49 46
      buf[0] = w & 0xFF;
50
      buf[1] = (w >> 16) & 0xFF;
47
      buf[1] = (w >> 8) & 0xFF;
51 48
    }
52 49
    boot_program_page(current_page, buf);
53 50
    current_page++;
......
67 64
  }
68 65
}
69 66

  
70

  
71

  
72

  
73 67
int main() {
68
  smb_init(slave_rx);
69
  smb_set_address(3); // TODO parameterize address
70
  twi_run();
71
  // TODO timeout
74 72
  return 0;
75
}
73
}
scout_avr/bom/bootvectors.S
1
.text
2
rjmp 0xA00 ; TODO parameterize this

Also available in: Unified diff