cancel
Showing results for 
Search instead for 
Did you mean: 

How to write boot loader

neeraj_dil2dil
Associate
Posted on September 05, 2007 at 17:17

How to write boot loader

7 REPLIES 7
neeraj_dil2dil
Associate
Posted on October 04, 2006 at 09:52

Hi Friends,

I have to write a boot loader for ST10F276, Its my first time to write a boot loader.

Could anybody help me to give some guideline to start n what is necessary task that the boot loader must do.

Thanks n Regards,

Neeraj

najoua
Associate II
Posted on October 05, 2006 at 06:24

Hello,

The first 32 bytes that Neila had talked about are almost always a loop to download more instruction bytes.

Please find below an example of the first 32 bytes received from the ASC0 downloading more code to program the user application:

mov R0, #0FA60h ; R0 is the address to the next byte

W0:

jnb S0RIR, W0 ; wait until a byte is received

movb [R0], S0RBUF ; place the received byte in memory

bclr S0RIR ; clear serial receive flag

movb S0TBUF, [R0] ; transmit (echo) the byte

cmpi1 R0, #(0FA60h+NUMBYTES-1) ; see if all bytes are received

jmpr cc_NE, W0 ; if not repeat

nop

nop

nop

nop

This loop takes exactly 32 bytes to implement. Note that NOP instructions are used to pad the loop to make it exactly 32 bytes. Once the 32-byte loop is received, the microcontroller branches to 0FA40h and starts executing this 32-byte loop. This loop expects more characters to be received and places the received characters in internal memory. After sending the 32-byte loop, more bytes are sent, now to be placed in memory by the loop rather than by the microcontroller’s bootstrap.

This way, when the loop finishes downloading the bytes, execution simply continues, and after the four NOP instructions, the instruction bytes downloaded by the loop are executed.

Regards,

Najoua.

dhiller
Associate II
Posted on October 27, 2006 at 15:03

Najula,

I understand how your boot loader works but I have additional questions.

1)What is the address and bit position of SORIR? The datasheets don't tell me. I do know where SORBUF and SOTBUF are.

2)If I start loading another program at FA60h when do I run out of IRAM?

The datasheets don't tell me where IRAM start and ends. I know I have 2K bytes, but I don't know where it's mapped.

Dudley

:-?

najoua
Associate II
Posted on October 30, 2006 at 03:44

Hello,

Below are answers to your questions:

- SORIR is bit field 7 in register S0RIC (FF6Eh).

S0TBUF address is FEB0h and S0RBUF address is FEB2h.

You can find all registers' description in the ST10F276 user's manual.

- The IRAM address range is: 0xF600 - 0xFDFF. This is indicated in the ST10F276 datasheet, in section 4 MEMORY ORGANIZATION, Figure 4 : ST10F276 On-chip Memory Mapping, page 22.

Regards,

Najoua.

dhiller
Associate II
Posted on November 07, 2006 at 22:06

Najoua,

This bootloader program works, but only if I add a leading NOP.

The resultis I get is the first instruction at FA40h always mis-executes.

i.e. the MOV R0, #0FA60h doesn't happen unless i do

NOP

MOV R0, #0FA60h

...

Is there an erata sheet that confirms this?

Dudley

dhiller
Associate II
Posted on November 08, 2006 at 11:30

Adding to the last message.

I think I have a theory as to why this might happen to me. See last message.

I send a 00 to the ST10 through the UART to start the BSL and set the baud rate.

The ST10 replies with a D5 acknowledge byte.

I start sending the first byte (of the 32 byte BSL program) to the ST10s UART as soon as the last rising edge of TXD0. So the acknowledge byte really had not completed. Is it possible that this first byte gets corrupted if I'm sending it too soon?

Tomorrow, I will try adding a delay here, and see if my first instruction starts working.

Dudley

fsikkema
Associate II
Posted on September 05, 2007 at 17:17

Hi Dudley,

Although it is almost a year ago... But do you have found a solution?

Regards, Folkert