Found a bug using included files

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

Studio 7.0.1645

 

This is an odd one that had me clawing what was left of my hair out!

 

I have this assembly file included in my program...

 

// INCLUDE USER CODE
#include "Ball Demo.asm"

 

I also have both the main application and this included file open side by side.

If I make changes to the included file and upload, the changes are not written to the program memory.

 

There are only 2 ways to make the changes work...

 

1) Close AS7 and reopen the project.

2) Insert any character in the included name, then delete it!

 

Yeah... if I simply add a space after Ball Demo, then erase that space, the project then compiles with the changes.

 

This is a caching bug of some sort, that I am sure of.

I first considered blaming Bill Gates, but then I found the #2 solution, which puts the blame back here.

 

Any ideas?

Cheers,

Brad

 

I Like to Build Stuff : http://www.AtomicZombie.com

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

Isn't this a classic make problem ?

ie If you edit anywhere in the main file, does that also work ?

 

If the build system does not 'see' the include file, any change to only the include file will skip build.

- These days, with  PC speeds, 'smart' make is pretty much redundant as a build all is no different in speed (and guaranteed to give a fresh HEX every time !)

 

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

How did you add the included file to the project?

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Wed. Mar 7, 2018 - 07:57 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Odd, yes I can add white space (then delete) in the main file and that also fixes the bug.

I added the file using the line shown above.

Make?... I don't use C and know nothing of such things.

 

What I do know is that I have been doing this the same way since 2002, and never had this issue until this morning.

Nothing has changed on this project since 2 years ago, and I was doing fun until a few hours ago.

Tried the obvious things... reboot, different system, shaved a yak, etc.

 

No big deal, just that this is the first time in 16 years of using studio (the same way) that this has happened.

 

Thanks,

Brad

I Like to Build Stuff : http://www.AtomicZombie.com

Last Edited: Wed. Mar 7, 2018 - 08:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Actually, here is one small difference... I don't have a main.s file this time, just two files...

 

Core.s (the main system)

Ball Demo.s (the included user code)

 

Does AS7 have a "C" kind of mind that may force me to call my driver main.s again?

It's such an ugly name.

 

I do have this in the Core.s file...

 

.global main

main:

 

Also note that there is no error thrown, it just fails to add changes when I compile and load without the "change anything" fix.

 

Brad

 

I Like to Build Stuff : http://www.AtomicZombie.com

Last Edited: Wed. Mar 7, 2018 - 08:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ball Demo.s (the included user code)

But is that part of the project?  Or have you simply #include'd it in Core.s?

 

If the latter, make (which AS7 uses to build your project... make is not C-centric, it can be used to build [or do] anything!) would have no idea that a change to Ball Demo.s would require a rebuild of Core.s.

 

By the way Brad, my days have gotten away from me and I haven't yet been to the shop to see if they have a 40 MHz osc.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Wed. Mar 7, 2018 - 08:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No problem, I am continuing to comment and imporve the code.

Will be cool to finally see it running outside my basement lab.

 

Not sure that you mean by "part of the project".

I just usually add the #include line, and that's it.

 

I can even see the file in "dependencies", so that proves that AS7 is aware of it.

 

Maybe I will just rename Core.s back to main.s to see if that was the issue.

 

Brad

I Like to Build Stuff : http://www.AtomicZombie.com

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

Update...

 

Yes, renaming Core.s to Main.s fixes the "I forgot about your include" bug.

 

Not sure why that would cause the issue, but I have a feeling the letter C is going to have something to do with it!

 

For now, I will just continue to hit space and delete before compile... I don't like being told how to name my files.

 

Brad

 

I Like to Build Stuff : http://www.AtomicZombie.com

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

but I have a feeling the letter C is going to have something to do with it

You're a bigot! ;-)

 

No, C has nothing to do with it.  Rather, it would be AS7's default makefile structure.  I'm not an AS7 user, so I can't really comment on exactly what is going on, but I'd have a look at the auto-generated makefile for each (with main.s and without main.s), you'll likely get a clue what the difference is.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

AtomicZombie wrote:

Update...

 

Yes, renaming Core.s to Main.s fixes the "I forgot about your include" bug.

 

Not sure why that would cause the issue, but I have a feeling the letter C is going to have something to do with it!

 

For now, I will just continue to hit space and delete before compile... I don't like being told how to name my files.

 

A classic case of trying to be too clever...

And, of course, thinking "everyone uses C, we do not need to test anything else.."  (sigh)

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

I may just do a little digging when I have time.

 

But I am still calling it a bug either way.

An IDE that allows you to edit and even save a file, yet refuses to compile those changes until a restart is not normal.

