would be very nice if someone can share his recipe or have a look at my partial solution. i am looking for a way to make the bootloaderHID starting from the firmware without the needs to press any button or set any jumper and then application use the bootloadHID.exe -r to update the firmware.
here's my solution, not really working cause i don't fully understand obdev usb...
bootloaderconfig.h
- Code: Select all
#define USB_CFG_PULLUP_IOPORTNAME D
#define USB_CFG_PULLUP_BIT 4
#define BOOTLOADER_CAN_EXIT 1
#define JUMPER_BIT 5
static inline void bootLoaderInit(void)
{
PORTD |= (1 << JUMPER_BIT);
}
#define bootLoaderCondition() ((PIND & (1 << JUMPER_BIT)) == 0)
i need to change the bootLoaderCondition, but i am not sure what to use. what i know is that i need to press and hold the jumper (button) to update the firmware. like i said, i would like to simply start the bootloader from the firmware without any intervention.
in the firmware i have this piece of code that seems to work.
- Code: Select all
// ------------------------------------------------------------------------------
// - Start Bootloader
// ------------------------------------------------------------------------------
// dummy function doing the jump to bootloader section (Adress 1C00 on Atmega16)
void (*jump_to_bootloader)(void) = 0x1C00; __attribute__ ((unused))
void startBootloader(void) {
MCUCSR &= ~(1 << PORF); // clear power on reset flag
// this will hint the bootloader that it was forced
cli(); // turn off interrupts
wdt_disable(); // disable watchdog timer
usbDeviceDisconnect(); // disconnect gnusb from USB bus
cbi(ADCSRA, ADIE); // disable ADC interrupts
cbi(ADCSRA, ADEN); // disable ADC (turn off ADC power)
PORTA = 0; // pull all pins low
PORTB = 0;
PORTC = 0;
jump_to_bootloader();
}
pat

