AVRStudio7 Debugging a GCC Assembler Project

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

I am trying to use AVRStudio 7 to debug a simple program written as a GCC flavor Assembler File (.S)

Initially i will be using the Simulator, but eventually i will test on a target using debug wire.

 

Its very simple, No startup code, no standard libraries, no C code, its just a single file : main.S

 

I can compile it and start the simulator and step my code no problem, BUT the debugger shows "No Source File" for all the code and just shows a disassembly view.

How do I build my project such that the .S file is recognized as the Source when i debug, so that I can see the source I wrote and the generated assembler being debugged?

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

Look at how the GCC tools select debug information in a regular C project and how the linker retains it.
.
Or if you are really keen, you read ALL the Tool documentation.
It still comes down to the Linker flags.
.
Simple ASM projects are easier with the non-linking Atmel Assembler.
.
David.

Last Edited: Mon. Jul 17, 2017 - 07:31 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not near AS7 to check this but when AS7 invokes the assembler is it passing a -g option?

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

Here is the output of the build.

 

I am using GCC instead of AVR assembler, because I wrote this on Linux and will deploy it on Linux and production program from Linux.  But I am targeting an attiny9 which has no on chip debug capability and isn't supported by any open source simulators.  Which leaves me with running a VM and AtmelStudio, unfortunately.

 

I have managed to get my project to build and it can simulate,but I am getting the "No Source File" messages, yet the .lss file generated by this line:

"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "EskimoPi-AS.elf" > "EskimoPi-AS.lss"

 

clearly shows my source code intermixed with the dump, like so (extract):

0000026c <read_osccal_calibration>:
; ***************************************************************************
; * Read the OSCCAL Calibration value from flash, and if not valid, get the
; * HW Default from Calibration memory.
; * return it in rSCRATCH
read_osccal_calibration:
    ldif16      rXLO, rXHI, OSC_FINE_CAL        ; Get Address of Soft OSCCAL in
Flash
 26c:   ae e0           ldi     r26, 0x0E       ; 14
 26e:   b0 e4           ldi     r27, 0x40       ; 64
    ld          rSCRATCH, X+                    ; Read Flash OSCCAL Value
 270:   0d 91           ld      r16, X+
    ld          rSCRATCH2, X                    ; Read Flash OSCCAL Check Value
 272:   2c 91           ld      r18, X
    eor         rSCRATCH2, rSCRATCH             ; Calculate Check digit result.
 274:   20 27           eor     r18, r16
    cpi         rSCRATCH2, OSCCAL_CHECKVALUE    ; Is it valid?
 276:   2a 35           cpi     r18, 0x5A       ; 90
    breq        osccal_calibration_read         ; yes, so return it.
 278:   19 f0           breq    .+6             ; 0x280 <osccal_calibration_read
>
    read_signature_osccal  rSCRATCH             ; No, so get Hardware default
 27a:   a0 e8           ldi     r26, 0x80       ; 128
 27c:   bf e3           ldi     r27, 0x3F       ; 63
 27e:   0c 91           ld      r16, X

00000280 <osccal_calibration_read>:
osccal_calibration_read:
    ret                                         ; Finished - rSCRATCH = Current
Software OSCCAL Value
 280:   08 95           ret

 

The build ALSO shows that the Debug switches are being passed to the assembler and linker, and if i objdump the .elf file it creates manually I can see the debug data in the .Elf.  So this seems to be less of a problem with the Debug data not being present and more of a problem that Atmel Studio cant read it somehow.??

 

This is the Build Log:

 

------ Rebuild All started: Project: EskimoPi-AS, Configuration: Debug AVR ------

Build started.

Project "EskimoPi-AS.cproj" (default targets):

Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').

Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "c:\users\atmel-vm\Documents\Atmel Studio\7.0\EskimoPi-AS\EskimoPi-AS\EskimoPi-AS.cproj" (target "Build" depends on it):

Task "RunCompilerTask"

Shell Utils Path C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils

C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils\make.exe all --jobs 4 --output-sync 

Building file: .././main.S

Invoking: AVR/GNU Assembler : 5.4.0

"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe" -Wa,-gdwarf2 -x assembler-with-cpp -c -mmcu=attiny9 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\gcc\dev\attiny9" -I "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\include"  -v -MD -MP -MF "main.d" -MT"main.d" -MT"main.o" -Wa,-g   -o "main.o" ".././main.S" 

Finished building: .././main.S

Using built-in specs.

Reading specs from C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.2.118/gcc/dev/attiny9/device-specs/specs-attiny9

COLLECT_GCC=C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe

Target: avr

Configured with: /home/toolsbuild/workspace/avr8-gnu-toolchain/src/gcc/configure LDFLAGS=-L/home/toolsbuild/workspace/avr8-gnu-toolchain/avr8-gnu-toolchain-win32_x86-hostlibs/lib CPPFLAGS= --target=avr --host=i686-w64-mingw32 --build=x86_64-pc-linux-gnu --prefix=/home/toolsbuild/workspace/avr8-gnu-toolchain/avr8-gnu-toolchain-win32_x86 --libdir=/home/toolsbuild/workspace/avr8-gnu-toolchain/avr8-gnu-toolchain-win32_x86/lib --enable-languages=c,c++ --with-dwarf2 --enable-doc --disable-shared --disable-libada --disable-libssp --disable-nls --with-avrlibc=yes --with-mpfr=/home/toolsbuild/workspace/avr8-gnu-toolchain/avr8-gnu-toolchain-win32_x86-hostlibs --with-gmp=/home/toolsbuild/workspace/avr8-gnu-toolchain/avr8-gnu-toolchain-win32_x86-hostlibs --with-mpc=/home/toolsbuild/workspace/avr8-gnu-toolchain/avr8-gnu-toolchain-win32_x86-hostlibs --enable-win32-registry=avrtoolchain --with-pkgversion=AVR_8_bit_GNU_Toolchain_3.6.0_1734 --with-bugurl=http://www.atmel.com

