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

Sam3u port #83

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "external/cmsis-dfp-sams70"]
path = external/cmsis-dfp-sams70
url = https://github.com/cmsis-packs/cmsis-dfp-sams70
[submodule "external/cmsis-dfp-sam3u"]
path = external/cmsis-dfp-sam3u
url = https://github.com/cmsis-packs/cmsis-dfp-sam3u
12 changes: 12 additions & 0 deletions build_system/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def __init__(self, location: BuildLocation, target: str) -> None:
'cmsis-dfp-stm32f1',
'cmsis-dfp-efm32gg12b',
'cmsis-dfp-sams70',
'cmsis-dfp-sam3u',
}


Expand Down Expand Up @@ -192,6 +193,17 @@ def __init__(self, location: BuildLocation) -> None:
}


class CMSISDeviceSAM3UDependency(Dependency, name='cmsis-dfp-sam3u'):
def __init__(self, location: BuildLocation) -> None:
super().__init__(location)
self.dependencies = {
'cmsis-5',
}
self.external_include = {
self.base_path / 'include',
}


class SensorBlobDependency(Dependency, name='sensor-blobs'):
def __init__(self, location: BuildLocation) -> None:
super().__init__(location)
Expand Down
45 changes: 45 additions & 0 deletions config/families/sam3u.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
toolchain = 'arm-none-eabi'
c_flags = [
'-g',
'-Os',
'-nostdlib',
'-nostartfiles',
'-ffunction-sections',
'-fdata-sections',
'-march=armv7-m',
'-mtune=cortex-m3',
'-mthumb',
'-mfloat-abi=soft',
'-ffreestanding',
]
ld_flags = [
'-g',
'-lm',
'-lc',
'-lgcc',
'-lnosys',
'-nostdlib',
'-nostartfiles',
'-fdata-sections',
'-ffunction-sections',
'--specs=nano.specs',
'--specs=nosys.specs',
'-Wl,--gc-sections',
'-march=armv7-m',
'-mtune=cortex-m3',
'-mthumb',
]
source = [
'startup.c',
'eefc.c',
'wdt.c',
'pmc.c',
'pio.c',
'systick.c',
'exceptions.c',
]

[dependencies]
cmsis-5 = {}
cmsis-dfp-sam3u = {}
#tinyusb = { target = 'microchip/sam3u' }
2 changes: 2 additions & 0 deletions config/linker/russian-woodpecker/russian-woodpecker.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

INCLUDE sam3u/sam3u2.ld
140 changes: 140 additions & 0 deletions config/linker/sam3u/common.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
ENTRY(_reset_isr)

_min_heap_size = 0x800;
_min_stack_size = 0x400;

/* Initial stack pointer (must be 8 byte aligned) */
_estack = (ORIGIN(ram) + LENGTH(ram)) & ~7;

/* Internal device memory */
PROVIDE(_system_unique_id = 0x1FFFF7E8);
PROVIDE(_system_memory = 0x1FFFF000);

SECTIONS
{
/* ISR Vectors */
.isr_vector :
{
. = ALIGN(4);
_svect = .;

KEEP(*(.isr_vector))

. = ALIGN(4);
_evect = .;
} > rom

/* Flash Code */
.text :
{
. = ALIGN(4);
_stext = .;

*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */

KEEP(*(.init))
KEEP(*(.fini))

. = ALIGN(4);
_etext = .;
} > rom

/* ARM */
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > rom
.ARM :
{
__exidx_start = .;

*(.ARM.exidx*)

__exidx_end = .;
} > rom
.ARM.attributes :
{
*(.ARM.attributes)
} > rom

/* C Array init/fini */
.preinit_array :
{
PROVIDE_HIDDEN(__preinit_array_start = .);
KEEP(*(.preinit_array*))
PROVIDE_HIDDEN(__preinit_array_end = .);
} > rom
.init_array :
{
PROVIDE_HIDDEN(__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array*))
PROVIDE_HIDDEN(__init_array_end = .);
} > rom
.fini_array :
{
PROVIDE_HIDDEN(__fini_array_start = .);
KEEP(*(.fini_array*))
KEEP(*(SORT(.fini_array.*)))
PROVIDE_HIDDEN(__fini_array_end = .);
} > rom

/* RAM Data */
_sidata = LOADADDR(.data);

.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */

*(.data) /* .data sections */
*(.data*) /* .data* sections */

. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} > ram AT > rom

/* BSS */
.bss :
{
. = ALIGN(4);
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;

*(.bss)
*(.bss*)
*(COMMON)

. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} > ram

PROVIDE(end = _ebss);
PROVIDE(_end = _ebss);

/* Ensure minimum stack & heap */
.min_heap_stack :
{
. = ALIGN(4);

. = . + _min_heap_size;
. = . + _min_stack_size;

. = ALIGN(4);
} > ram

/* Remove unused code from libs */
/DISCARD/ :
{
libc.a(*)
libm.a(*)
libgcc.a(*)
libnosys.a(*)
}
}
7 changes: 7 additions & 0 deletions config/linker/sam3u/sam3u1.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MEMORY
{
rom (rx) : ORIGIN = 0x00080000, LENGTH = 0x00010000
ram (rw) : ORIGIN = 0x20000000, LENGTH = 0x00004000
}

INCLUDE sam3u/common.ld
7 changes: 7 additions & 0 deletions config/linker/sam3u/sam3u2.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MEMORY
{
rom (rx) : ORIGIN = 0x00080000, LENGTH = 0x00020000
ram (rw) : ORIGIN = 0x20000000, LENGTH = 0x00008000
}

INCLUDE sam3u/common.ld
7 changes: 7 additions & 0 deletions config/linker/sam3u/sam3u4.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MEMORY
{
rom (rx) : ORIGIN = 0x00080000, LENGTH = 0x00040000
ram (rw) : ORIGIN = 0x20000000, LENGTH = 0x0000C000
}

INCLUDE sam3u/common.ld
2 changes: 2 additions & 0 deletions config/targets/russian-woodpecker.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
family = 'sam3u'
has-config = true
1 change: 1 addition & 0 deletions external/cmsis-dfp-sam3u
Submodule cmsis-dfp-sam3u added at 32d3f7
Loading