Complile error

Hi,

I have built a shrimpkey board (fromScratchEd.nl) and Im using a cp2104 module and arduino to try and program it.

I am getting the errors detailed at the bottom of this post.
I get the same errors whether or not I have the module plugged in and the same errors when I try to program the board from a PC.

This is time critical for a project so any help would be greatly appreciated.

Thanks
Brian


Arduino: 1.6.8 (Mac OS X), Board: "Arduino/Genuino Uno"

In file included from /Users/brian/Desktop/shrimpkey/ShrimpKey-master/ShrimpKey/ShrimpKey.ino:3:0:
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/usbdrv.h:479:26: error: variable 'usbDescriptorDevice' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char usbDescriptorDevice[];
^
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/usbdrv.h:485:33: error: variable 'usbDescriptorConfiguration' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char usbDescriptorConfiguration[];
^
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/usbdrv.h:491:29: error: variable 'usbDescriptorHidReport' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char usbDescriptorHidReport[];
^
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/usbdrv.h:497:27: error: variable 'usbDescriptorString0' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char usbDescriptorString0[];
^
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/usbdrv.h:503:31: error: variable 'usbDescriptorStringVendor' must be const in order to be put into read-only section by means of 'attribute((progmem))'
int usbDescriptorStringVendor[];
^
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/usbdrv.h:509:31: error: variable 'usbDescriptorStringDevice' must be const in order to be put into read-only section by means of 'attribute((progmem))'
int usbDescriptorStringDevice[];
^
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/usbdrv.h:515:37: error: variable 'usbDescriptorStringSerialNumber' must be const in order to be put into read-only section by means of 'attribute((progmem))'
int usbDescriptorStringSerialNumber[];
^
In file included from /Users/brian/Desktop/shrimpkey/ShrimpKey-master/ShrimpKey/ShrimpKey.ino:4:0:
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:36:39: error: variable 'usbDescriptorHidReport' must be const in order to be put into read-only section by means of 'attribute((progmem))'
PROGMEM char usbHidReportDescriptor[35] = { /* USB report descriptor */
^
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '161' from 'int' to 'char' inside { } [-Wnarrowing]
};
^
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '224' from 'int' to 'char' inside { } [-Wnarrowing]
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '231' from 'int' to 'char' inside { } [-Wnarrowing]
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '149' from 'int' to 'char' inside { } [-Wnarrowing]
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '129' from 'int' to 'char' inside { } [-Wnarrowing]
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '149' from 'int' to 'char' inside { } [-Wnarrowing]
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '129' from 'int' to 'char' inside { } [-Wnarrowing]
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '192' from 'int' to 'char' inside { } [-Wnarrowing]
exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

can you show us the sketch please?

Did you try just making the variables const? :slight_smile:

brenden_nerd_:
can you show us the sketch please?

I'm a noob, you may have to be more specific. Is the sketch the program itself? If so is that the settings.h file?

aarg:
Did you try just making the variables const? :slight_smile:

This is my first project. I am trying to build a makeymakey equivalent downloaded from 'fromScratchEd.nl and really have little idea of what I am doing - just trying to follow instructions to the letter.

For each line of the error I tried a fix that I thought was logical. For example, as a result of the following error

/Users/brian/Documents/Arduino/libraries/UsbKeyboard/usbdrv.h:479:26: error: variable 'usbDescriptorDevice' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char usbDescriptorDevice[];

I opened the usbdrv.h program with a text editor and changed usbDescriptorDevice[] to usbDescriptorDevice[1]

I did this for each on the "const" messages and tried to load the program again but got the same error.

I really appreciate you guys helping me out with this.

Hi,

Can you please post a copy of your sketch, using code tags?
Please use code tags.. See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html
You sketch is your program that you have written in the IDE.

A link to "shrimpkey board " would also be helpful.
What model arduino are you using.

Thanks.. Tom.. :slight_smile:

First thing is to remove your alterations from the "usbdrv.h" file.

Second, you could try what aarg suggests. ie add 'const' to the beginning to each of the offending lines in the library files.

....10 minutes later....
I just did that, and got it all to compile OK with the provided example.
(I compiled for UNO, with IDE V1.6.5)

Three files need to be modified:-
"usbdrv.h"
"usbdrv.c"
"UsbKeyboard.h"

