cancel
Showing results for 
Search instead for 
Did you mean: 

Why would code work when compiled with Atollic - but not with Code Sourcery ??

jlchoobs
Associate II
Posted on May 31, 2012 at 20:16

I successfully compiled the stm3240g Sample Project using Code Sourcery.

But, it does nothing on the Discovery Board.

But, this code is directly converted from as WORKING Code on the Discovery Board

- when compiled with Atollic Compiler.

-> Why should the Code not run successfully if it compiles by the Code Sourcery too ??

What could cause this problem - difference ?

Would WinArm work any better ?
42 REPLIES 42
jlchoobs
Associate II
Posted on June 13, 2012 at 18:21

clive,

Attached is a zip of ALL files needed/used ONLY/EXACTLY for the WORKING ATOLLIC compile that runs correctly.

- just without the complex Directories.

So this should only need makefile configurations for Winarm compiling.

- Not the messy files that you complained about.

jlc.

________________

Attachments :

_Stm324xG_BlkUrt_Eval-Usb_v009.stm3240.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzQG&d=%2Fa%2F0X0000000bNb%2FspYX.fSdtLC1.O.I.xXiJWlFtTyaHbuwintX.Y_klqM&asPdf=false
Posted on June 14, 2012 at 02:47

Attached is a zip of ALL files needed/used ONLY/EXACTLY for the WORKING ATOLLIC compile that runs correctly.

This is going to crash because STAT_P is never initialized, but is then used in Beep(). Most likely it will Hard Fault

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jlchoobs
Associate II
Posted on June 14, 2012 at 05:46

Sorry,

I accidentally deleted this from App.c , just add it in :

    STAT_P = GPIOA;  // = Port PA

    STAT_B = 0;   // = Pin/Bit #0 

This should also be there:

    GPIO_TypeDef * STAT_P;

    int  STAT_B;

I have this running perfectly under Atollic.

Do you have any more results yet for Winarm on your board ??

Did you compile and run this yet ?

- This is working code ...
jlchoobs
Associate II
Posted on June 14, 2012 at 07:24

Here is a version of the same code setupfor Winarm.

Can you try this ? - you claim to prefer Winarm.

- But I can't get past an error 'undefined reference to _init' from libs directories.

All mycode listed here for Atollic and Code Sourceryboth successfully Compile and Run on the Stm32f4Discovery Board.

I just have a Clock problem on the Code Sourcery version.

Did youtryexecuting any of the Code ?

________________

Attachments :

_Stm324xG_BlkUrt_Eval-Usb_v009_stm3240_WinArm.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzYd&d=%2Fa%2F0X0000000bNc%2F17Fc4evEWiwbehX_u9NeskOG7FMyh1MplFVW7mBBOCk&asPdf=false
jlchoobs
Associate II
Posted on June 14, 2012 at 10:01

clive,

You Asked for me to send you the Code in zip.

I sent you 3 different versions for 3 different compilers,

- 2 of the versions do compile and run successfully.

Can you atleast try compiling and executing One of the versions ? - thanks !

Posted on June 14, 2012 at 17:22

I'm working through this as I get time. I'm doing static analysis first, as this might shed the most light on the clocking issue.

I'm working with F2's, the version of WinARM (4.3.0) I'm using does not support -mcpu=cortex-m4, instead using Yagarto 4.6.2 for that. My STM32F4-Discovery does not have an SD Socket attached.

The code that has problems with Code Sourcery does not share the same code base as the source code that works with others. In order to understand why one compiler/linker is working one way, and another works another you're going to want to start with the same code.

There are bits missing, none of this is compiling out of the box.

_Stm324xG_BlkUrt_Eval-Usb_v009.min builds with Yagarto (GNU/GCC) 4.6.2

_Stm324xG_BlkUrt_Eval-Usb_v009.stm3240 does not, looking for _init (newlib)

_Stm324xG_BlkUrt_Eval-Usb_v009_stm3240_WinArm also does not build with Yagarto 4.6.2

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jlchoobs
Associate II
Posted on June 14, 2012 at 18:41

Understand clive - thanks.

>> _Stm324xG_BlkUrt_Eval-Usb_v009.min builds with Yagarto (GNU/GCC) 4.6.2

-> For me, this compiles in Code Sourcery and runs - but at half Clock Speed

>> _Stm324xG_BlkUrt_Eval-Usb_v009.stm3240 does not, looking for _init (newlib)

-> For me, this builds under Atollic and runs correctly.

>> _Stm324xG_BlkUrt_Eval-Usb_v009_stm3240_WinArm also does not build with Yagarto 4.6.2

-> For me, this gives me the same as above _init Error - you probably confused the versions - I thought you could possibly make sense of this one.

