0

TV B GONE Not working after reprogramming (attiny)
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

TV B GONE Not working after reprogramming (attiny)

by kandizzy on Sat Feb 10, 2018 11:59 pm

I would like to modify some of the codes sent from this device. Before modifying anything I wanted to make sure that I could reprogram the chip. So I got the firmware from Github here: https://github.com/adafruit/TV-B-Gone-kit After running
Code: Select all | TOGGLE FULL SIZE
make full
, all seems well. The fuses are set correctly.

However, after this build, the IR codes being sent are slightly condensed, and therefore not recognized. They are about 10-15% condensed.

Is there is something I'm missing?

Here is the output:

Code: Select all | TOGGLE FULL SIZE
make full
make burn-fuse
avrdude -p attiny85 -c usbtiny -B 250 -u -U lfuse:w:0xfd:m -U hfuse:w:0xdf:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e930b (probably t85)
avrdude: reading input file "0xfd"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xfd:
avrdude: load data lfuse data from input file 0xfd:
avrdude: input file 0xfd contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xdf"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xdf:
avrdude: load data hfuse data from input file 0xdf:
avrdude: input file 0xdf contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified

avrdude done.  Thank you.

make program

Creating load file for EEPROM: tvbgone.eep
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
   --change-section-lma .eeprom=0 -O ihex  tvbgone.elf tvbgone.eep
avr-objcopy: --change-section-lma .eeprom=0x0000000000000000 never used
avrdude -p attiny85 -c usbtiny -B 1 -U flash:w:tvbgone.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e930b (probably t85)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "tvbgone.hex"
avrdude: input file tvbgone.hex auto detected as Intel Hex
avrdude: writing flash (7948 bytes):

Writing | ################################################## | 100% 3.46s

avrdude: 7948 bytes of flash written
avrdude: verifying flash memory against tvbgone.hex:
avrdude: load data flash data from input file tvbgone.hex:
avrdude: input file tvbgone.hex auto detected as Intel Hex
avrdude: input file tvbgone.hex contains 7948 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 3.81s

avrdude: verifying ...
avrdude: 7948 bytes of flash verified

avrdude: safemode: Fuses OK (E:FF, H:DF, L:FD)

avrdude done.  Thank you.


And here is the correct Sony off code in green, and Sony off code in yellow with the new firmware

Screenshot 2018-02-10 22.54.57.png
Screenshot 2018-02-10 22.54.57.png (55.08 KiB) Viewed 1052 times

kandizzy
 
Posts: 11
Joined: Wed Feb 19, 2014 4:28 pm

Re: TV B GONE Not working after reprogramming (attiny)

by adafruit_support_carter on Mon Feb 12, 2018 1:54 pm

Just to be clear, green trace = signal using shipped firmware, yellow = signal using updated firmware

adafruit_support_carter
 
Posts: 5657
Joined: Tue Nov 29, 2016 2:45 pm

Re: TV B GONE Not working after reprogramming (attiny)

by kandizzy on Mon Feb 12, 2018 2:04 pm

Hello! Yes, that is correct. Further developments: compiling with an older version of avr-gcc on Windows without the `const` updates to the code works. I also tried compiling the latest version of the firmware with the `const` updates on ubuntu 14.04 and that also resulted in the condensed signal.

kandizzy
 
Posts: 11
Joined: Wed Feb 19, 2014 4:28 pm

Re: TV B GONE Not working after reprogramming (attiny)

by adafruit_support_carter on Mon Feb 12, 2018 2:09 pm

What are the const updates?

adafruit_support_carter
 
Posts: 5657
Joined: Tue Nov 29, 2016 2:45 pm

Re: TV B GONE Not working after reprogramming (attiny)

by kandizzy on Mon Feb 12, 2018 2:39 pm

Ah sorry, these are the changes:

on lines 82 and 83 of main.c, the one that works on the older version of avr-gcc looks like this:

Code: Select all | TOGGLE FULL SIZE
extern const PGM_P *NApowerCodes[] PROGMEM;
extern const PGM_P *EUpowerCodes[] PROGMEM;


To get it to compile on Mac OSX and Ubuntu 14.04 I had to change it to:

Code: Select all | TOGGLE FULL SIZE
extern const PGM_P * const NApowerCodes[] PROGMEM;
extern const PGM_P * const EUpowerCodes[] PROGMEM;


I also had to change lines 8229 and 8373 in WORLDCodes.c respectively to:

