• Welcome to Andy's Workshop Forums. Please login or sign up.
 
March 29, 2024, 01:25:27 am

News:

SMF - Just Installed!


Blink example on F103 custom board

Started by kyildirim, September 29, 2014, 02:57:05 pm

Previous topic - Next topic

kyildirim

September 29, 2014, 02:57:05 pm Last Edit: October 04, 2014, 07:11:14 am by Andy Brown
Hi there Andy,
Thank you for your effort to building this amazing library and sharing with us.
I was looking a way to prepare a development platform for STM32. And now I am here.
I am able to build the stm32plus library on scons(cygwin) and also on Eclipse (Kepler)
Examples builds on scons successfully, but I have problem to build the examples on Eclipse.
After build the library, I have copy the libstm32plus.a file to the toolchain directory "C:\Program Files (x86)\GNU Tools ARM Embedded\4.8 2014q2\arm-none-eabi\lib"

I did not do any action for header files.!?

I am getting different errors regarding the build which I am working:

23:53:36 **** Build of configuration Debug_f4_168 for project stm32plus-examples-adc_analog_watchdog ****
make all
'Building file: ../system/f4/Startup.asm'
'Invoking: Cross ARM GNU Assembler'
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -O0 -fmessage-length=0 -ffunction-sections -fdata-sections -Werror -Wall -Wextra  -g3 -x assembler-with-cpp -DSTM32PLUS_F4 -DHSE_VALUE=8000000 -I"D:\STM32\stm32plus-3.0\lib" -I"D:\STM32\stm32plus-3.0\lib\include" -I"D:\STM32\stm32plus-3.0\examples\adc_analog_watchdog" -MMD -MP -MF"system/f4/Startup.d" -MT"system/f4/Startup.o" -c -o "system/f4/Startup.o" "../system/f4/Startup.asm"
'Finished building: ../system/f4/Startup.asm'
' '
'Building file: ../system/f4/System.c'
'Invoking: Cross ARM C Compiler'
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -O0 -fmessage-length=0 -ffunction-sections -fdata-sections -Werror -Wall -Wextra  -g3 -DSTM32PLUS_F4 -DHSE_VALUE=8000000 -I"D:\STM32\stm32plus-3.0\lib" -I"D:\STM32\stm32plus-3.0\lib\include" -I"D:\STM32\stm32plus-3.0\examples\adc_analog_watchdog" -std=gnu11 -MMD -MP -MF"system/f4/System.d" -MT"system/f4/System.o" -c -o "system/f4/System.o" "../system/f4/System.c"
'Finished building: ../system/f4/System.c'
' '
'Building file: ../system/LibraryHacks.cpp'
'Invoking: Cross ARM C++ Compiler'
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -O0 -fmessage-length=0 -ffunction-sections -fdata-sections -Werror -Wall -Wextra  -g3 -DSTM32PLUS_F4 -DHSE_VALUE=8000000 -I"D:\STM32\stm32plus-3.0\lib" -I"D:\STM32\stm32plus-3.0\lib\include" -I"D:\STM32\stm32plus-3.0\lib\include\stl" -I"D:\STM32\stm32plus-3.0\examples\adc_analog_watchdog" -std=gnu++0x -fabi-version=0 -fno-exceptions -fno-rtti -pedantic-errors -fno-threadsafe-statics -MMD -MP -MF"system/LibraryHacks.d" -MT"system/LibraryHacks.o" -c -o "system/LibraryHacks.o" "../system/LibraryHacks.cpp"
'Finished building: ../system/LibraryHacks.cpp'
' '
'Building file: ../adc_analog_watchdog.cpp'
'Invoking: Cross ARM C++ Compiler'
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -O0 -fmessage-length=0 -ffunction-sections -fdata-sections -Werror -Wall -Wextra  -g3 -DSTM32PLUS_F4 -DHSE_VALUE=8000000 -I"D:\STM32\stm32plus-3.0\lib" -I"D:\STM32\stm32plus-3.0\lib\include" -I"D:\STM32\stm32plus-3.0\lib\include\stl" -I"D:\STM32\stm32plus-3.0\examples\adc_analog_watchdog" -std=gnu++0x -fabi-version=0 -fno-exceptions -fno-rtti -pedantic-errors -fno-threadsafe-statics -MMD -MP -MF"adc_analog_watchdog.d" -MT"adc_analog_watchdog.o" -c -o "adc_analog_watchdog.o" "../adc_analog_watchdog.cpp"
'Finished building: ../adc_analog_watchdog.cpp'
' '
'Building target: stm32plus-examples-adc_analog_watchdog.elf'
'Invoking: Cross ARM C++ Linker'
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -O0 -fmessage-length=0 -ffunction-sections -fdata-sections -Werror -Wall -Wextra  -g3 -T D:\STM32\stm32plus-3.0\examples\adc_analog_watchdog/system/f4/Linker.ld -Xlinker --gc-sections -Wl,-Map,"stm32plus-examples-adc_analog_watchdog.map" -Wl,-wrap,__aeabi_unwind_cpp_pr0 -Wl,-wrap,__aeabi_unwind_cpp_pr1 -Wl,-wrap,__aeabi_unwind_cpp_pr2 -o "stm32plus-examples-adc_analog_watchdog.elf"  ./system/f4/Startup.o ./system/f4/System.o  ./system/LibraryHacks.o  ./adc_analog_watchdog.o   -lstm32plus
./adc_analog_watchdog.o: In function `stm32plus::Adc::startRegularConversion() const':
D:\STM32\stm32plus-3.0\lib\include/adc/f4/Adc.h:173: undefined reference to `ADC_SoftwareStartConv'
./adc_analog_watchdog.o: In function `stm32plus::AdcPeripheral<(stm32plus::PeripheralName)0>::initialisePeripheral()':
D:\STM32\stm32plus-3.0\lib\include/adc/f4/AdcPeripheral.h:63: undefined reference to `ADC_CommonInit'
collect2.exe: error: ld returned 1 exit status
make: *** [stm32plus-examples-adc_analog_watchdog.elf] Error 1

