Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: Porting Atmega2560 code to Teensy 4.1

  1. #1
    Junior Member
    Join Date
    Jan 2023
    Posts
    5

    Porting Atmega2560 code to Teensy 4.1

    Hi,
    I have an existing project for a custom board using Atmega2560 made on PlatformIO on VSCode.

    I use EEPROM to store some configuration data. My code takes Serial data from all serial ports of Atmega2560 connected to sensors like GPS, inclinometer and compass and sends it to another controller.

    I will post my code if required but it is a large project so I am not posting it right now.



    I imported Arduino-Blink example for Teensy4.1 and changed the src with my src folder, lib with my lib folder.

    I have made basic changes to the code like disabling GPIO port manipulation etc which was specific to Atmega.

    When I Verify the code it gives the following error

    Code:
    In file included from C:\Users\DELL\.platformio\packages\framework-arduinoteensy\cores\teensy4/WProgram.h:41:0,
                     from C:\Users\DELL\.platformio\packages\framework-arduinoteensy\cores\teensy4/Arduino.h:6,
                     from src\misc.h:6,
                     from src\BUC_TERR.cpp:2:
    C:\Users\DELL\.platformio\packages\framework-arduinoteensy\cores\teensy4/avr/pgmspace.h:30:52: error: section attribute not allowed for 'arr'
     #define PROGMEM __attribute__((section(".progmem")))
                                                        ^
    lib\Flash\src/Flash.h:71:33: note: in expansion of macro 'PROGMEM'
       _FLASH_STRING(const char *arr PROGMEM);
                                     ^
    C:\Users\DELL\.platformio\packages\framework-arduinoteensy\cores\teensy4/avr/pgmspace.h:30:52: error: section attribute not allowed for '_arr'
     #define PROGMEM __attribute__((section(".progmem")))
                                                        ^
    lib\Flash\src/Flash.h:105:20: note: in expansion of macro 'PROGMEM'
       const char *_arr PROGMEM;
                        ^
    C:\Users\DELL\.platformio\packages\framework-arduinoteensy\cores\teensy4/avr/pgmspace.h:30:52: error: section attribute not allowed for 'arr'
     #define PROGMEM __attribute__((section(".progmem")))
                                                        ^
    lib\Flash\src/Flash.h:200:40: note: in expansion of macro 'PROGMEM'
       _FLASH_STRING_ARRAY(const char **arr PROGMEM, size_t count) : _arr(arr), _size(count) {}
                                            ^
    C:\Users\DELL\.platformio\packages\framework-arduinoteensy\cores\teensy4/avr/pgmspace.h:30:52: error: section attribute not allowed for '_arr'
     #define PROGMEM __attribute__((section(".progmem")))
                                                        ^
    lib\Flash\src/Flash.h:223:21: note: in expansion of macro 'PROGMEM'
       const char **_arr PROGMEM;
    I have no idea where to look for this kind of error. It does not seem to be related directly to the code, but to the libraries.

  2. #2
    Senior Member
    Join Date
    Mar 2017
    Location
    Oakland, CA, USA
    Posts
    631
    If the program is large, perhaps pushing it to GitHub or some online text storage might be a good idea so that people could have a look.

  3. #3
    Junior Member
    Join Date
    Jan 2023
    Posts
    5
    Quote Originally Posted by shawn View Post
    If the program is large, perhaps pushing it to GitHub or some online text storage might be a good idea so that people could have a look.


    Hi,
    Thanks for the response.

    Please find the link to my project.

    Code:
    https://github.com/mohitsingh2806/pjrc_query.git

  4. #4
    Junior Member
    Join Date
    Jan 2023
    Posts
    5
    Can someone help me out here. This ks the first time I am using Teensy. The code works perfectly fine for atmega2560.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,694
    Do you have a copy which works with Arduino IDE?

  6. #6
    Junior Member
    Join Date
    Jan 2023
    Posts
    5
    Quote Originally Posted by PaulStoffregen View Post
    Do you have a copy which works with Arduino IDE?
    Hi,

    Thanks for response.

    I do not have a version which works with Arduino IDE as I had to move to VSCode when the code started becoming too big for me to handle.

    I will try to make a copy which works with arduino IDE and upload here if it helps.

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,694
    Have you tried deleting "PROGMEM" from all the places with "error: section attribute not allowed"? Seems like the easy and obvious first step.

    Looking only briefly at your code, I see you have a "lib" folder where you've copied several popular libraries like Ethernet and a variant of the EEPROM library. Teensy has its own versions of these libraries which you might need to use.

  8. #8
    Junior Member
    Join Date
    Jan 2023
    Posts
    5
    Quote Originally Posted by PaulStoffregen View Post
    Have you tried deleting "PROGMEM" from all the places with "error: section attribute not allowed"? Seems like the easy and obvious first step.

    Looking only briefly at your code, I see you have a "lib" folder where you've copied several popular libraries like Ethernet and a variant of the EEPROM library. Teensy has its own versions of these libraries which you might need to use.
    Thanks a lot for the response.
    I replaced
    Code:
     #define PROGMEM __attribute__((section(".progmem")))
    with
    Code:
    #define PROGMEM
    As you pointed out, it has resolved the current issue. I am able to compile my code now.


    I have replaced the EEPROM and Ethernet libraries too.

    I did not know enough about PROGMEM to have seen this issue as I assumed it would not create problems as it was included from within the Teensy framework.
    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •