Page 1 of 1

USB bootloader with program using usb?

Posted: Wed Jul 22, 2015 10:27 am
by confus
I wondered if one could use a vusb-based bootloader and still use the USB connection in ones' main firmware.

Say I have device that uses the USB conncetion e.g. to switch a few relays controlled by the connected PC. I then press a button to put the device in bootloader mode. I then update the firmware over the same USB connection, the device resets and I can switch the relays again over USB. Would that at all be possible?

I guess one would have to change a few compile time options to runtime stuff in v-usb but maybe a ready-made bootloader exists? Does someone know of one?

Re: USB bootloader with program using usb?

Posted: Thu Jul 23, 2015 10:38 am
by blargg
USBaspLoader and variations allow this on devices with bootloader support (separate interrupt vectors for bootloader). I use such a setup all the time and it's great. Some allow various ways of entering bootloader: for a few seconds on device being plugged in, when reset is pressed, etc.

Re: USB bootloader with program using usb?

Posted: Thu Jul 23, 2015 11:46 am
by confus
Ah, thanks. Would you mind giving me a kick start by posting the firmware and schematic of one of your simpler or a minimal projects? I find it easier to learn from examples.

Re: USB bootloader with program using usb?

Posted: Mon Jul 27, 2015 6:26 am
by blargg
The simplest approach is to get one (or two) USBasp hardware boards and flash USBaspLoader on it. Then you can load a new program into the board and use it as a development board with I/O and USB. If you have two of these or one and another ICSP programmer, I'll post one that's configured and ready to build and flash.