WSN Demo compilation problem RCB_AtMega128RFA1

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hy all,

I have an RCB128RFA1 board (AtMega128rfa1 based) and I'm trying to run WSNDemo on it. I installed BitCloud 1.14 and installed the board specific extensions provided by the board manufacturer. I'm using Atmel Studio 6.0.
First I configured the configuration.h specific to run a "coordinator" on my board.
I compile and it seems averything is ok but in the output files I notice that my WSNDemo.hex file has a size of just 16KB that comparing it to the pre-compiled files (about 350KB) of this example is too small.
I download the image to the board and it do nothing and I try to debug and it gets stopped just in the begining .
Im doing something wrong but I dont know what.

This is part of my output(the one that i consider important to show):

------ Build started: Project: RCB, Configuration: All_Rcb_Atmega128rfa1_8Mhz_Gcc AVR ------
Build started.
Project "RCB.cproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files\Atmel\Atmel Studio 6.0\Vs\Compiler.targets" from project "C:\BIT_CLOUD\BitCloud_MEGARF_1_14_0\Applications\WSNDemo\as5_projects\RCB.cproj" (target "Build" depends on it):
	Task "RunCompilerTask"
		C:\Program Files\Atmel\Atmel Studio 6.0\make\make.exe -C "C:\BIT_CLOUD\BitCloud_MEGARF_1_14_0\Applications\WSNDemo\as5_projects\..\makefiles\RCB" -f "Makefile_All_Rcb_Atmega128rfa1_8Mhz_Gcc" all 
		make: Entering directory `C:/BIT_CLOUD/BitCloud_MEGARF_1_14_0/Applications/WSNDemo/makefiles/RCB'
.
.
.
.
C:\BIT_CLOUD\BitCloud_MEGARF_1_14_0\Applications\WSNDemo\BitCloud\Components\ConfigServer\src\configServer.c(63,24): uninitialized variable 'csMemoryItems' put into program memory area [-Wuninitialized]
		avr-gcc -Wl,-Map=All_Rcb_Atmega128rfa1_8Mhz_Gcc/List/WSNDemo.map -Wl,--gc-sections -Wl,--script=./../../linkerScr/atmega128rfa1.ld -Wl,--section-start=.data=0x800200 -mmcu=atmega128rfa1 All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/WSNSensorManager.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/WSNVisualizer.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/WSNEndDevice.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/WSNCoord.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/WSNMessageSender.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/WSNCommandHandler.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/WSNRouter.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/WSNDemoApp.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/WSNUARTManager.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/pdsMem.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/pdsWriteData.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/pdsDataServer.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/pdsInit.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/pdsTimer.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/pdsEvents.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/pdsMemAccess.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/pdsCrcService.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/usbFifoVirtualUsart.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/usbFifoFT245RL.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/leds.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/bspTaskManager.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/buttons.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/fakeBSP.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/csPersistentMem.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/csMem.o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Obj/configServer.o -Wl,-\( ./../../../../BitCloud/lib/libHAL_RcbAtm128rfa1_Atmega128rfa1_8Mhz_Gcc.a ./../../../../BitCloud/lib/libBc_All_Atmega128rfa1_Atmega128rfa1_Gcc.a ./../../../../BitCloud/lib/WdtInitatmega128rfa1_Gcc.o  -Wl,-\) -o All_Rcb_Atmega128rfa1_8Mhz_Gcc/Exe/WSNDemo.elf
		avr-objcopy -O ihex -R .eeprom All_Rcb_Atmega128rfa1_8Mhz_Gcc/Exe/WSNDemo.elf All_Rcb_Atmega128rfa1_8Mhz_Gcc/Exe/WSNDemo.hex
		avr-objcopy -O srec --srec-len 128 All_Rcb_Atmega128rfa1_8Mhz_Gcc/Exe/WSNDemo.elf All_Rcb_Atmega128rfa1_8Mhz_Gcc/Exe/WSNDemo.srec
		avr-objcopy -O binary --strip-debug --strip-unneeded -R .eeprom All_Rcb_Atmega128rfa1_8Mhz_Gcc/Exe/WSNDemo.elf All_Rcb_Atmega128rfa1_8Mhz_Gcc/Exe/WSNDemo.bin
		cp -f All_Rcb_Atmega128rfa1_8Mhz_Gcc/Exe/*.* ./../../
		O comando ECHO está desactivado.
		   text	   data	    bss	    dec	    hex	filename
		   5790	   4096	   2631	  12517	   30e5	All_Rcb_Atmega128rfa1_8Mhz_Gcc/Exe/WSNDemo.elf
		   5790	   4096	   2631	  12517	   30e5	(TOTALS)
		make: Leaving directory `C:/BIT_CLOUD/BitCloud_MEGARF_1_14_0/Applications/WSNDemo/makefiles/RCB'
	Done executing task "RunCompilerTask".
	Using "RunOutputFileVerifyTask" task from assembly "C:\Program Files\Atmel\Atmel Studio 6.0\Vs\Compiler.Task.dll".
	Task "RunOutputFileVerifyTask"
		
		Display Output File Size Skipped due to : Output File not found
	Done executing task "RunOutputFileVerifyTask".
