Trouble compiling firmware

Get help and show off your TV-B-Gone kit!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
zimmerleut
 
Posts: 2
Joined: Sat Apr 14, 2012 1:42 pm

Trouble compiling firmware

Post by zimmerleut »

Hi, I tried to compile firmware 1.2 on my system (set up according to instructions here: http://www.nongnu.org/avr-libc/user-man ... tools.html, with gcc 4.6.3 (also tested: 4.7.0), avr-libc 1.8.0, binutils 2.22).
Running make, I get this error message:

Code: Select all

avr-gcc (GCC) 4.6.3
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))'
main.c:83:21: error: variable 'EUpowerCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
main.c: In function 'main':
main.c:271:7: warning: passing argument 1 of 'putnum_uh' makes integer from pointer without a cast [enabled by default]
util.h:11:6: note: expected 'uint16_t' but argument is of type 'const char *'
make: *** [main.o] Error 1
What configuration did you use to compile the firmware, and do you have hints how to fix this?
Thanks,
Jonas

User avatar
zimmerleut
 
Posts: 2
Joined: Sat Apr 14, 2012 1:42 pm

Re: Trouble compiling firmware

Post by zimmerleut »

So .. Can anyone confirm a set up under which the firmware will compile?

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Trouble compiling firmware

Post by adafruit_support_bill »

I don't know the configuration under which it was originally built, but from the error messages, it appears that your environment is applying more strict rules with respect to const variables in read-only memeory. You could figure out what compiler option is controlling that, or just add the const attribute to the places it is complaining about.

User avatar
kscharf
 
Posts: 277
Joined: Wed Sep 10, 2008 10:29 am

Re: Trouble compiling firmware

Post by kscharf »

Just saw this, same problem I'm having.

OK it now works.
I am running Linux Mint version 13 with KDE.
I had installed the avr toolset from Atmel, and had compile issues.
I unzipped a fresh copy of the TVBGone firmware and installed the version(s) of avr-tools from the Mint package repository with GCC version 4.6.2.
I then ran the makefile and the previous problems were gone.

If you are trying to compile on a 'buntu based Linux distro just get the latest versions of the avr tools from the repository with synatpic.
If you are on windows, try the 2010 version of Winavr. Ohterwise you are stuck with using either the toolset from arduino, or from Atmel. Those are the ones I have had issues with (but on Linux).

Aleks
 
Posts: 1
Joined: Tue Jan 15, 2013 3:46 pm

Re: Trouble compiling firmware

Post by Aleks »

zimmerleut wrote:Hi, I tried to compile firmware 1.2 on my system (set up according to instructions here: http://www.nongnu.org/avr-libc/user-man ... tools.html, with gcc 4.6.3 (also tested: 4.7.0), avr-libc 1.8.0, binutils 2.22).


What configuration did you use to compile the firmware, and do you have hints how to fix this?
Thanks,
Jonas
This is cos' of the new way that GCC-4.6 (and later) interpret the PROGMEM variables, it's documented here : http://gcc.gnu.org/gcc-4.6/changes.html#avr

I made a small patch that fixes this *bug* on gcc-4.7.2, binutils-2.23 :

firmware_v1.2_gcc-4.7.2.patch :

Code: Select all


Regards,
Aleks
diff -Naur fw_v1.2-old/main.c fw_v1.2-new/main.c
--- fw_v1.2-old/main.c	2009-08-16 21:48:34.000000000 +0200
+++ fw_v1.2-new/main.c	2013-01-15 20:45:52.479525370 +0100
@@ -79,8 +79,8 @@
 
 
 
-extern const PGM_P *NApowerCodes[] PROGMEM;
-extern const PGM_P *EUpowerCodes[] PROGMEM;
+extern const PGM_P * const NApowerCodes[] PROGMEM;
+extern const PGM_P * const EUpowerCodes[] PROGMEM;
 extern const uint8_t num_NAcodes, num_EUcodes;
 
 
diff -Naur fw_v1.2-old/WORLDcodes.c fw_v1.2-new/WORLDcodes.c
--- fw_v1.2-old/WORLDcodes.c	2009-08-16 21:50:24.000000000 +0200
+++ fw_v1.2-new/WORLDcodes.c	2013-01-15 20:47:04.919538679 +0100
@@ -8226,7 +8226,7 @@
 ////////////////////////////////////////////////////////////////
 
 
-const struct IrCode *NApowerCodes[] PROGMEM = {
+const struct IrCode * const NApowerCodes[] PROGMEM = {
 #ifdef NA_CODES
 	&code_na000Code,
 	&code_na001Code,
@@ -8370,7 +8370,7 @@
 #endif
 }; 
 
-const struct IrCode *EUpowerCodes[] PROGMEM = {
+const struct IrCode * const EUpowerCodes[] PROGMEM = {
 #ifdef EU_CODES
         &code_eu000Code,
 	&code_eu001Code,
Regards,
Aleks

User avatar
davidbradway
 
Posts: 1
Joined: Thu Sep 26, 2013 4:57 pm

Re: Trouble compiling firmware

Post by davidbradway »

Aleks when I try your patch, I get:

Code: Select all

FloraTVB2.ino:84:1: error: duplicate ‘const’
FloraTVB2.ino:85:1: error: duplicate ‘const’
It doesn't seem to like the two 'const' definitions on these lines I edited:

Code: Select all

extern const PGM_P * const NApowerCodes[] PROGMEM;
extern const PGM_P * const EUpowerCodes[] PROGMEM;
Thanks in advance.

User avatar
lightningstalker
 
Posts: 1
Joined: Thu Dec 26, 2013 6:54 am

Re: Trouble compiling firmware

Post by lightningstalker »

Trying to cut and paste the above code was a major pain in my ass.
Here is a new patch done the right way, in binary form.
If you want to do something right, you have to do it yourself.
Attachments
TVBGone.tar.bz2
(560 Bytes) Downloaded 199 times
TVBGone.zip
(541 Bytes) Downloaded 296 times

User avatar
i.gavriljev
 
Posts: 1
Joined: Tue Jan 07, 2014 9:04 am

Re: Trouble compiling firmware

Post by i.gavriljev »

Hello.
I'm trying to write a firmware to Attiny with my arduino uno. So I added libraries : "BANNED_firmwarev12' and 'include' from avr-libc-1.8.0. and added them to the sketch.

Code: Select all

 #include <alloca.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <math.h>
#include <setjmp.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <main.h>
#include <util.h> 
I receive an error :
main.c: In function 'main':
main.c:338: error: 'for' loop initial declaration used outside C99 mode

I'm a very beginner in programming. Can you help me with step-by-step what to do, where to download, where to put, what to write etc?

Locked
Please be positive and constructive with your questions and comments.

Return to “TV-B-Gone Kit”