From 449d47500a54a0ceb3eb67dba92ff07a762d766d Mon Sep 17 00:00:00 2001 From: Christopher Kormanyos Date: Mon, 25 Dec 2023 18:16:16 +0100 Subject: [PATCH] Update avr target linker found from GCC 12/13 --- ref_app/target/build/build.bat | 4 +- ref_app/target/micros/avr/make/avr.ld | 11 ++- .../target/micros/avr/startup/int_vect.cpp | 69 +++++++++---------- 3 files changed, 40 insertions(+), 44 deletions(-) diff --git a/ref_app/target/build/build.bat b/ref_app/target/build/build.bat index d3baf956c..006942c9b 100644 --- a/ref_app/target/build/build.bat +++ b/ref_app/target/build/build.bat @@ -1,5 +1,5 @@ @rem -@rem Copyright Christopher Kormanyos 2007 - 2022. +@rem Copyright Christopher Kormanyos 2007 - 2023. @rem Distributed under the Boost Software License, @rem Version 1.0. (See accompanying file LICENSE_1_0.txt @rem or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -27,7 +27,7 @@ @rem @rem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -@Set build_command=tools\Util\msys64\usr\bin\make.exe -f target/app/make/app_make.gmk %2 TGT=%1 +@set build_command=tools\Util\msys64\usr\bin\make.exe -f target/app/make/app_make.gmk %2 TGT=%1 @echo Executing Command: %build_command% diff --git a/ref_app/target/micros/avr/make/avr.ld b/ref_app/target/micros/avr/make/avr.ld index 23b93a57f..b574ec1ba 100644 --- a/ref_app/target/micros/avr/make/avr.ld +++ b/ref_app/target/micros/avr/make/avr.ld @@ -12,10 +12,6 @@ INPUT(libc.a libm.a libgcc.a) OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr") OUTPUT_ARCH(avr:5) -/* The beginning and end of the program ROM area. */ -_rom_begin = 0x00000000; -_rom_end = 0x00007FFC; - /* The beginning and end (i.e., top) of the stack */ /* Set up a stack with a size of 0x180=(3/8)K */ _stack_begin = 0x00800780; @@ -26,8 +22,9 @@ __initial_stack_pointer = 0x00800900 - 2; MEMORY { - ROM(rx) : ORIGIN = 0, LENGTH = 32K - 4 - RAM(rw!x) : ORIGIN = 0x00800100, LENGTH = 0x00000780 - 0x00000100 + VEC(rx) : ORIGIN = 0, LENGTH = 0x80 + ROM(rx) : ORIGIN = 0x80, LENGTH = 32K - 0x80 + RAM(rwx) : ORIGIN = 0x00800100, LENGTH = 0x00000780 - 0x00000100 } SECTIONS @@ -41,7 +38,7 @@ SECTIONS *(.isr_vector) . = ALIGN(0x10); KEEP(*(.isr_vector)) - } > ROM = 0xAAAA + } > VEC = 0x5555 /* Startup code */ .startup : diff --git a/ref_app/target/micros/avr/startup/int_vect.cpp b/ref_app/target/micros/avr/startup/int_vect.cpp index 9afd70e9a..b173da191 100644 --- a/ref_app/target/micros/avr/startup/int_vect.cpp +++ b/ref_app/target/micros/avr/startup/int_vect.cpp @@ -6,6 +6,7 @@ // #include +#include #include #include @@ -22,49 +23,47 @@ 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(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_vector __attribute__((section(".isr_vector"))); + using isr_vector_array_type = std::array(UINT8_C(26))>; +} -extern "C" -const volatile std::array __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, 0, reset - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x02, 1, ext0 - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x04, 2, ext1 - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x06, 3, pin0 - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x08, 4, pin1 - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x0A, 5, pin2 - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x0C, 6, watchdog - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x0E, 7, timer2 cmp a - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x10, 8, timer2 cmp b - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x12, 9, timer2 ovf - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x14, 10, timer1 cap - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x16, 11, timer1 cmp a - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x18, 12, timer1 cmp b - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x1A, 13, timer1 ovf - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x1C, 14, timer0 cmp a - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x1E, 15, timer0 cmp b - { { 0x0C, 0x94 }, __vector_16 }, // 0x2E, 16, timer0 ovf - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x20, 17, spi(TM) - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x22, 18, usart rx - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x24, 19, usart err - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x26, 20, usart tx - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x28, 21, adc - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x2A, 22, eep ready - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x2C, 23, comparator - { { 0x0C, 0x94 }, __vector_unused_irq }, // 0x2E, 24, two-wire - { { 0x0C, 0x94 }, __vector_unused_irq } // 0x30, 25, spm + // addr. nr. interrupt source + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __my_startup }, // 0x00, 0, reset + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x02, 1, ext0 + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x04, 2, ext1 + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x06, 3, pin0 + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x08, 4, pin1 + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x0A, 5, pin2 + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x0C, 6, watchdog + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x0E, 7, timer2 cmp a + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x10, 8, timer2 cmp b + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x12, 9, timer2 ovf + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x14, 10, timer1 cap + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x16, 11, timer1 cmp a + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x18, 12, timer1 cmp b + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x1A, 13, timer1 ovf + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x1C, 14, timer0 cmp a + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x1E, 15, timer0 cmp b + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_16 }, // 0x2E, 16, timer0 ovf + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x20, 17, spi(TM) + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x22, 18, usart rx + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x24, 19, usart err + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x26, 20, usart tx + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x28, 21, adc + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x2A, 22, eep ready + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x2C, 23, comparator + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x2E, 24, two-wire + { { static_cast(UINT8_C(0x0C)), static_cast(UINT8_C(0x94)) }, __vector_unused_irq } // 0x30, 25, spm }};