$begingroup$
I am looking for a cheap and minimalist dev board, and found the above one (Cortex M3 for Arduino). I am used to stm32 but normally their dev boards are a bit expensive if I am going to use them in a bunch of units, so this seemed like a good choise at 3$.
However, I would like to program it in C and be able to debug it. It has a SWD interface, but I am finding very little info on how to set up programming and debugging (almost all links seems to be for AVR based Arduino, not stm32). Will absolutely not use the Arduino IDE.
Sep 20, 2017 - Error: stm32x device protected. I solved this. I try to use the Bluepill as an I2C slave device, like an I2C extension to an RPi (or any other xPi). SOLVED 'Active read protected STM32 device' message after upgrading J-Trace to V5.10g Jan 21st 2016, 10:42am The J-Trace CM (3.2 14-34) was working well with my STM32F746IGK6 application before updating to the newest firmware V5.10g.
Anyone knows where to find this info, or any similar really cheap 32-bit dev boards?
RolleRolle
$endgroup$closed as off-topic by old_timer, Bence Kaulics, laptop2d, Wesley Lee, pipeApr 19 '17 at 23:53
This question appears to be off-topic. The users who voted to close gave this specific reason:
- 'Questions seeking recommendations for specific products or places to purchase them are off-topic as they are rarely useful to others and quickly obsolete. Instead, describe your situation and the specific problem you're trying to solve.' – Bence Kaulics, Wesley Lee, pipe
3 Answers
$begingroup$These Are everywhere on ebay/amazon and the like. The SWD interface is clearly labeled if you are questioning the PCB you posted. But for 3 dollars you might as well buy one, buzz it out then see if it fits your needs. Getting these running with the ST-Link Utility over the command-line and GCC is pretty simple. GDB is a different story, but there are plenty of canned IDE's you can use thet will work out of the box. Embitz is nice, as is the MCUonEclipse plugin. Hope this helps
Luke GaryLuke Gary
$endgroup$$begingroup$I think I got mine for closer to $2.50 and at times you can get them less than $2. Careful though I got taken for $20 buy an ebay vendor, I didnt read the reviews carefully enough to know they send a package with a few inches of wire or something of little value to satisfy ebays package tracking. It is on you to deal with the loss, not ebay nor paypal.
It is hard to compete with those prices so long as you dont get taken too often. but for a few bucks you could buy parts and boards from places that are not going to leave you empty handed.
either way with many/most of the cortex-ms you can use an ftdi based board that supports mpsse, you can get j-link (I assume clones) for ten bucks on ebay from asia, they work just fine with this board/chip (note there is a cortex-m0 based board on ebay for around the same price has both the swd and serial broken out on the bottom). For about ten bucks you can get a nucleo board from ST, those or the discovery boards you can remove the jumpers to get at the swd pins and then use that header for other chips/boards/vendors. If you get the right nucleo board as not all of them support this you can also use the stlink debugger for uart access. have to check the docs, the boards often have RX/TX pins but not all are usable.
You can go the tiva-c route as well and some of those boards you can get at the header although some are wee tiny and painful. i find stlink or j-link much easier.
use openocd, can telnet into the openocd server and erase and load flash or run programs from ram. all free.
These parts have a bootloader in them as well so with a usb to uart you can move the jumper over and boot that way and download your program that way, simple protocol, can bang out your own tool in tens of minutes, or an afternoon depending.
Can apt-get tools or easily come by pre-build gnu based tools.
ST has various libraries if you dont want to get your hands dirty, should have support for free tools, and might provide an ide which supports the stlink.
Should be very easy to find more than enough examples out there, only took a few seconds for me...
As with any mcu start at the vendors web page, for arm details you go to arms website although ST does have a document similar to the architectural reference manual, even though you are not normally allowed to re-distribute that info. It is in the vendors best interest to provide for free/cheap a set of libraries that hide the details of the chip, and an ide and other tools for programming the parts. And they do that, there is churn on these items so as soon as you get used to one another one comes out that is completely different, but at least there is something. or you can just program them using the docs, these parts are fairly simple to program.
Note I found these parts on these asia/ebay boards locked.
can use the write unprotect bootloader command which doesnt respond, but on the next power cycle it is now unlocked.
I also figured out how to do it with openocd, but dont remember where I wrote that down. I think my bigger batch of boards I just ran them through the uart interface like an assembly line to unlock them all then used a jlink with a hand made adapter that plugs into the end for development. have not finished my usb based bootloader...
old_timerold_timer
$endgroup$$begingroup$They have just soldered the MCU to the board for you. It is very well documented, nothing mysterious.
Baremetal recipe:
- Read a book about those processors. For example, The Definitive Guide To the ARM Cortex M3 by Joseph Yiu.
- stm32-discovery board, configure it to use its SWD interface on remote devices.
- Programming (processor core specific) and reference (manufacturer's implemention specific) manuals of that specific MCU.
- Openocd for programming interface (with telnet) and debugging backend
- GCC for compiling
- GDB for debugging (with --tui mode it is good enough to be standalone)
This page is a good starter especially for linux:
AyhanAyhan
$endgroup$
Not the answer you're looking for? Browse other questions tagged arduinostm32 or ask your own question.
I have two boards with a STM32F437 (IGH6 7BA4S VQ PHL 7B 542) processor. We program these with openocd and a jtag, however lately one card stopped working. It is no longer possible to program the card and one of the differences we have found is that the user option bytes differ between the cards.
- 0x0EC On the working card
- 0xCFC On the broken
What I tried to do is using the options_write command. Note that the STM32F4 apparently goes under the 'stm32f2x' command.
openocd -f openocd.cfg -c 'reset halt; stm32f2x unlock 0; reset halt; stm32f2x options_write 0 0x0EC'
This resulted in the error message: 'Error: stm32x device protected'
In the STM32F437 Reference manual RM0090 under '3.7.2 Programming user option bytes' it says:
To run any operation on this sector, the option lock bit (OPTLOCK) in the Flash option control register (FLASH_OPTCR) must be cleared. To be allowed to clear this bit, you have to perform the following sequence: n
- Write OPTKEY1 = 0x0819 2A3B in the Flash option key register (FLASH_OPTKEYR)
- Write OPTKEY2 = 0x4C5D 6E7F in the Flash option key register (FLASH_OPTKEYR)
The user option bytes can be protected against unwanted erase/program operations by setting the OPTLOCK bit by software.
To do that I tried the following in a telnet session:
mww 0x08 0x08192A3B
mww 0x08 0x04C5D6E7F
mdw 0x0C
mww 0x18 0x0EC
mww 0x14 0x0EC
The 0x08 on line 1 is FLASH_OPTKEYR, 0x0C on line 3 is FLASH_SR to check if BSY bit is not set, 0x14 on line 4 is FLASH_OPTCR1, and 0x14 on line 5 is FLASH_OPTCR.
Then a reboot and trying to program the application
openocd -f openocd.cfg -c 'program HCF-220_07_010_PA2.hex reset exit'
This results in the error:
Error: stm32x device protected.
I also tried to do the following command to unlock before programming:
openocd -f openocd.cfg -c 'openocd -f openocd.cfg -c 'reset halt; stm32f2x unlock 0; program HCF-220_07_010_PA2.hex reset exit'
Same result:
Error: stm32x device protected.
Update
I tried the following in telnet without luck, the user option is still 0xCFC:
mww 0x40023C08 0x08192A3B
mww 0x40023C08 0x04C5D6E7F
mdw 0x40023c0c
mww 0x40023C18 0x0EC
mww 0x40023C14 0x0EC
mww 0x40023C08 0x02
Power Cycle
In RM0090 chapter 3.7.2 it also says:
4. Set the option start bit (OPTSTRT) in the FLASH_OPTCR register
Hence the nr 6. above.Heneer
HeneerHeneer
2 Answers
Flash register base address is 0x40023C00 (as per RM0090). 0x08 is offset from base, so you should write to 0x40023C08
stiebrsstiebrs
The working solution for me was as follows:
stm32f2x lock 0
Yes lock not unlock.- Do a power cycle
reset init
mww 0x40023C08 0x08192A3B
mww 0x40023C08 0x04C5D6E7F
mdw 0x40023c0c
Wait for flash write to finish, make sure we receive 00000000mww 0x40023C18 0x0FFF0000
mww 0x40023C14 0x0FFFAAEC
Write user_options to same as a workingmww 0x40023C14 0x0FFFAAEE
Set option start bit, step '4.' in rm0090.mdw 0x40023c0c
Wait for flash erase to finish, make sure we receive 00000. This takes about 10 seconds.- Do a power cycle
The reason why it did not work with OpenOCD command 'options_write', can be found in the manual for OpenOCD. The 'user_options' argument takes the bits 31-28 and 7-0 from FLASH_OPTCR.
HeneerHeneer