New Uno microcontroller

It seemed I had burned my arduino uno microcontroller and so went on to bying a new ATmega328. I replaced the burned one and I am now trying to load the bootloader (Examples: ArduinoISP). It is the first time I am doing this so what I ask is whether or not I can load the bootloader to the microcontroller using only my arduino Uno (only the board with the replaced ATmega 328). If not what options do I have except bying a new one. Thanx in advance, Alex

You need a second Arduino to burn a bootloader.

Thank you very much ! I guess i can't avoid bying a new one....

One more thing. How can I burn the bootloader on to the ATmega368 with an Arduino Mega 2560 ?

Use Nick Gammon's bootloader sketch. http://www.gammon.com.au/forum/?id=11635

Connect to the SPI pins on the ICSP header on the Mega - and I think D10 to drive the Reset line. Or pick up the SPI pins in the 50-53 area, check the schematic.

guess i can't avoid bying a new one.

Woah! If you are going to spend money, just buy a 328 with the bootloader already loaded: http://www.adafruit.com/products/123 When you fix the UNO you can run ArduinoISP and bootload the blank chip - then build a boarduino, etc.

Ray

Use Nick Gammon's bootloader sketch. http://www.gammon.com.au/forum/?id=11635

Well I tried that and it seems that I cant get it right. I am using a mega as the programmer and a uno as the board being programmed. The wiring is correct but when I press 'G' the following comes up:

