Thursday, March 10, 2011

stm32vld

Updated project at

https://github.com/dwelch67/stm32vld/wiki/stm32vld

Learned a few things that are not necessarily in the code. When erasing a page the FLASH_AR register is the address of the page not the page number. For example to erase page four put 0x1000 in this register. Second the flash programming doc mentions writing a single halfword to flash then waiting for the busy bit. So far I have been able to write a whole flash page before waiting on the busy bit. Well not a whole page as the sample program is not that big but the whole program.

If you mess up the flash, for example doing something like an ARM based address (lsbit of zero) for the reset vector. The usb/stlink interface will let you get at the registers in the chip, you can blink the leds for example, but I was not able to load programs and run them. Basically was not able to change the program counter (r15) to a thumb based address, allowing it to return execution to sram, the bad boot from flash put it in a bad state. By removing the BOOT0 jumper/strap on the back of the board, the processor will boot using the factory bootloader. Then either using the stlink interface or using a uart based programmer to talk to the bootloader you can then repair the flash with something usable. The board is not bricked. Then if you desire add a solder blob back on there to boot from flash again. It would have been nice if they had a two pin jumper instead of a no-ohm resistor (or solder bridge).

Once I find out how to perform 16 bit writes using the stlink interface then programming the flash can happen directly and not require this two step of loading a program and having the program write the flash.

Wednesday, March 9, 2011

STM32 Value line discovery


ST now has an eval board everyone can afford. No doubt like the msp430 launchpad ST must be delivering these at a loss. Personally I would rather have a bare bones eval board than a rubber ducky or mousepad with a logo, when it comes to the marketing folks giving away handouts. Perhaps that is whose budget is paying for this.

Anyway, thanks to http://capitanio.org/mlink/index.html there is some work underway to support the usb interface into the stlink side allowing access from linux to the evaulation chip. As with mcapitanio I have a lot more work to do on this (programming the flash or experimenting with other boot modes or loading methods) but for now I went with a trivial solution. Load ram (address 0x20000000) with a simple blink the leds program, while the stm32 was halted changed register 15 to point at the program in ram, then allowed the stm32 to run again and sure enough it blinks the leds. change the program to blink faster or slower, re-run the program and you can see the new program is loaded and running.