EmbeddedRelated.com
Forums

Update internal flash through UART

Started by Ivan Z. February 18, 2009
Hi,

I'm working with TMS470R1A384. And I'd like to have ability to update my
Program  through UART.
In others words, I'd like to write FlashLoader.
But I have no idea how to write my program for it.

I configured *.xcl so as my Program was in Bank_1 and INTVEC too. 
and my FlashLoader - in Bank_0.
But my Programs interrupts use addresses at the beginning anyway.

How can I tell tms470 that vector tabale is in Bank_1?

Or Have you got any others suggestion?

Best regards,
Ivan Z.


On Wed, 18 Feb 2009 10:12:09 -0600, Ivan Z. wrote:

> Hi, > > I'm working with TMS470R1A384. And I'd like to have ability to update my > Program through UART. > In others words, I'd like to write FlashLoader. But I have no idea how > to write my program for it. > > I configured *.xcl so as my Program was in Bank_1 and INTVEC too. and my > FlashLoader - in Bank_0. > But my Programs interrupts use addresses at the beginning anyway. > > How can I tell tms470 that vector tabale is in Bank_1? > > Or Have you got any others suggestion? > > Best regards, > Ivan Z.
It would help to know why you are trying to move the interrupt vector table around -- is this bank 0 in flash? Some processors fix the interrupt vector locations in hardware, and you can never ever change them. Some processors let you move the interrupt vector table by writing a base address in software -- you'll have to look at yours to figure out which you have. If you need flash memory for interrupts, then I suggest you write a flash loader that polls the UART instead of depending on interrupts. Generally you want a serial protocol that recognizes the fact that the processor will go away during flash writes, or at least that it'll fill a buffer that will stay full for a while. So you need some sort of flow control, and you need a sending program that can handle this flow control gracefully. Given good flow control, you can organize your program so that it's not doing anything else when serial data is due to come in, so it'll be able to poll the UART in a tight loop, and probably be more responsive than an ISR would be. -- http://www.wescottdesign.com
>On Wed, 18 Feb 2009 10:12:09 -0600, Ivan Z. wrote: > >> Hi, >> >> I'm working with TMS470R1A384. And I'd like to have ability to update
my
>> Program through UART. >> In others words, I'd like to write FlashLoader. But I have no idea how >> to write my program for it. >> >> I configured *.xcl so as my Program was in Bank_1 and INTVEC too. and
my
>> FlashLoader - in Bank_0. >> But my Programs interrupts use addresses at the beginning anyway. >> >> How can I tell tms470 that vector tabale is in Bank_1? >> >> Or Have you got any others suggestion? >> >> Best regards, >> Ivan Z. > >It would help to know why you are trying to move the interrupt vector >table around -- is this bank 0 in flash? > >Some processors fix the interrupt vector locations in hardware, and you >can never ever change them. Some processors let you move the interrupt >vector table by writing a base address in software -- you'll have to look
>at yours to figure out which you have. > >If you need flash memory for interrupts, then I suggest you write a flash
>loader that polls the UART instead of depending on interrupts. Generally
>you want a serial protocol that recognizes the fact that the processor >will go away during flash writes, or at least that it'll fill a buffer >that will stay full for a while. So you need some sort of flow control,
>and you need a sending program that can handle this flow control >gracefully. > >Given good flow control, you can organize your program so that it's not >doing anything else when serial data is due to come in, so it'll be able
>to poll the UART in a tight loop, and probably be more responsive than an
>ISR would be. > >-- >http://www.wescottdesign.com >
My goal is to reprogram chip through UART (update FLASH by users). I decided to write my FlashLoader in bank_0, which runs my Program in bank_1. Also my FlashLoader have to reprogram bank_1. I thought, if I'd written my Program with interrupt in bank_1, it helped compiling and reprogramming (all would be in bank_1). I decided this trouble in the next way: 1. My program is compiled in the bank_1, interrupts routines in the bank_1 at certain address, vector table in the bank_0. myprog.xcl: [code] -Z(CODE)INTVEC=VECSTART:+0x40 -Z(CODE)ICODE,DIFUNCT=Bank1_START-Bank1_END -Z(CODE)SWITAB=0x00030000-0x00037fff [/code] 2. My flash loader don't use any interrupts, so I wrote that interrupts routines in the bank_1 cstartuo.s79: [code] B ?cstartup ; Relative branch allows remap, limited to 32 MByte ; Vectors can be enabled by removing the comments below or by ; using #pragma vector from C code. org 0x04 ; B undef_handler ; Branch to undef_handler org 0x08 ; B swi_handler ; Branch to swi_handler org 0x0c ; B prefetch_handler; Branch to prefetch_handler org 0x10 ; B data_handler ; Branch to data_handler org 0x18 ; B irq_handler ; Branch to irq_handler b 0x00030000 org 0x1c ; B fiq_handler ; Branch to fiq_handler ; Constant table entries (for ldr pc) will be placed at 0x20 ; Exception vectors can be specified in C code by #pragma vector or by filling ; in the vectors below. The vector address is the ARM vector number + 0x20. org 0x20 dc32 ?cstartup org 0x24 ; dc32 undef_handler org 0x28 ; dc32 swi_handler org 0x2c ; dc32 prefetch_handler org 0x30 ; dc32 data_handler org 0x38 ; dc32 irq_handler org 0x3c ; dc32 fiq_handler LTORG ; ENDMOD __program_start ENDMOD ;--------------------------------------------------------------- ; ?CSTARTUP ;--------------------------------------------------------------- MODULE ?CSTARTUP RSEG IRQ_STACK:DATA(2) RSEG SVC_STACK:DATA:NOROOT(2) RSEG CSTACK:DATA(2) RSEG ICODE:CODE:NOROOT(2) PUBLIC ?cstartup EXTERN ?main [/code]