Atmega chip programmer.
Written by Nick Gammon.
Entered programming mode OK.
Signature = 0x1E 0x95 0x14 
Processor = ATmega328
Flash memory size = 32768 bytes.
LFuse = 0x62 
HFuse = 0xD9 
EFuse = 0xFF 
Lock byte = 0xFF 
Clock calibration = 0xA4 
Bootloader address = 0x7E00
Bootloader length = 512 bytes.
Type 'L' to use Lilypad (8 MHz) loader, or 'U' for Uno (16 MHz) loader ...
Using Uno Optiboot 16 MHz loader.
Type 'V' to verify, or 'G' to program the chip with the bootloader ...
Erasing chip ...
Writing bootloader ...
Committing page starting at 0x7E00
Committing page starting at 0x7E80
Committing page starting at 0x7F00
Committing page starting at 0x7F80
Written.
Verifying ...
Verification error at address 7E00. Got: 0xFF  Expected: 0x11 
Verification error at address 7E01. Got: 0xFF  Expected: 0x24 
Verification error at address 7E02. Got: 0xFF  Expected: 0x84 
Verification error at address 7E03. Got: 0xFF  Expected: 0xB7 
Verification error at address 7E04. Got: 0xFF  Expected: 0x14 
Verification error at address 7E05. Got: 0xFF  Expected: 0xBE 
Verification error at address 7E06. Got: 0xFF  Expected: 0x81 
Verification error at address 7E08. Got: 0xFF  Expected: 0xF0 
Verification error at address 7E09. Got: 0xFF  Expected: 0xD0 
Verification error at address 7E0A. Got: 0xFF  Expected: 0x85 
Verification error at address 7E0B. Got: 0xFF  Expected: 0xE0 
Verification error at address 7E0C. Got: 0xFF  Expected: 0x80 
Verification error at address 7E0D. Got: 0xFF  Expected: 0x93 
Verification error at address 7E0E. Got: 0xFF  Expected: 0x81 
Verification error at address 7E0F. Got: 0xFF  Expected: 0x00 
Verification error at address 7E10. Got: 0xFF  Expected: 0x82 
Verification error at address 7E11. Got: 0xFF  Expected: 0xE0 
Verification error at address 7E12. Got: 0xFF  Expected: 0x80 
Verification error at address 7E13. Got: 0xFF  Expected: 0x93 
Verification error at address 7E14. Got: 0xFF  Expected: 0xC0 
Verification error at address 7E15. Got: 0xFF  Expected: 0x00 
Verification error at address 7E16. Got: 0xFF  Expected: 0x88 
Verification error at address 7E17. Got: 0xFF  Expected: 0xE1 
Verification error at address 7E18. Got: 0xFF  Expected: 0x80 
Verification error at address 7E19. Got: 0xFF  Expected: 0x93 
Verification error at address 7E1A. Got: 0xFF  Expected: 0xC1 
Verification error at address 7E1B. Got: 0xFF  Expected: 0x00 
Verification error at address 7E1C. Got: 0xFF  Expected: 0x86 
Verification error at address 7E1D. Got: 0xFF  Expected: 0xE0 
Verification error at address 7E1E. Got: 0xFF  Expected: 0x80 
Verification error at address 7E1F. Got: 0xFF  Expected: 0x93 
Verification error at address 7E20. Got: 0xA2  Expected: 0xC2 
Verification error at address 7E25. Got: 0xFF  Expected: 0x93 
Verification error at address 7E26. Got: 0x01  Expected: 0xC4 
Verification error at address 7E2B. Got: 0x15  Expected: 0xD0 
Verification error at address 7E2C. Got: 0xC9  Expected: 0x25 
Verification error at address 7E2F. Got: 0xFF  Expected: 0xE0 
Verification error at address 7E30. Got: 0xFE  Expected: 0x20 
Verification error at address 7E31. Got: 0xFF  Expected: 0xE3 
Verification error at address 7E33. Got: 0x3C  Expected: 0xEF 
Verification error at address 7E42. Got: 0x82  Expected: 0xFE 
Verification error at address 7E43. Got: 0x84  Expected: 0xCF 
Verification error at address 7E4D. Got: 0x64  Expected: 0x24 
Verification error at address 7E52. Got: 0x29  Expected: 0x83 
Verification error at address 7E53. Got: 0xFF  Expected: 0x94 
Verification error at address 7E55. Got: 0xE1  Expected: 0xE0 
Verification error at address 7E5A. Got: 0xFF  Expected: 0x9A 
Verification error at address 7E5B. Got: 0xFF  Expected: 0x2E 
Verification error at address 7E5F. Got: 0x0E  Expected: 0x2E 
Verification error at address 7E76. Got: 0xFF  Expected: 0x01 
Verification error at address 7E77. Got: 0xFF  Expected: 0xC0 
Verification error at address 7E78. Got: 0xFF  Expected: 0x83 
Verification error at address 7E79. Got: 0xFF  Expected: 0xE0 
Verification error at address 7E7A. Got: 0x88  Expected: 0x8D 
Verification error at address 7E7B. Got: 0x00  Expected: 0xD0 
Verification error at address 7E7F. Got: 0x3F  Expected: 0x34 
Verification error at address 7E80. Got: 0xFF  Expected: 0x11 
Verification error at address 7E81. Got: 0xFF  Expected: 0xF4 
Verification error at address 7E82. Got: 0xFF  Expected: 0x84 
Verification error at address 7E83. Got: 0xFF  Expected: 0xE1 
Verification error at address 7E84. Got: 0xFF  Expected: 0x03 
Verification error at address 7E85. Got: 0xFF  Expected: 0xC0 
Verification error at address 7E86. Got: 0xFF  Expected: 0x85 
Verification error at address 7E87. Got: 0xFF  Expected: 0x34 
Verification error at address 7E88. Got: 0xFF  Expected: 0x19 
Verification error at address 7E89. Got: 0xFF  Expected: 0xF4 
Verification error at address 7E8A. Got: 0xFF  Expected: 0x85 
Verification error at address 7E8B. Got: 0xFF  Expected: 0xE0 
Verification error at address 7E8C. Got: 0xFF  Expected: 0xA6 
Verification error at address 7E8D. Got: 0xFF  Expected: 0xD0 
Verification error at address 7E8E. Got: 0xFF  Expected: 0x80 
Verification error at address 7E8F. Got: 0xFF  Expected: 0xC0 
Verification error at address 7E90. Got: 0xFF  Expected: 0x85 
Verification error at address 7E91. Got: 0xFF  Expected: 0x35 
Verification error at address 7E92. Got: 0xFF  Expected: 0x79 
Verification error at address 7E93. Got: 0xFF  Expected: 0xF4 
Verification error at address 7E94. Got: 0x4E  Expected: 0x88 
Verification error at address 7E95. Got: 0xFF  Expected: 0xD0 
Verification error at address 7E96. Got: 0xFF  Expected: 0xE8 
Verification error at address 7E97. Got: 0x4B  Expected: 0x2E 
Verification error at address 7E99. Got: 0xFF  Expected: 0x24 
Verification error at address 7E9A. Got: 0x4D  Expected: 0x85 
Verification error at address 7E9B. Got: 0xFF  Expected: 0xD0 
Verification error at address 7E9C. Got: 0x82  Expected: 0x08 
Verification error at address 7EA2. Got: 0xFF  Expected: 0x00 
Verification error at address 7EA3. Got: 0xFF  Expected: 0x27 
Verification error at address 7EA5. Got: 0xD0  Expected: 0x29 
Verification error at address 7EB5. Got: 0xFF  Expected: 0xF4 
Verification error at address 7EB6. Got: 0x43  Expected: 0x84 
Verification error at address 7EC8. Got: 0xFF  Expected: 0x08 
Verification error at address 7EC9. Got: 0xFF  Expected: 0x2F 
Verification error at address 7ED2. Got: 0xFF  Expected: 0xD8 
Verification error at address 7ED3. Got: 0x01  Expected: 0x06 
Verification error at address 7ED5. Got: 0x6A  Expected: 0xF4 
Verification error at address 7EDA. Got: 0xFF  Expected: 0xE8 
Verification error at address 7EDB. Got: 0xFF  Expected: 0x95 
Verification error at address 7EE2. Got: 0x71  Expected: 0x89 
Verification error at address 7EEE. Got: 0xFF  Expected: 0xDF 
Verification error at address 7EEF. Got: 0xFF  Expected: 0x06 
Verification error at address 7EF5. Got: 0xFF  Expected: 0xBE 
Verification error at address 7EF6. Got: 0x6F  Expected: 0xE8 
229 verification error(s).
First 100 shown.
Type 'C' when ready to continue with another chip ...

