Skip to content

Commit

Permalink
now it compiles with UART
Browse files Browse the repository at this point in the history
  • Loading branch information
zevero committed Oct 24, 2015
1 parent f544597 commit 30e0f13
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -9,7 +9,7 @@ F_CPU = 16000000 # CPU clock frequency [Hz]
USE_LED = 0 # Debug with two (defined in asmfunc.S)
USE_UART = 0 # Debug on Serial. 0 ... deactivate or divider of http://wormfood.net/avrbaudcalc.php for baud rate!
#------------------------------------------------------------------
CSRC = main.c pff/src/pff.c diskio.c #uart/uart.c #uart/uart.c is taken out by --gc,sections if USE_UART = 0
CSRC = main.c pff/src/pff.c diskio.c uart/uart.c #uart/uart.c is taken out by --gc,sections if USE_UART = 0

TARGET = avr_boot
ASRC = asmfunc.S
Expand Down
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -41,9 +41,10 @@ This is with avr-gcc and avrdude under linux with an Atmega1284p and avrIsp mkII
- it might already have happend!

# Bootloader size
For devices with less and more than 64kb
- 3650 - 3700 bytes
- 3960 - 4010 bytes debugging with USE_LED
- ? bytes debugging with USE_UART (does not compile any more - please help)
- 3870 - 3930 bytes debugging with USE_UART

# Serial support - Help wanted
it should not be so difficult to fit a normal serial bootloader (with automatic baudrate detection?) into the remaining 500 bytes ... help is appreciated!
Expand Down
8 changes: 7 additions & 1 deletion main.c
Expand Up @@ -46,6 +46,12 @@ const char filename[13] ="FIRMWARE.BIN\0"; // EDIT FILENAME HERE
#include <string.h>
#include "pff/src/pff.h"

#if BOOT_ADR > 0xFFFF
#define PGM_READ_BYTE(x) pgm_read_byte_far(x)
#else
#define PGM_READ_BYTE(x) pgm_read_byte(x)
#endif

#if USE_UART
#include "uart/uart.h"
#endif
Expand Down Expand Up @@ -73,7 +79,7 @@ static uint8_t pagecmp(const DWORD fa, uint8_t buff[SPM_PAGESIZE])
UINT i;
uint8_t b_flash,b_buff;
for (i = 0; i < SPM_PAGESIZE; i++) {
b_flash = BOOT_ADR>0xFFFF ? pgm_read_byte_far(fa+i):pgm_read_byte(fa+i);
b_flash = PGM_READ_BYTE(fa+i);
b_buff = buff[i];
if ( b_flash != b_buff) {
#if USE_UART //output first difference
Expand Down
9 changes: 8 additions & 1 deletion uart/uart.c
Expand Up @@ -12,6 +12,13 @@
#define UDRE UDRE0
#define UDR UDR0
#define RXC RXC0

#if BOOT_ADR > 0xFFFF
#define PGM_READ_BYTE(x) pgm_read_byte_far(x)
#else
#define PGM_READ_BYTE(x) pgm_read_byte(x)
#endif

// Just enable the UART Tx and set baud rate for 38400 on 3.6864MHz (STK500)

void UART_init(void) {
Expand All @@ -30,7 +37,7 @@ void UART_put(uint8_t c) {
void UART_puts(const char * str) {
char c;
do {
c = pgm_read_byte_far(str++);
c = PGM_READ_BYTE(str++);
if (c) {
UART_put(c);
}
Expand Down

0 comments on commit 30e0f13

Please sign in to comment.