There are no changes needed to the "Shrimpkey.ino" or "settings.h" files, just the above-mentioned files from the "UsbKeyboard" library.

In the three files I listed above, everywhere that there's a "PROGMEM", you need to add "const" before the variable type name.

Or, since I've already done it once, you could back up your current library files just in case, then replace them with the three modified ones that I've attached at the bottom of this post.

UsbKeyboard.h (6.42 KB)

usbdrv.c (24.1 KB)

usbdrv.h (30.5 KB)

For anyone else that's following this thread, here are the "Shrimpkey.ino" and "settings.h" files, (attached - they're too big to post).

And a link to the "Shrimpkey" files:- ShrimpKey

settings.h (1.55 KB)

ShrimpKey.ino (10.2 KB)

TomGeorge:
What model arduino are you using.

Tom, it's not an Arduino as such, it's this board:-

Boy, the response in here is great. Each time I try to post it tells me that there are more posts.
I replaced the files with the modified ones (Thank you so much) and got past the first errors but had some others. I then downloaded definitions through the Boards Manager for 1.6.5 (I was using 1.6.10)

The program looks like it's uploading with 5 warning messages. It's been going 5 minutes. How long should it take?

ozbrian:
Boy, the response in here is great. Each time I try to post it tells me that there are more posts.
I replaced the files with the modified ones (Thank you so much) and got past the first errors but had some others. I then downloaded definitions through the Boards Manager for 1.6.5 (I was using 1.6.10)

The program looks like it's uploading with 5 warning messages. It's been going 5 minutes. How long should it take?

