aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFlorian Heilmann <Florian.Heilmann@gmx.net>2018-08-07 01:03:54 +0200
committerKevin O'Connor <kevin@koconnor.net>2018-08-08 10:44:49 -0400
commit64e6d8589883975e6bd9656ac9ef05c6f6de6579 (patch)
treebd60fcda043b5d8a1db6519cdf74064e20e1655d /lib
parentd15c106288ccd585570832fdf849a42cd5dab213 (diff)
downloadkutter-64e6d8589883975e6bd9656ac9ef05c6f6de6579.tar.gz
kutter-64e6d8589883975e6bd9656ac9ef05c6f6de6579.tar.xz
kutter-64e6d8589883975e6bd9656ac9ef05c6f6de6579.zip
sam4e8e: Add the SAM4e8e port
This can be flashed to e.g. the duet wifi using bossac. It requires a later version as is currently included in the klipper repo (1.8 vs. 1.2). Comms are currently via UART0 only, USB serial is still TBD Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/README8
-rw-r--r--lib/cmsis-sam4e/cmsis-sam4e.patch56
-rw-r--r--lib/cmsis-sam4e/gcc/gcc/startup_sam4e.c9
-rw-r--r--lib/cmsis-sam4e/include/component/afec.h4
4 files changed, 73 insertions, 4 deletions
diff --git a/lib/README b/lib/README
index 5976b7cc..c785c7de 100644
--- a/lib/README
+++ b/lib/README
@@ -25,6 +25,14 @@ version 1.3.304 (extracted on 20180725). It has been modified to
compile with gcc's LTO feature and to work with chips that have a
bootloader. See samd21.patch for the modifications.
+The cmsis-sam4e8e directory contains code from the
+Atmel.SAM4E_DFP.1.1.57.atpack zip file found at:
+ http://packs.download.atmel.com/
+version 1.1.57 (extracted on 20180806). It has been modified to compile
+with gcc's LTO feature. Also, some AFEC register RW accesses have been modified
+to comply with the SAM4E datasheet. Finally, the interrupt vector table has
+been slightly modified to allow the code to run. See cmsis-sam4e8e.patch for the modifications.
+
The lpc176x directory contains code from the mbed project:
https://github.com/ARMmbed/mbed-os
version mbed-os-5.8.3 (c05d72c3c005fbb7e92c3994c32bda45218ae7fe).
diff --git a/lib/cmsis-sam4e/cmsis-sam4e.patch b/lib/cmsis-sam4e/cmsis-sam4e.patch
new file mode 100644
index 00000000..f69edfb2
--- /dev/null
+++ b/lib/cmsis-sam4e/cmsis-sam4e.patch
@@ -0,0 +1,56 @@
+--- a/lib/cmsis-sam4e/gcc/gcc/startup_sam4e.c
++++ b/lib/cmsis-sam4e/gcc/gcc/startup_sam4e.c
+@@ -104,7 +105,7 @@ void GMAC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
+ void UART1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
+
+ /* Exception Table */
+-__attribute__ ((section(".vectors")))
++__attribute__ ((section(".vectors"))) __attribute__((externally_visible))
+ const DeviceVectors exception_table = {
+
+ /* Configure Initial Stack Pointer, using linker-generated symbols */
+@@ -135,6 +136,7 @@ const DeviceVectors exception_table = {
+ (void*) PMC_Handler, /* 5 Power Management Controller */
+ (void*) EFC_Handler, /* 6 Enhanced Embedded Flash Controller */
+ (void*) UART0_Handler, /* 7 UART 0 */
++ (void*) Dummy_Handler, /* 8 Dummy */
+ (void*) PIOA_Handler, /* 9 Parallel I/O Controller A */
+ (void*) PIOB_Handler, /* 10 Parallel I/O Controller B */
+ (void*) PIOC_Handler, /* 11 Parallel I/O Controller C */
+@@ -166,6 +168,10 @@ const DeviceVectors exception_table = {
+ (void*) CAN0_Handler, /* 37 CAN0 */
+ (void*) CAN1_Handler, /* 38 CAN1 */
+ (void*) AES_Handler, /* 39 AES */
++ (void*) Dummy_Handler, /* 40 Dummy */
++ (void*) Dummy_Handler, /* 41 Dummy */
++ (void*) Dummy_Handler, /* 42 Dummy */
++ (void*) Dummy_Handler, /* 43 Dummy */
+ (void*) GMAC_Handler, /* 44 EMAC */
+ (void*) UART1_Handler /* 45 UART */
+ };
+@@ -198,7 +204,7 @@ void Reset_Handler(void)
+ SCB->VTOR = ((uint32_t) pSrc & SCB_VTOR_TBLOFF_Msk);
+
+ /* Initialize the C library */
+- __libc_init_array();
++ // __libc_init_array();
+
+ /* Branch to main function */
+ main();
+diff --git a/lib/cmsis-sam4e/include/component/afec.h b/lib/cmsis-sam4e/include/component/afec.h
+index 34c4e61d..9a4f8f96 100644
+--- a/lib/cmsis-sam4e/include/component/afec.h
++++ b/lib/cmsis-sam4e/include/component/afec.h
+@@ -59,9 +59,9 @@ typedef struct {
+ RoReg Reserved2[1];
+ RwReg AFE_CDOR; /**< \brief (Afec Offset: 0x5C) Channel DC Offset Register */
+ RwReg AFE_DIFFR; /**< \brief (Afec Offset: 0x60) Channel Differential Register */
+- RoReg AFE_CSELR; /**< \brief (Afec Offset: 0x64) Channel Register Selection */
++ RwReg AFE_CSELR; /**< \brief (Afec Offset: 0x64) Channel Register Selection */
+ RoReg AFE_CDR; /**< \brief (Afec Offset: 0x68) Channel Data Register */
+- RoReg AFE_COCR; /**< \brief (Afec Offset: 0x6C) Channel Offset Compensation Register */
++ RwReg AFE_COCR; /**< \brief (Afec Offset: 0x6C) Channel Offset Compensation Register */
+ RwReg AFE_TEMPMR; /**< \brief (Afec Offset: 0x70) Temperature Sensor Mode Register */
+ RwReg AFE_TEMPCWR; /**< \brief (Afec Offset: 0x74) Temperature Compare Window Register */
+ RoReg Reserved3[7];
+
diff --git a/lib/cmsis-sam4e/gcc/gcc/startup_sam4e.c b/lib/cmsis-sam4e/gcc/gcc/startup_sam4e.c
index fa6b305b..78402954 100644
--- a/lib/cmsis-sam4e/gcc/gcc/startup_sam4e.c
+++ b/lib/cmsis-sam4e/gcc/gcc/startup_sam4e.c
@@ -104,7 +104,7 @@ void GMAC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
void UART1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
/* Exception Table */
-__attribute__ ((section(".vectors")))
+__attribute__ ((section(".vectors"))) __attribute__((externally_visible))
const DeviceVectors exception_table = {
/* Configure Initial Stack Pointer, using linker-generated symbols */
@@ -135,6 +135,7 @@ const DeviceVectors exception_table = {
(void*) PMC_Handler, /* 5 Power Management Controller */
(void*) EFC_Handler, /* 6 Enhanced Embedded Flash Controller */
(void*) UART0_Handler, /* 7 UART 0 */
+ (void*) Dummy_Handler, /* 8 Dummy */
(void*) PIOA_Handler, /* 9 Parallel I/O Controller A */
(void*) PIOB_Handler, /* 10 Parallel I/O Controller B */
(void*) PIOC_Handler, /* 11 Parallel I/O Controller C */
@@ -166,6 +167,10 @@ const DeviceVectors exception_table = {
(void*) CAN0_Handler, /* 37 CAN0 */
(void*) CAN1_Handler, /* 38 CAN1 */
(void*) AES_Handler, /* 39 AES */
+ (void*) Dummy_Handler, /* 40 Dummy */
+ (void*) Dummy_Handler, /* 41 Dummy */
+ (void*) Dummy_Handler, /* 42 Dummy */
+ (void*) Dummy_Handler, /* 43 Dummy */
(void*) GMAC_Handler, /* 44 EMAC */
(void*) UART1_Handler /* 45 UART */
};
@@ -198,7 +203,7 @@ void Reset_Handler(void)
SCB->VTOR = ((uint32_t) pSrc & SCB_VTOR_TBLOFF_Msk);
/* Initialize the C library */
- __libc_init_array();
+ // __libc_init_array();
/* Branch to main function */
main();
diff --git a/lib/cmsis-sam4e/include/component/afec.h b/lib/cmsis-sam4e/include/component/afec.h
index 34c4e61d..9a4f8f96 100644
--- a/lib/cmsis-sam4e/include/component/afec.h
+++ b/lib/cmsis-sam4e/include/component/afec.h
@@ -59,9 +59,9 @@ typedef struct {
RoReg Reserved2[1];
RwReg AFE_CDOR; /**< \brief (Afec Offset: 0x5C) Channel DC Offset Register */
RwReg AFE_DIFFR; /**< \brief (Afec Offset: 0x60) Channel Differential Register */
- RoReg AFE_CSELR; /**< \brief (Afec Offset: 0x64) Channel Register Selection */
+ RwReg AFE_CSELR; /**< \brief (Afec Offset: 0x64) Channel Register Selection */
RoReg AFE_CDR; /**< \brief (Afec Offset: 0x68) Channel Data Register */
- RoReg AFE_COCR; /**< \brief (Afec Offset: 0x6C) Channel Offset Compensation Register */
+ RwReg AFE_COCR; /**< \brief (Afec Offset: 0x6C) Channel Offset Compensation Register */
RwReg AFE_TEMPMR; /**< \brief (Afec Offset: 0x70) Temperature Sensor Mode Register */
RwReg AFE_TEMPCWR; /**< \brief (Afec Offset: 0x74) Temperature Compare Window Register */
RoReg Reserved3[7];