I've written my own USB bootloader and it is ALMOST working. I'd like
to describe my
approach and ask for any ideas on what is wrong.
First, I'm using IAR C-compiler, my own hardware with an AT81SAM7S256 mpu
with USB.
All bootloader and USB stack code is located at 3B000 (top 16 k of the 256
flash), and will
only allow updating of the lower 240k (more than enough for my application). My
application starts running from 0 (reset vector) and run the normal C-startup
code from
IAR. (this works fine).
To update my application, the app passes control to my bootloader which reads an
Intel
Hex formatted file via usb and flash each page as it is received. (Remember I
will only write
flash that is below 3B000 so as to not change my bootloader while running).
(this works
fine and successfully re-writes all flash).
An interesting case is that I delay writing page 0 of the flash until the very
last moment
(because of the interrupt and reset vectors located there). I know it must be
delayed
because my loader crashes early on if I write page 0 as it is received.... but
by only writing
page 0 as the final task before trying to restart, it all seems OK).
So - the problem is that after flashing everything and then page 0, my
'new' code does not
run! Hitting my reset button does not seem to init the processor, leading me to
believe
there are some steps I am missing. The 'new' code does of course
contain a full image
including IAR's startup code which is what I am expecting to start running
when I hit my
hardware reset.
Any ideas? Thanks much. -steve-
final steps to getting my own boot loader to work
Started by ●February 4, 2008
Reply by ●February 4, 20082008-02-04
Hi,
updating any page (your case page 0) which has mission critical content
for the boot-loader is risky. What happens if there is a power failure
while you are reprogramming page 0? The boot-loader is dead, and you
loose access to the chip (ok other means like JTAG will still work, but
you can not use these on the filed).
So why don't you put your boot loader to the first sector and remap the
vector table?
Foltos
fa50_pilot wrote:
>
> I've written my own USB bootloader and it is ALMOST working. I'd like
> to describe my
> approach and ask for any ideas on what is wrong.
>
> First, I'm using IAR C-compiler, my own hardware with an AT81SAM7S256
> mpu with USB.
>
> All bootloader and USB stack code is located at 3B000 (top 16 k of the
> 256 flash), and will
> only allow updating of the lower 240k (more than enough for my
> application). My
> application starts running from 0 (reset vector) and run the normal
> C-startup code from
> IAR. (this works fine).
>
> To update my application, the app passes control to my bootloader
> which reads an Intel
> Hex formatted file via usb and flash each page as it is received.
> (Remember I will only write
> flash that is below 3B000 so as to not change my bootloader while
> running). (this works
> fine and successfully re-writes all flash).
>
> An interesting case is that I delay writing page 0 of the flash until
> the very last moment
> (because of the interrupt and reset vectors located there). I know it
> must be delayed
> because my loader crashes early on if I write page 0 as it is
> received.... but by only writing
> page 0 as the final task before trying to restart, it all seems OK).
>
> So - the problem is that after flashing everything and then page 0, my
> 'new' code does not
> run! Hitting my reset button does not seem to init the processor,
> leading me to believe
> there are some steps I am missing. The 'new' code does of course
> contain a full image
> including IAR's startup code which is what I am expecting to start
> running when I hit my
> hardware reset.
>
> Any ideas? Thanks much. -steve-
>
>
updating any page (your case page 0) which has mission critical content
for the boot-loader is risky. What happens if there is a power failure
while you are reprogramming page 0? The boot-loader is dead, and you
loose access to the chip (ok other means like JTAG will still work, but
you can not use these on the filed).
So why don't you put your boot loader to the first sector and remap the
vector table?
Foltos
fa50_pilot wrote:
>
> I've written my own USB bootloader and it is ALMOST working. I'd like
> to describe my
> approach and ask for any ideas on what is wrong.
>
> First, I'm using IAR C-compiler, my own hardware with an AT81SAM7S256
> mpu with USB.
>
> All bootloader and USB stack code is located at 3B000 (top 16 k of the
> 256 flash), and will
> only allow updating of the lower 240k (more than enough for my
> application). My
> application starts running from 0 (reset vector) and run the normal
> C-startup code from
> IAR. (this works fine).
>
> To update my application, the app passes control to my bootloader
> which reads an Intel
> Hex formatted file via usb and flash each page as it is received.
> (Remember I will only write
> flash that is below 3B000 so as to not change my bootloader while
> running). (this works
> fine and successfully re-writes all flash).
>
> An interesting case is that I delay writing page 0 of the flash until
> the very last moment
> (because of the interrupt and reset vectors located there). I know it
> must be delayed
> because my loader crashes early on if I write page 0 as it is
> received.... but by only writing
> page 0 as the final task before trying to restart, it all seems OK).
>
> So - the problem is that after flashing everything and then page 0, my
> 'new' code does not
> run! Hitting my reset button does not seem to init the processor,
> leading me to believe
> there are some steps I am missing. The 'new' code does of course
> contain a full image
> including IAR's startup code which is what I am expecting to start
> running when I hit my
> hardware reset.
>
> Any ideas? Thanks much. -steve-
>
>
Reply by ●February 10, 20082008-02-10
Good suggestion! I am currently working on moving main() (and C-startup) to the
bootloader (protected) area which will check to see if its bootloading or running the
application, and then dispatch accordingly. That way I will NOT be changing page 0 (its
become part of my 'protected' area) and if the load fails a reset should re-run the boot
loader. Thanks
--- In A..., Foltos wrote:
>
> Hi,
>
> updating any page (your case page 0) which has mission critical content
> for the boot-loader is risky. What happens if there is a power failure
> while you are reprogramming page 0? The boot-loader is dead, and you
> loose access to the chip (ok other means like JTAG will still work, but
> you can not use these on the filed).
> So why don't you put your boot loader to the first sector and remap the
> vector table?
>
> Foltos
>
bootloader (protected) area which will check to see if its bootloading or running the
application, and then dispatch accordingly. That way I will NOT be changing page 0 (its
become part of my 'protected' area) and if the load fails a reset should re-run the boot
loader. Thanks
--- In A..., Foltos wrote:
>
> Hi,
>
> updating any page (your case page 0) which has mission critical content
> for the boot-loader is risky. What happens if there is a power failure
> while you are reprogramming page 0? The boot-loader is dead, and you
> loose access to the chip (ok other means like JTAG will still work, but
> you can not use these on the filed).
> So why don't you put your boot loader to the first sector and remap the
> vector table?
>
> Foltos
>