Skip to content

Commit

Permalink
Merge pull request #459 from ckormanyos/update_avr_linker
Browse files Browse the repository at this point in the history
Update avr target linker found from GCC 12/13
  • Loading branch information
ckormanyos authored Dec 25, 2023
2 parents c567cd6 + 449d475 commit 8d3d86e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 44 deletions.
4 changes: 2 additions & 2 deletions ref_app/target/build/build.bat
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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%

Expand Down
11 changes: 4 additions & 7 deletions ref_app/target/micros/avr/make/avr.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -41,7 +38,7 @@ SECTIONS
*(.isr_vector)
. = ALIGN(0x10);
KEEP(*(.isr_vector))
} > ROM = 0xAAAA
} > VEC = 0x5555

/* Startup code */
.startup :
Expand Down
69 changes: 34 additions & 35 deletions ref_app/target/micros/avr/startup/int_vect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

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

Expand All @@ -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<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, 26U> __isr_vector __attribute__((section(".isr_vector")));
using isr_vector_array_type = std::array<isr_type, static_cast<std::size_t>(UINT8_C(26))>;
}

extern "C"
const volatile std::array<isr_type, 26U> __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<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, ext0
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x04, 2, ext1
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x06, 3, pin0
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x08, 4, pin1
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x0A, 5, pin2
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x0C, 6, watchdog
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x0E, 7, timer2 cmp a
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x10, 8, timer2 cmp b
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x12, 9, timer2 ovf
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x14, 10, timer1 cap
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x16, 11, timer1 cmp a
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x18, 12, timer1 cmp b
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x1A, 13, timer1 ovf
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x1C, 14, timer0 cmp a
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x1E, 15, timer0 cmp b
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_16 }, // 0x2E, 16, timer0 ovf
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x20, 17, spi(TM)
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x22, 18, usart rx
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x24, 19, usart err
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x26, 20, usart tx
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x28, 21, adc
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x2A, 22, eep ready
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x2C, 23, comparator
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq }, // 0x2E, 24, two-wire
{ { static_cast<std::uint8_t>(UINT8_C(0x0C)), static_cast<std::uint8_t>(UINT8_C(0x94)) }, __vector_unused_irq } // 0x30, 25, spm
}};

0 comments on commit 8d3d86e

Please sign in to comment.