STM32 VisualGDB beginning issues. - Page 1
Forum section: electronics / general

author: CM800
author_rank: Frequent Contributor
timestamp: November 02, 2016, 07:30:29 pm
content: Right,I'm trying to give VisualGDB a go, it looks quite a nice piece of software and I already do a lot in Visual Studio anyway with C#.Right now, I'm trying to use it to do a simple blink-LED with an STM32F411E-Discovery board.I've followed these instructions:http://visualgdb.com/tutorials/arm/st-link/ST-Link V2 tests fine.When I go to build / debug I get this:The GDB Session hold this:Code:-gdb-version=thread-group-added,id="i1"GNU gdb (GDB) 7.12Copyright (C) 2016 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law. Type "show copying"and "show warranty" for details.This GDB was configured as "--host=i686-pc-mingw32 --target=arm-eabi".Type "show configuration" for configuration details.For bug reporting instructions, please see:<http://www.gnu.org/software/gdb/bugs/>.Find the GDB manual and other documentation resources online at:<http://www.gnu.org/software/gdb/documentation/>.For help, type "help".Type "apropos word" to search for commands related to "word"...Reading symbols from D:\Projects\VisualGDBTest\EmbeddedProject1\VisualGDB\Debug\EmbeddedProject1...done.GNU gdb (GDB) 7.12Copyright (C) 2016 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law. Type "show copying"and "show warranty" for details.This GDB was configured as "--host=i686-pc-mingw32 --target=arm-eabi".Type "show configuration" for configuration details.For bug reporting instructions, please see:<http://www.gnu.org/software/gdb/bugs/>.Find the GDB manual and other documentation resources online at:<http://www.gnu.org/software/gdb/documentation/>.For help, type "help".Type "apropos word" to search for commands related to "word".OK-list-features^done,features=["frozen-varobjs","pending-breakpoints","thread-info","data-read-memory-bytes","breakpoint-notifications","ada-task-info","language-option","info-gdb-mi-command","undefined-command-error-code","exec-run-start-option"]-gdb-set disassembly-flavor intelNo symbol "disassembly" in current context.-gdb-set print demangle offOK-break-insert -f main^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x080008e2",func="main()",file="LEDBlink.cpp",fullname="D:\\Projects\\VisualGDBTest\\EmbeddedProject1\\EmbeddedProject1\\LEDBlink.cpp",line="14",thread-groups=["i1"],times="0",original-location="main"}set remotetimeout 60&"set remotetimeout 60\n"=cmd-param-changed,param="remotetimeout",value="60"OKtarget remote :63291&"target remote :63291\n"Remote debugging using :63291=thread-group-started,id="i1",pid="42000"=thread-created,id="1",group-id="i1"0x0f00f1b8 in ?? ()*stopped,frame={addr="0x0f00f1b8",func="??",args=[]},thread-id="1",stopped-threads="all"OKinfo shared&"info shared\n"No shared libraries loaded at this time.OKmon halt&"mon halt\n"OKmon reset init&"mon reset init\n"adapter speed: 2000 kHzstm32f4x.cpu: target state: haltedtarget halted due to debug-request, current mode: ThreadxPSR: 00000000 pc: 0x0f00f1b8 msp: 0x8000f8d0adapter speed: 8000 kHzOKload&"load\n"Loading section .isr_vector, size 0x198 lma 0x8000000+download,{section=".isr_vector",section-size="408",total-size="42559"}+download,{section=".isr_vector",section-sent="408",section-size="408",total-sent="408",total-size="42559"}Loading section .text, size 0x82c lma 0x8000198+download,{section=".text",section-size="2092",total-size="42559"}Loading section .init_array, size 0x4 lma 0x80009c4+download,{section=".init_array",section-size="4",total-size="42559"}Loading section .fini_array, size 0x4 lma 0x80009c8+download,{section=".fini_array",section-size="4",total-size="42559"}Loading section .data, size 0x4 lma 0x80009cc+download,{section=".data",section-size="4",total-size="42559"}&"Error finishing flash operation\n"Error finishing flash operation-data-evaluate-expression "sizeof(void *)"^done,value="4"-data-evaluate-expression "sizeof(int)"^done,value="4"-data-evaluate-expression "sizeof(short)"^done,value="2"-data-evaluate-expression "sizeof(long)"^done,value="4"-data-evaluate-expression "sizeof(long long)"^done,value="8"-data-evaluate-expression "sizeof(char)"^done,value="1"-data-evaluate-expression "sizeof(wchar_t)"No symbol "wchar_t" in current context.-data-evaluate-expression "sizeof(float)"^done,value="4"-data-evaluate-expression "sizeof(double)"^done,value="8"-data-evaluate-expression "sizeof(long double)"^done,value="8"info target&"info target\n"Symbols from "D:\Projects\VisualGDBTest\EmbeddedProject1\VisualGDB\Debug\EmbeddedProject1".Remote serial target in gdb-specific protocol:Debugging a target over a serial line.While running this, GDB does not access memory from...Local exec file:`D:\Projects\VisualGDBTest\EmbeddedProject1\VisualGDB\Debug\EmbeddedProject1', file type elf32-littlearm.Entry point: 0x800028c0x08000000 - 0x08000198 is .isr_vector0x08000198 - 0x080009c4 is .text0x080009c4 - 0x080009c8 is .init_array0x080009c8 - 0x080009cc is .fini_array0x20000000 - 0x20000004 is .data0x20000004 - 0x20000024 is .bssOK-data-evaluate-expression "&_estack"^done,value="0x20020000 \"\""-var-create - * "*((void **)0x2001fffc)"^done,name="var1",numchild="0",value="0xc6bff67",type="void *",has_more="0"-var-assign "var1" 0x6600f7fe^done,value="0x6600f7fe"-data-evaluate-expression "\*\(\(void\ \*\*\)0x2001fffc\)"^done,value="0x6600f7fe"-exec-continue^running*running,thread-id="all"Note: automatically using hardware breakpoints for read-only addresses.Looking through it, around half-way down, this seems to stick out:Code:&"Error finishing flash operation\n"Error finishing flash operationDoes anyone have any suggestions?Also, anyone got thoughts on Visual GDB? (anyone used it and had a really terrible time?, before I go buy it myself)

