This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Segger Embedded Studio project does not run code without press reset button

Hi All,

I am using Keil and GCC but I want to migrate my projject to "Seggers Embedded Studio for ARM". After following the tutorial about migration, i have been able to import my project into Embedded Studio and upload the code using the "Build and Run" button. However, after uploading the firmware to the NRF51-DK board,  I must click on-board reset button to make my firmware working. This problem is not visible in KEIL and GCC. (When the code is starting correctlyi LED1 and LED2 is on and bluetooth advertisement is active.)

The my sample example is here.(https://github.com/srcnert/NRF51_Template_Segger_Keil_GCC). You must create a folder inside the SDK 12.3.0 folder and paste my template project inside this new folder to build my sample project.

What is the problem of the segger embedded studio and how can I get the code to automatically run without press reset button?

My second question is about RAM and ROM management. When i compile this sample project, i get following results,

Keil creates 41kB hex file. RAM size: 4008 byte ROM Size: 15052byte. (Program Size: Code=14448 RO-data=300 RW-data=304 ZI-data=3704 )

GCC creates 59kB hex file. RAM size: 1824 byte ROM Size: 21368byte. (Program Size: text=21204 data=164 bss=1660 dec=23028 ) 

Segger creates 89kB hex file. RAM size: 3.7kb ROM Size: 31,6kB. (The values in the memory usage section)

Is this number normal? For example, Ram size is a lot lower in the GCC compiler. Is this the expected behaviour? If not, how can i calculate correct ram and rom size?

Thanks.

 

  • Try adding 'TargetInterface.resetAndStop(1000)' to project -> options -> common -> Target Script, as well as adding 'main' to project -> options -> MY_PROJECT -> Debugger -> Run To. 

  • I want to fix my error in RAM calculation. I made Heap Size: 1024, Stack Size: 1024 for all compilers and update the results according to this heap and stack size.

    Keil creates 41kB hex file. RAM size: 2984 byte ROM Size: 15052byte. (Program Size: Code=14448 RO-data=300 RW-data=304 ZI-data=2680)

    I think that real RAM size is equal to (2984 + HEAP SIZE = 4008 byte). Because, I make HEAP_SIZE zero in KEIL but RW or ZI data does not change. (Edit: Enabling MicroLIB removes the HEAP.)

    GCC creates 59kB hex file. RAM size: 1824 byte ROM Size: 21368byte. (Program Size: text=21204 data=164 bss=1660 dec=23028 )

    I changed HEAP_SIZE and STACK_SIZE in GCC makefile. However, All values(text, data, bss, dec) are same. So, I think that real RAM size equal to 1824 + 1024 +1024 = 3872 byte.

     

    In segger, heap and stack remained same (1024 byte)  but i change optimization level as Level-3 and segger creates 57kB hex file and the ROM size changed as follow.

    KEIL, ROM:15052 byte, RAM: 4008 byte

    GCC, ROM:21368 byte byte, RAM: 3872 byte

    SEGGER, ROM: 20,2 kB RAM: 3,7 kB

    Now, ROM and RAM size is almost same. Do you think these calculations are correct? Why do segger and gcc create so big hex file? I made something wrong?

    Thanks everybody for their response.

  • Yeah I think you've made the correct calculations after you set the optimization level to 3 in SES. Then it should be very close to GCC with opt lvl 3. 

    I also believe that level 3 optimizes for both code size AND execution time. It might be that the Keil compiler is set to optimize for code size only(level 1 or 2). 

    Segger uses GCC as it's compiler, whereas Keil has it's own compiler who's very good, but costs $$$. 

  • Hi , thank you for response. I've added your proposed settings to project. However, the situation does not change.You can see the settings in the picture.

      And this is the output.

    Also, i can make debug without problem before and after settings. Do you have any other suggestions? Thanks.

  • Hmm, try adding 'SetRestartOnClose = 1' to common -> debug-> jlink -> additional j-link options.

    If that does not work try adding 'SetResetType = 0' as well. 

Related