[bug #54652] Missing support for ATmega328PB

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #54652] Missing support for ATmega328PB

Kevin Cuzner-2
URL:
  <https://savannah.nongnu.org/bugs/?54652>

                 Summary: Missing support for ATmega328PB
                 Project: AVR C Runtime Library
            Submitted by: leonerd
            Submitted on: Wed 12 Sep 2018 05:29:13 PM UTC
                Category: Header
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Header files
                  Status: None
        Percent Complete: 0%
             Assigned to: None
        Originator Email:
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 2.0.0
           Fixed Release: None

    _______________________________________________________

Details:

(copied from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=867235)

Attempting to build a program for the new ATmega328PB, it seems the
device-specific IO file is not found:

avr-gcc -std=gnu99 -Wall -Os -DF_CPU=16000000 -mmcu=atmega328pb -flto
-ffunction-sections ...
In file included from src/test.c:1:0:
/usr/lib/avr/include/avr/io.h:623:6: warning: #warning "device type not
defined" [-Wcpp]
 #    warning "device type not defined"
      ^

I do have the required iom328pb.h file though:

-rw-r--r-- 1 root root 27K Jul 22  2016 /usr/lib/avr/include/avr/iom328pb.h

Further, I see that iom328pb.h isn't listed in the big long section of
#ifdef-guarded #includes in the main io.h. I see there is an attempted generic
fallback section based on value of __AVR_DEV_LIB_NAME__ but it seems for
whatever reason that isn't kicking in today.

If I simply add the required 2 lines (by copying the 328P example), my code
will compile fine. Attached is my patch and the new file.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Wed 12 Sep 2018 05:29:13 PM UTC  Name: iom328pb.h  Size: 27KiB   By:
leonerd

<http://savannah.nongnu.org/bugs/download.php?file_id=44992>
-------------------------------------------------------
Date: Wed 12 Sep 2018 05:29:13 PM UTC  Name: add-iom328pb-h.diff  Size: 422B  
By: leonerd

<http://savannah.nongnu.org/bugs/download.php?file_id=44993>

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?54652>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
AVR-libc-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev
Reply | Threaded
Open this post in threaded view
|

[bug #54652] Missing support for ATmega328PB

Kevin Cuzner-2
Follow-up Comment #1, bug #54652 (project avr-libc):

Thanks Paul for getting this started.

I've attached a new patch (add_m328pb_to_svn_r2548.diff) that can be applied
to the now-current (rev 2548) svn trunk and which will add support for the
atmega328pb.  This includes edits to various makefiles and scripts so that
support gets built in, plus two critical files: (1) atmega328pb.S which I
generated using the existing devtools/ioreg.pl against the ATmega328PB.atdf
XML file provided by Atmel in the now-current ATmega_DFP.1.2.272.atpack that I
retrieved from http://packs.download.atmel.com/; and (2) iom328pb.h which I
pulled from this atpack as well.  One therefore need not use the
Atmel-distributed binary copies of crtatmega328pb.o and libatmega328pb.a

It seems to work for me, but better support for this chip can/should be added,
e.g. util/twi.h assumes only a single TWI module exists.


(file #45510)
    _______________________________________________________

Additional Item Attachment:

File name: add_m328pb_to_svn_r2548.diff   Size:178 KB


    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?54652>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
AVR-libc-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev
Reply | Threaded
Open this post in threaded view
|

[bug #54652] Missing support for ATmega328PB

Kevin Cuzner-2
Follow-up Comment #2, bug #54652 (project avr-libc):

Any update on this? I'm keen to not have to regularly make that 2-line edit to
my "io.h" file every time the debian package gets updated.

Is there a process by which this can make its way into a release?

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?54652>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/


_______________________________________________
AVR-libc-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev
Reply | Threaded
Open this post in threaded view
|

Re: [bug #54652] Missing support for ATmega328PB

Paulo Marques
Hi all,

I had to support the ATmega328PB in a personal project, and did with a
hack. I'm posting it here in case it helps anyone. I just created a
"hack.S" file with:

        .macro vector name
        .weak \name
        .set \name, __my_bad_interrupt
        jmp \name
        .endm

        .section .vectors,"ax",@progbits

        .global __extra_vectors
        .func __extra_vectors
__extra_vectors:
        vector __vector_26
        vector __vector_27
        vector __vector_28
        vector __vector_29
        vector __vector_30
        vector __vector_31
        vector __vector_32
        vector __vector_33
        vector __vector_34
        vector __vector_35
        vector __vector_36
        vector __vector_37
        vector __vector_38
        vector __vector_39
        vector __vector_40
        vector __vector_41
        vector __vector_42
        vector __vector_43
        vector __vector_44
        vector __vector_45
        .endfunc

        .text
        .global __my_bad_interrupt
        .func __my_bad_interrupt
__my_bad_interrupt:
        jmp __bad_interrupt
        .endfunc

Then to use the serial port 1 RX interrupt (for instance), just write on
the C code:

// serial port 1 rx data available
ISR(_VECTOR(28))
{
   //.... code goes here
}

and I just compile as if it were 328P.

It is certainly a ugly hack, but it stays limited to your project,
without having to make changes to the toolchain.

Regards,

On 05/06/19 16:49, Paul Evans wrote:

> Follow-up Comment #2, bug #54652 (project avr-libc):
>
> Any update on this? I'm keen to not have to regularly make that 2-line edit to
> my "io.h" file every time the debian package gets updated.
>
> Is there a process by which this can make its way into a release?
>
>      _______________________________________________________
>
> Reply to this item at:
>
>    <https://savannah.nongnu.org/bugs/?54652>
>
> _______________________________________________
>    Message sent via Savannah
>    https://savannah.nongnu.org/
>
>
> _______________________________________________
> AVR-libc-dev mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/avr-libc-dev
>


--
Paulo Marques - www.grupopie.com

"To know recursion, you must first know recursion."

_______________________________________________
AVR-libc-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev