W dniu 2012-01-24 16:01, Jonathan Dumaresq pisze:
> HI all,
>
> I try my best to get the asm file work with the M0. I have modified the
> stm32f2x.S becaus eit look simpler than the on from the stm32f1x.S
>
> Here how it's look.
>
> // Build : arm-eabi-gcc -c stm32f2xxx.S
>       .text
>       .syntax unified
>       .cpu cortex-m0
>       .thumb
>       .thumb_func
>       .global write
>
> /*
>       r0 - source address
>       r1 - target address
>       r2 - count (halfword-16bit)
>       r3 - result out
>       r4 - flash base
> */
>
> #define STM32_FLASH_CR_OFFSET 0x10                    /* offset of CR
> register in FLASH struct */
> #define STM32_FLASH_SR_OFFSET 0x0c                    /* offset of CR
> register in FLASH struct */
>
> write:
>
> write_half_word:
>       ldr             r3, STM32_PG
>       str             r3, [r4, #STM32_FLASH_CR_OFFSET]
>       ldrh    r3, [r0]
> /* read one half-word from src */
>       strh    r3, [r1]
> /* write one half-word from src*/
>       adds            r0, r0, #2
> /*  increment ptr */
>       adds            r1, r1, #2
> /*  increment ptr  */
> busy:
>       ldrb    r3, [r4, #STM32_FLASH_SR_OFFSET]
>       cmp             r3, #0x1
> /* BSY (bit0) == 1 =>  operation in progress */
>       beq     busy
> /* wait more... */
>       cmp             r3, #0x24
> /* PGPERR | WRPERR */
>       beq             exit
> /* fail... */
>       subs    r2, r2, #0x01                                           /*
> decrement counter */
>       bne             write_half_word
> /* write next half-word if anything left */
> exit:
>       bkpt    #0x00
>
>
                                                        /*
> PG */
>
> Is it possible to have a small review on this. I'm really poor in assembly
> language !

First of all - does it work?

 >      ldr             r3, STM32_PG
 > STM32_PG: .word 0x001

You can do that in an easier way:

movs r3, #0x001

 >      cmp             r3, #0x24
 > /* PGPERR | WRPERR */

So only having BOTH those errors will cause the code to exit? If BUSY is 
also lit up you'll get 0x25... You should probably mask that to obtain 
BUSY and the errors if you consider that possible to have only PGPERR or 
WRPERR only.

One final thing - I'd prefer to have comments either in-line or in the 
line before code - having them in next line doesn't seem a common 
practice...

4\/3!!

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to