If it threw an error, that I could understand, but it leaves the programmer to believe that the compile was a success.

 

I think it is caching the file in ram, and forgets about it until something changes in the text window (even whitespace!).

 

Maybe there is a "safeguard?" against non C programmers?

AS7 looks for a startup called main, and if it does not exist assumes you are insane and blocks you from editing code.

 

... just kidding in case that sounded serious.

 

Brad

 

 

 

Who-me wrote:

AtomicZombie wrote:

Update...

 

Yes, renaming Core.s to Main.s fixes the "I forgot about your include" bug.

 

Not sure why that would cause the issue, but I have a feeling the letter C is going to have something to do with it!

 

For now, I will just continue to hit space and delete before compile... I don't like being told how to name my files.

 

A classic case of trying to be too clever...

And, of course, thinking "everyone uses C, we do not need to test anything else.."  (sigh)

I Like to Build Stuff : http://www.AtomicZombie.com

Last Edited: Wed. Mar 7, 2018 - 09:27 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think it is caching the file in ram, and forgets about it until something changes in the text window (even whitespace!).

Unlikely.  As I said, the auto-generated makefile is likely to blame.  While AS7 may be aware of your file as a dependency, it seems clear it hasn't encoded that information into the makefile.

 

You could likely simply 'touch' the file from the command line, and it would build correctly.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

AtomicZombie wrote:

But I am still calling it a bug either way.

Yes, certainly less than ideal Assembler project operation.

 

AtomicZombie wrote:

An IDE that allows you to edit and even save a file, yet refuses to compile those changes until a restart is not normal.

If it threw an error, that I could understand, but it leaves the programmer to believe that the compile was a success.

 

I think it is caching the file in ram, and forgets about it until something changes in the text window (even whitespace!).

Usually, IDEs have a save before compile step. (you could check that via file timestamps)

 

It's likely the C-tested-make that is the issue, rather than a cache.  

There, if it thinks the Binary is not older than the source, it does nothing.

Somewhere, a 'nothing to do' message will be generated, but it may not make it to a GUI.

 

There may be some way to disable such 'intelligence' and force a save-build-all every time ?

Or, you may be able to find the make file for this project and manually edit it to add the file names you are using.

 

 

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

Ok, I saved two version of the project...

 

1) Main.s with #include "UserCode.s"

2) Core.s with #include "UserCode.s"

 

I also had my first look at that make file mess, and in both files there is no reference to UserCode.s

 

Here is make from the version that actually remembers that I typed something...

 

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

SHELL := cmd.exe
RM := rm -rf

USER_OBJS :=

LIBS := 
PROJ := 

O_SRCS := 
C_SRCS := 
S_SRCS := 
S_UPPER_SRCS := 
OBJ_SRCS := 
ASM_SRCS := 
PREPROCESSING_SRCS := 
OBJS := 
OBJS_AS_ARGS := 
C_DEPS := 
C_DEPS_AS_ARGS := 
EXECUTABLES := 
OUTPUT_FILE_PATH :=
OUTPUT_FILE_PATH_AS_ARGS :=
AVR_APP_PATH :=$$$AVR_APP_PATH$$$
QUOTE := "
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:=
LIB_DEP:=
LINKER_SCRIPT_DEP:=

# Every subdirectory with source files must be described here
SUBDIRS := 


# Add inputs and outputs from these tool invocations to the build variables 
C_SRCS += 


PREPROCESSING_SRCS +=  \
../Main.s


ASM_SRCS += 


OBJS +=  \
Main.o

OBJS_AS_ARGS +=  \
Main.o

C_DEPS +=  \
Main.d

C_DEPS_AS_ARGS +=  \
Main.d

OUTPUT_FILE_PATH +=Quark-85\ VGA.elf

OUTPUT_FILE_PATH_AS_ARGS +="Quark-85 VGA.elf"

ADDITIONAL_DEPENDENCIES:=

OUTPUT_FILE_DEP:= ./makedep.mk

LIB_DEP+= 

LINKER_SCRIPT_DEP+= 


# AVR32/GNU C Compiler



# AVR32/GNU Preprocessing Assembler



# AVR32/GNU Assembler
./Main.o: .././Main.s
	@echo Building file: $<
	@echo Invoking: AVR/GNU Assembler : 5.4.0
	$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -Wa,-gdwarf2 -x assembler-with-cpp -c -mmcu=attiny85 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.0.71\gcc\dev\attiny85" -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -Wa,-g   -o "$@" "$<" 
	@echo Finished building: $<
	