Done building target "CoreBuild" in project "RCB.cproj".
Target "PostBuildEvent" in file "C:\Program Files\Atmel\Atmel Studio 6.0\Vs\Avr.common.targets" from project "C:\BIT_CLOUD\BitCloud_MEGARF_1_14_0\Applications\WSNDemo\as5_projects\RCB.cproj" (target "Build" depends on it):
	Using "Exec" task from assembly "Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
	Task "Exec"
		Command:
		cp -fu C:\BIT_CLOUD\BitCloud_MEGARF_1_14_0\Applications\WSNDemo\as5_projects\..\makefiles\RCB\All_Rcb_Atmega128rfa1_8Mhz_Gcc\Exe\WSNDemo.elf C:\BIT_CLOUD\BitCloud_MEGARF_1_14_0\Applications\WSNDemo\as5_projects\..\makefiles\RCB\All_Rcb_Atmega128rfa1_8Mhz_Gcc\Exe\RCB.elf
	Done executing task "Exec".
Done building target "PostBuildEvent" in project "RCB.cproj".
Target "Build" in file "C:\Program Files\Atmel\Atmel Studio 6.0\Vs\Avr.common.targets" from project "C:\BIT_CLOUD\BitCloud_MEGARF_1_14_0\Applications\WSNDemo\as5_projects\RCB.cproj" (entry point):
Done building target "Build" in project "RCB.cproj".
Done building project "RCB.cproj".

Build succeeded.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

Can someone say if something is wrong?

Last Edited: Fri. Oct 16, 2015 - 02:18 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm having the same problem. The gcc flag (-gc-sections) discards all "unused" code. And this results in all the code from WSNDemoApp.c getting
stripped away.

If I compile manually (without the -gc-sections) then the binary is much larger, and indeed it includes main() from WSNDemoApp.c. But I don't see any output upon running the new binary.

I looked at the elf headers and I don't think
the entry point is right i.e. I don't think its
jumping to main().

By the way, if you run the precompiled binary in the Evaluation tools directory I see some output (with the Ghost prefix!) - so I know my hardware is working.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I got this to work. The problem was that the main entry point to the main() function in WSNDemoApp.c was not defined.

I added the following lines before the main() function in WSNDemoApp.c, recompiled and I got the "Ghost" output from the uart:

int main(void) __attribute__ ((naked)) \
__attribute__ ((section (".text.main")));

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks a lot!
It's working perfect! I knew that something was wrong because when I tried to debug with my dragon it stuck right in the beggining of the code!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you know how we can contact the Bitcloud developers so we can let
them know about this issue? Maybe its a tools problem? Maybe it works
with certain environments?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sagarwal10 wrote:
Do you know how we can contact the Bitcloud developers so we can let
them know about this issue? Maybe its a tools problem? Maybe it works
with certain environments?

avr@atmel.com is the Technical support's mail ID.. Hope u ll get clear solution from them. :wink:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm looking into it.

A bit of a history. In the linker script (atmega128rfa1.ld) there is a code:

    *(.init7)
    KEEP (*(.init7))
    *(.init8)
    KEEP (*(.init8))

    *(.text.main)
    KEEP (*(.text.main))
    *(.text)
    *(.text.*)

Normally there would be a section

    *(.init9)
    KEEP (*(.init9))

Which contains only call to main. By moving text.main first and removing init9 I saved 2 bytes of RAM and 4 bytes of Flash with seemingly no consequences.

So now it looks like linker ignores "KEEP (*(.text.main))".

Can anyone having this problem change this linker script section to:

    *(.init7)
    KEEP (*(.init7))
    *(.init8)
    KEEP (*(.init8))
    *(.init9)
    KEEP (*(.init9))

    *(.text)
    *(.text.*)