Any ideas what can be wrong ?

You have the "divide clock by 8" fuse set.

Fix that first and the bootloader should then install.

I have another sketch which will do that:

http://www.gammon.com.au/forum/?id=11638

(Warning: different wiring).

You can run that without an SD card for the purpose of changing fuses.

You need to change the LOW fuse, I think 0xFF is an OK value if you are running with the crystal or resonator.

If not try 0xE2.

I changed this

byte lFuse = program (readLowFuseByte, readLowFuseByteArg2);

to this

byte lFuse = 0xFF;

but still getting:

Erasing chip ...
Writing bootloader ...
Committing page starting at 0x7E00
Committing page starting at 0x7E80
Committing page starting at 0x7F00
Committing page starting at 0x7F80
Written.
Verifying ...
Verification error at address 7E00. Got: 0xFF  Expected: 0x11 
Verification error at address 7E01. Got: 0xFF  Expected: 0x24 
Verification error at address 7E02. Got: 0xFF  Expected: 0x84 
Verification error at address 7E03. Got: 0xFF  Expected: 0xB7 
Verification error at address 7E04. Got: 0xFF  Expected: 0x14 
Verification error at address 7E05. Got: 0xFF  Expected: 0xBE 
Verification error at address 7E06. Got: 0xFF  Expected: 0x81 
Verification error at address 7E08. Got: 0xFF  Expected: 0xF0 
Verification error at address 7E09. Got: 0xFF  Expected: 0xD0 
Verification error at address 7E0A. Got: 0xFF  Expected: 0x85 
Verification error at address 7E0B. Got: 0xFF  Expected: 0xE0 
Verification error at address 7E0C. Got: 0xFF  Expected: 0x80 
Verification error at address 7E0D. Got: 0xFF  Expected: 0x93 
Verification error at address 7E0E. Got: 0xFF  Expected: 0x81 
Verification error at address 7E0F. Got: 0xFF  Expected: 0x00 
Verification error at address 7E10. Got: 0xFF  Expected: 0x82 
Verification error at address 7E11. Got: 0x08  Expected: 0xE0 
Verification error at address 7E12. Got: 0xFF  Expected: 0x80 
Verification error at address 7E13. Got: 0xFF  Expected: 0x93 
Verification error at address 7E14. Got: 0xFF  Expected: 0xC0 
Verification error at address 7E15. Got: 0xFF  Expected: 0x00 
Verification error at address 7E16. Got: 0xFF  Expected: 0x88 
Verification error at address 7E17. Got: 0xFF  Expected: 0xE1 
Verification error at address 7E18. Got: 0xFF  Expected: 0x80 
Verification error at address 7E19. Got: 0xFF  Expected: 0x93 
Verification error at address 7E1A. Got: 0xFF  Expected: 0xC1 
Verification error at address 7E1B. Got: 0xFF  Expected: 0x00 
Verification error at address 7E1C. Got: 0xFF  Expected: 0x86 
Verification error at address 7E1D. Got: 0xFF  Expected: 0xE0 
Verification error at address 7E1E. Got: 0xFF  Expected: 0x80 
Verification error at address 7E1F. Got: 0xFF  Expected: 0x93 
Verification error at address 7E20. Got: 0xFF  Expected: 0xC2 
Verification error at address 7E21. Got: 0xFF  Expected: 0x00 
Verification error at address 7E22. Got: 0xFF  Expected: 0x80 
Verification error at address 7E23. Got: 0xFF  Expected: 0xE1 
Verification error at address 7E24. Got: 0xFF  Expected: 0x80 
Verification error at address 7E25. Got: 0xFF  Expected: 0x93 
Verification error at address 7E26. Got: 0xFF  Expected: 0xC4 
Verification error at address 7E27. Got: 0xFF  Expected: 0x00 
Verification error at address 7E28. Got: 0xFF  Expected: 0x8E 
Verification error at address 7E29. Got: 0xFF  Expected: 0xE0 
Verification error at address 7E2A. Got: 0xFF  Expected: 0xC9 
Verification error at address 7E2B. Got: 0xFF  Expected: 0xD0 
Verification error at address 7E2C. Got: 0xFF  Expected: 0x25 
Verification error at address 7E2D. Got: 0xFF  Expected: 0x9A 
Verification error at address 7E2E. Got: 0xFF  Expected: 0x86 
Verification error at address 7E2F. Got: 0xFF  Expected: 0xE0 
Verification error at address 7E30. Got: 0xFF  Expected: 0x20 
Verification error at address 7E31. Got: 0xFF  Expected: 0xE3 
Verification error at address 7E32. Got: 0xFF  Expected: 0x3C 
Verification error at address 7E33. Got: 0xFF  Expected: 0xEF 
Verification error at address 7E34. Got: 0xFF  Expected: 0x91 
Verification error at address 7E35. Got: 0xFF  Expected: 0xE0 
Verification error at address 7E36. Got: 0xFF  Expected: 0x30 
Verification error at address 7E37. Got: 0xFF  Expected: 0x93 
Verification error at address 7E38. Got: 0xFF  Expected: 0x85 
Verification error at address 7E39. Got: 0xFF  Expected: 0x00 
Verification error at address 7E3A. Got: 0xFF  Expected: 0x20 
Verification error at address 7E3B. Got: 0xFF  Expected: 0x93 
Verification error at address 7E3C. Got: 0xFF  Expected: 0x84 
Verification error at address 7E3D. Got: 0xFF  Expected: 0x00 
Verification error at address 7E3E. Got: 0xFF  Expected: 0x96 
Verification error at address 7E3F. Got: 0xFF  Expected: 0xBB 
Verification error at address 7E40. Got: 0xFF  Expected: 0xB0 
Verification error at address 7E41. Got: 0xFF  Expected: 0x9B 
Verification error at address 7E42. Got: 0xFF  Expected: 0xFE 
Verification error at address 7E43. Got: 0xFF  Expected: 0xCF 
Verification error at address 7E44. Got: 0xFF  Expected: 0x1D 
Verification error at address 7E45. Got: 0xFF  Expected: 0x9A 
Verification error at address 7E46. Got: 0xFF  Expected: 0xA8 
Verification error at address 7E47. Got: 0xFF  Expected: 0x95 
Verification error at address 7E48. Got: 0xFF  Expected: 0x81 
Verification error at address 7E49. Got: 0xFE  Expected: 0x50 
Verification error at address 7E4A. Got: 0xFF  Expected: 0xA9 
Verification error at address 7E4B. Got: 0xFF  Expected: 0xF7 
Verification error at address 7E4C. Got: 0xFF  Expected: 0xCC 
Verification error at address 7E4D. Got: 0xFF  Expected: 0x24 
Verification error at address 7E4E. Got: 0xFF  Expected: 0xDD 
Verification error at address 7E4F. Got: 0x27  Expected: 0x24 
Verification error at address 7E50. Got: 0xFF  Expected: 0x88 
Verification error at address 7E51. Got: 0xFF  Expected: 0x24 
Verification error at address 7E52. Got: 0xFF  Expected: 0x83 
Verification error at address 7E53. Got: 0xFF  Expected: 0x94 
Verification error at address 7E54. Got: 0xFF  Expected: 0xB5 
Verification error at address 7E55. Got: 0xFF  Expected: 0xE0 
Verification error at address 7E56. Got: 0xFF  Expected: 0xAB 
Verification error at address 7E57. Got: 0xFF  Expected: 0x2E 
Verification error at address 7E58. Got: 0xFF  Expected: 0xA1 
Verification error at address 7E59. Got: 0x83  Expected: 0xE1 
Verification error at address 7E5A. Got: 0xFF  Expected: 0x9A 
Verification error at address 7E5B. Got: 0xFF  Expected: 0x2E 
Verification error at address 7E5C. Got: 0xFF  Expected: 0xF3 
Verification error at address 7E5D. Got: 0xFF  Expected: 0xE0 
Verification error at address 7E5E. Got: 0xFF  Expected: 0xBF 
Verification error at address 7E5F. Got: 0xFF  Expected: 0x2E 
Verification error at address 7E60. Got: 0xFF  Expected: 0xA2 
Verification error at address 7E61. Got: 0xFF  Expected: 0xD0 
Verification error at address 7E62. Got: 0xFF  Expected: 0x81 
Verification error at address 7E63. Got: 0xFF  Expected: 0x34 
Verification error at address 7E64. Got: 0xFF  Expected: 0x61 
Verification error at address 7E65. Got: 0xFF  Expected: 0xF4 
422 verification error(s).
First 100 shown.
Type 'C' when ready to continue with another chip ...

