ATmega128 compilation errors with example GatewayW5100 sketch



  • Hello,

    I'm working on GatewayW5100 example sketch. When board is with ATmega328P or ATmega2560 it is ok, but with ATmega128 board there are errors during compilation. Tested on ArduinoIDE and on PlatformIO.

    Do you have any ideas what to do for repair or workaround ?

    See output for ATmega128

    > Executing task in folder home_light_automation: C:\.platformio\penv\Scripts\platformio.exe run <
    
    Processing ATmega128 (platform: atmelavr; board: ATmega128; framework: arduino)
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Verbose mode can be enabled via `-v, --verbose` option
    CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/ATmega128.html
    PLATFORM: Atmel AVR 2.0.0 > ATmega128/A
    HARDWARE: ATMEGA128 16MHz, 4KB RAM, 127KB Flash
    PACKAGES:
     - framework-arduino-avr-megacore 2.0.2
     - toolchain-atmelavr 1.50400.190710 (5.4.0)
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 14 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- <Ethernet> 2.0.0
    |   |-- <SPI> 1.0
    |-- <MySensors> 2.3.1
    |   |-- <Wire> 1.0
    |   |-- <SPI> 1.0
    |   |-- <EEPROM> 2.0
    Building in release mode
    Compiling .pio\build\ATmega128\src\main.cpp.o
    Compiling .pio\build\ATmega128\lib475\SPI\SPI.cpp.o
    Compiling .pio\build\ATmega128\lib134\Ethernet-2.0.0\Dhcp.cpp.o
    Compiling .pio\build\ATmega128\lib134\Ethernet-2.0.0\Dns.cpp.o
    In file included from C:\.platformio\packages\framework-arduino-avr-megacore\cores\MegaCore/Arduino.h:30:0,
                     from lib\Ethernet-2.0.0\src/Ethernet.h:49,
                     from src\main.cpp:124:
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp: In function 'void WDT_vect()':
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp:79:6: warning: 'WDT_vect' appears to be a misspelled signal handler, missing __vector prefix [-Wmisspelled-isr]
     ISR (WDT_vect)
          ^
    In file included from lib\MySensors/MySensors.h:62:0,
                     from src\main.cpp:125:
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp: In function 'void hwPowerDown(uint8_t)':
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp:93:26: error: 'WDTCSR' was not declared in this scope
      const uint8_t WDTsave = WDTCSR;
                              ^
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp:97:33: error: 'WDIE' was not declared in this scope
       WDTCSR |= (1 << WDCE) | (1 << WDIE);
                                     ^
    In file included from c:\.platformio\packages\toolchain-atmelavr\avr\include\avr\io.h:99:0,
                     from c:\.platformio\packages\toolchain-atmelavr\avr\include\avr\pgmspace.h:90,
                     from C:\.platformio\packages\framework-arduino-avr-megacore\cores\MegaCore/Arduino.h:28,
                     from lib\Ethernet-2.0.0\src/Ethernet.h:49,
                     from src\main.cpp:124:
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp: In function 'bool hwUniqueID(uint8_t (*)[16])':
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp:264:27: error: 'SIGRD' was not declared in this scope
      *((uint8_t *)uniqueID) = boot_signature_byte_get(0x00);
                               ^
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp:265:31: error: 'SIGRD' was not declared in this scope
      *((uint8_t *)uniqueID + 1) = boot_signature_byte_get(0x02);
                                   ^
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp:266:31: error: 'SIGRD' was not declared in this scope
      *((uint8_t *)uniqueID + 2) = boot_signature_byte_get(0x04);
                                   ^
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp:267:31: error: 'SIGRD' was not declared in this scope
      *((uint8_t *)uniqueID + 3) = boot_signature_byte_get(0x01); //OSCCAL
                                   ^
    In file included from lib\MySensors/MySensors.h:62:0,
                     from src\main.cpp:125:
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp: In function 'uint16_t hwCPUFrequency()':
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp:304:26: error: 'WDTCSR' was not declared in this scope
      const uint8_t WDTsave = WDTCSR;
                              ^
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp:308:2: error: 'TIFR1' was not declared in this scope
      TIFR1 = 0xFF;
      ^
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp:315:18: error: 'WDIE' was not declared in this scope
      WDTCSR |= (1 << WDIE);
                      ^
    In file included from c:\.platformio\packages\toolchain-atmelavr\avr\include\avr\io.h:99:0,
                     from c:\.platformio\packages\toolchain-atmelavr\avr\include\avr\pgmspace.h:90,
                     from C:\.platformio\packages\framework-arduino-avr-megacore\cores\MegaCore/Arduino.h:28,
                     from lib\Ethernet-2.0.0\src/Ethernet.h:49,
                     from src\main.cpp:124:
    lib\MySensors/hal/architecture/AVR/MyHwAVR.cpp:320:29: error: 'WDIF' was not declared in this scope
      while (bit_is_clear(WDTCSR,WDIF)) {};
                                 ^
    *** [.pio\build\ATmega128\src\main.cpp.o] Error 1
    =================================================================================== [FAILED] Took 1.07 seconds ===================================================================================
    The terminal process terminated with exit code: 1
    
    Terminal will be reused by tasks, press any key to close it.
    
    

    And for ATmega2560 board output is here:

    > Executing task in folder home_light_automation: C:\.platformio\penv\Scripts\platformio.exe run <
    
    Processing ATmega2560 (platform: atmelavr; board: ATmega2560; framework: arduino)
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Verbose mode can be enabled via `-v, --verbose` option
    CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/ATmega2560.html
    PLATFORM: Atmel AVR 2.0.0 > ATmega2560
    HARDWARE: ATMEGA2560 16MHz, 8KB RAM, 255KB Flash
    PACKAGES:
     - framework-arduino-avr-megacore 2.0.2
     - toolchain-atmelavr 1.50400.190710 (5.4.0)
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 14 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- <Ethernet> 2.0.0
    |   |-- <SPI> 1.0
    |-- <MySensors> 2.3.1
    |   |-- <Wire> 1.0
    |   |-- <SPI> 1.0
    |   |-- <EEPROM> 2.0
    Building in release mode
    Checking size .pio\build\ATmega2560\firmware.elf
    Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
    RAM:   [=         ]  11.6% (used 952 bytes from 8192 bytes)
    Flash: [=         ]   7.8% (used 20492 bytes from 261120 bytes)
    =================================================================================== [SUCCESS] Took 0.90 seconds ===================================================================================
    
    Terminal will be reused by tasks, press any key to close it.
    

  • Mod

    Welcome to the forum @wagi
    The MySensors library is not aware of the atmega128. You’ll either need to add support (yourself or someone else), or use a board that MySensors is aware of.



  • We can see the problem is with MyHwAVR.cpp, where was not declared somethings when board is ATmega128.
    But deeper is MyHwAVR.h, and has included wdt.h. There are this definitions:

    #define wdt_reset() __asm__ __volatile__ ("wdr")
    
    #ifndef __DOXYGEN__
    
    #if defined(WDP3)
    # define _WD_PS3_MASK       _BV(WDP3)
    #else
    # define _WD_PS3_MASK       0x00
    #endif
    
    #if defined(WDTCSR)
    #  define _WD_CONTROL_REG     WDTCSR
    #elif defined(WDTCR)
    #  define _WD_CONTROL_REG     WDTCR
    #else
    #  define _WD_CONTROL_REG     WDT
    #endif
    
    #if defined(WDTOE)
    #define _WD_CHANGE_BIT      WDTOE
    #else
    #define _WD_CHANGE_BIT      WDCE
    #endif
    
    #endif	/* !__DOXYGEN__ */
    

    I've noticed, that when compiling good-working boards i.e. ATmega2560, we have defined WDP3, WDTCSR and WDTOE is not defined. But when compiling ATmega128 board we have NOT defined WDP3, NOT defined WDTCSR, but defined WDTCR and NOT defined WDTOE.

    I'm not programmer, but I suppose, maybe in MyHwAVR.cpp there should be used the new other defined here constants. What do you think ?




Log in to reply
 

Suggested Topics

19
Online

11.2k
Users

11.1k
Topics

112.5k
Posts