author: Sal Ammoniac
author_rank: Super Contributor
timestamp: November 02, 2016, 08:52:09 pm
content: To answer your second question, I've used VisualGDB. Here are my thoughts... I was very excited when I heard about VisualGDB because, like you, I use VS for C# programming. I paid for a license and gave it a go. Unfortunately, I was very disappointed in the results. The support for Segger J-Link and the ST-Link probes seems half-baked. I had lots of trouble getting everything to work, and even then it was intermittent. I had the same timeout errors that you're seeing. The biggest gotcha I found is how slow downloading code to a board and single-stepping code in the debugger is.After a week of trying, I just gave up. I wish I'd tried the trial version first before forking over $89 for the Embedded Edition. I went back to my old standards: Eclipse and Segger Embedded Studio (AKA Rowley CrossWorks).

author: thm_w
author_rank: Super Contributor
timestamp: November 02, 2016, 09:18:44 pm
content: I'm using it and like it a lot.I have none of the issues mentioned above. J-link and STlink both work fine, takes 2-3s or so to upload code to the micro. Single stepping is fine.I tried playing with loading code to SRAM or Flash, but didn't see a clear difference in speed (STM32L476 ~80kB?).Although the integration with HAL isn't great (if you need the latest version you will have to link it yourself), its still good.Also with STlink if you have too many hardware breakpoints it will give a similar GDB error, but you have to dig in to find out why.QuoteWhen you say this, you mean the stlink utility is working OK to communicate with your board, it will detect the micro and erase?and stlink detects OK in visualgdb project properties?If you don't find the solution here post in their forums, they check it regularly.

