[tuxdroid-svn] r1290 - firmware/rf/trunk
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2008-07-01 14:49:21
|
Author: jaguarondi Date: 2008-07-01 16:49:24 +0200 (Tue, 01 Jul 2008) New Revision: 1290 Modified: firmware/rf/trunk/Makefile firmware/rf/trunk/device.c Log: * Fixed the jump for the bootloader. Modified: firmware/rf/trunk/Makefile =================================================================== --- firmware/rf/trunk/Makefile 2008-07-01 08:39:18 UTC (rev 1289) +++ firmware/rf/trunk/Makefile 2008-07-01 14:49:24 UTC (rev 1290) @@ -7,6 +7,15 @@ CC = avr-gcc AVRDUDE = avrdude +#Bootloader can be included with the program. If you keep the bootloader +#already in the RF board, set this to 0. +#CAUTION: don't set this to 1 if you want to reprogram the RF board with +#tuxup, you may use a wrong rjump to the bootloader and brick your board. You +#need an ISP programmer if you intend to play with the bootloader. +#As of now, only GCC 3.4.6 seems to compile the bootlodaer so that it fits in +#the 256 bytes section. 4.x generates code slightly too large to fit in. +BOOTLOADER=0 + ## Options common to compile, link and assembly rules COMMON = -mmcu=$(MCU) @@ -14,6 +23,7 @@ CFLAGS = $(COMMON) CFLAGS += -Wall -gstabs -DF_CPU=13824000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d +CFLAGS += -DBOOTLOADER=$(BOOTLOADER) ifneq (,$(findstring master, $(TYPE))) PROJECT = fuxrf CFLAGS += -D_MASTER @@ -32,7 +42,7 @@ ## Linker flags LDFLAGS = $(COMMON) -LDFLAGS += -Wl,--section-start=.bootloader=0x0F00 -Wl,--section-start=.version=0x0EF0 rf.ld +LDFLAGS += -Wl,--section-start=.bootloader=0x0F00 -Wl,--section-start=.version=0x0EF0 -Wl,--defsym=bootloader_start=0x0F0A rf.ld ## Intel Hex file production flags HEX_FLASH_FLAGS = -R .eeprom @@ -42,7 +52,11 @@ HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 ## Objects that must be built in order to link +ifeq ($(BOOTLOADER),1) OBJECTS = device.o init.o misc.o prot.o rf_ctrl.o varis.o interface.o bootloader.o +else +OBJECTS = device.o init.o misc.o prot.o rf_ctrl.o varis.o interface.o +endif ## Objects explicitly added by the user LINKONLYOBJECTS = Modified: firmware/rf/trunk/device.c =================================================================== --- firmware/rf/trunk/device.c 2008-07-01 08:39:18 UTC (rev 1289) +++ firmware/rf/trunk/device.c 2008-07-01 14:49:24 UTC (rev 1290) @@ -70,8 +70,6 @@ const version_t tag_version __attribute__ ((section("version.1"))) = {VERSION_CMD, CPU_VER_JOIN(CPU_NUMBER, VER_MAJOR), VER_MINOR, VER_UPDATE}; -/* Bootloader can be included with the program */ -#define BOOTLOADER 1 /* Set to 1 to enable stack debugging. */ #define DBG_STACK 0 @@ -114,18 +112,31 @@ // 14 - 30 -> Payload * // 31 -> Checksum * //***************************************************************************** +typedef void (*AppPtr_t)(void); +const AppPtr_t RunBoot = (AppPtr_t) 0x0785; + int main(void) { -#if (BOOTLOADER) #ifdef _SLAVE volatile uint16_t _count=0; + /* Wait for the head button signal to rise if it isn't pressed. */ for (;_count<0xFFFF; _count++); - if (!(PIND & 0x40)) /* if head is pushed at startup */ - /* TODO change to a rjump to 0x0F0A */ - asm volatile ("rjmp bootloader" ::); /* jump to bootloader */ + /* If head is pushed at startup */ + if (!(PIND & 0x40)) + /* jump to bootloader */ +#if (BOOTLOADER) + asm volatile ("rjmp bootloader" ::); +#else + asm volatile ("rjmp bootloader_start" ::); +#endif #elif defined(_MASTER) - if (!(PINB & 0x04)) /* if SPI_SS is cleared at startup */ - asm volatile ("rjmp bootloader" ::); /* jump to bootloader */ + /* If SPI_SS is cleared at startup */ + if (!(PINB & 0x04)) + /* jump to bootloader */ +#if (BOOTLOADER) + asm volatile ("rjmp bootloader" ::); +#else + asm volatile ("rjmp bootloader_start" ::); #endif #endif |