>> ''My STM32F4-Discovery does not have an SD Socket attached.''

-> You can hook up the Sd Card identical as the stm3240g board schematic - its just missing the Detect pin which is ignored anyway.  Just make sure to use 200R Resistors in series to the SD Card (besides the Pullups) just in case you output to the wrong pins (I already blew an IO Pin on AVR this way).

Even without a Sd Card - Windows should still Detect the Usb Mass Storage - just 'Disk Not Ready' Error.

I have and use WinArm in Dos - I was using this for LPC2148 chips about 2 years ago.

Also, I have Yagarto and use it on Eclipse - I was using this for Avr chips last year.

(You don't want to know how many Eclipse versions that I have lying around beween CodSrc..Keil..Avr..Avr32..Atollic..Portable..etc) -so I'm kind of split-brained on remembering each one's quirks !
Posted on June 14, 2012 at 19:22

I'm probably not going to strap an SD socket on the F4, I have one on my F2 design, and I can access via my own app. Porting ST's USB/MSD library is the route I'm likely to take. Yes, I need to get your binaries uploaded.

The clocking is a bit of a mess, the CMSIS method is using SystemInit() -> SetSysClock() and setting up the PLL/VCO basically 8  / 8 * 336 / 2 = 168, whereas pll_start() is 8 / 4 * 168 / 2.

pll_start() is also setting PLLQ to 9 which gets a 37.333 MHz SDIO bus, SetSysClock() uses 7 and gets 48 MHz.

pll_start() does not pay attention to if HSE is already enabled, or if the PLL is currently clocking the part, this is probably very dangerous, so I'm not sure of the need to use it.  The Code Sourcery ''out'' binary example calls both. I'm not sure that using the ''Freddie Chopin'' code is necessary, the CMSIS/Ride7 or Atollic startup code makes more sense in providing a consistent environment to develop or port code from other ST firmware examples and demos. The Atollic version differing in that it calls __libc_init_array

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on June 14, 2012 at 19:53

Ok, have the vstm3240 building with Yagarto

My linker scripts look like this currently. stm32f4xx.ld

/*
Linker script for STM32F40x
*/
/* include the common STM32F40x sub-script */
INCLUDE ''STM32F4_COMMON.ld''
/* Memory Spaces Definitions */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 112K
AUX (xrw) : ORIGIN = 0x2001C000, LENGTH = 16K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1M
CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K /* also change _estack below */
}
/* highest address of the user mode stack */
_estack = 0x10010000;
/* Sections Definitions */
SECTIONS
{
/* for Cortex devices, the beginning of the startup code is stored in the .isr_vector section, which goes to FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* for some STRx devices, the beginning of the startup code is stored in the .flashtext section, which goes to FLASH */
.flashtext :
{
. = ALIGN(4);
*(.flashtext) /* Startup code */
. = ALIGN(4);
} >FLASH
/* the program code is stored in the .text section, which goes to Flash */
.text :
{
. = ALIGN(4);
*(.text) /* remaining code */
*(.text.*) /* remaining code */
*(.rodata) /* read-only data (constants) */
*(.rodata*)
*(.glue_7)
*(.glue_7t)
. = ALIGN(4);
_etext = .;
/* This is used by the startup in order to initialize the .data secion */
_sidata = _etext;
} >FLASH
/* This is the initialized data section
The program executes knowing that the data is in the RAM
but the loader puts the initial values in the FLASH (inidata).
It is one task of the startup to copy the initial values from FLASH to RAM. */
.data : AT ( _sidata )
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .data secion */
_sdata = . ;
*(.data)
*(.data.*)
. = ALIGN(4);
/* This is used by the startup in order to initialize the .data secion */
_edata = . ;
} >RAM
/* This is the uninitialized data section */
.bss :
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .;
*(.bss)
*(COMMON)
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_ebss = . ;
} >RAM
PROVIDE ( end = _ebss );
PROVIDE ( _end = _ebss );
/* This is the user stack section
This is just to check that there is enough RAM left for the User mode stack
It should generate an error if it's full.
*/
._usrstack :
{
. = ALIGN(4);
_susrstack = . ;
. = . + _Minimum_Stack_Size ;
. = ALIGN(4);
_eusrstack = . ;
} >CCM
__exidx_start = .;
__exidx_end = .;
/* after that it's only debugging information. */
/* remove the debugging information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
}

STM32F4_COMMON.ld

/* default stack sizes.
These are used by the startup in order to allocate stacks for the different modes.
*/
__Stack_Size = 8192 ;
PROVIDE ( _Stack_Size = __Stack_Size ) ;
__Stack_Init = _estack - __Stack_Size ;
/*''PROVIDE'' allows to easily override these values from an object file or the commmand line.*/
PROVIDE ( _Stack_Init = __Stack_Init ) ;
/*
There will be a link error if there is not this amount of RAM free at the end.
*/
_Minimum_Stack_Size = 0x100 ;
/*
this sends all unreferenced IRQHandlers to reset
*/
PROVIDE ( Undefined_Handler = 0 ) ;
PROVIDE ( SWI_Handler = 0 ) ;
PROVIDE ( IRQ_Handler = 0 ) ;
PROVIDE ( Prefetch_Handler = 0 ) ;
PROVIDE ( Abort_Handler = 0 ) ;
PROVIDE ( FIQ_Handler = 0 ) ;
PROVIDE ( NMIException = 0 ) ;
PROVIDE ( HardFaultException = 0 ) ;
PROVIDE ( MemManageException = 0 ) ;
PROVIDE ( BusFaultException = 0 ) ;
PROVIDE ( UsageFaultException = 0 ) ;
PROVIDE ( SVCHandler = 0 ) ;
PROVIDE ( DebugMonitor = 0 ) ;
PROVIDE ( PendSVC = 0 ) ;
PROVIDE ( SysTickHandler = 0 ) ;
PROVIDE ( WWDG_IRQHandler = 0 ) ;
PROVIDE ( PVD_IRQHandler = 0 ) ;
PROVIDE ( TAMP_STAMP_IRQHandler = 0 ) ;
PROVIDE ( RTC_WKUP_IRQHandler = 0 ) ;
PROVIDE ( FLASH_IRQHandler = 0 ) ;
PROVIDE ( RCC_IRQHandler = 0 ) ;
PROVIDE ( EXTI0_IRQHandler = 0 ) ;
PROVIDE ( EXTI1_IRQHandler = 0 ) ;
PROVIDE ( EXTI2_IRQHandler = 0 ) ;
PROVIDE ( EXTI3_IRQHandler = 0 ) ;
PROVIDE ( EXTI4_IRQHandler = 0 ) ;
PROVIDE ( DMA1_Stream0_IRQHandler = 0 ) ;
PROVIDE ( DMA1_Stream1_IRQHandler = 0 ) ;
PROVIDE ( DMA1_Stream2_IRQHandler = 0 ) ;
PROVIDE ( DMA1_Stream3_IRQHandler = 0 ) ;
PROVIDE ( DMA1_Stream4_IRQHandler = 0 ) ;
PROVIDE ( DMA1_Stream5_IRQHandler = 0 ) ;
PROVIDE ( DMA1_Stream6_IRQHandler = 0 ) ;
PROVIDE ( ADC_IRQHandler = 0 ) ;
PROVIDE ( CAN1_TX_IRQHandler = 0 ) ;
PROVIDE ( CAN1_RX0_IRQHandler = 0 ) ;
PROVIDE ( CAN1_RX1_IRQHandler = 0 ) ;
PROVIDE ( CAN1_SCE_IRQHandler = 0 ) ;
PROVIDE ( EXTI9_5_IRQHandler = 0 ) ;
PROVIDE ( TIM1_BRK_TIM9_IRQHandler = 0 ) ;
PROVIDE ( TIM1_UP_TIM10_IRQHandler = 0 ) ;
PROVIDE ( TIM1_TRG_COM_TIM11_IRQHandler = 0 ) ;
PROVIDE ( TIM1_CC_IRQHandler = 0 ) ;
PROVIDE ( TIM2_IRQHandler = 0 ) ;
PROVIDE ( TIM3_IRQHandler = 0 ) ;
PROVIDE ( TIM4_IRQHandler = 0 ) ;
PROVIDE ( I2C1_EV_IRQHandler = 0 ) ;
PROVIDE ( I2C1_ER_IRQHandler = 0 ) ;
PROVIDE ( I2C2_EV_IRQHandler = 0 ) ;
PROVIDE ( I2C2_ER_IRQHandler = 0 ) ;
PROVIDE ( SPI1_IRQHandler = 0 ) ;
PROVIDE ( SPI2_IRQHandler = 0 ) ;
PROVIDE ( USART1_IRQHandler = 0 ) ;
PROVIDE ( USART2_IRQHandler = 0 ) ;
PROVIDE ( USART3_IRQHandler = 0 ) ;
PROVIDE ( EXTI15_10_IRQHandler = 0 ) ;
PROVIDE ( RTC_Alarm_IRQHandler = 0 ) ;
PROVIDE ( OTG_FS_WKUP_IRQHandler = 0 ) ;
PROVIDE ( TIM8_BRK_TIM12_IRQHandler = 0 ) ;
PROVIDE ( TIM8_UP_TIM13_IRQHandler = 0 ) ;
PROVIDE ( TIM8_TRG_COM_TIM14_IRQHandler = 0 ) ;
PROVIDE ( TIM8_CC_IRQHandler = 0 ) ;
PROVIDE ( DMA1_Stream7_IRQHandler = 0 ) ;
PROVIDE ( FSMC_IRQHandler = 0 ) ;
PROVIDE ( SDIO_IRQHandler = 0 ) ;
PROVIDE ( TIM5_IRQHandler = 0 ) ;
PROVIDE ( SPI3_IRQHandler = 0 ) ;
PROVIDE ( UART4_IRQHandler = 0 ) ;
PROVIDE ( UART5_IRQHandler = 0 ) ;
PROVIDE ( TIM6_DAC_IRQHandler = 0 ) ;
PROVIDE ( TIM7_IRQHandler = 0 ) ;
PROVIDE ( DMA2_Stream0_IRQHandler = 0 ) ;
PROVIDE ( DMA2_Stream1_IRQHandler = 0 ) ;
PROVIDE ( DMA2_Stream2_IRQHandler = 0 ) ;
PROVIDE ( DMA2_Stream3_IRQHandler = 0 ) ;
PROVIDE ( DMA2_Stream4_IRQHandler = 0 ) ;
PROVIDE ( ETH_IRQHandler = 0 ) ;
PROVIDE ( ETH_WKUP_IRQHandler = 0 ) ;
PROVIDE ( CAN2_TX_IRQHandler = 0 ) ;
PROVIDE ( CAN2_RX0_IRQHandler = 0 ) ;
PROVIDE ( CAN2_RX1_IRQHandler = 0 ) ;
PROVIDE ( CAN2_SCE_IRQHandler = 0 ) ;
PROVIDE ( OTG_FS_IRQHandler = 0 ) ;
PROVIDE ( DMA2_Stream5_IRQHandler = 0 ) ;
PROVIDE ( DMA2_Stream6_IRQHandler = 0 ) ;
PROVIDE ( DMA2_Stream7_IRQHandler = 0 ) ;
PROVIDE ( USART6_IRQHandler = 0 ) ;
PROVIDE ( I2C3_EV_IRQHandler = 0 ) ;
PROVIDE ( I2C3_ER_IRQHandler = 0 ) ;
PROVIDE ( OTG_HS_EP1_OUT_IRQHandler = 0 ) ;
PROVIDE ( OTG_HS_EP1_IN_IRQHandler = 0 ) ;
PROVIDE ( OTG_HS_WKUP_IRQHandler = 0 ) ;
PROVIDE ( OTG_HS_IRQHandler = 0 ) ;
PROVIDE ( DCMI_IRQHandler = 0 ) ;
PROVIDE ( CRYP_IRQHandler = 0 ) ;
PROVIDE ( HASH_RNG_IRQHandler = 0 ) ;
PROVIDE ( FPU_IRQHandler = 0 ) ;

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jlchoobs
Associate II
Posted on June 14, 2012 at 20:38

