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 11, 2012 at 06:04

STARTUP.S:

////////////////////////

/*

+=============================================================================+

| includes

+=============================================================================+

*/

#include ''hdr/hdr_special_registers.h''

/*

+=============================================================================+

| ARMv7-M(E) (Cortex-M3 / Cortex-M4) startup code

+=============================================================================+

*/

.text

.balign 2

.syntax unified

.thumb

.thumb_func

.global Reset_Handler

Reset_Handler:

/*

+-----------------------------------------------------------------------------+

| Initialize the process stack pointer

+-----------------------------------------------------------------------------+

*/

 ldr  r0, =__process_stack_end

 msr  PSP, r0

/*

+-----------------------------------------------------------------------------+

| Thread mode uses process stack (PSP) and is privileged

+-----------------------------------------------------------------------------+

*/

 movs r0, #CONTROL_ALTERNATE_STACK

 msr  CONTROL, r0

 isb

/*

+-----------------------------------------------------------------------------+

| Branch to low_level_init_0() function (.data and .bss are not initialized!)

+-----------------------------------------------------------------------------+

*/

 ldr  r0, =low_level_init_0

 blx  r0

/*

+-----------------------------------------------------------------------------+

| Initialize .data section

+-----------------------------------------------------------------------------+

*/

 ldr  r1, =__data_init_start

    ldr  r2, =__data_start

    ldr  r3, =__data_end

1: cmp  r2, r3

 ittt lo

 ldrlo r0, [r1], #4

 strlo r0, [r2], #4

 blo  1b

/*

+-----------------------------------------------------------------------------+

| Zero-init .bss section

+-----------------------------------------------------------------------------+

*/

 movs r0, #0

 ldr  r1, =__bss_start

 ldr  r2, =__bss_end

1: cmp  r1, r2

 itt  lo

 strlo r0, [r1], #4

 blo  1b

/*

| Call the clock system intitialization function.

*/

/*  bl  SystemInit */

 ldr  r0, =SystemInit

 blx  r0

/*

+-----------------------------------------------------------------------------+

| Call C++ constructors for global and static objects

+-----------------------------------------------------------------------------+

*/

#ifdef __USES_CXX

 ldr  r0, =__libc_init_array

 blx  r0

#endif

/*

+-----------------------------------------------------------------------------+

| Branch to low_level_init_1() function

+-----------------------------------------------------------------------------+

*/

 ldr  r0, =low_level_init_1

 blx  r0

/*

+-----------------------------------------------------------------------------+

| Branch to main() with link

+-----------------------------------------------------------------------------+

*/

 ldr  r0, =main

 blx  r0

/*

+-----------------------------------------------------------------------------+

| Call C++ destructors for global and static objects

+-----------------------------------------------------------------------------+

*/

#ifdef __USES_CXX

 ldr  r0, =__libc_fini_array

 blx  r0

#endif

/*

+-----------------------------------------------------------------------------+

| On return - loop till the end of the world

+-----------------------------------------------------------------------------+

*/

 b  .

/*

+=============================================================================+

| __default_low_level_init() - replacement for undefined low_level_init_0()

| and/or low_level_init_1(). This function just returns.

+=============================================================================+

*/

.text

.balign 2

.syntax unified

.thumb

.thumb_func

.global __default_low_level_init

__default_low_level_init:

 bx  lr

/*

+=============================================================================+

| assign undefined low_level_init_0() and/or low_level_init_1() to

| __default_low_level_init()

+=============================================================================+

*/

.weak low_level_init_0

.global low_level_init_0

.set low_level_init_0, __default_low_level_init

.weak low_level_init_1

.global low_level_init_1

.set low_level_init_1, __default_low_level_init

/******************************************************************************

* END OF FILE

******************************************************************************/
jlchoobs
Associate II
Posted on June 11, 2012 at 06:07

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6l8&d=%2Fa%2F0X0000000bul%2FFx3b1lqa.t_QTmtOwWo.5JjyyDz37uqCor1AOGBQBgk&asPdf=false
jlchoobs
Associate II
Posted on June 11, 2012 at 07:43

* Is there some Fuse Setting that I need to program into the Chip for the Clock ?

lastsamurai
Associate III
Posted on June 11, 2012 at 13:03

Hi,

Just a background fact.  I've been using CodeSourcery G++ with Eclipse for quite a some time and happy with it.  Before that I used KeilMDK and IAR, and the outstanding Eclipse IDE makes the coding lot more easier.  