kyildirim

My mistake,
I found that I was trying to build for wrong platform, because I have build the library for STM32F103 chip
but the example default target was Cortex M4 chips.

Now the time for testing and playing with library on development board.
I got a cheap FarEast version of board, need to change port and pin numbers accordingly.

regards,

kyildirim

September 30, 2014, 07:31:15 am #2 Last Edit: September 30, 2014, 01:40:39 pm by Andy Brown
Hi,
what need to be changed on library portion or in example codes to work on an unofficial development board?
I am currently working with a board which has STM32F103RBT6 chip on it.

I just started with blink example, changed gpio.h in folder "f1hd" according to my boards LED pin (PA2).
changed code as below, even I have a successfull buil, nothing happed after flash.


GpioA<DefaultDigitalOutputFeature<2> > pa;
for(;;) {

        pa[2].set();
        MillisecondTimer::delay(1000);

        pa[2].reset();
        MillisecondTimer::delay(1000);
      }


regards,
Kemal

Andy Brown

September 30, 2014, 01:39:14 pm #3 Last Edit: September 30, 2014, 01:41:35 pm by Andy Brown
Hi Kemal,

Welcome to the forum, I've moved your posts to a new topic for you so that we can work together on getting you started.

Quote from: kyildirim on September 30, 2014, 07:31:15 am
Hi,
what need to be changed on library portion or in example codes to work on an unofficial development board?
I am currently working with a board which has STM32F103RBT6 chip on it.

I just started with blink example, changed gpio.h in folder "f1hd" according to my boards LED pin (PA2).
changed code as below, even I have a successfull buil, nothing happed after flash.


GpioA<DefaultDigitalOutputFeature<2> > pa;
for(;;) {

        pa[2].set();
        MillisecondTimer::delay(1000);

        pa[2].reset();
        MillisecondTimer::delay(1000);
      }

regards,
Kemal


3rd party boards are fine, that's what I use when programming the F103. I'm assuming it's got an 8MHz external oscillator on the board.

Firstly, don't change "gpio.h". The files in there are the ST standard peripheral library and do not need to be modified unless you find a bug. I recommend that you restore the original files.

To test a LED blinker I recommend that you modify examples/blink/blink.cpp in the way that you have quoted here, build with scons and upload the hex file to your board. This is the basic sanity test. When you've got that going you have a known-good platform and can move on to editing and debugging in Eclipse.
It's worse than that, it's physics Jim!

kyildirim

October 03, 2014, 12:55:06 pm #4 Last Edit: October 04, 2014, 07:00:56 am by Andy Brown
Hi there Andy,
My external oscillator is 8Mhz, no need to change any config I guess.
By the way, my board have 128K Flash and 20K RAM.
I have prepared a untouched testbed, changed examples/blink/blink.cpp as per quoted before,
changed examples/blink/system/f1hd/Linker.ld as below


ENTRY(Reset_Handler)

_estack = 0x08000000;    /* end of $(RAM_LENGTH) RAM */

_Min_Heap_Size = 0;      /* required amount of heap  */
_Min_Stack_Size = 4K; /* required amount of stack */

MEMORY
{
  FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 128K
  RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 20K
}

I have no problem with building scons(cygwin/linux) or on eclipse (windows/linux)
but the LED is not blinking at all.
also I have no a debugger at the moment, so have no idea what is happening after flashing to the board.

regards,
Kemal

Andy Brown

October 04, 2014, 07:07:59 am #5 Last Edit: October 04, 2014, 07:12:26 am by Andy Brown
Hi Kemal,

You were right to modify the linker script. With only 20Kb of RAM I would recommend shrinking the _Min_Stack_Size as well, perhaps down to 0x200 (512 bytes). One issue might be your value for _estack (end of the stack). This value should point to the last byte in SRAM where the stack will start before growing downwards. Your SRAM starts at 0x20000000 and you have 20Kb of it so _estack should be 0x20004FFF.

I can't recommend a debugger highly enough. Do you have any of the *discovery boards around? There are hacks out there on the internet that document how to use these as a ST-Link debugger.

Regards,
- Andy
It's worse than that, it's physics Jim!

kyildirim

Hi Andy,
At the end, I have a blink now.  :)
Just as you explained, I have changed the linker file regarding to my board resources.
Now its time to write more meaningfull.
thanks again,
regards,