Bootloader - how to access app exception vectors

Started by Konrad Heksel July 29, 2009
Hi,
I wrote bootloader on LPC2388 + Keil.
Everything works ok when I load an application that uses only IRQ exception.
My concern is about the remain exceptions (Swi, Fiq...). If application uses them and they occur, the code jumps to bootloader vectors routines, instead of its own.
The current rom memory layout is:
bootloader 0 - 0x10000
application 0x10000 - 0x80000

Could you advice me or give some code example how it should be done correctly?

Regards,
Konrad

An Engineer's Guide to the LPC2100 Series



You should redirect the vectors in the bootloader to a known unmoveble place on application, such as:


Vectors LDR PC, Reset_Addr
LDR PC, Undef_Addr
LDR PC, SWI_Addr
LDR PC, PAbt_Addr
LDR PC, DAbt_Addr
NOP ; Reserved Vector
LDR PC, [PC,#-0x120]
LDR PC, FIQ_Addr

Reset_Addr DCD Reset_Handler
Undef_Addr DCD 0x00010004
SWI_Addr DCD 0x00010008
PAbt_Addr DCD 0x0001000C
DAbt_Addr DCD 0x00010010
FIQ_Addr DCD 0x00010014


So you could change the applications vector whenever you want, you just cant move it anymore in application.
The applications vector would be a branch to the handlers, like:


Vectors LDR PC, =Reset_Handler
Undef_Handler B Undef_Handler
LDR PC, =SWI_Handler
PAbt_Handler B PAbt_Handler
DAbt_Handler B DAbt_Handler
FIQ_Handler B FIQ_Handler

IMPORT SWI_Handler


In this case, only SWI is treated(by RTX), the others are infinite loops until you would use them. This vector should be place at 0x10000, so Undef is at 0x10004, Swi is at 0x10008 and so on.


Best regards,

Ivan Amancio - ivan topdata com br

________________________________

De: l... [mailto:l...] Em nome de Konrad Heksel
Enviada em: quarta-feira, 29 de julho de 2009 12:28
Para: l...
Assunto: [lpc2000] Bootloader - how to access app exception vectors


Hi,
I wrote bootloader on LPC2388 + Keil.
Everything works ok when I load an application that uses only IRQ exception.
My concern is about the remain exceptions (Swi, Fiq...). If application uses them and they occur, the code jumps to bootloader vectors routines, instead of its own.
The current rom memory layout is:
bootloader 0 - 0x10000
application 0x10000 - 0x80000

Could you advice me or give some code example how it should be done correctly?

Regards,
Konrad

--------

AVISO LEGAL
Esta mensagem eh exclusivamente para a pessoa do destinatario, podendo conter infomacoes confidencias ou legalmente protegidas. A transmissao incorreta da mensagem nao acarreta a perda de sua confidencialidade. Caso esta mensagem tenha sido recebida por engano, solicitamos que seja devolvida ao rementente e apagada de seu sistema imediatamente. Eh vedado a qualquer pessoa que nao seja destinatario usar, revelar, distribuir ou copiar qualquer parte desta mensagem.

DISCLAIMER
This message is destined exclusively to the intendend receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is receiveid by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not intendend receiver to use, reveal, distribute, or copy any part if this message.

www.topdata.com.br
--- In l..., "Konrad Heksel" wrote:
>
> Hi,
> I wrote bootloader on LPC2388 + Keil.
> Everything works ok when I load an application that uses only IRQ exception.
> My concern is about the remain exceptions (Swi, Fiq...). If application uses them and they occur, the code jumps to bootloader vectors routines, instead of its own.
> The current rom memory layout is:
> bootloader 0 - 0x10000
> application 0x10000 - 0x80000
>
> Could you advice me or give some code example how it should be done correctly?
>
> Regards,
> Konrad
>

Load application vectors to RAM and then remap after boot - that's what the 'map to RAM' feature is there for.

Rgds,
Martin

Hi,
Thanks for the answers. They've helped.

Just curious. Is this possible to reverse the placement, that application would start at 0x0000, and bootloader placed in higher location?

Regards,
Konrad



Its possible, but why would you do that? The reset vector, where the program counter starts after a reset, is placed at 0x0000, so after every reset or power cycle your application would run instead of the bootloader. Your application would be then bootloader of the bootloader.
If your application update sequence fails, you would never get application running again, nor the bootloader, so, thats why the bootloader should be at 0x0000 and should be error free.

Regards,

Ivan Amancio - ivan topdata com br

________________________________

De: l... [mailto:l...] Em nome de Konrad Heksel
Enviada em: quinta-feira, 30 de julho de 2009 11:14
Para: l...
Assunto: [lpc2000] Re: Bootloader - how to access app exception vectors


Hi,
Thanks for the answers. They've helped.

Just curious. Is this possible to reverse the placement, that application would start at 0x0000, and bootloader placed in higher location?

Regards,
Konrad
--------

AVISO LEGAL
Esta mensagem eh exclusivamente para a pessoa do destinatario, podendo conter infomacoes confidencias ou legalmente protegidas. A transmissao incorreta da mensagem nao acarreta a perda de sua confidencialidade. Caso esta mensagem tenha sido recebida por engano, solicitamos que seja devolvida ao rementente e apagada de seu sistema imediatamente. Eh vedado a qualquer pessoa que nao seja destinatario usar, revelar, distribuir ou copiar qualquer parte desta mensagem.

DISCLAIMER
This message is destined exclusively to the intendend receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is receiveid by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not intendend receiver to use, reveal, distribute, or copy any part if this message.

www.topdata.com.br
Sure, it doesn't make sense. I've just wanted doublecheck it. Thanks.

Konrad.

van Ferreira Amancio wrote:
>
> Its possible, but why would you do that? The reset vector, where the program counter starts after a reset, is placed at 0x0000, so after every reset or power cycle your application would run instead of the bootloader. Your application would be then bootloader of the bootloader.
> If your application update sequence fails, you would never get application running again, nor the bootloader, so, thats why the bootloader should be at 0x0000 and should be error free.
>
> Regards,
>
> Ivan Amancio - ivan topdata com br
>
> ________________________________
>
> De: l... [mailto:l...] Em nome de Konrad Heksel
> Enviada em: quinta-feira, 30 de julho de 2009 11:14
> Para: l...
> Assunto: [lpc2000] Re: Bootloader - how to access app exception vectors
>
>
>
>
> Hi,
> Thanks for the answers. They've helped.
>
> Just curious. Is this possible to reverse the placement, that application would start at 0x0000, and bootloader placed in higher location?
>
> Regards,
> Konrad
>
>
> --------
>
> AVISO LEGAL
> Esta mensagem eh exclusivamente para a pessoa do destinatario, podendo conter infomacoes confidencias ou legalmente protegidas. A transmissao incorreta da mensagem nao acarreta a perda de sua confidencialidade. Caso esta mensagem tenha sido recebida por engano, solicitamos que seja devolvida ao rementente e apagada de seu sistema imediatamente. Eh vedado a qualquer pessoa que nao seja destinatario usar, revelar, distribuir ou copiar qualquer parte desta mensagem.
>
> DISCLAIMER
> This message is destined exclusively to the intendend receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is receiveid by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not intendend receiver to use, reveal, distribute, or copy any part if this message.
>
> www.topdata.com.br
>