Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade avr gcc 12 #460

Merged
merged 2 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions ref_app/target/micros/atmega4809/make/atmega4809.ld
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@

/*
Copyright Christopher Kormanyos 2021.
Copyright Christopher Kormanyos 2021 - 2023.
Distributed under the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt
or copy at http://www.boost.org/LICENSE_1_0.txt)
*/

/* Linker script for ATMEL(R) AVR(R) ATmega32P. */

INPUT(libgcc.a libc.a libm.a)
INPUT(libc.a libm.a libgcc.a)

OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
OUTPUT_ARCH(avr:103)

/* The beginning and end of the program ROM area. */
_rom_begin = 0x00000000;
_rom_end = 0x0000BFFC;

/* The beginning and end (i.e., top) of the stack */
/* Set up a stack with a size of 0x200=(1/2)K */
_stack_begin = 0x00803E00;
Expand All @@ -27,8 +22,9 @@ __initial_stack_pointer = 0x00803FFE;

MEMORY
{
ROM(rx) : ORIGIN = 0, LENGTH = 48K - 4
RAM(rw!x) : ORIGIN = 0x00802800, LENGTH = 0x00001600
VEC(rx) : ORIGIN = 0x00000000, LENGTH = 0x00000100
ROM(rx) : ORIGIN = 0x00000100, LENGTH = 48K - 0x00000100
RAM(rwx) : ORIGIN = 0x00802800, LENGTH = 0x00001600
}

SECTIONS
Expand All @@ -42,7 +38,7 @@ SECTIONS
*(.isr_vector)
. = ALIGN(0x10);
KEEP(*(.isr_vector))
} > ROM = 0xAAAA
} > VEC = 0x5555

/* Startup code */
.startup :
Expand Down Expand Up @@ -71,11 +67,6 @@ SECTIONS
. = ALIGN(2);
} > ROM

.text :
{
. = ALIGN(0x10);
} > ROM = 0xAAAA

. = 0x00802800;
. = ALIGN(2);

Expand All @@ -89,7 +80,7 @@ SECTIONS
*(.data*)
. = ALIGN(2);
KEEP (*(.data*))
*(.rodata) /* Do *NOT* move this! Include .rodata here if gcc is used with -fdata-sections. */
*(.rodata) /* Use special handling of rodata (i.e., as part of data since _const_ variables are stored in RAM for AVR arch). */
. = ALIGN(2);
KEEP (*(.rodata))
*(.rodata*)
Expand Down
9 changes: 4 additions & 5 deletions ref_app/target/micros/atmega4809/make/atmega4809_flags.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# ------------------------------------------------------------------------------

ifneq ($(MAKE),make)
GCC_VERSION = 11.2.0
GCC_VERSION = 12.3.0
endif
GCC_TARGET = avr
GCC_PREFIX = avr
Expand All @@ -25,11 +25,10 @@ TGT_ALLFLAGS = -O2
-finline-limit=16 \
-fsigned-char \

ifeq ($(GCC_VERSION),11.2.0)
ifeq ($(GCC_VERSION),12.3.0)
TGT_ALLFLAGS := $(TGT_ALLFLAGS) \
-mlong-double=64 \
-DAVR_LIBC_LEGACY_IO=0 \
-D__AVR_DEV_LIB_NAME__=atmega4809
-mdouble=32 \
-mlong-double=64
endif

TGT_CFLAGS = -std=c99 \
Expand Down
101 changes: 51 additions & 50 deletions ref_app/target/micros/atmega4809/startup/int_vect.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2019.
// Copyright Christopher Kormanyos 2007 - 2023.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#include <array>
#include <cstddef>
#include <cstdint>
#include <mcal_cpu.h>

Expand All @@ -22,63 +23,63 @@ void __vector_unused_irq()
}
}

namespace
namespace local
{
typedef struct struct_isr_type
{
typedef void(*function_type)();

const std::uint8_t jmp[2]; // JMP instruction (0x940C): 0x0C = low byte, 0x94 = high byte.
const function_type func; // The interrupt service routine.
const std::uint8_t jmp[static_cast<std::size_t>(UINT8_C(2))]; // JMP instruction (0x940C): 0x0C = low byte, 0x94 = high byte.
const function_type func; // The interrupt service routine.
}
isr_type;
}

extern "C"
const volatile std::array<isr_type, 40U> __isr_vector __attribute__((section(".isr_vector")));
constexpr auto count_of_isr_vector = static_cast<std::size_t>(UINT8_C(40));

extern "C"
const volatile std::array<isr_type, 40U> __isr_vector =
using isr_vector_array_type = std::array<isr_type, count_of_isr_vector>;
}