clive,

okay - thanks for the linker info.

The version that I sent you may still connect USB - even with the clock issue.

I am still working on the Clock issue but have a version running with your Linker

- and it connects successfully (via Windows) as Mass Storage.

-

The output should be less than 32K but is compiling to 80K though (I have additional code - but it should still be less than 32k).

- Fixed

-

Now I am going to try copying identical settings from Atollic to the Makefile.

Great !

- Thanks for the help Clive !

Now I can continue working in Code Src instead of limited Atollic.

Well, I am not as worried about the code size,

but I can not bring the speed up - I tried removing all of the alternate chung code - and calling SystemInit() and 

SystemCoreClockUpdate() in main() func, even setting the PLL regs directly  - but all with no result.  I am confused.

- Fixed

-

-> Okay, that Optimize=Os may have corrected the Slow SPEED issue.  My Heartbeat is twice as fast now.   In Atolic, I had disabled the Optimizer (but used the Remove_Dead_Code parm) to avoid messing up my delay loops -like for audio and spi timings.  But now I added a j=SPDA->IDR in the delay loops and still have my delays.

And, my Code BIN is down to 35K now - which sounds about where Atollic was compiling (and blocking for Code size limit).

-

Now, I have the USB Mass Storage, LCD, and my SpaceInvader test app running smoothly.

So I can continue on coding the project in eclipse now - without the Atollic size limitation.

Do you have any suggested Toolchain - Linux Gcc / CodSrc / Win Gcc / ... ?

THANKS again !

You were a great help - I was tearing-my-hair-out thinking that few months work was wasted because of code size limits.