optimize size, and make debug and ftl stuff optional

This commit is contained in:
David Voswinkel 2009-08-01 16:59:31 +02:00
parent c5e72c48eb
commit 1539ff6111
12 changed files with 1729 additions and 1639 deletions

View File

@ -22,9 +22,14 @@ F_CPU = 20000000 # in Hz
TARGET = main
AVRDUDE = avrdude -c usbasp -p $(DEVICE)
SIZE = avr-size
CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o dump.o timer.o watchdog.o huffman-decode.o rle.c loader.o
#LDFLAGS = -Wl,-u,vfprintf -lprintf_flt
#CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0
LDFLAGS = -Wl,-u,vfprintf
CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0 -DNO_DEBUG
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o dump.o timer.o watchdog.o huffman-decode.o rle.c loader.o info.o
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
@ -60,48 +65,36 @@ fuse:
{ echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; }
$(AVRDUDE) -U hfuse:w:$(FUSE_H):m -U lfuse:w:$(FUSE_L):m
# rule for uploading firmware:
flash: main.hex
$(AVRDUDE) -U flash:w:main.hex:i
# rule for deleting dependent files (those which can be built by Make):
clean:
rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.elf *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s
# Generic rule for compiling C files:
.c.o:
$(COMPILE) -c $< -o $@
# Generic rule for assembling Assembler source files:
.S.o:
$(COMPILE) -x assembler-with-cpp -c $< -o $@
# "-x assembler-with-cpp" should not be necessary since this is the default
# file type for the .S (with capital S) extension. However, upper case
# characters are not always preserved on Windows. To ensure WinAVR
# compatibility define the file type manually.
# Generic rule for compiling C to assembler, used for debugging only.
.c.s:
$(COMPILE) -S $< -o $@
# file targets:
# Since we don't want to ship the driver multipe times, we copy it into this project:
usbdrv:
cp -r ../../../usbdrv .
main.elf: usbdrv $(OBJECTS) # usbdrv dependency only needed because we copy it
$(COMPILE) -o main.elf $(OBJECTS) -Wl,-u,vfprintf -lprintf_flt
$(COMPILE) -o main.elf $(OBJECTS) $(LDFLAGS)
main.hex: main.elf
rm -f main.hex main.eep.hex
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
avr-size main.hex
# debugging targets:
disasm: main.elf
avr-objdump -d main.elf
cpp:
$(COMPILE) -E main.c
clean:
rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.elf *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s

View File

@ -21,6 +21,7 @@
#ifndef __CONFIH_H__
#define __CONFIH_H__
#define DEBUG 1
#define DEBUG_USB 2
#define DEBUG_USB_TRANS 4

View File

@ -31,12 +31,10 @@ extern FILE uart_stdout;
extern int debug_level; /* the higher, the more messages... */
#if defined(NO_DEBUG) && defined(__GNUC__)
/* Nothing. debug has been "defined away" in debug.h already. */
#else
void debug(int level, char* format, ...) {
#ifdef NO_DEBUG
/* Empty body, so a good compiler will optimise calls
to pmesg away */
#else
va_list args;
if (!(debug_level & level))
@ -44,8 +42,8 @@ void debug(int level, char* format, ...) {
va_start(args, format);
vprintf(format, args);
va_end(args);
#endif /* NDEBUG */
#endif /* NDEBUG && __GNUC__ */
#endif
}
#endif

View File

@ -13,7 +13,6 @@
*
* Version: 1.0
* Created: 07/21/2009 03:32:16 PM
* Author: david@optixx.org
*
* =====================================================================================
*/

View File

@ -13,7 +13,6 @@
*
* Version: 1.0
* Created: 07/21/2009 03:32:16 PM
* Author: david@optixx.org
*
* =====================================================================================
*/

49
avr/usbload/info.c Normal file
View File

@ -0,0 +1,49 @@
/*
* =====================================================================================
*
* ________ .__ __ ________ ____ ________
* \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
* / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
* / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
* \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
* \__> \/ \/ \/ \/ \/
*
* www.optixx.org
*
*
* Version: 1.0
* Created: 07/21/2009 03:32:16 PM
* Author: david@optixx.org
*
* =====================================================================================
*/
#include <stdlib.h>
#include <stdint.h>
#include "info.h"
#include "uart.h"
extern FILE uart_stdout;
#if defined(NO_INFO) && defined(__GNUC__)
#define info(format, args...) ((void)0)
#else
void info(char* format, ...) {
#ifdef NO_INFO
#else
va_list args;
va_start(args, format);
vprintf(format, args);
va_end(args);
#endif
}
#endif

42
avr/usbload/info.h Normal file
View File

@ -0,0 +1,42 @@
/*
* =====================================================================================
*
* ________ .__ __ ________ ____ ________
* \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
* / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
* / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
* \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
* \__> \/ \/ \/ \/ \/
*
* www.optixx.org
*
*
* Version: 1.0
* Created: 07/21/2009 03:32:16 PM
* Author: david@optixx.org
*
* =====================================================================================
*/
#ifndef __INFO_H__
#define __INFO_H__
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#if defined(NO_INFO) && defined(__GNUC__)
/* gcc's cpp has extensions; it allows for macros with a variable number of
arguments. We use this extension here to preprocess pmesg away. */
#define info(format, args...) ((void)0)
#else
void info(char *format, ...);
/* print a message, if it is considered significant enough.
Adapted from [K&R2], p. 174 */
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,6 @@
#ifndef __FIFO_H__
#define __FIFO_H__
#define ROM_SIZE 30178
#define ROM_SIZE 30151
#endif

View File

@ -166,8 +166,13 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
rx_remaining = rq->wLength.word;
if (req_addr && req_addr % req_bank_size == 0) {
debug(DEBUG_USB,"USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%.4f\n",
#ifdef FLT_DEBUG
debug(DEBUG_USB,"USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%.4f\n",
req_bank, req_addr,timer_stop());
#else
debug(DEBUG_USB,"USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%i\n",
req_bank, req_addr,timer_stop_int());
#endif
req_bank++;
timer_start();
@ -193,8 +198,13 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
sram_bulk_write_start(req_addr);
#endif
if (req_addr && ( req_addr % req_bank_size) == 0) {
debug(DEBUG_USB,"USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%.4f\n",
#ifdef FLT_DEBUG
debug(DEBUG_USB,"USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%.4f\n",
req_bank, req_addr,timer_stop());
#else
debug(DEBUG_USB,"USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%i\n",
req_bank, req_addr,timer_stop_int());
#endif
req_bank++;
timer_start();
@ -539,7 +549,7 @@ int main(void)
printf("Poll\n");
while (req_state != REQ_STATUS_AVR){
usbPoll();
#if 1
#ifdef DO_IRQ
i = 10;
while (--i) { /* fake USB disconnect for > 250 ms */
_delay_ms(100);
@ -548,7 +558,7 @@ int main(void)
send_irq();
#endif
#if 0
#ifdef DO_BUS_STEALING
avr_bus_active();
sram_bulk_read_start(0x003000);
c = sram_bulk_read();

View File

@ -78,9 +78,9 @@ void timer_start( void )
}
double timer_stop(void)
uint16_t timer_stop_int(void)
{
double t = ((double)(DEBOUNCE - prescaler) / DEBOUNCE ) + second;
uint16_t t = ((DEBOUNCE - prescaler) / DEBOUNCE ) + second;
return t;
}

View File

@ -24,5 +24,6 @@
int16_t timer_start( void );
double timer_stop( void );
int16_t timer_stop_int( void );
#endif