That was just reading the fuse. You need to commit (write) a new fuse setting. Then the processor runs faster and you can reprogram it.

Ok so far so good but how exactly do i do that ?

http://www.gammon.com.au/forum/?id=11638

As I might have mentioned above.

Well I tried to load the program to the arduino board but I get lots of errors

Atmega_Hex_Uploader:160: error: 'SdFat' does not name a type
Atmega_Hex_Uploader.ino: In function 'boolean readHexFile(const char*, byte)':
Atmega_Hex_Uploader:690: error: 'ifstream' was not declared in this scope
Atmega_Hex_Uploader:690: error: expected `;' before 'sdin'
Atmega_Hex_Uploader:708: error: 'sdin' was not declared in this scope
Atmega_Hex_Uploader:734: error: 'sdin' was not declared in this scope
Atmega_Hex_Uploader.ino: In function 'void showDirectory()':
Atmega_Hex_Uploader:1014: error: 'SdFile' was not declared in this scope
Atmega_Hex_Uploader:1014: error: expected `;' before 'file'
Atmega_Hex_Uploader:1022: error: 'sd' was not declared in this scope
Atmega_Hex_Uploader:1025: error: 'file' was not declared in this scope
Atmega_Hex_Uploader:1025: error: 'O_READ' was not declared in this scope
Atmega_Hex_Uploader:1040: error: 'dir_t' was not declared in this scope
Atmega_Hex_Uploader:1040: error: expected `;' before 'd'
Atmega_Hex_Uploader:1041: error: 'd' was not declared in this scope
Atmega_Hex_Uploader:1043: error: 'FAT_DEFAULT_DATE' was not declared in this scope
Atmega_Hex_Uploader.ino: In function 'void setup()':
Atmega_Hex_Uploader:1089: error: 'sd' was not declared in this scope
Atmega_Hex_Uploader:1089: error: 'SPI_HALF_SPEED' was not declared in this scope
Atmega_Hex_Uploader.ino: In function 'void readFlashContents()':
Atmega_Hex_Uploader:1211: error: 'sd' was not declared in this scope
Atmega_Hex_Uploader:1226: error: 'SdFile' was not declared in this scope
Atmega_Hex_Uploader:1226: error: expected `;' before 'myFile'
Atmega_Hex_Uploader:1229: error: 'myFile' was not declared in this scope
Atmega_Hex_Uploader:1229: error: 'O_WRITE' was not declared in this scope
Atmega_Hex_Uploader:1229: error: 'O_CREAT' was not declared in this scope
Atmega_Hex_Uploader:1229: error: 'O_TRUNC' was not declared in this scope
Atmega_Hex_Uploader:1274: error: 'myFile' was not declared in this scope
Atmega_Hex_Uploader:1291: error: 'myFile' was not declared in this scope
Atmega_Hex_Uploader:1304: error: 'myFile' was not declared in this scope
Atmega_Hex_Uploader:1307: error: 'sd' was not declared in this scope