./%.o: .././%.s
	@echo Building file: $<
	@echo Invoking: AVR/GNU Assembler : 5.4.0
	$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -Wa,-gdwarf2 -x assembler-with-cpp -c -mmcu=attiny85 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.0.71\gcc\dev\attiny85" -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -Wa,-g   -o "$@" "$<" 
	@echo Finished building: $<
	




ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif

# Add inputs and outputs from these tool invocations to the build variables 

# All Target
all: $(OUTPUT_FILE_PATH) $(ADDITIONAL_DEPENDENCIES)

$(OUTPUT_FILE_PATH): $(OBJS) $(USER_OBJS) $(OUTPUT_FILE_DEP) $(LIB_DEP) $(LINKER_SCRIPT_DEP)
	@echo Building target: $@
	@echo Invoking: AVR/GNU Linker : 5.4.0
	$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -Wl,-Map="Quark-85 VGA.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mmcu=attiny85 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.0.71\gcc\dev\attiny85"  
	@echo Finished building target: $@
	"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  "Quark-85 VGA.elf" "Quark-85 VGA.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 "Quark-85 VGA.elf" "Quark-85 VGA.eep" || exit 0
	"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "Quark-85 VGA.elf" > "Quark-85 VGA.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 "Quark-85 VGA.elf" "Quark-85 VGA.srec"
	"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "Quark-85 VGA.elf"
	
	





# Other Targets
clean:
	-$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES)  
	-$(RM) $(C_DEPS_AS_ARGS)   
	rm -rf "Quark-85 VGA.elf" "Quark-85 VGA.a" "Quark-85 VGA.hex" "Quark-85 VGA.lss" "Quark-85 VGA.eep" "Quark-85 VGA.map" "Quark-85 VGA.srec" "Quark-85 VGA.usersignatures"
	

 

I think I may just go back to looking up instruction values and typing them into a sector editor.

 

Brad

 

I Like to Build Stuff : http://www.AtomicZombie.com

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

I also had my first look at that make file mess, and in both files there is no reference to UserCode.s

That is as expected, since you haven't added that file to the project, but only #include'd it into another file.

 

There is an explicit recipe for Main.o dependent upon Main.s, and a catch-all recipe for other .o/.s dependencies.  Maybe AS7 auto-saves any files called Main.s, but doesn't do so for other files? 

 

There is also PREPROCESSING_SRCS which is defined as ../Main.s.  I can find no useful reference to that makefile variable.  Perhaps it's an AS thing whereby any files named therein are re-built regardless of the timestamp on the file?

 

What happens if you just do a 'clean build' or whatever AS7 calls it?

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

I did a bit more testing, and found that the only way to have AS7 assemble changes in my included file is to have a file called main.s or Main.s as the file that actually includes the "main:" global address.

The odd bug remains... simply hit space, then delete in the file (if it is not names main.s), and then AS7 wakes up and remembers to assemble the include file changes.

 

Even with the other file being added to the project like this, it still gets ignored after the first assemble...

 

 

In the project shown above, Q85 Core.s contains this...

 

.global main
main:

#include "Ball Demo.asm"

On first load, I can assemble normally.

If I change anything in Ball Demo, everything will assemble error free, but no changes are written from Ball Demo.

 

A workaround is to either reload the project, or add anything (even white-space) to Core.s

The other workaround is to just call the startup file Main.s.

 

For now, I am just going to go back to calling the startup file Main.s

 

Brad

 

 

 

 

I Like to Build Stuff : http://www.AtomicZombie.com

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

wonder....

 

what does happen when you make the extension ".asm" instead of ".s"

 

thought that when you do an assembler project you need to have the .asm extension  and that the .S extension was for C projects....

But it has been ages since I have done any assembler projects so might have been messing up things in the mean time.

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

Didn't there used to be a "bug" in AS that prevented the use of file or directory names with spaces? Try changing Ball Demo.asm to Ball_Demo.asm. Maybe it is fixed by now, but I have not heard one way or the other or have forgotten it (latter being the most likely, of course).

 

Jim

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Fri. Mar 9, 2018 - 07:03 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try changing Ball Demo.asm to Ball_Demo.asm.

He's had the same trouble with UserCode.s

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Thanks for the ideas.

Tried everything above, and the bug still remains.

 

The only fix is to call the start file Main.s or press any key in the startup file before assemble.

 

At least I don't have to put a semicolon after every instruction... just trying to see the positive here!

 

Brad

I Like to Build Stuff : http://www.AtomicZombie.com

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

Brad,

 

not sure if ti will help, but just noticed this:

 

My main.asm is set as "entry file" It has a special icon in front of it.

You might need to make your main project file like this.....