I'm using Eclipse CDT with Cross Compiler Support.  The CDT internal builder is used, as such the makefile is not needed.  Moreover, Atolics startup and linker descriptions can be used straight away, to start Hello World!  

I even used Scons instead of make, and happy with it too.

 

jlchoobs
Associate II
Posted on June 11, 2012 at 22:41

Clive,

Any ideas from the code ?

Posted on June 11, 2012 at 23:30

Clive, Any ideas from the code ?

I seem to be missing a lot of the pieces (zipping up a complete buildable project might help, bit it is rather a mess), and you seem to have created rather a hybrid environment mixing the standard library code with a lot of other stuff which I don't have any visibility to. I'm not sure why that was necessary as the standard library is serviceable.

I've been using GCC with pretty the stock library and example code and customize linker script based on the STM32F1 version I used, Lanchon's I think. And the Ride startup code.

What USART are you outputting data too, and does the baud rate match expectations? If the data is garbled it's a pretty good indicator that the hardware and software have different ideas about what the clock rates/settings are.

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 11, 2012 at 23:39

I can only assume the problem is in the makefile or startup.S

Or low_level_init_0, low_level_init_1 or SystemInit

Other functions work back the PLL settings, and HSE_VALUE.

Another potential is that it's using HSI (16 MHz) vs HSE (8 MHz), you could direct the clocks out the MCO pins and measure it with a scope to confirm it's what you expect.

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 12, 2012 at 06:24

clive,

Sorry about looking messy.

This is the result of dropping my working Port of stm3240g into a BlinkLed Project for Code Sourcery.

I have not been able to get noticable executable code from Code Sourcery before this.

The Usart is not enabled.

The Startup is the Blink Led Startup - not from stm3240g, but it is calling the stm3240g clock startup.

This is running on the Stm32f4Discovery Board.

As I said for speed, the Heartbeat Led is twice as slow, the Beeps are lower in Pitch, and the usb is not working - so I think that is already clear as a problem.

Let me try to put together a zip then.

Try this zip:

http://www.filedropper.com/stm324xgblkurteval-usbv009min

Posted on June 12, 2012 at 23:16

You should be able to attach things here.

Missing fonts.h, pulled from another STM32 library

Missing chip.h, fudged some code for STAT_P

Builds with Yagarto GCC 4.6.2

Want to attach your out directory from Code Sourcery? Mine expired, not hot to do a reinstall or buy a license.

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 13, 2012 at 04:29

Yagarto GCC should be fine.

I have Code Sourcery Lite, but My current Toolchain is Linux GCC.

Chip.his listed below.

Fonts.his not needed.

- Fonts are only needed with LCD which is not enabled.

Should be able to compile with your Winarm.

This compiles down to 16K bin in Atollic.

But, compiles into 144K Bin in Code Sourcery or Linux GCC.

- Remove Unused code seems to have no effect.

-

Withthe Zipthat Isent you,

and connecting a SDCard to Stm32F4Discovery Board,

will give you Usb FlashDisk when connecting second Usb cable back to PC running Windows.

Just compile with WinArm or Yagarto, etc.

This is a TestedWorking port of Stm3240g Firmware running on Stm32f4Discovery Board.

I sent working Code - just needs configuration tweaks for Code Sourcery or Winarm.

- Maybe Startup file issue ?

- try using the other Startup_stmstm3240 as Startup.S

-

Here I attached the OUT dir - I had avoided this because it is 16MB.

But, I would suggest just compiling this yourself

- you stated that you wanted to try the Usb on your stm32f4disc board

-- here you got it ...

I would like to post this as the Stm3240g Firmware port for Stm32F4Discovery Board.

It is already complete and working under Atollic.

But, I can not get it to compile and runwith Code Sourcery or Winarm correctly.

Can you give it a shot? - it would be appreciated.

- I think a lot of other developers are/would beinterested in this.

I already see manyrelated questions on the forum about this topic,

- like Sd Card on stm32f4disc.

---

//// CHIP.H ////

#ifndefCHIP_H

#defineCHIP_H1

#include ''stm32f4xx.h''

extern intCPU_MODE_ST;

extern GPIO_TypeDef *STAT_P;

extern intSTAT_B;

#endif

________________

Attachments :

out.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzYn&d=%2Fa%2F0X0000000bNd%2FDP9omEPT_NZ4zh1Sv_wyWd1HtNhIK89A7dfKXJ.VKto&asPdf=false