Well I tried to load the program to the arduino board but I get lots of errors

Looks like a missing header file. Did you
#include <SD.h>
???

Now I did but still lots of errors

Atmega_Hex_Uploader:160: error: 'SdFat' does not name a type
Atmega_Hex_Uploader.ino: In function 'boolean readHexFile(const char*, byte)':
Atmega_Hex_Uploader:690: error: 'ifstream' was not declared in this scope
Atmega_Hex_Uploader:690: error: expected `;' before 'sdin'
Atmega_Hex_Uploader:708: error: 'sdin' was not declared in this scope
Atmega_Hex_Uploader:734: error: 'sdin' was not declared in this scope
Atmega_Hex_Uploader.ino: In function 'void showDirectory()':
Atmega_Hex_Uploader:1022: error: 'sd' was not declared in this scope
Atmega_Hex_Uploader:1025: error: 'class SdFile' has no member named 'openNext'
Atmega_Hex_Uploader:1026: error: 'class SdFile' has no member named 'getFilename'
Atmega_Hex_Uploader:1046: error: no matching function for call to 'SdFile::printFatDate(HardwareSerial*, uint16_t&)'
C:\Users\TURBO_X\Desktop\desktop\arduino-1.0.3\libraries\SD/utility/SdFat.h:228: note: candidates are: static void SdFile::printFatDate(uint16_t)
Atmega_Hex_Uploader:1048: error: no matching function for call to 'SdFile::printFatTime(HardwareSerial*, uint16_t&)'
C:\Users\TURBO_X\Desktop\desktop\arduino-1.0.3\libraries\SD/utility/SdFat.h:229: note: candidates are: static void SdFile::printFatTime(uint16_t)
Atmega_Hex_Uploader:1050: error: no matching function for call to 'SdFile::printFatDate(HardwareSerial*, uint16_t&)'
C:\Users\TURBO_X\Desktop\desktop\arduino-1.0.3\libraries\SD/utility/SdFat.h:228: note: candidates are: static void SdFile::printFatDate(uint16_t)
Atmega_Hex_Uploader:1052: error: no matching function for call to 'SdFile::printFatTime(HardwareSerial*, uint16_t&)'
C:\Users\TURBO_X\Desktop\desktop\arduino-1.0.3\libraries\SD/utility/SdFat.h:229: note: candidates are: static void SdFile::printFatTime(uint16_t)
Atmega_Hex_Uploader.ino: In function 'void setup()':
Atmega_Hex_Uploader:1089: error: 'sd' was not declared in this scope
Atmega_Hex_Uploader.ino: In function 'void readFlashContents()':
Atmega_Hex_Uploader:1211: error: 'sd' was not declared in this scope
Atmega_Hex_Uploader:1229: error: no matching function for call to 'SdFile::open(char [13], int)'
C:\Users\TURBO_X\Desktop\desktop\arduino-1.0.3\libraries\SD/utility/SdFat.h:223: note: candidates are: uint8_t SdFile::open(SdFile*, uint16_t, uint8_t)
C:\Users\TURBO_X\Desktop\desktop\arduino-1.0.3\libraries\SD/utility/SdFat.h:224: note:                 uint8_t SdFile::open(SdFile*, const char*, uint8_t)
C:\Users\TURBO_X\Desktop\desktop\arduino-1.0.3\libraries\SD/utility/SdFat.h:331: note:                 uint8_t SdFile::open(SdFile&, const char*, uint8_t)
C:\Users\TURBO_X\Desktop\desktop\arduino-1.0.3\libraries\SD/utility/SdFat.h:335: note:                 uint8_t SdFile::open(SdFile&, const char*)
C:\Users\TURBO_X\Desktop\desktop\arduino-1.0.3\libraries\SD/utility/SdFat.h:341: note:                 uint8_t SdFile::open(SdFile&, uint16_t, uint8_t)
Atmega_Hex_Uploader:1307: error: 'sd' was not declared in this scope