author: CM800
author_rank: Frequent Contributor
timestamp: November 02, 2016, 10:30:20 pm
content: Quote from: thm_w on November 02, 2016, 09:18:44 pmBy 'tests fine' I meant testing it on the config where you select the debugger, I pressed the 'test' button and it seemed all happy.The code is the default 'blink led' code, no breakpoints added.

author: thm_w
author_rank: Super Contributor
timestamp: November 02, 2016, 10:58:01 pm
content: Ensure hardware is working if you haven't already, using stlink utility:http://www.st.com/en/embedded-software/stsw-link004.html

author: CM800
author_rank: Frequent Contributor
timestamp: November 03, 2016, 08:04:30 am
content: I was able to erase it successfully using the utility suggested.When I tried to build without debugging, it successfully compiled, however I then got this:Good news! I changed over to an F0 dev board... and it worked perfectly off the bat.Seems I've killed 2 F4 boards without even using them.... Have I?Could it be something else? I've still been able to connect to them with the ST-Link tool, erase, write and verify, but only thing is I don't get any outs from any ports.I do worry how many of my DevKits I've killed from ESD now... Carpet & Dressing gown don't make a good lab environment.

author: newbrain
author_rank: Super Contributor
timestamp: November 03, 2016, 08:31:18 am
content: Quote from: CM800 on November 03, 2016, 08:04:30 amGood, this means two things:The target HW is workingThe toolchain is installed correctlyAn additional test can be to flash the generated hex or bin file with the ST-Link utility.From the first log you posted, it would appear that also the communication between gdb and OpenOCD (the bit of SWtaking care of communicating with the target HW) is correctly working, and that OpenOCD manages to contact the board.There's one strange thing, though:Code:stm32f4x.cpu: target state: haltedtarget halted due to debug-request, current mode: ThreadxPSR: 00000000 pc: 0x0f00f1b8 msp: 0x8000f8d0adapter speed: 8000 kHzOK8000kHz is very high.None of my boards uses that speed, did you perchance change it manually in the VGDB debugging setup?You could try to lower it to 1800kHz, or to the speed the ST-Link utility uses when connecting to the target.Quote from: Sal Ammoniac on November 02, 2016, 08:52:09 pmThis is the exact opposite of my experience: VS + VGDB was more or less the only IDE/toolchain I had immediately working "out of the box".Even ST's own Software Workbench took some fiddling before being fully operational (debug TCP port conflicts).Let's forget about TI's abomination.I used the trial for a couple of weeks and then paid for the Embedded+Linux version, and don't regret at all the money I spent.I use VisualGDB almost every day, mostly with STM32(F/L)nnn and a bit with EP8266, and I find no problems whatsoever.Single stepping is fast and reliable, as is flashing.The only issue (documented) I had is deadly slow debugging/flash on MSP432 with CMSIS-DAP, but that's TI making, not VisualGDB or OpenOCD.If I use a "J-linkified" ST-Link with it, it goes without a hitch (but that's not allowed by the J-Link license).

author: CM800
author_rank: Frequent Contributor
timestamp: November 03, 2016, 12:27:34 pm
content: QuoteThat was default, I had no reason.. or option to change it.Now I've had it working, I'm gonna try some other Chips tonight and see how it goes, if all is well I think I'll buy, expecially considering the student discountAlso curious about this:QuoteSave me buying a J-Link?

author: newbrain
author_rank: Super Contributor
timestamp: November 03, 2016, 02:10:20 pm
content: Quote from: CM800 on November 03, 2016, 12:27:34 pmGood!The speed can be changed where you set the OpenOCD options (I never used Texane), IIRC it's grayed out by default, but it's possible to enable (or go in the advanced setting page and change just that).If it uses 8MHz, it might not work every time, I'd think.One month is quite a long time, don't hurry, evaluate your other (also free) alternatives.It works very well for me, but Sal Ammoniac had a different experience.Quote from: CM800 on November 03, 2016, 12:27:34 pmSeehere: there are some license restrictions and, of course, it's not the full, real thing, but it's another blade in your Swiss Army knife...

author: CM800
author_rank: Frequent Contributor
timestamp: November 03, 2016, 03:11:37 pm
content: Quote from: newbrain on November 03, 2016, 02:10:20 pmWhat tools are recommended (programmers etc.) for microcontroller development.I have devkits galore, but for actual future development, I'm still very stuck on choosing a microcontroller and programming suite.What tools have the best chance of covering as much of the microcontroller ranges as possible.Main parts I'm interested in are:- STM32- Infineon XMC- Atmel ARM (though I already have their tool)- NXP KinetisPossibly:- NXP- Texas Instruments MCUsTo be honest I haven't played around with microcontrollers nearly as much as I'd like. I've spent more time with CPLDs then ARM, as a bezzar twist from many.

author: Sal Ammoniac
author_rank: Super Contributor
timestamp: November 03, 2016, 04:52:52 pm
content: Quote from: CM800 on November 03, 2016, 03:11:37 pmThe Segger J-Link works with all of these and is very robust and reliable. Cheap too. Only USD$60 for the "EDU" version for students and hobbyists, and around USD$380 for the commercial version.

author: CM800
author_rank: Frequent Contributor
timestamp: November 03, 2016, 06:10:54 pm
content: Quote from: Sal Ammoniac on November 03, 2016, 04:52:52 pmBeyond licenses, any reason I'd want commercial over EDU?

author: Sal Ammoniac
author_rank: Super Contributor
timestamp: November 03, 2016, 08:13:10 pm
content: Quote from: CM800 on November 03, 2016, 06:10:54 pmOnly if you want one with more capabilities, such as the Ultra+, which is faster than the lesser models, or the Pro, which has Ethernet in addition to USB.The EDU is equivalent to the Base model, except that the EDU has the unlimited breakpoints in flash license that the Base doesn't.

author: julianhigginson
author_rank: Frequent Contributor
timestamp: November 04, 2016, 01:23:03 am
content: I had to use visualGDB for a few months earlier this year, for a project that was already using it.I liked that it allowed having embedded arm and linux cross compiler projects in the same UI which made working on the overall system a bit more seamless, but to be honest, for just doing stm32 dev in windows you'd be better off with atollic truestudio or ST's free system workbench.I found VisualGDB's embedded capability integration with normal VS a bit weird as Visual Studio is not designed for embedded development, so the build/debug options were weird (our stm32 project still had "win32" as the default build selection!) And the smart highlighting for C it used in the editor (clang intellisense) was really quite broken. It wouldn't find some references, it would hang the whole IDE in some circumstances, and sometimes even crash visual studio completely.I also found getting the toolchain setup for a new PC with fresh VS and VisualGDB to work on an existing project was a bit ass about - the only way to install a visualGDB toolchain is to make a dummy empty project for the specific target. Then it identifies you need a toolchain and goes and gets it for you... Compare to how Visual Studio works with normal VS projects these days - it can identify and automatically pull down dependencies when you go to compile a project that has dependencies that aren't already installed.in short - it is mostly there, minus some bugs that need addressing... but even if the bugs fixed it really feels like a square peg in a round hole, and the developers really haven't given much thought to user experience. I was often scratching my head and wondering if it was working right (when it was) and clicking around madly trying to find the right place to change a setting when it wasn't.

author: newbrain
author_rank: Super Contributor
timestamp: November 05, 2016, 10:27:20 am
content: Disclaimer: I have no ties with Sysprogs, apart from being a customer, and all of the following is said IMHO and from the perspective of an hobbyist.Quote from: julianhigginson on November 04, 2016, 01:23:03 amTo each their poison...IDE choices are as personal as can be.I find Eclipse annoying as hell, from the handling of windows, through the workspace concept, to perspectives and the maze of tiny twisted menus.Quote from: julianhigginson on November 04, 2016, 01:23:03 amYes, this definitely a weirdness, but a cosmetic one I'd say. More annoying is that they don't provide an empty project template, but only some blinky...Quote from: julianhigginson on November 04, 2016, 01:23:03 amThis has never occurred to me, I had some crashes but only with trying beta/preview versions of either VisualGDB or Visual Studio: one time the project/solution/VGD settings was so mangled I had to start over (source was there, though) as it would crash any version while opening.But, OTOH, autocompletion/references get messed up often in my ST System Workbench...There's also the option of using the native VS engine instead of clang.Quote from: julianhigginson on November 04, 2016, 01:23:03 amI started using VGDB about one year ago, there's always been an "embedded package manger" windows in the tools menu -see screen capture, it's been recently "refurbished"- where one can pick and choose the toolchains and BSPs to install. It's also possible to point it to the gcc of your choice, and there tools to make your own BSP on Sysprogs' GitHub repository.It's not fully automatic, though.TLDR: YMMV.

author: julianhigginson
author_rank: Frequent Contributor
timestamp: November 06, 2016, 11:28:40 am
content: Quote from: newbrain on November 05, 2016, 10:27:20 amwell, if you're really used to VS then I guess it'd be nice to be able to use it for embedded. personally, due to the sheer number of eclipse based things I've had to use over the years, I'm just kind of used to eclipse. I don't love it, I just know how to make it work, and that's what I need.Quoteis there an option?? I wasn't sure VS had any plain C syntax highlighting?As for the buggyness with clang intellisense, this was a pretty much fresh install of win10 pro 64 bit on a lenovo W540visual studio community and I was using visualGDB in demo mode for 1 month, then paid mode for a few more.It's the buggiest IDE experience I've had in quite a while....The other guy I was working with (he was doing more of the linux target stuff) also reported really long UI freezes when typing in things.. (macbook pro, windows 10 pro in VM especially for using VS with VisualGDB!, etc etc)maybe it was because the original projects were just plain gcc makefile projects to start, and another contractor had started using VS/VGDB by migrating the projects into that?Quoteyeah I did find that once when I was trying to cross-compile some embedded linux software for a different linux system than originally setup.. there seemed to be a way to chuck in a bunch of different target boards/packages.Except, I just went looking for it again, and totally can't find it...QuoteAbsolutely..

author: CM800
author_rank: Frequent Contributor
timestamp: November 07, 2016, 09:36:35 pm
content: Things are going quite well now, except for one thing:My username on the computer has a space in it, something not supported by Visual GDB... what's the best way to get around this, all the appdata files are in thereI'd love to re-install my computer, but it would be a solid 2 days work to clear everything out and ensure I have everything. (Changing your username doesn't change the folder name, it just makes a new one)

author: thm_w
author_rank: Super Contributor
timestamp: November 08, 2016, 12:41:45 am
content: Its not visualgdb but GDB itself.The warning is "GDB does not support paths with spaces correctly. Some of your breakpoints will not work"I found this, but it says they have fixed it already:http://stackoverflow.com/questions/9500790/gdb-how-to-set-a-breakpoint-in-a-file-with-spacesAnyway, what isn't working, is it the same programming error still? You think that it was caused by the space maybe?Its possible to move those HAL references elsewhere but it takes some effort. I would move the project folder, and see if thats enough.edit: if anyone has issues with slow single stepping there are solutions in visualgdb forums (https://sysprogs.com/w/forums/topic/slow-single-stepping-with-st-link/https://sysprogs.com/w/forums/topic/slow-stepping-here-is-why-i-think/)

author: CM800
author_rank: Frequent Contributor
timestamp: November 08, 2016, 07:10:19 am
content: Quote from: thm_w on November 08, 2016, 12:41:45 amAh right, the actual issue I'm having here is with intellisense.Maybe I'm wrong here but that's one of the functions I need to implement SPI. I've taken it directly from the HAL file for SPI but it won't recognize it?This is popping up at the top:and won't clear no matter how many times I click 'Add Now'

author: thm_w
author_rank: Super Contributor
timestamp: November 08, 2016, 08:15:17 pm
content: Yes thats right its needed for SPI.Can you go to Project properties -> Intellisense settings -> Automatic discovery: enabled in silent mode (no notifications)Try building and see if it actually generates a build error. Sometimes I would get clang errors but it would build OK.It it still doesn't compile: Do you have stm32xx_hal_conf.h in project with SPI lined defined (#define HAL_SPI_MODULE_ENABLED)? In Project properties -> Embedded frameworks you have STM32xx HAL checked right?You will need to edit the code to:SPI_HandleTypeDef hspi;...settings here...HAL_SPI_Init(&hspi)If you have clang options set to code completion popup, when you start typing HAL_ it will show all the options right? If not try out, it helps a lot.btw here is example of cubemx startup code. Its up to you, but I use error handler + USE_FULL_ASSERT defined to catch simple mistakes (if you write the wrong setting to a register).Code:hspi2.Instance =SPI2;hspi2.Init.Mode =SPI_MODE_MASTER;hspi2.Init.Direction =SPI_DIRECTION_2LINES;hspi2.Init.DataSize =SPI_DATASIZE_8BIT;hspi2.Init.CLKPolarity = SPI_POLARITY_HIGH;hspi2.Init.CLKPhase =SPI_PHASE_2EDGE;hspi2.Init.NSS =SPI_NSS_SOFT;hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;//Spec for SSD1306 is 10MHz, 40/8 = 5MHzhspi2.Init.FirstBit =SPI_FIRSTBIT_MSB;hspi2.Init.TIMode =SPI_TIMODE_DISABLE;hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;hspi2.Init.NSSPMode = SPI_NSS_PULSE_DISABLED;if (HAL_SPI_Init(&hspi2) != HAL_OK)Error_Handler();

author: CM800
author_rank: Frequent Contributor
timestamp: November 08, 2016, 08:51:33 pm
content: Quote from: thm_w on November 08, 2016, 08:15:17 pmGreat, I managed to make that change (Can you go to Project properties -> Intellisense settings -> Automatic discovery: enabled in silent mode (no notifications))and that's made things a good bit better.The change in the code '&hspi' has fixed the error and allows me to compile now which is awesome. I just need to fix clang to do code-completion like the picture showed (I can't find that setting however)I look forward to that, it's one of my favorite features of MSVS, I use it religiously in C#

author: thm_w
author_rank: Super Contributor
timestamp: November 08, 2016, 08:59:53 pm
content: When you start up visual studio it should show these clang options.If not go to Tools -> options -> text editor -> c/c++ (visualgdb) -> Advanced -> Code completion -> Suggest names while typing: True

author: CM800
author_rank: Frequent Contributor
timestamp: November 08, 2016, 09:02:49 pm
content: Quote from: thm_w on November 08, 2016, 08:59:53 pmNice.Have you got any recommended reading materials / info to get me started.As much as I like to think I'm 'getting pretty good at this' I am ashamed to admit for all the theory I know I haven't done much past Arduino / registers and dabbling with CPLDs

author: thm_w
author_rank: Super Contributor
timestamp: November 08, 2016, 10:19:22 pm
content: Quote from: CM800 on November 08, 2016, 09:02:49 pmI haven't purchased this book, and a lot of it is not relevant (setting up compilers) but it looks good:https://leanpub.com/mastering-stm32You can learn a lot by playing with CubeMX, looking at what settings there are for peripherals/clocks/interrupts.Read example projects if there are relevant ones: C:\Users\xxxxx\AppData\Local\VisualGDB\EmbeddedBSPs\arm-eabi\com.sysprogs.arm.stm32\VendorSamples\STM32Cube_FW_F0_V1.6.0\Projects