Code: Select all | TOGGLE FULL SIZE
const struct IrCode * const NApowerCodes[] PROGMEM = {
const struct IrCode * const EUpowerCodes[] PROGMEM = {


And here are all the outputs of the avr-gcc versions if it helps.

avr-gcc -v on Mac is:
avr-gcc (GCC) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.

avr-gcc -v on Ubuntu is:
Using built-in specs.
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/4.8.2/lto-wrapper
Target: avr
Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-libssp --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=avr
Thread model: single
gcc version 4.8.2 (GCC)

avr-gcc -v on Windows is:
Using built-in specs.
Target: avr
Configured with: ../gcc-4.3.3/configure --enable-win32-registry=WinAVR-20100110 --with-gmp=/usr/local --with-mpfr=/usr/local --prefix=/c/WinAVR --target=avr --enable-languages=c,c++,objc --with-dwarf2 --enable-doc --disable-shared --disable-libada --disable-libssp --disable-nls --with-pkgversion='WinAVR 20100110' --with-bugurl='URL:http://sourceforge.net/tracker/?atid=520074&group_id=68108&func=browse'
Thread model: single
gcc version 4.3.3 (WinAVR 20100110)

kandizzy
 
Posts: 11
Joined: Wed Feb 19, 2014 4:28 pm

Re: TV B GONE Not working after reprogramming (attiny)

by adafruit_support_carter on Mon Feb 12, 2018 2:51 pm

Instead of recompiling from the repo source, what if you just use the hex file that is already there? Just clone the repo (or extract the contents of the zip file) and then run:
Code: Select all | TOGGLE FULL SIZE
make program

adafruit_support_carter
 
Posts: 5657
Joined: Tue Nov 29, 2016 2:45 pm

Re: TV B GONE Not working after reprogramming (attiny)

by kandizzy on Mon Feb 12, 2018 2:58 pm

I think I tried that, and received the same results. But i tried so many things I don't remember, so let me get back to you shortly with a definitive answer.

kandizzy
 
Posts: 11
Joined: Wed Feb 19, 2014 4:28 pm

Re: TV B GONE Not working after reprogramming (attiny)

by kandizzy on Mon Feb 12, 2018 4:39 pm

I downloaded the zip you have linked in your post.

After running make program, these are the results on Mac OSX (It will be the same on Ubuntu)

Code: Select all | TOGGLE FULL SIZE
make program
set -e; avr-gcc -MM -mmcu=attiny85 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -DF_CPU=8000000 -Wa,-adhlns=util.lst  -std=gnu99 -DEU_CODES -DNA_CODES util.c \
   | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > util.d; \
   [ -s util.d ] || rm -f util.d
set -e; avr-gcc -MM -mmcu=attiny85 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -DF_CPU=8000000 -Wa,-adhlns=WORLDcodes.lst  -std=gnu99 -DEU_CODES -DNA_CODES WORLDcodes.c \
   | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > WORLDcodes.d; \
   [ -s WORLDcodes.d ] || rm -f WORLDcodes.d
set -e; avr-gcc -MM -mmcu=attiny85 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -DF_CPU=8000000 -Wa,-adhlns=main.lst  -std=gnu99 -DEU_CODES -DNA_CODES main.c \
   | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > main.d; \
   [ -s main.d ] || rm -f main.d

Compiling: main.c
avr-gcc -c -mmcu=attiny85 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -DF_CPU=8000000 -Wa,-adhlns=main.lst  -std=gnu99 -DEU_CODES -DNA_CODES main.c -o main.o
main.c:82:21: error: variable 'NApowerCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
 extern const PGM_P *NApowerCodes[] PROGMEM;
                     ^~~~~~~~~~~~
main.c:83:21: error: variable 'EUpowerCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
 extern const PGM_P *EUpowerCodes[] PROGMEM;
                     ^~~~~~~~~~~~
In file included from main.c:21:0:
main.c: In function 'main':
main.c:271:49: warning: passing argument 1 of 'putnum_uh' makes integer from pointer without a cast [-Wint-conversion]
       DEBUGP(putstring("\n\rAddr: "); putnum_uh(code_ptr));
                                                 ^
main.h:15:37: note: in definition of macro 'DEBUGP'
 #define DEBUGP(x) if (DEBUG == 1) { x ; }
                                     ^
In file included from main.c:22:0:
util.h:11:6: note: expected 'uint16_t {aka unsigned int}' but argument is of type 'const char *'
 void putnum_uh(uint16_t n);
      ^~~~~~~~~
make: *** [main.o] Error 1


Then I tried this command, and that flashed firmware that works fine.
Code: Select all | TOGGLE FULL SIZE
avrdude -c usbtiny -p attiny85 -U flash:w:tvbgone.hex


Then I fixed the above errors regarding const and ran make program again, and landed back at the same problem illustrated in the two signals above, where the signals are condensed and unrecognized.

kandizzy
 
Posts: 11
Joined: Wed Feb 19, 2014 4:28 pm

Re: TV B GONE Not working after reprogramming (attiny)

by adafruit2 on Thu Feb 15, 2018 7:05 pm

oof its been a long time since we wrote that code. one thing to check, are you sure you've got it set up to use the external oscillator? changing the fuses can make it use the internal one which isnt calibrated as much.

adafruit2
Site Admin
 
Posts: 16564
Joined: Fri Mar 11, 2005 7:36 pm

Re: TV B GONE Not working after reprogramming (attiny)

by kandizzy on Fri Feb 16, 2018 10:59 am

Yes, good point about the fuses. Spent a lot of time here http://www.engbedded.com/fusecalc The ones the original MakeFile is setting are still the best.

kandizzy
 
Posts: 11
Joined: Wed Feb 19, 2014 4:28 pm

Re: TV B GONE Not working after reprogramming (attiny)

by adafruit2 on Tue Feb 20, 2018 1:31 am

ok to clarify, if you use our compiled hex
https://github.com/adafruit/TV-B-Gone-k ... vbgone.hex
the codes are fine. its just when you compile the firmware, thats when it is compressed?
sounds like a compiler change. which happens a lot. can you use an earlier compiler? :(

adafruit2
Site Admin
 
Posts: 16564
Joined: Fri Mar 11, 2005 7:36 pm

Please be positive and constructive with your questions and comments.