I didn't mean "Arduino AVR Boards" version 1.6.5, I meant that I'm using Arduino IDE V1.6.5. (Looking back, that's exactly what I said:-

(I compiled for UNO, with IDE V1.6.5)

I'm using "Arduino AVR Boards" version 1.6.8.
(You shouldn't need to change your AVR boards version for the code to compile. I only mentioned the IDE version I'm using for your extra information. I didn't say you should change your AVR board definitions.)
Edit: It is possible that you're still experiencing a version problem, since this library code is very old. IDE versions V1.6.6, V1.6.7 and V1.6.8 have had some issues. That's why I've stuck with V1.6.5.

Rather than make more unnecessary changes, perhaps you should have simply posted your later error messages.

It shouldn't take more than a few seconds to upload.
I have no idea what you've done now. What are the warning messages?
I just re-compiled with "verbose outout" enabled, and still get no warnings or errors. It compiles exactly as it should:-

Sketch uses 3,772 bytes (11%) of program storage space. Maximum is 32,256 bytes.
Global variables use 214 bytes (10%) of dynamic memory, leaving 1,834 bytes for local variables. Maximum is 2,048 bytes.

This is becoming far harder than it should have been. Have you tested the "Blink" example with your board yet?

Please excuse my ignorance. I am sorry that this is frustrating and I know that is my fault.
This is a music assignment - I am not a programmer.

I am using Arduino 1.6.8
I am now using Arduino built in boards version 1.6.10 (board = Arduino\Genuino Uno)
I am using port /dev/cu.SLAB_USBtoUART that was created when I loaded drivers etc for the cp2104
The programmer defaulted to AVRISP mkII and there was no mention of this in the instructions so I left it as-is.

I'm not sure what you mean by the blink example. When I press the button on the pcb the LED blinks three times.

When I compile the program it returns a "done compiling" note with the warnings.
When I load the program I get the same warnings and the program just sits there "loading" I left it 5 minutes and it didn't finish.

here is the message I receive;

In file included from /Users/brian/Desktop/shrimpkey/ShrimpKey-master/ShrimpKey/ShrimpKey.ino:4:0:
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '161' from 'int' to 'const char' inside { } [-Wnarrowing]
 };
 ^
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '224' from 'int' to 'const char' inside { } [-Wnarrowing]
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '231' from 'int' to 'const char' inside { } [-Wnarrowing]
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '149' from 'int' to 'const char' inside { } [-Wnarrowing]
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '129' from 'int' to 'const char' inside { } [-Wnarrowing]
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '149' from 'int' to 'const char' inside { } [-Wnarrowing]
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '129' from 'int' to 'const char' inside { } [-Wnarrowing]
/Users/brian/Documents/Arduino/libraries/UsbKeyboard/UsbKeyboard.h:55:1: warning: narrowing conversion of '192' from 'int' to 'const char' inside { } [-Wnarrowing]

Sketch uses 3,772 bytes (11%) of program storage space. Maximum is 32,256 bytes.
Global variables use 214 bytes (10%) of dynamic memory, leaving 1,834 bytes for local variables. Maximum is 2,048 bytes.

Right. I suspect that you have two different problems at the same time.

I'm using Windows, so can't help at all with Mac-related issues.

The warnings are most likely because you're using the later version of the IDE. As I mentioned, there are some issues with the later versions. Once your other problem is fixed, you could possibly uninstall the IDE and install V1.6.5 if they become a real problem, but I think there's nothing to worry about there.
They are only warnings, not errors, and the code compiles, so ignore them for now. I think you have bigger problems right now. (Looking at line 55 of the "UsbKeyboard.h" file, I don't think the warning is anything to be concerned about.)

Have you ever successfully uploaded a sketch (program) to your new board?
"Blink" is a good place to start, rather than a complex example like you're trying.

The "Blink" sketch can be found in the examples included in the IDE, under >File >Examples >Basics "Blink"

It requires no additional hardware, and if it uploads OK and your board is OK, the onboard LED will blink once every 2 seconds.

Let us know how it goes. I suspect that it won't upload either.

Edit: And it shouldn't matter which programmer you have selected in the IDE since you're uploading using the USB to TTL converter. You need to click on the "Upload" button in the IDE to upload a program. Don't click on >Sketch >Upload using programmer. (Because you aren't using an ISP programmer.)

OldSteve:
Right. I suspect that you have two different problems at the same time.

I'm using Windows, so can't help at all with Mac-related issues.

The warnings are most likely because you're using the later version of the IDE. As I mentioned, there are some issues with the later versions. Once your other problem is fixed, you could possibly uninstall the IDE and install V1.6.5 if they become a real problem, but I think there's nothing to worry about there.
They are only warnings, not errors, and the code compiles, so ignore them for now. I think you have bigger problems right now. (Looking at line 55 of the "UsbKeyboard.h" file, I don't think the warning is anything to be concerned about.)

Have you ever successfully uploaded a sketch (program) to your new board?
"Blink" is a good place to start, rather than a complex example like you're trying.

The "Blink" sketch can be found in the examples included in the IDE, under >File >Examples >Basics "Blink"

It requires no additional hardware, and if it uploads OK and your board is OK, the onboard LED will blink once every 2 seconds.

Let us know how it goes. I suspect that it won't upload either.

Edit: And it shouldn't matter which programmer you have selected in the IDE since you're uploading using the USB to TTL converter. You need to click on the "Upload" button in the IDE to upload a program. Don't click on >Sketch >Upload using programmer. (Because you aren't using an ISP programmer.)

I have not loaded anything to the board before.
Thank you for explaining the "blink" program.
I tried that and it does the same thing. After compiling, it just sits at the uploading stage and nothing else happens.
I will have to check if my led is on pin 13.
I will also have access to a pc tonight so I will try it on that.

Once again, thanks for your help.

ozbrian:
I have not loaded anything to the board before.
Thank you for explaining the "blink" program.
I tried that and it does the same thing. After compiling, it just sits at the uploading stage and nothing else happens.
I will have to check if my led is on pin 13.
I will also have access to a pc tonight so I will try it on that.

Once again, thanks for your help.

No worries Brian. So that 'Shrimpkey' sketch is probably OK. Just put it aside for the moment until you get your board working properly.

Looking at your photo, the LED is correctly connected to pin 13, so it will blink when you eventually get "Blink" to load.

I think I just spotted your problem. It looks like your Tx and Rx lines are reversed. Tx on your board should go to Rx on the CP2104 module, and your board's Rx should go to the CP2104 Tx, I'm pretty sure. Edit: (Definitely - I just double-checked my CP2102 modules because I get confused sometimes too. :slight_smile: )
Swap them around and try again.

Hi,

Tom, it's not an Arduino as such, it's this board:-

Ahh yes.. bareduino.
(A naked UNO)
Thanks...Tom.. :slight_smile:

Brian, I was looking at the Freetronics site earlier. (I'm in Oz too - NSW.)
For just over the cost of one of their ATMega328P dip chips, you can get a whole UNO R3 clone, with delivery. Overall, the UNO clone would be a fair bit cheaper than the board you had to make yourself.

The Freetronics ATMega328P chip that you're using is AUD$8.00, then there are all of the other bits and pieces, but the UNO clones that I buy through eBay are only AUD$8.47 delivered, with a USB cable provided as well.

They're not the CH340G version of the clones, either. They use an ATMega16U2 for a USB to serial converter just like a genuine UNO, and behave exactly the same as one too.
The only downside is that they take a few weeks to arrive, because they come from China.

In case you're interested, here's a link to where I get them:-
Precision UNO R3 Board ATmega328P ATmega16U2 For Arduino ATAU
I've bought a few from there now, and haven't had any problems.

OldSteve:
No worries Brian. So that 'Shrimpkey' sketch is probably OK. Just put it aside for the moment until you get your board working properly.

Looking at your photo, the LED is correctly connected to pin 13, so it will blink when you eventually get "Blink" to load.

I think I just spotted your problem. It looks like your Tx and Rx lines are reversed. Tx on your board should go to Rx on the CP2104 module, and your board's Rx should go to the CP2104 Tx, I'm pretty sure. Edit: (Definitely - I just double-checked my CP2102 modules because I get confused sometimes too. :slight_smile: )
Swap them around and try again.

Woohoo. That worked like a charm. I tried the blink program first and I have never been so happy to see a flashing light! A BIG thankyou for all of your help, especially the program changes.

Should I have cleared the old program (blink) before I loaded the new one? I just restarted Arduino IDE with the shrimp sketch and uploaded it over the top of the old program.

OldSteve:
Brian, I was looking at the Freetronics site earlier. (I'm in Oz too - NSW.)
For just over the cost of one of their ATMega328P dip chips, you can get a whole UNO R3 clone, with delivery. Overall, the UNO clone would be a fair bit cheaper than the board you had to make yourself.

The Freetronics ATMega328P chip that you're using is AUD$8.00, then there are all of the other bits and pieces, but the UNO clones that I buy through eBay are only AUD$8.47 delivered, with a USB cable provided as well.

They're not the CH340G version of the clones, either. They use an ATMega16U2 for a USB to serial converter just like a genuine UNO, and behave exactly the same as one too.
The only downside is that they take a few weeks to arrive, because they come from China.

In case you're interested, here's a link to where I get them:-
Precision UNO R3 Board ATmega328P ATmega16U2 For Arduino ATAU
I've bought a few from there now, and haven't had any problems.

I'm in NSW too - north of Parramatta. I initially bought a cheap chip off eBay that was supposed to have bootloader on it but didn't. I picked up the replacement Freetronics chip from Jaycar. It was quite dear ($15) and came packaged with the crystal which I didn't need. I was trying to make this prototype on the cheap but was on a time constraint.

This is for a uni assignment - I am not being marked on the unit itself, just the idea of using a shrimpkey (equivalent to the $70 Makey Makey) in music therapy for handicapped children. If the therapy program is successful I will be buying the UNO clones for sure. $8.47 is a bargain and wouldn't have paid for the panadol I needed building this one.

I now have to assemble the second board in the project but at least there is no programming involved.

Once again. Thanks for all your help and to all the others that took the time to reply.

ozbrian:
Woohoo. That worked like a charm. I tried the blink program first and I have never been so happy to see a flashing light! A BIG thankyou for all of your help, especially the program changes.

Excellent. I'm glad that it worked out.

Should I have cleared the old program (blink) before I loaded the new one? I just restarted Arduino IDE with the shrimp sketch and uploaded it over the top of the old program.

No, there's no need to erase the previous program. That's done automatically during the upload process.

Good luck with the rest of your project.

OldSteve:
Excellent. I'm glad that it worked out.

No, there's no need to erase the previous program. That's done automatically during the upload process.

Good luck with the rest of your project.

I thought I would update you and give this thread closure. I built the second part of the project, basically a keyboard emulator and every worked fine. I have also passed on the required program changes to the person who designed this project.

Thank you.