Project

General

Profile

Revision 167

Added by Kevin Woo about 14 years ago

Debug script, bootloader can send without hacks

View differences:

trunk/toolbox/bootloader/debug.sh
1
#!/bin/sh
2

  
3
avrdude -c avrispmkii -P usb -p t2313 -U flash:r:$1:i
4
avr-objdump -D -m avr  $1 | less
0 5

  
trunk/toolbox/bootloader/bootloader.c
51 51
	UBRRH = (uint8_t)(baud>>8);
52 52
	UBRRL = (uint8_t)baud;
53 53
	
54
	// Enable RX/TX and RX/TX Interrupt
54
	// Enable RX/TX
55 55
	UCSRB = _BV(RXEN) | _BV(TXEN);
56 56
 
57 57
	// Enable the TXEN pin as output
......
71 71
BOOTLOADER_SECTION void uart_send_byte(uint8_t data) {
72 72
	//Waits until current transmit is done
73 73
    while (!(UCSRA & _BV(UDRE)));
74
    PORTB |= _BV(PORTB2);
74
    //PORTB |= _BV(PORTB2);
75 75

  
76 76
    // Enable writes and send
77 77
	uart_toggle_transmit(UART_TX_ON);
78 78
    UDR = data;
79 79

  
80 80
    // Waits until the transmit is done
81
    while(!(UCSRA & _BV(UDRE)));
82
    PORTB |= _BV(PORTB1);
83

  
81
    while(!(UCSRA & _BV(TXC)));
84 82
    uart_toggle_transmit(UART_TX_OFF);
83
    UCSRA |= _BV(TXC);
85 84

  
85
    //PORTB |= _BV(PORTB1);
86

  
87

  
86 88
	return;
87 89
}
88 90

  
......
189 191
    uart_send_byte(SERVER);
190 192
    uart_send_byte(cmd);
191 193
    uart_send_byte(ACK_CRC ^ cmd);
192
    uart_send_byte(0);
193 194
}
194 195

  
195 196
//#define SPM_PAGESIZE 32
......
210 211

  
211 212
BOOTLOADER_SECTION void  __init(void) {
212 213
  uint8_t mbuf[PROGD_PACKET_SIZE];
213
  uint8_t jbuf[2];
214
  uint8_t jbuf[2] = {0, 0};
214 215
  uint16_t caddr = MAIN_ADDR;
215 216
  uint8_t iteration = 0;
216 217
  uint8_t resp;
......
221 222

  
222 223
  //set LED pin as output
223 224
  LED_DDR |= 0x07;
224
  PORTB = 0x00;
225
  PORTB = 0x07;
225 226

  
226 227
  //Start bootloading process
227 228
  send_packet(TT_BOOT);
......
248 249

  
249 250
              *((uint16_t*)mbuf) = pgm_read_word(MAIN_ADDR);
250 251

  
251
              onboard_program_write(caddr, mbuf);
252 252
              iteration = 1;
253
              caddr += PROGD_PACKET_SIZE - 2;
254
          } else {
255
              onboard_program_write(caddr, mbuf);
256
              caddr += PROGD_PACKET_SIZE;
257 253
          }
254

  
255
          onboard_program_write(caddr, mbuf);
256
          caddr += PROGD_PACKET_SIZE;
258 257
      } else {
259 258
          //main_start();
260 259
          while(1);
......
263 262
      send_packet(TT_ACK);
264 263

  
265 264
      if (prog_len <= PROGD_PACKET_SIZE) {
266
          //send_packet(TT_ACK);
267

  
268 265
          for (i = 0; i < PROGD_PACKET_SIZE; i++) {
269 266
              mbuf[i]= 0;
270 267
          }

Also available in: Unified diff