Thread model: single

gcc version 5.4.0 (AVR_8_bit_GNU_Toolchain_3.6.0_1734) 

COLLECT_GCC_OPTIONS='-c'  '-B' 'C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\gcc\dev\attiny9' '-I' 'C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\include' '-v' '-MD' '-MP' '-MF' 'main.d' '-MT' 'main.d' '-MT' 'main.o' '-o' 'main.o' '-specs=device-specs/specs-attiny9' '-mmcu=avrtiny'

c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../libexec/gcc/avr/5.4.0/cc1.exe -E -lang-asm -quiet -v -I C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\include -imultilib avrtiny -iprefix c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\../lib/gcc/avr/5.4.0/ -MD main.d -MF main.d -MP -MT main.d -MT main.o -D__AVR_ATtiny9__ -D__AVR_DEVICE_NAME__=attiny9 -D__AVR_DEV_LIB_NAME__=tn9 .././main.S -mn-flash=1 -mno-skip-bug -mmcu=avrtiny -fno-directives-only -o C:\Users\Atmel-VM\AppData\Local\Temp\ccjYjTsd.s

ignoring nonexistent directory "c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\../lib/gcc/avr/5.4.0/../../../../avr/sys-include"

ignoring duplicate directory "c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/lib/gcc/../../lib/gcc/avr/5.4.0/include"

ignoring duplicate directory "c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/lib/gcc/../../lib/gcc/avr/5.4.0/include-fixed"

ignoring nonexistent directory "c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/lib/gcc/../../lib/gcc/avr/5.4.0/../../../../avr/sys-include"

ignoring duplicate directory "c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/lib/gcc/../../lib/gcc/avr/5.4.0/../../../../avr/include"

#include "..." search starts here:

#include <...> search starts here:

C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\include

c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\../lib/gcc/avr/5.4.0/include

c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\../lib/gcc/avr/5.4.0/include-fixed

c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\../lib/gcc/avr/5.4.0/../../../../avr/include

End of search list.

COLLECT_GCC_OPTIONS='-c'  '-B' 'C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\gcc\dev\attiny9' '-I' 'C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\include' '-v' '-MD' '-MP' '-MF' 'main.d' '-MT' 'main.d' '-MT' 'main.o' '-o' 'main.o' '-specs=device-specs/specs-attiny9' '-mmcu=avrtiny'

c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/as.exe -mmcu=avrtiny -mno-skip-bug -gdwarf2 -g -o main.o C:\Users\Atmel-VM\AppData\Local\Temp\ccjYjTsd.s

COMPILER_PATH=C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.2.118/gcc/dev/attiny9/;c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../libexec/gcc/avr/5.4.0/;c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../libexec/gcc/;c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/

LIBRARY_PATH=C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.2.118/gcc/dev/attiny9/avrtiny/;c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avrtiny/;c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/avrtiny/;C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.2.118/gcc/dev/attiny9/;c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/;c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/;c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/

COLLECT_GCC_OPTIONS='-c'  '-B' 'C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\gcc\dev\attiny9' '-I' 'C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\include' '-v' '-MD' '-MP' '-MF' 'main.d' '-MT' 'main.d' '-MT' 'main.o' '-o' 'main.o' '-specs=device-specs/specs-attiny9' '-mmcu=avrtiny'

Building target: EskimoPi-AS.elf

Invoking: AVR/GNU Linker : 5.4.0

"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe" -o EskimoPi-AS.elf  main.o   -nostartfiles -nodefaultlibs -nostdlib -Wl,-static -Wl,-Map="EskimoPi-AS.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mmcu=attiny9 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.2.118\gcc\dev\attiny9"  

Finished building target: EskimoPi-AS.elf

"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures  "EskimoPi-AS.elf" "EskimoPi-AS.hex"

"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom  --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0  --no-change-warnings -O ihex "EskimoPi-AS.elf" "EskimoPi-AS.eep" || exit 0

"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "EskimoPi-AS.elf" > "EskimoPi-AS.lss"

"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O srec -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "EskimoPi-AS.elf" "EskimoPi-AS.srec"

"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "EskimoPi-AS.elf"

  text   data    bss    dec    hex filename

   642     10      0    652    28c EskimoPi-AS.elf

Done executing task "RunCompilerTask".

Task "RunOutputFileVerifyTask"

Program Memory Usage : 652 bytes   63.7 % Full

Data Memory Usage : 10 bytes   31.3 % Full

Done executing task "RunOutputFileVerifyTask".

Done building target "CoreBuild" in project "EskimoPi-AS.cproj".

Target "PostBuildEvent" skipped, due to false condition; ('$(PostBuildEvent)' != '') was evaluated as ('' != '').

Target "Build" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Avr.common.targets" from project "c:\users\atmel-vm\Documents\Atmel Studio\7.0\EskimoPi-AS\EskimoPi-AS\EskimoPi-AS.cproj" (entry point):

Done building target "Build" in project "EskimoPi-AS.cproj".

Done building project "EskimoPi-AS.cproj".

 

Build succeeded.

========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

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

Well, its weird.

 

I added :

 

.section .vectors,"ax",@progbits

 

before the vector table, so that i could keep section garbage collection on in the linker, and now my code in the .text section has line source information in the debugger.

 

There is no debug information in the .vectors section, but i can live with that.

 

Its weird, I don't see how adding a .vectors section can allow the debugger to suddenly see debug information in the .text section. Yet, that's all i changed.