and try it?

BitCloud is always tested before the release, but in this case it was tested on AS5.1, since AS6.0 was not ready by the time release cycle started. So there might be a compiler/linker incompatibility here.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did a grep to look for C code marked with a
"init9" tag but could not find anything. Anyway
I tried as you suggested and got a linker error
(something to the effect of exit being referenced in
section .init9).

Note that at the end of the linker script, there
was a discard of *(.init9). I tried to remove it,
but I still get the same error.

C:\BitCloud_MEGARF_1_14_0\BitCloud_MEGARF_1_14_0\BitCloud\Components\ConfigServer\src\configServer.c(63,30): uninitialized variable 'csMemoryItems' put into program memory area [-Wuninitialized]
avr-gcc -Wl,-Map=Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/List/WSNDemo.map -Wl,--gc-sections -Wl,--script=./../../linkerScr/atmega128rfa1.ld -Wl,--section-start=.data=0x800200 -mmcu=atmega128rfa1 Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/WSNSensorManager.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/WSNVisualizer.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/WSNEndDevice.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/WSNCoord.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/WSNMessageSender.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/WSNCommandHandler.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/WSNRouter.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/WSNDemoApp.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/WSNUARTManager.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/pdsMem.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/pdsWriteData.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/pdsDataServer.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/pdsInit.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/pdsTimer.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/pdsEvents.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/pdsMemAccess.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/pdsCrcService.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/fakeBSP.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/buttons.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/leds.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/bspTaskManager.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/csPersistentMem.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/csMem.o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Obj/configServer.o -Wl,-\( ./../../../../BitCloud/lib/libHAL_AtmlStk600_Atmega128rfa1_8Mhz_Gcc.a ./../../../../BitCloud/lib/libBc_Coordinator_Sec_Atmega128rfa1_Atmega128rfa1_Gcc.a ./../../../../BitCloud/lib/WdtInitatmega128rfa1_Gcc.o -Wl,-\) -o Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Exe/WSNDemo.elf
`exit' referenced in section `.init9' of c:/program files/atmel/atmel studio 6.0/extensions/atmel/avrgcc/3.4.0.65/avrtoolchain/bin/../lib/gcc/avr/4.6.2/../../../../avr/lib/avr51/crtm128rfa1.o: defined in discarded section `.fini9' of c:/program files/atmel/atmel studio 6.0/extensions/atmel/avrgcc/3.4.0.65/avrtoolchain/bin/../lib/gcc/avr/4.6.2/avr51\libgcc.a(_exit.o)
collect2: ld returned 1 exit status
make: *** [Coordinator_Sec_Stk600_Atmega128rfa1_8Mhz_Gcc/Exe/WSNDemo.elf] Error 1
make: Leaving directory `C:/BitCloud_MEGARF_1_14_0/BitCloud_MEGARF_1_14_0/Applications/WSNDemo/makefiles/STK600'
Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "STK600.cproj" -- FAILED.
Done building project "STK600.cproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh yeah, you should not discard both *(.init9) and *(.fini*). So just remove /DISCARD/ section completely.

Thanks to trying it out.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

.initX section are from the standard library, at least first few of them are used, others can be used by the programmer. In particular .init9 contains call to main() after BSS initialization and this kind of stuff.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes - I removed the DISCARD section completely and
indeed it works! Very good!

For my own understanding, I could not find any code labelled 'init9' that calls main. Is the init9 section
in some library?

So to summarize, the linker in Studio 6 ignores the section .text.main?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, it is in the standard GCC library. Normally you would see something like this code in this section:

  // ...clear BSS...
  call    main
  jmp     _exit

main() never returns, obviously, so jump to _exit() is never executed. All this code could be removed if main() will be placed right after "clear BSS" part. But now main is never referenced and linker can throw it away. KEEP (*(.text.main)) instructs it not to throw it away, but for some reason linker ignores this.

This was a hack, obviously, but this behavior also means that something might be broken inside GCC.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok. So it is GCC bug, here it is: http://sourceware.org/bugzilla/show_bug.cgi?id=14265. BitCloud is officially released for AS5.1, where compiler is different.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to summarize:
In a linker script make following changes (add in green, delete in red):

Quote:

*(.init7)
KEEP (*(.init7))
*(.init8)
KEEP (*(.init8))
*(.init9)
KEEP (*(.init9))

*(.text)
*(.text.*)

/DISCARD/ :
{
*(.init9)
*(.fini*)
}

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.