const volatile local::isr_vector_array_type my_isr_vector __attribute__((section(".isr_vector"))) =
{{
// addr. nr. interrupt source
{ { 0x0C, 0x94 }, __my_startup }, // 0x00 RESET
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x02 NMI Non-Maskable Interrupt from CRC 2
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x04 VLM Voltage Level Monitor 3
{ { 0x0C, 0x94 }, __vector_3 }, // 0x06 RTC Overflow or compare match 4
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x08 PIT Periodic interrupt 5
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x0A CCL Configurable Custom Logic 6
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x0C PORTA External interrupt 7
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x0E TCA0 Overflow 8
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x10 TCA0 Underflow (Split mode) 9
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x12 TCA0 Compare channel 0
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x14 TCA0 Compare channel 1 11
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x16 TCA0 Compare channel 2 12
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x18 TCB0 Capture 13
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x1A TCB1 Capture 14
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x1C TWI0 Slave 15
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x1E TWI0 Master 16
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x20 SPI0 Serial Peripheral Interface 0 17
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x22 USART0 Receive Complete 18
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x24 USART0 Data Register Empty 19
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x26 USART0 Transmit Complete 20
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x28 PORTD External interrupt 21
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x2A AC0 Compare 22
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x2C ADC0 Result Ready 23
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x2E ADC0 Window Compare 24
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x30 PORTC External interrupt 25
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x32 TCB2 Capture 26
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x34 USART1 Receive Complete 27
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x36 USART1 Data Register Empty 28
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x38 USART1 Transmit Complete 29
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x3A PORTF External interrupt 30
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x3C NVM Ready 31
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x3E USART2 Receive Complete 32
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x40 USART2 Data Register Empty 33
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x42 USART2 Transmit Complete 34
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x44 PORTB External interruptX35
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x46 PORTE External interrupt 36
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x48 TCB3 Capture 37
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x4A USART3 Receive Complete 38
{ { 0x0C, 0x94 }, __vector_unused_irq }, // 0x4C USART3 Data Register Empty 39
{ { 0x0C, 0x94 }, __vector_unused_irq } // 0x4E USART3 Transmit Complete
// address index interrupt source
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __my_startup }, // 0x00 0 RESET
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x02 1 NMI Non-Maskable Interrupt from CRC
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x04 2 VLM Voltage Level Monitor
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_3 }, // 0x06 3 RTC Overflow or compare match
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x08 4 PIT Periodic interrupt
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x0A 5 CCL Configurable Custom Logic
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x0C 6 PORTA External interrupt
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x0E 7 TCA0 Overflow
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x10 8 TCA0 Underflow (Split mode)
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x12 9 TCA0 Compare channel
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x14 10 TCA0 Compare channel 1
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x16 11 TCA0 Compare channel 2
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x18 12 TCB0 Capture
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x1A 13 TCB1 Capture
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x1C 14 TWI0 Slave
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x1E 15 TWI0 Master
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x20 16 SPI0 Serial Peripheral Interface 0
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x22 17 USART0 Receive Complete
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x24 18 USART0 Data Register Empty
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x26 19 USART0 Transmit Complete
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x28 20 PORTD External interrupt
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x2A 21 AC0 Compare
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x2C 22 ADC0 Result Ready
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x2E 23 ADC0 Window Compare
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x30 24 PORTC External interrupt
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x32 25 TCB2 Capture
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x34 26 USART1 Receive Complete
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x36 27 USART1 Data Register Empty
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x38 28 USART1 Transmit Complete
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x3A 29 PORTF External interrupt
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x3C 30 NVM Ready
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x3E 31 USART2 Receive Complete
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x40 32 USART2 Data Register Empty
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x42 33 USART2 Transmit Complete
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x44 34 PORTB External interruptX
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x46 35 PORTE External interrupt
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x48 36 TCB3 Capture
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x4A 37 USART3 Receive Complete
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x4C 38 USART3 Data Register Empty
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq } // 0x4E 39 USART3 Transmit Complete
}};
14 changes: 8 additions & 6 deletions ref_app/target/micros/avr/make/avr.ld
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ __initial_stack_pointer = 0x00800900 - 2;

MEMORY
{
VEC(rx) : ORIGIN = 0, LENGTH = 0x80
ROM(rx) : ORIGIN = 0x80, LENGTH = 32K - 0x80
VEC(rx) : ORIGIN = 0x00000000, LENGTH = 0x00000080
ROM(rx) : ORIGIN = 0x00000080, LENGTH = 32K - 0x00000080
RAM(rwx) : ORIGIN = 0x00800100, LENGTH = 0x00000780 - 0x00000100
}

Expand Down Expand Up @@ -65,10 +65,6 @@ SECTIONS
. = ALIGN(2);
*(.text*)
. = ALIGN(2);
*(.rodata)
. = ALIGN(2);
*(.rodata*)
. = ALIGN(2);
} > ROM

. = 0x00800100;
Expand All @@ -84,6 +80,12 @@ SECTIONS
*(.data*)
. = ALIGN(2);
KEEP (*(.data*))
*(.rodata) /* Use special handling of rodata (i.e., as part of data since _const_ variables are stored in RAM for AVR arch). */
. = ALIGN(2);
KEEP (*(.rodata))
*(.rodata*)
. = ALIGN(2);
KEEP (*(.rodata*))
_data_end = .;
} > RAM AT > ROM

Expand Down
4 changes: 2 additions & 2 deletions ref_app/target/micros/avr/make/avr_flags.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# ------------------------------------------------------------------------------

ifneq ($(MAKE),make)
GCC_VERSION = 11.2.0
GCC_VERSION = 12.3.0
endif
GCC_TARGET = avr
GCC_PREFIX = avr
Expand All @@ -24,7 +24,7 @@ TGT_ALLFLAGS = -Os
-finline-limit=32 \
-fsigned-char

ifeq ($(GCC_VERSION),11.2.0)
ifeq ($(GCC_VERSION),12.3.0)
TGT_ALLFLAGS := $(TGT_ALLFLAGS) \
-mdouble=32 \
-mlong-double=64
Expand Down
Loading