2017-06-26 01:17 AM
Hi,
I am new to putting together my own projects and have followed this
great write up, adapting the instructions for the Nucleo 144 the STM32F429ZIT6 to be specific. In CubeMX i enabled the ethenet, TIM1 and RTC. The project builds in eclipse but when I flash the hex from st-flash it doesn't seem to do anything. I haven't been able to find a good write up anywhere detailing putting together a project for a STM board from start to complete finish. Can anyone help me with this?Cheers,Alex#rtos2017-06-26 09:20 AM
Hi Alex
I've looked at the methode that is being used and I find it somewhat strange.Normally when using cubeMX you dont need to make a project in your IDE before going into the cubeMX software.It is the cube itself that creates it.If you want to use eclipse i suggest that you use systemwork bench for stm32s (also called SW4STM32) its basically a version of eclipse with a few addons.To create a project just do the steps in cubeMX.Make a new project go in ''Boards'' then select your board form the list.Once the project is openned enable all the peripherals you want.Then go into project->settings.Chose your IDE , name the project (if you are planning to use FreeRTOS Id suggest you make the stack and heap bigger) then hit project->generate code.Once the code is generated open your IDE.In eclipse go in File-> import.Then a window will open.Click on general->existing project (hit next) .Then make sure ''select root directory'' is selected and browse to the directory where your project is.Then hit finish and the project should be in the project explorer on the left side of the screen (if not it may be because your project explorer is closed there is a little symbol to the left aligned with the word ''file'' that you can click)The project shouldbuild and if ou have your board connected you can direcly enable the debugger which will send your code in your board and start the debuger.You have no project config to do in eclipse (normally) the project should be preconfigured by the cube.If you have any questions ,fire away !Good luck-Andy2017-06-27 12:48 PM
Hi Andy,
Thanks for this great reply! will give this a good next week and see how it goes.Cheers2017-08-01 11:07 AM
Hi again Andy,
Finally managed to get time to give this a go, seeing as it took all of 10 minutes to sort out I should of been able to do this earlier. Creating the project in Cube then importing to systemwork worked without errors, thanks again for the great reply in that regard, but I have am not sure if I am using the IDE correctly to flash the board. I added the following code to the default code.
static void MX_GPIO_Init(void)
{/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); GPIO_InitStructure.Pin = GPIO_PIN_7; GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStructure.Pull = GPIO_PULLUP; GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.Pin = GPIO_PIN_14; HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);}GPIO init runs before scheduler starts and then to the default task:
void StartDefaultTask(void const * argument)
{/* USER CODE BEGIN 5 */
/* Infinite loop */ for(;;) { HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7); HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_14); osDelay(1000); } /* USER CODE END 5 */ }Trying a simple blink example. I then use Run -> Run as -> Ac6 STM32 C/C++ Application. This gives me the following console output:
Open On-Chip Debugger 0.10.0-dev-00302-gc211ca5-dirty (2017-07-03-10:36)
Licensed under GNU GPL v2For bug reports, readhttps://community.st.com/external-link.jspa?url=http%3A%2F%2Fopenocd.org%2Fdoc%2Fdoxygen%2Fbugs.html
srst_only separate srst_nogate srst_open_drain connect_assert_srstInfo : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWDadapter speed: 1800 kHzadapter_nsrst_delay: 100Info : clock speed 1800 kHzInfo : STLINK v2 JTAG v28 API v2 M v17 VID 0x0483 PID 0x374BInfo : using stlink api v2Info : Target voltage: 3.257030Info : STM32F429ZITx.cpu: hardware has 6 breakpoints, 4 watchpointsadapter speed: 1800 kHzSTM32F429ZITx.cpu: target state: haltedtarget halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x080025f4 msp: 0x20030000configuring PLLadapter speed: 4000 kHz** Programming Started **auto erase enabledInfo : device id = 0x20016419Info : flash size = 2048kbytesSTM32F429ZITx.cpu: target state: haltedtarget halted due to breakpoint, current mode: Thread xPSR: 0x61000000 pc: 0x20000046 msp: 0x20030000wrote 16384 bytes from file Debug/STM32F429ZIxxFreeRTOS.elf in 0.579916s (27.590 KiB/s)** Programming Finished **** Verify Started **STM32F429ZITx.cpu: target state: haltedtarget halted due to breakpoint, current mode: Thread xPSR: 0x61000000 pc: 0x2000002e msp: 0x20030000verified 9996 bytes in 0.115263s (84.691 KiB/s)** Verified OK **** Resetting Target **adapter speed: 1800 kHzshutdown command invokedJust wondering if you are able to see where I have goofed up. Cheers,Alex2017-08-01 11:28 AM
Hi Alex
Have you tried shooting the code in your chip without the code you've added ?If your debugger works fine after testing without any added code that means that you have an error in your code.If that is the case just tell me I know a few things you can check.
If your debugger doesnt work with cube generated code only.
The console output seems fine exept the last commande.I would recommend that you use ST Utility to check and make sure your ST-Link is up to date :
http://www.st.com/en/embedded-software/stsw-link004.html
.If you are using a discovery / nucleo board.Simply remove the jumpers and plug your board by the usual usb port.Then fire up st utility and check for the version running in your st-link.If you are using an external st-link simply plug it in your pc and leave the mcu side unplugged.Then open st utility and check for firmware updates.When you know your st-link is up to date replug your board/put the jumpers back in their place then try to connect to your board using st utility.This will enable you to check for corrupted memory and this will confirme that you have no issues with your hardware.Hope this helps
-Andy2017-08-01 11:40 AM
Hi again
Before doing anything that I've mentionned (jumped the gun a bit re-read your question and realised a few things)here are simple tips on how to use this IDE.When you are ready to build your code.First of all right click your project in the project explorer and hit ''build'' then to shoot the code in your chip and to start the debuggerhit the arrow next to the most left green symbol on the tool bar which is located in the top left corner.This will open a small scroll down menu.Just select the (there will probably be only one) project you want to debug.Then hit the green symbol itself. The IDE should transfert you to the debugger (you can switch between the two using the small icons in the top right corner) Remember that to restart the debugger you have to make sure it is stopped .Press the green arrow to start (or restart after a pause) the debugger , the two vertical yellow lines to pause the debugger and the red square to completely stop the debugger.If you are searching for tutotirals on how to change the theme or if you have weird compiler issues or any other IDE questions always search using ''eclipse'' in your search bar (and not SW4STM32) since this is basically eclipse with a few different bibs and bobs you will get much better result by looking on eclipse forums.(This will take you a while to read but I tried making it as short as possible)-Andy2017-08-03 04:53 AM
Hi Andy,
thanks for the reply. I didn't realize that debugging config would be so easy in this IDE. I'm used to tediously setting up eclipse. Found my problem and it was that the auto generated ethernet init code was halting the micro. Removed that and everything works as expected! thanks for your help!
Cheers,Alex