arm: Add support for CSK6011A SOC and CSK6011A-NANO board
Signed-off-by: tfzou <tfzou@listenai.com>
This commit is contained in:
parent
198630a809
commit
fad8a22074
@ -441,6 +441,23 @@ config ARCH_CHIP_STM32
|
|||||||
---help---
|
---help---
|
||||||
STMicro STM32 architectures (ARM Cortex-M3/4).
|
STMicro STM32 architectures (ARM Cortex-M3/4).
|
||||||
|
|
||||||
|
config ARCH_CHIP_CSK6
|
||||||
|
bool "STMicro STM6 6001A/6011B/6012"
|
||||||
|
select ARCH_HAVE_MPU
|
||||||
|
select ARCH_HAVE_FETCHADD
|
||||||
|
select ARCH_HAVE_I2CRESET
|
||||||
|
select ARCH_HAVE_HEAPCHECK
|
||||||
|
select ARCH_HAVE_PROGMEM
|
||||||
|
select ARCH_HAVE_SPI_BITORDER
|
||||||
|
select ARCH_HAVE_TICKLESS
|
||||||
|
select ARCH_HAVE_TIMEKEEPING
|
||||||
|
select ARM_HAVE_MPU_UNIFIED
|
||||||
|
select ARMV8M_HAVE_STACKCHECK
|
||||||
|
select ARCH_HAVE_ADJTIME
|
||||||
|
select ARCH_CORTEXM33
|
||||||
|
---help---
|
||||||
|
LISTEANAI CSK6architectures (ARM Cortex-M33).
|
||||||
|
|
||||||
config ARCH_CHIP_STM32F0
|
config ARCH_CHIP_STM32F0
|
||||||
bool "STMicro STM32 F0"
|
bool "STMicro STM32 F0"
|
||||||
select ARCH_CORTEXM0
|
select ARCH_CORTEXM0
|
||||||
@ -1116,6 +1133,7 @@ config ARCH_CHIP
|
|||||||
default "goldfish" if ARCH_CHIP_GOLDFISH_ARM
|
default "goldfish" if ARCH_CHIP_GOLDFISH_ARM
|
||||||
default "at32" if ARCH_CHIP_AT32
|
default "at32" if ARCH_CHIP_AT32
|
||||||
default "cxd32xx" if ARCH_CHIP_CXD32XX
|
default "cxd32xx" if ARCH_CHIP_CXD32XX
|
||||||
|
default "csk6" if ARCH_CHIP_CSK6
|
||||||
|
|
||||||
config ARM_THUMB
|
config ARM_THUMB
|
||||||
bool "Thumb Mode"
|
bool "Thumb Mode"
|
||||||
|
37
arch/arm/include/csk6/chip.h
Normal file
37
arch/arm/include/csk6/chip.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/arm/include/csk6/chip.h
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ARCH_ARM_INCLUDE_CSK6_CHIP_H
|
||||||
|
#define __ARCH_ARM_INCLUDE_CSK6_CHIP_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
/* NVIC priority levels *****************************************************/
|
||||||
|
|
||||||
|
#define NVIC_SYSH_PRIORITY_MIN 0xf0 /* All bits set in minimum priority */
|
||||||
|
#define NVIC_SYSH_PRIORITY_DEFAULT 0x80 /* Midpoint is the default */
|
||||||
|
#define NVIC_SYSH_PRIORITY_MAX 0x00 /* Zero is maximum priority */
|
||||||
|
#define NVIC_SYSH_PRIORITY_STEP 0x10 /* Four bits of interrupt priority used */
|
||||||
|
|
||||||
|
#endif /* __ARCH_ARM_INCLUDE_CSK6_CHIP_H */
|
89
arch/arm/include/csk6/irq.h
Normal file
89
arch/arm/include/csk6/irq.h
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/arm/include/csk6/irq.h
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* This file should never be included directly but, rather,
|
||||||
|
* only indirectly through nuttx/irq.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __ARCH_ARM_INCLUDE_CSK6_IRQ_H
|
||||||
|
#define __ARCH_ARM_INCLUDE_CSK6_IRQ_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/irq.h>
|
||||||
|
#include <arch/csk6/chip.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Processor Exceptions (vectors 0-15) */
|
||||||
|
|
||||||
|
#define CSK6_IRQ_RESERVED (0) /* Reserved vector (only used with CONFIG_DEBUG_FEATURES) */
|
||||||
|
/* Vector 0: Reset stack pointer value */
|
||||||
|
/* Vector 1: Reset (not handler as an IRQ) */
|
||||||
|
#define CSK6_IRQ_NMI (2) /* Vector 2: Non-Maskable Interrupt (NMI) */
|
||||||
|
#define CSK6_IRQ_HARDFAULT (3) /* Vector 3: Hard fault */
|
||||||
|
#define CSK6_IRQ_MEMFAULT (4) /* Vector 4: Memory management (MPU) */
|
||||||
|
#define CSK6_IRQ_BUSFAULT (5) /* Vector 5: Bus fault */
|
||||||
|
#define CSK6_IRQ_USAGEFAULT (6) /* Vector 6: Usage fault */
|
||||||
|
/* Vectors 7-10: Reserved */
|
||||||
|
#define CSK6_IRQ_SVCALL (11) /* Vector 11: SVC call */
|
||||||
|
#define CSK6_IRQ_DBGMONITOR (12) /* Vector 12: Debug Monitor */
|
||||||
|
/* Vector 13: Reserved */
|
||||||
|
#define CSK6_IRQ_PENDSV (14) /* Vector 14: Pendable system service request */
|
||||||
|
#define CSK6_IRQ_SYSTICK (15) /* Vector 15: System tick */
|
||||||
|
|
||||||
|
#define CSK6_IRQ_FIRST (16) /* Vector number of the first external interrupt */
|
||||||
|
#define CSK6_NEXTINT (32)
|
||||||
|
|
||||||
|
#define NR_IRQS (CSK6_IRQ_FIRST + CSK6_NEXTINT)
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __ARCH_ARM_INCLUDE_CSK6_IRQ_H */
|
32
arch/arm/src/csk6/CMakeLists.txt
Normal file
32
arch/arm/src/csk6/CMakeLists.txt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# ##############################################################################
|
||||||
|
# arch/arm/src/csk6/CMakeLists.txt
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
|
||||||
|
# license agreements. See the NOTICE file distributed with this work for
|
||||||
|
# additional information regarding copyright ownership. The ASF licenses this
|
||||||
|
# file to you under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
# use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
# the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations under
|
||||||
|
# the License.
|
||||||
|
#
|
||||||
|
# ##############################################################################
|
||||||
|
|
||||||
|
set(SRCS)
|
||||||
|
|
||||||
|
list(
|
||||||
|
APPEND
|
||||||
|
SRCS
|
||||||
|
csk6_start.c
|
||||||
|
csk6_lowputc.c
|
||||||
|
csk6_irq.c
|
||||||
|
csk6_timer.c
|
||||||
|
csk6_serial.c)
|
||||||
|
|
||||||
|
target_sources(arch PRIVATE ${SRCS})
|
27
arch/arm/src/csk6/Make.defs
Normal file
27
arch/arm/src/csk6/Make.defs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
############################################################################
|
||||||
|
# arch/arm/src/csk6/Make.defs
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership. The
|
||||||
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance with the
|
||||||
|
# License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
include armv8-m/Make.defs
|
||||||
|
|
||||||
|
CHIP_CSRCS = ./csk6_start.c
|
||||||
|
CHIP_CSRCS += ./csk6_lowputc.c
|
||||||
|
CHIP_CSRCS += ./csk6_irq.c
|
||||||
|
CHIP_CSRCS += ./csk6_timer.c
|
||||||
|
CHIP_CSRCS += ./csk6_serial.c
|
44
arch/arm/src/csk6/chip.h
Normal file
44
arch/arm/src/csk6/chip.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/arm/src/csk6/chip.h
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ARCH_ARM_SRC_CSK6_CHIP_H
|
||||||
|
#define __ARCH_ARM_SRC_CSK6_CHIP_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
/* Include the chip capabilities file */
|
||||||
|
|
||||||
|
#include <arch/csk6/chip.h>
|
||||||
|
|
||||||
|
/* Include the chip interrupt definition file */
|
||||||
|
|
||||||
|
#include <arch/csk6/irq.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define ARMV8M_PERIPHERAL_INTERRUPTS (CSK6_NEXTINT)
|
||||||
|
|
||||||
|
#endif /* __ARCH_ARM_SRC_CSK6_CHIP_H */
|
340
arch/arm/src/csk6/csk6_irq.c
Normal file
340
arch/arm/src/csk6/csk6_irq.c
Normal file
@ -0,0 +1,340 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/arm/src/csk6/csk6_irq.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/arch.h>
|
||||||
|
#include <debug.h>
|
||||||
|
#include <arch/csk6/irq.h>
|
||||||
|
|
||||||
|
#include "arm_internal.h"
|
||||||
|
#include "nvic.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define NVIC_ENA_OFFSET (0)
|
||||||
|
#define NVIC_CLRENA_OFFSET (NVIC_IRQ0_31_CLEAR - NVIC_IRQ0_31_ENABLE)
|
||||||
|
|
||||||
|
#define DEFPRIORITY32 (NVIC_SYSH_PRIORITY_DEFAULT << 24 | \
|
||||||
|
NVIC_SYSH_PRIORITY_DEFAULT << 16 | \
|
||||||
|
NVIC_SYSH_PRIORITY_DEFAULT << 8 | \
|
||||||
|
NVIC_SYSH_PRIORITY_DEFAULT)
|
||||||
|
|
||||||
|
/* Size of the interrupt stack allocation */
|
||||||
|
|
||||||
|
#define INTSTACK_ALLOC (CONFIG_SMP_NCPUS * INTSTACK_SIZE)
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_FEATURES
|
||||||
|
static int csk6_nmi(int irq, void *context, void *arg)
|
||||||
|
{
|
||||||
|
up_irq_save();
|
||||||
|
_err("PANIC!!! NMI received\n");
|
||||||
|
PANIC();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int csk6_pendsv(int irq, void *context, void *arg)
|
||||||
|
{
|
||||||
|
up_irq_save();
|
||||||
|
_err("PANIC!!! PendSV received\n");
|
||||||
|
PANIC();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int csk6_reserved(int irq, void *context, void *arg)
|
||||||
|
{
|
||||||
|
up_irq_save();
|
||||||
|
_err("PANIC!!! Reserved interrupt\n");
|
||||||
|
PANIC();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: csk6_prioritize_syscall
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set the priority of an exception. This function may be needed
|
||||||
|
* internally even if support for prioritized interrupts is not enabled.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARMV8M_USEBASEPRI
|
||||||
|
static inline void csk6_prioritize_syscall(int priority)
|
||||||
|
{
|
||||||
|
uint32_t regval;
|
||||||
|
|
||||||
|
/* SVCALL is system handler 11 */
|
||||||
|
|
||||||
|
regval = getreg32(NVIC_SYSH8_11_PRIORITY);
|
||||||
|
regval &= ~NVIC_SYSH_PRIORITY_PR11_MASK;
|
||||||
|
regval |= (priority << NVIC_SYSH_PRIORITY_PR11_SHIFT);
|
||||||
|
putreg32(regval, NVIC_SYSH8_11_PRIORITY);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_irqinitialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function is called by up_initialize() during the bring-up of the
|
||||||
|
* system. It is the responsibility of this function to but the interrupt
|
||||||
|
* subsystem into the working and ready state.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void up_irqinitialize(void)
|
||||||
|
{
|
||||||
|
uint32_t regaddr;
|
||||||
|
int num_priority_registers;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Disable all interrupts */
|
||||||
|
|
||||||
|
for (i = 0; i < NR_IRQS - CSK6_IRQ_FIRST; i += 32)
|
||||||
|
{
|
||||||
|
putreg32(0xffffffff, NVIC_IRQ_CLEAR(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
putreg32((uint32_t)_vectors, NVIC_VECTAB);
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_RAMVECTORS
|
||||||
|
/* If CONFIG_ARCH_RAMVECTORS is defined, then we are using a RAM-based
|
||||||
|
* vector table that requires special initialization.
|
||||||
|
*/
|
||||||
|
|
||||||
|
up_ramvec_initialize();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Set all interrupts (and exceptions) to the default priority */
|
||||||
|
|
||||||
|
putreg32(DEFPRIORITY32, NVIC_SYSH4_7_PRIORITY);
|
||||||
|
putreg32(DEFPRIORITY32, NVIC_SYSH8_11_PRIORITY);
|
||||||
|
putreg32(DEFPRIORITY32, NVIC_SYSH12_15_PRIORITY);
|
||||||
|
|
||||||
|
/* The NVIC ICTR register (bits 0-4) holds the number of of interrupt
|
||||||
|
* lines that the NVIC supports:
|
||||||
|
*
|
||||||
|
* 0 -> 32 interrupt lines, 8 priority registers
|
||||||
|
* 1 -> 64 " " " ", 16 priority registers
|
||||||
|
* 2 -> 96 " " " ", 32 priority registers
|
||||||
|
* ...
|
||||||
|
*/
|
||||||
|
|
||||||
|
num_priority_registers = (getreg32(NVIC_ICTR) + 1) * 8;
|
||||||
|
|
||||||
|
/* Now set all of the interrupt lines to the default priority */
|
||||||
|
|
||||||
|
regaddr = NVIC_IRQ0_3_PRIORITY;
|
||||||
|
while (num_priority_registers--)
|
||||||
|
{
|
||||||
|
putreg32(DEFPRIORITY32, regaddr);
|
||||||
|
regaddr += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Attach the SVCall and Hard Fault exception handlers. The SVCall
|
||||||
|
* exception is used for performing context switches; The Hard Fault
|
||||||
|
* must also be caught because a SVCall may show up as a Hard Fault
|
||||||
|
* under certain conditions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
irq_attach(CSK6_IRQ_SVCALL, arm_svcall, NULL);
|
||||||
|
irq_attach(CSK6_IRQ_HARDFAULT, arm_hardfault, NULL);
|
||||||
|
|
||||||
|
/* Set the priority of the SVCall interrupt */
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_IRQPRIO
|
||||||
|
|
||||||
|
/* up_prioritize_irq(CSK6_IRQ_PENDSV, NVIC_SYSH_PRIORITY_MIN); */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_ARMV8M_USEBASEPRI
|
||||||
|
csk6_prioritize_syscall(NVIC_SYSH_SVCALL_PRIORITY);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If the MPU is enabled, then attach and enable the Memory Management
|
||||||
|
* Fault handler.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARM_MPU
|
||||||
|
irq_attach(CSK6_IRQ_MEMFAULT, arm_memfault, NULL);
|
||||||
|
up_enable_irq(CSK6_IRQ_MEMFAULT);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Attach all other processor exceptions (except reset and sys tick) */
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_FEATURES
|
||||||
|
irq_attach(CSK6_IRQ_NMI, csk6_nmi, NULL);
|
||||||
|
#ifndef CONFIG_ARM_MPU
|
||||||
|
irq_attach(CSK6_IRQ_MEMFAULT, arm_memfault, NULL);
|
||||||
|
#endif
|
||||||
|
irq_attach(CSK6_IRQ_BUSFAULT, arm_busfault, NULL);
|
||||||
|
irq_attach(CSK6_IRQ_USAGEFAULT, arm_usagefault, NULL);
|
||||||
|
irq_attach(CSK6_IRQ_PENDSV, csk6_pendsv, NULL);
|
||||||
|
arm_enable_dbgmonitor();
|
||||||
|
irq_attach(CSK6_IRQ_DBGMONITOR, arm_dbgmonitor, NULL);
|
||||||
|
irq_attach(CSK6_IRQ_RESERVED, csk6_reserved, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_SUPPRESS_INTERRUPTS
|
||||||
|
|
||||||
|
/* And finally, enable interrupts */
|
||||||
|
|
||||||
|
up_irq_enable();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static int csk6_irqinfo(int irq, uintptr_t *regaddr, uint32_t *bit,
|
||||||
|
uintptr_t offset)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
|
DEBUGASSERT(irq >= CSK6_IRQ_NMI && irq < NR_IRQS);
|
||||||
|
|
||||||
|
/* Check for external interrupt */
|
||||||
|
|
||||||
|
if (irq >= CSK6_IRQ_FIRST)
|
||||||
|
{
|
||||||
|
n = irq - CSK6_IRQ_FIRST;
|
||||||
|
*regaddr = NVIC_IRQ_ENABLE(n) + offset;
|
||||||
|
*bit = (uint32_t)0x1 << (n & 0x1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle processor exceptions. Only a few can be disabled */
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*regaddr = NVIC_SYSHCON;
|
||||||
|
if (irq == CSK6_IRQ_MEMFAULT)
|
||||||
|
{
|
||||||
|
*bit = NVIC_SYSHCON_MEMFAULTENA;
|
||||||
|
}
|
||||||
|
else if (irq == CSK6_IRQ_BUSFAULT)
|
||||||
|
{
|
||||||
|
*bit = NVIC_SYSHCON_BUSFAULTENA;
|
||||||
|
}
|
||||||
|
else if (irq == CSK6_IRQ_USAGEFAULT)
|
||||||
|
{
|
||||||
|
*bit = NVIC_SYSHCON_USGFAULTENA;
|
||||||
|
}
|
||||||
|
else if (irq == CSK6_IRQ_SYSTICK)
|
||||||
|
{
|
||||||
|
*regaddr = NVIC_SYSTICK_CTRL;
|
||||||
|
*bit = NVIC_SYSTICK_CTRL_ENABLE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -EINVAL; /* Invalid or unsupported exception */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_disable_irq
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Disable the IRQ specified by 'irq'
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void up_disable_irq(int irq)
|
||||||
|
{
|
||||||
|
uintptr_t regaddr;
|
||||||
|
uint32_t regval;
|
||||||
|
uint32_t bit;
|
||||||
|
|
||||||
|
if (csk6_irqinfo(irq, ®addr, &bit, NVIC_CLRENA_OFFSET) == 0)
|
||||||
|
{
|
||||||
|
/* Modify the appropriate bit in the register to disable the interrupt.
|
||||||
|
* For normal interrupts, we need to set the bit in the associated
|
||||||
|
* Interrupt Clear Enable register. For other exceptions, we need to
|
||||||
|
* clear the bit in the System Handler Control and State Register.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (irq >= CSK6_IRQ_FIRST)
|
||||||
|
{
|
||||||
|
putreg32(bit, regaddr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
regval = getreg32(regaddr);
|
||||||
|
regval &= ~bit;
|
||||||
|
putreg32(regval, regaddr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_enable_irq
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Enable the IRQ specified by 'irq'
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void up_enable_irq(int irq)
|
||||||
|
{
|
||||||
|
uintptr_t regaddr;
|
||||||
|
uint32_t regval;
|
||||||
|
uint32_t bit;
|
||||||
|
|
||||||
|
if (csk6_irqinfo(irq, ®addr, &bit, NVIC_ENA_OFFSET) == 0)
|
||||||
|
{
|
||||||
|
/* Modify the appropriate bit in the register to enable the interrupt.
|
||||||
|
* For normal interrupts, we need to set the bit in the associated
|
||||||
|
* Interrupt Set Enable register. For other exceptions, we need to
|
||||||
|
* set the bit in the System Handler Control and State Register.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (irq >= CSK6_IRQ_FIRST)
|
||||||
|
{
|
||||||
|
putreg32(bit, regaddr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
regval = getreg32(regaddr);
|
||||||
|
regval |= bit;
|
||||||
|
putreg32(regval, regaddr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: arm_ack_irq
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void arm_ack_irq(int irq)
|
||||||
|
{
|
||||||
|
}
|
279
arch/arm/src/csk6/csk6_lowputc.c
Normal file
279
arch/arm/src/csk6/csk6_lowputc.c
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/arm/src/csk6/csk6_lowputc.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
#include "arm_internal.h"
|
||||||
|
|
||||||
|
#include "chip.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define CSK6_IOMUX_BASE 0x46200000 // size=1MB
|
||||||
|
#define CSK6_SYSCTRL_BASE 0x46000000 // size=64KB
|
||||||
|
#define CSK6_SYSPLL_CTRL_BASE 0x46020000 // size=64KB
|
||||||
|
#define CSK6_UART0_BASE 0x45000000 // size=1MB
|
||||||
|
|
||||||
|
#define CSK6011A_NANO_BOARD_H_XTAL_SRC_FREQ 24000000UL
|
||||||
|
#define CSK6011A_NANO_BOARD_L_XTAL_SRC_FREQ 32768UL
|
||||||
|
|
||||||
|
#define CSK6_IOMUX_PIN_OFFSET(pin) (pin << 2)
|
||||||
|
#define CSK6_IOMUX_FSEL_MASK (0X0f)
|
||||||
|
#define CSK6_IOMUX_FSEL_UART0 (0x2)
|
||||||
|
#define CSK6_UART0_TX_GPIO_PIN (2)
|
||||||
|
#define CSK6_UART0_RX_GPIO_PIN (3)
|
||||||
|
|
||||||
|
#define REG_FIELD_MASK(w, s) (((1U << (w)) - 1) << (s))
|
||||||
|
#define REG_FIELD_EXTRACT(v, w, s) ((v & REG_FIELD_MASK(w, s)) >> s)
|
||||||
|
#define REG_VALUE_SHIFT(v, s) (v << s)
|
||||||
|
|
||||||
|
/* Select USART parameters for the selected console */
|
||||||
|
#if defined(CONFIG_USART0_SERIAL_CONSOLE)
|
||||||
|
#define HAVE_CONSOLE
|
||||||
|
#define CSK6_CONSOLE_BASE() ((DW_UART_RegDef *)UART0_BASE)
|
||||||
|
#define CSK6_CONSOLE_BAUD CONFIG_USART0_BAUD
|
||||||
|
#define CSK6_CONSOLE_PARITY CONFIG_USART0_PARITY
|
||||||
|
#define CSK6_CONSOLE_NBITS CONFIG_USART0_BITS
|
||||||
|
#define CSK6_CONSOLE_2STOP CONFIG_USART0_2STOP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static inline float uart_compute_div(uint32_t baudrate, uint32_t clk)
|
||||||
|
{
|
||||||
|
uint32_t tmp = 16 * baudrate;
|
||||||
|
uint32_t div_i = clk / tmp;
|
||||||
|
|
||||||
|
float div_f = ((float)clk / (float)tmp) - div_i;
|
||||||
|
float div1 = div_i + (float)((uint32_t)(div_f * 16)) / 16.0;
|
||||||
|
float div2 = div_i + (float)((uint32_t)(div_f * 16) + 1) / 16.0;
|
||||||
|
|
||||||
|
int32_t err = clk - div1 * tmp;
|
||||||
|
int32_t err2 = div2 * tmp - clk;
|
||||||
|
|
||||||
|
if (err2 < 0)
|
||||||
|
{
|
||||||
|
err2 = err2 * (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return err > err2 ? div2 : div1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void csk6_lowsetup_gpio_init(void)
|
||||||
|
{
|
||||||
|
modreg32(CSK6_IOMUX_FSEL_UART0,
|
||||||
|
CSK6_IOMUX_FSEL_MASK,
|
||||||
|
CSK6_IOMUX_BASE + CSK6_IOMUX_PIN_OFFSET(CSK6_UART0_TX_GPIO_PIN));
|
||||||
|
|
||||||
|
modreg32(CSK6_IOMUX_FSEL_UART0,
|
||||||
|
CSK6_IOMUX_FSEL_MASK,
|
||||||
|
CSK6_IOMUX_BASE + CSK6_IOMUX_PIN_OFFSET(CSK6_UART0_RX_GPIO_PIN));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t get_uart0_clock(void)
|
||||||
|
{
|
||||||
|
uint32_t freq;
|
||||||
|
uint32_t pll_freq;
|
||||||
|
uint8_t div_n;
|
||||||
|
uint8_t div_m;
|
||||||
|
uint32_t reg_val;
|
||||||
|
|
||||||
|
reg_val = getreg32(CSK6_SYSCTRL_BASE + 0x3c);
|
||||||
|
div_n = REG_FIELD_EXTRACT(reg_val, 5, 25);
|
||||||
|
div_m = REG_FIELD_EXTRACT(reg_val, 5, 20) + 1;
|
||||||
|
|
||||||
|
if (!REG_FIELD_EXTRACT(reg_val, 1, 16)) /* CRM_IpSrcXtal */
|
||||||
|
{
|
||||||
|
freq = CSK6011A_NANO_BOARD_H_XTAL_SRC_FREQ;
|
||||||
|
}
|
||||||
|
else /* CRM_IpSrcSysPllPeri */
|
||||||
|
{
|
||||||
|
uint32_t div;
|
||||||
|
reg_val = getreg32(CSK6_SYSCTRL_BASE + 0x30);
|
||||||
|
div = REG_FIELD_EXTRACT(reg_val, 2, 29) + 10;
|
||||||
|
pll_freq = CSK6011A_NANO_BOARD_H_XTAL_SRC_FREQ *
|
||||||
|
REG_FIELD_EXTRACT(getreg32(CSK6_SYSPLL_CTRL_BASE + 0x14), 7, 1) /
|
||||||
|
(REG_FIELD_EXTRACT(
|
||||||
|
getreg32(CSK6_SYSPLL_CTRL_BASE + 0x14), 4, 8)
|
||||||
|
+ 1);
|
||||||
|
freq = pll_freq / div;
|
||||||
|
}
|
||||||
|
|
||||||
|
return freq * div_n / div_m;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void csk6_uart_clock_enable(void)
|
||||||
|
{
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x01, 19),
|
||||||
|
REG_FIELD_MASK(1, 19),
|
||||||
|
CSK6_SYSCTRL_BASE + 0x3c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(HAVE_CONSOLE)
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: arm_lowputc
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Output one byte on the serial console
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void arm_lowputc(char ch)
|
||||||
|
{
|
||||||
|
while (!REG_FIELD_EXTRACT(getreg32(CSK6_UART0_BASE + 0x14), 1, 6))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
putreg32(ch, CSK6_UART0_BASE + 0x00);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: csk6_lowsetup
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This performs basic initialization of the USART used for the serial
|
||||||
|
* console. Its purpose is to get the console output available as soon
|
||||||
|
* as possible.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void csk6_lowsetup(void)
|
||||||
|
{
|
||||||
|
uint32_t uart_clock = 0;
|
||||||
|
float div;
|
||||||
|
uint32_t div_i;
|
||||||
|
uint32_t div_f;
|
||||||
|
|
||||||
|
csk6_lowsetup_gpio_init();
|
||||||
|
csk6_uart_clock_enable();
|
||||||
|
uart_clock = get_uart0_clock();
|
||||||
|
|
||||||
|
/* disable all */
|
||||||
|
|
||||||
|
putreg32(0, CSK6_UART0_BASE + 0x04);
|
||||||
|
|
||||||
|
div = uart_compute_div(CSK6_CONSOLE_BAUD, uart_clock);
|
||||||
|
div_i = (uint32_t)div;
|
||||||
|
div_f = (div - div_i) * 16;
|
||||||
|
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x01, 7),
|
||||||
|
REG_FIELD_MASK(1, 7),
|
||||||
|
CSK6_UART0_BASE + 0x0c);
|
||||||
|
|
||||||
|
modreg32(REG_VALUE_SHIFT(div_i, 0),
|
||||||
|
REG_FIELD_MASK(8, 0),
|
||||||
|
CSK6_UART0_BASE + 0x00);
|
||||||
|
|
||||||
|
modreg32(REG_VALUE_SHIFT(div_i >> 8, 0),
|
||||||
|
REG_FIELD_MASK(8, 0),
|
||||||
|
CSK6_UART0_BASE + 0x04);
|
||||||
|
|
||||||
|
modreg32(REG_VALUE_SHIFT(div_f, 0),
|
||||||
|
REG_FIELD_MASK(4, 0),
|
||||||
|
CSK6_UART0_BASE + 0xc0);
|
||||||
|
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x00, 0),
|
||||||
|
REG_FIELD_MASK(1, 7),
|
||||||
|
CSK6_UART0_BASE + 0x0c);
|
||||||
|
|
||||||
|
#if (CSK6_CONSOLE_PARITY == 1)
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x01, 3),
|
||||||
|
REG_FIELD_MASK(1, 3),
|
||||||
|
CSK6_UART0_BASE + 0x0c);
|
||||||
|
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x01, 3),
|
||||||
|
REG_FIELD_MASK(1, 4),
|
||||||
|
CSK6_UART0_BASE + 0x0c);
|
||||||
|
|
||||||
|
#elif (CSK6_CONSOLE_PARITY == 2)
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x01, 3),
|
||||||
|
REG_FIELD_MASK(1, 3),
|
||||||
|
CSK6_UART0_BASE + 0x0c);
|
||||||
|
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x00, 3),
|
||||||
|
REG_FIELD_MASK(1, 4),
|
||||||
|
CSK6_UART0_BASE + 0x0c);
|
||||||
|
|
||||||
|
#else
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x00, 3),
|
||||||
|
REG_FIELD_MASK(1, 3),
|
||||||
|
CSK6_UART0_BASE + 0x0c);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (CSK6_CONSOLE_NBITS == 5)
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x00, 0),
|
||||||
|
REG_FIELD_MASK(2, 0),
|
||||||
|
CSK6_UART0_BASE + 0x0c);
|
||||||
|
#elif (CSK6_CONSOLE_NBITS == 6)
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x00, 0),
|
||||||
|
REG_FIELD_MASK(2, 0),
|
||||||
|
CSK6_UART0_BASE + 0x0c);
|
||||||
|
#elif (CSK6_CONSOLE_NBITS == 7)
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x00, 0),
|
||||||
|
REG_FIELD_MASK(2, 0),
|
||||||
|
CSK6_UART0_BASE + 0x0c);
|
||||||
|
#else
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x03, 0),
|
||||||
|
REG_FIELD_MASK(2, 0),
|
||||||
|
CSK6_UART0_BASE + 0x0c);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (CSK6_CONSOLE_2STOP)
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x01, 2),
|
||||||
|
REG_FIELD_MASK(1, 2),
|
||||||
|
CSK6_UART0_BASE + 0x0c);
|
||||||
|
#else
|
||||||
|
modreg32(REG_VALUE_SHIFT(0x00, 2),
|
||||||
|
REG_FIELD_MASK(1, 2),
|
||||||
|
CSK6_UART0_BASE + 0x0c);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
putreg32(REG_VALUE_SHIFT(0x02, 4) | REG_VALUE_SHIFT(0x01, 0),
|
||||||
|
CSK6_UART0_BASE + 0x08); /* set fifo */
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void arm_lowputc(char ch)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void csk6_lowsetup(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
60
arch/arm/src/csk6/csk6_lowputc.h
Normal file
60
arch/arm/src/csk6/csk6_lowputc.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/arm/src/csk6/csk6_lowputc.h
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ARCH_ARM_SRC_CSK6_LOWPUTC_H
|
||||||
|
#define __ARCH_ARM_SRC_CSK6_LOWPUTC_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: csk6_lowsetup
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Called at the very beginning of _start.
|
||||||
|
* Performs low level initialization of serial console.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void csk6_lowsetup(void);
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __ASSEMBLY__ */
|
||||||
|
#endif /* __ARCH_ARM_SRC_CSK6_CSK6XXX_LOWPUTC_H */
|
63
arch/arm/src/csk6/csk6_serial.c
Normal file
63
arch/arm/src/csk6/csk6_serial.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* arch/arm/src/csk6/csk6_serial.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Included Files
|
||||||
|
***************************************************************************/
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <nuttx/serial/uart_16550.h>
|
||||||
|
|
||||||
|
#include <arm_internal.h>
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Name: arm_serialinit
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Register serial console and serial ports. This assumes that
|
||||||
|
* arm_earlyserialinit was called previously.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
void arm_serialinit(void)
|
||||||
|
{
|
||||||
|
u16550_serialinit();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if USE_EARLYSERIALINIT
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Name: arm_earlyserialinit
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Performs the low level UART initialization early in debug so that the
|
||||||
|
* serial console will be available during bootup. This must be called
|
||||||
|
* before arm_serialinit.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
void arm_earlyserialinit(void)
|
||||||
|
{
|
||||||
|
u16550_earlyserialinit();
|
||||||
|
}
|
||||||
|
#endif
|
174
arch/arm/src/csk6/csk6_start.c
Normal file
174
arch/arm/src/csk6/csk6_start.c
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/arm/src/csk6/csk6_start.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/init.h>
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
#include "arm_internal.h"
|
||||||
|
#include "nvic.h"
|
||||||
|
|
||||||
|
#include "csk6_lowputc.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Memory Map ***************************************************************/
|
||||||
|
|
||||||
|
#define HEAP_BASE ((uintptr_t)_ebss + CONFIG_IDLETHREAD_STACKSIZE)
|
||||||
|
|
||||||
|
/* g_idle_topstack: _sbss is the start of the BSS region as defined by the
|
||||||
|
* linker script. _ebss lies at the end of the BSS region. The idle task
|
||||||
|
* stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE.
|
||||||
|
* The IDLE thread is the thread that the system boots on and, eventually,
|
||||||
|
* becomes the IDLE, do nothing task that runs only when there is nothing
|
||||||
|
* else to run. The heap continues from there until the end of memory.
|
||||||
|
* g_idle_topstack is a read-only variable the provides this computed
|
||||||
|
* address.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const uintptr_t g_idle_topstack = HEAP_BASE;
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: showprogress
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Print a character on the UART to show boot status.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_FEATURES
|
||||||
|
#define showprogress(c) arm_lowputc(c)
|
||||||
|
#else
|
||||||
|
#define showprogress(c)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARMV8M_STACKCHECK
|
||||||
|
/* we need to get r10 set before we can allow instrumentation calls */
|
||||||
|
|
||||||
|
void __start(void) noinstrument_function;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: __start
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This is the reset entry point.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void __start(void)
|
||||||
|
{
|
||||||
|
const uint32_t *src;
|
||||||
|
uint32_t *dest;
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARMV8M_STACKCHECK
|
||||||
|
/* Set the stack limit before we attempt to call any functions */
|
||||||
|
|
||||||
|
__asm__ volatile("sub r10, sp, %0" : : "r"
|
||||||
|
(CONFIG_IDLETHREAD_STACKSIZE - 64) :);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Configure the UART so that we can get debug output as soon as possible */
|
||||||
|
|
||||||
|
csk6_lowsetup();
|
||||||
|
|
||||||
|
showprogress('A');
|
||||||
|
|
||||||
|
/* Clear .bss. We'll do this inline (vs. calling memset) just to be
|
||||||
|
* certain that there are no issues with the state of global variables.
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (dest = (uint32_t *)_sbss; dest < (uint32_t *)_ebss; )
|
||||||
|
{
|
||||||
|
*dest++ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
showprogress('B');
|
||||||
|
|
||||||
|
/* Move the initialized data section from his temporary holding spot in
|
||||||
|
* FLASH into the correct place in SRAM. The correct place in SRAM is
|
||||||
|
* give by _sdata and _edata. The temporary location is in FLASH at the
|
||||||
|
* end of all of the other read-only data (.text, .rodata) at _eronly.
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (src = (const uint32_t *)_eronly,
|
||||||
|
dest = (uint32_t *)_sdata; dest < (uint32_t *)_edata;
|
||||||
|
)
|
||||||
|
{
|
||||||
|
*dest++ = *src++;
|
||||||
|
}
|
||||||
|
|
||||||
|
showprogress('C');
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARMV8M_STACKCHECK
|
||||||
|
arm_stack_check_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Perform early serial initialization */
|
||||||
|
|
||||||
|
#ifdef USE_EARLYSERIALINIT
|
||||||
|
arm_earlyserialinit();
|
||||||
|
#endif
|
||||||
|
showprogress('D');
|
||||||
|
|
||||||
|
/* For the case of the separate user-/kernel-space build, perform whatever
|
||||||
|
* platform specific initialization of the user memory is required.
|
||||||
|
* Normally this just means initializing the user space .data and .bss
|
||||||
|
* segments.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Initialize onboard resources */
|
||||||
|
|
||||||
|
showprogress('F');
|
||||||
|
|
||||||
|
/* Then start NuttX */
|
||||||
|
|
||||||
|
showprogress('\r');
|
||||||
|
showprogress('\n');
|
||||||
|
|
||||||
|
nx_start();
|
||||||
|
|
||||||
|
/* Shoulnd't get here */
|
||||||
|
|
||||||
|
for (; ; );
|
||||||
|
}
|
55
arch/arm/src/csk6/csk6_timer.c
Normal file
55
arch/arm/src/csk6/csk6_timer.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/arm/src/csk6/csk6_timer.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
#include <nuttx/timers/arch_timer.h>
|
||||||
|
|
||||||
|
#include "arm_internal.h"
|
||||||
|
#include "systick.h"
|
||||||
|
#include "nvic.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define SYSTICK_RELOAD ((CSK6_SYSTICK_CLOCK / CLK_TCK) - 1)
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: up_timer_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function is called during start-up to initialize
|
||||||
|
* the timer hardware.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void up_timer_initialize(void)
|
||||||
|
{
|
||||||
|
/* Set reload register, qemu maybe have a bug,
|
||||||
|
* if RELOAD is zero, set CTRL is not useful
|
||||||
|
*/
|
||||||
|
|
||||||
|
putreg32(SYSTICK_RELOAD, NVIC_SYSTICK_RELOAD);
|
||||||
|
up_timer_set_lowerhalf(systick_initialize(true, CSK6_SYSTICK_CLOCK, -1));
|
||||||
|
}
|
@ -2586,6 +2586,12 @@ config ARCH_BOARD_STM32F4_DISCOVERY
|
|||||||
---help---
|
---help---
|
||||||
STMicro STM32F4-Discovery board based on the STMicro STM32F407VGT6 MCU.
|
STMicro STM32F4-Discovery board based on the STMicro STM32F407VGT6 MCU.
|
||||||
|
|
||||||
|
config ARCH_BOARD_CSK6011A_NANO
|
||||||
|
bool "Listenai csk6011a-nano board"
|
||||||
|
depends on ARCH_CHIP_CSK6
|
||||||
|
---help---
|
||||||
|
Listenai csk6011a-nano board based on the listenai csk6011a MCU.
|
||||||
|
|
||||||
config ARCH_BOARD_STM32F411E_DISCO
|
config ARCH_BOARD_STM32F411E_DISCO
|
||||||
bool "STMicro STM32F411E-Discovery board"
|
bool "STMicro STM32F411E-Discovery board"
|
||||||
depends on ARCH_CHIP_STM32F411VE
|
depends on ARCH_CHIP_STM32F411VE
|
||||||
@ -3534,6 +3540,7 @@ config ARCH_BOARD
|
|||||||
default "hpm6360evk" if ARCH_BOARD_HPM6360EVK
|
default "hpm6360evk" if ARCH_BOARD_HPM6360EVK
|
||||||
default "hpm6750evk2" if ARCH_BOARD_HPM6750EVK2
|
default "hpm6750evk2" if ARCH_BOARD_HPM6750EVK2
|
||||||
default "at32f437-mini" if ARCH_BOARD_AT32F437_MINI
|
default "at32f437-mini" if ARCH_BOARD_AT32F437_MINI
|
||||||
|
default "csk6011a-nano" if ARCH_BOARD_CSK6011A_NANO
|
||||||
|
|
||||||
comment "Common Board Options"
|
comment "Common Board Options"
|
||||||
|
|
||||||
@ -4526,6 +4533,9 @@ endif
|
|||||||
if ARCH_BOARD_AT32F437_MINI
|
if ARCH_BOARD_AT32F437_MINI
|
||||||
source "boards/arm/at32/at32f437-mini/Kconfig"
|
source "boards/arm/at32/at32f437-mini/Kconfig"
|
||||||
endif
|
endif
|
||||||
|
if ARCH_BOARD_CSK6011A_NANO
|
||||||
|
source "boards/arm/csk6/csk6011a-nano/Kconfig"
|
||||||
|
endif
|
||||||
|
|
||||||
comment "Board-Common Options"
|
comment "Board-Common Options"
|
||||||
|
|
||||||
|
28
boards/arm/csk6/csk6011a-nano/CMakeLists.txt
Normal file
28
boards/arm/csk6/csk6011a-nano/CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# ##############################################################################
|
||||||
|
# boards/arm/csk6/csk6011a-nano/CMakeLists.txt
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
|
||||||
|
# license agreements. See the NOTICE file distributed with this work for
|
||||||
|
# additional information regarding copyright ownership. The ASF licenses this
|
||||||
|
# file to you under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
# use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
# the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations under
|
||||||
|
# the License.
|
||||||
|
#
|
||||||
|
# ##############################################################################
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
if(NOT CONFIG_BUILD_FLAT)
|
||||||
|
add_subdirectory(kernel)
|
||||||
|
set_property(
|
||||||
|
GLOBAL PROPERTY LD_SCRIPT_USER ${CMAKE_CURRENT_LIST_DIR}/scripts/memory.ld
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/scripts/user-space.ld)
|
||||||
|
endif()
|
18
boards/arm/csk6/csk6011a-nano/Kconfig
Normal file
18
boards/arm/csk6/csk6011a-nano/Kconfig
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#
|
||||||
|
# For a description of the syntax of this configuration file,
|
||||||
|
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||||
|
#
|
||||||
|
|
||||||
|
if ARCH_BOARD_CSK6011A_NANO
|
||||||
|
choice
|
||||||
|
prompt "Console Mode"
|
||||||
|
default CSK6_CONSOLE_UART0
|
||||||
|
|
||||||
|
config CSK6_CONSOLE_UART0
|
||||||
|
bool "USART0 is a console port"
|
||||||
|
select USART0_SERIALDRIVER
|
||||||
|
|
||||||
|
#TODO add support other port
|
||||||
|
endchoice # USART0 Mode
|
||||||
|
endif
|
||||||
|
|
55
boards/arm/csk6/csk6011a-nano/configs/nsh/defconfig
Normal file
55
boards/arm/csk6/csk6011a-nano/configs/nsh/defconfig
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#
|
||||||
|
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||||
|
#
|
||||||
|
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||||
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
|
# modifications.
|
||||||
|
#
|
||||||
|
CONFIG_16550_ADDRWIDTH=32
|
||||||
|
CONFIG_16550_REGWIDTH=32
|
||||||
|
CONFIG_16550_SERIAL_DISABLE_REORDERING=y
|
||||||
|
CONFIG_16550_SUPRESS_CONFIG=y
|
||||||
|
CONFIG_16550_UART0=y
|
||||||
|
CONFIG_16550_UART0_BASE=0x45000000
|
||||||
|
CONFIG_16550_UART0_CLOCK=100000000
|
||||||
|
CONFIG_16550_UART0_IRQ=24
|
||||||
|
CONFIG_16550_UART0_SERIAL_CONSOLE=y
|
||||||
|
CONFIG_16550_UART=y
|
||||||
|
CONFIG_ARCH="arm"
|
||||||
|
CONFIG_ARCH_BOARD="csk6011a-nano"
|
||||||
|
CONFIG_ARCH_BOARD_CSK6011A_NANO=y
|
||||||
|
CONFIG_ARCH_CHIP="csk6"
|
||||||
|
CONFIG_ARCH_CHIP_CSK6=y
|
||||||
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
|
CONFIG_ARMV8M_SYSTICK=y
|
||||||
|
CONFIG_BOARD_LATE_INITIALIZE=y
|
||||||
|
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_DEBUG_FEATURES=y
|
||||||
|
CONFIG_DEBUG_SYMBOLS=y
|
||||||
|
CONFIG_EXAMPLES_HELLO=y
|
||||||
|
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||||
|
CONFIG_INTELHEX_BINARY=y
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
CONFIG_NSH_FILEIOSIZE=512
|
||||||
|
CONFIG_NSH_LINELEN=64
|
||||||
|
CONFIG_NSH_READLINE=y
|
||||||
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
|
CONFIG_RAM_SIZE=327680
|
||||||
|
CONFIG_RAM_START=0x80000
|
||||||
|
CONFIG_RAW_BINARY=y
|
||||||
|
CONFIG_READLINE_CMD_HISTORY=y
|
||||||
|
CONFIG_READLINE_TABCOMPLETION=y
|
||||||
|
CONFIG_RR_INTERVAL=200
|
||||||
|
CONFIG_SCHED_WAITPID=y
|
||||||
|
CONFIG_SERIAL_UART_ARCH_MMIO=y
|
||||||
|
CONFIG_START_DAY=6
|
||||||
|
CONFIG_START_MONTH=12
|
||||||
|
CONFIG_START_YEAR=2011
|
||||||
|
CONFIG_SYSTEM_NSH=y
|
||||||
|
CONFIG_TIMER=y
|
||||||
|
CONFIG_TIMER_ARCH=y
|
||||||
|
CONFIG_USART0_RXBUFSIZE=128
|
||||||
|
CONFIG_USART0_SERIAL_CONSOLE=y
|
||||||
|
CONFIG_USART0_TXBUFSIZE=128
|
||||||
|
CONFIG_USEC_PER_TICK=1000
|
37
boards/arm/csk6/csk6011a-nano/include/board.h
Normal file
37
boards/arm/csk6/csk6011a-nano/include/board.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/csk6/csk6011a-nano/include/board.h
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __BOARDS_ARM_CSK6_CSK6011A_NANO_INCLUDE_BOARD_H
|
||||||
|
#define __BOARDS_ARM_CSK6_CSK6011A_NANO_INCLUDE_BOARD_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#define CSK6_SYSTICK_CLOCK (24 * 1000 * 1000)
|
||||||
|
|
||||||
|
#ifndef __ASSEMBLY__
|
||||||
|
# include <stdint.h>
|
||||||
|
# include <stdbool.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __BOARDS_ARM_CSK6_CSK6011A_NANO_INCLUDE_BOARD_H */
|
41
boards/arm/csk6/csk6011a-nano/scripts/Make.defs
Normal file
41
boards/arm/csk6/csk6011a-nano/scripts/Make.defs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
############################################################################
|
||||||
|
# boards/arm/csk6/csk6011a-nano/scripts/Make.defs
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership. The
|
||||||
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance with the
|
||||||
|
# License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
include $(TOPDIR)/.config
|
||||||
|
include $(TOPDIR)/tools/Config.mk
|
||||||
|
include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs
|
||||||
|
|
||||||
|
LDSCRIPT = ld.script
|
||||||
|
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
|
||||||
|
|
||||||
|
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
|
||||||
|
|
||||||
|
CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
|
||||||
|
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
|
||||||
|
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
|
||||||
|
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
|
||||||
|
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
|
||||||
|
AFLAGS := $(CFLAGS) -D__ASSEMBLY__
|
||||||
|
|
||||||
|
NXFLATLDFLAGS1 = -r -d -warn-common
|
||||||
|
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
|
||||||
|
LDNXFLATFLAGS = -e main -s 2048
|
||||||
|
|
||||||
|
EXEEXT = .elf
|
116
boards/arm/csk6/csk6011a-nano/scripts/gnu-elf.ld
Normal file
116
boards/arm/csk6/csk6011a-nano/scripts/gnu-elf.ld
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/csk6/csk6011a-nano/scripts/gnu-elf.ld
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text 0x00000000 :
|
||||||
|
{
|
||||||
|
_stext = . ;
|
||||||
|
*(.text)
|
||||||
|
*(.text.*)
|
||||||
|
*(.gnu.warning)
|
||||||
|
*(.stub)
|
||||||
|
*(.glue_7)
|
||||||
|
*(.glue_7t)
|
||||||
|
*(.jcr)
|
||||||
|
|
||||||
|
/* C++ support: The .init and .fini sections contain specific logic
|
||||||
|
* to manage static constructors and destructors.
|
||||||
|
*/
|
||||||
|
|
||||||
|
*(.gnu.linkonce.t.*)
|
||||||
|
*(.init) /* Old ABI */
|
||||||
|
*(.fini) /* Old ABI */
|
||||||
|
_etext = . ;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata :
|
||||||
|
{
|
||||||
|
_srodata = . ;
|
||||||
|
*(.rodata)
|
||||||
|
*(.rodata1)
|
||||||
|
*(.rodata.*)
|
||||||
|
*(.gnu.linkonce.r*)
|
||||||
|
_erodata = . ;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
_sdata = . ;
|
||||||
|
*(.data)
|
||||||
|
*(.data1)
|
||||||
|
*(.data.*)
|
||||||
|
*(.gnu.linkonce.d*)
|
||||||
|
. = ALIGN(4);
|
||||||
|
_edata = . ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* C++ support. For each global and static local C++ object,
|
||||||
|
* GCC creates a small subroutine to construct the object. Pointers
|
||||||
|
* to these routines (not the routines themselves) are stored as
|
||||||
|
* simple, linear arrays in the .ctors section of the object file.
|
||||||
|
* Similarly, pointers to global/static destructor routines are
|
||||||
|
* stored in .dtors.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.ctors :
|
||||||
|
{
|
||||||
|
_sctors = . ;
|
||||||
|
*(.ctors) /* Old ABI: Unallocated */
|
||||||
|
*(.init_array) /* New ABI: Allocated */
|
||||||
|
_edtors = . ;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dtors :
|
||||||
|
{
|
||||||
|
_sdtors = . ;
|
||||||
|
*(.dtors) /* Old ABI: Unallocated */
|
||||||
|
*(.fini_array) /* New ABI: Allocated */
|
||||||
|
_edtors = . ;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
_sbss = . ;
|
||||||
|
*(.bss)
|
||||||
|
*(.bss.*)
|
||||||
|
*(.sbss)
|
||||||
|
*(.sbss.*)
|
||||||
|
*(.gnu.linkonce.b*)
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(4);
|
||||||
|
_ebss = . ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Stabs debugging sections. */
|
||||||
|
|
||||||
|
.stab 0 : { *(.stab) }
|
||||||
|
.stabstr 0 : { *(.stabstr) }
|
||||||
|
.stab.excl 0 : { *(.stab.excl) }
|
||||||
|
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||||
|
.stab.index 0 : { *(.stab.index) }
|
||||||
|
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||||
|
.comment 0 : { *(.comment) }
|
||||||
|
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||||
|
.debug_info 0 : { *(.debug_info) }
|
||||||
|
.debug_line 0 : { *(.debug_line) }
|
||||||
|
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||||
|
.debug_aranges 0 : { *(.debug_aranges) }
|
||||||
|
}
|
99
boards/arm/csk6/csk6011a-nano/scripts/kernel-space.ld
Normal file
99
boards/arm/csk6/csk6011a-nano/scripts/kernel-space.ld
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/csk6/csk6011a-nano/scripts/kernel-space.ld
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* NOTE: This depends on the memory.ld script having been included prior to
|
||||||
|
* this script.
|
||||||
|
*/
|
||||||
|
|
||||||
|
OUTPUT_ARCH(arm)
|
||||||
|
EXTERN(_vectors)
|
||||||
|
ENTRY(_stext)
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text : {
|
||||||
|
_stext = ABSOLUTE(.);
|
||||||
|
*(.vectors)
|
||||||
|
KEEP(*(.firmware_verification_table))
|
||||||
|
*(.text .text.*)
|
||||||
|
*(.fixup)
|
||||||
|
*(.gnu.warning)
|
||||||
|
*(.rodata .rodata.*)
|
||||||
|
*(.gnu.linkonce.t.*)
|
||||||
|
*(.glue_7)
|
||||||
|
*(.glue_7t)
|
||||||
|
*(.got)
|
||||||
|
*(.gcc_except_table)
|
||||||
|
*(.gnu.linkonce.r.*)
|
||||||
|
_etext = ABSOLUTE(.);
|
||||||
|
} > kflash
|
||||||
|
|
||||||
|
.init_section : {
|
||||||
|
_sinit = ABSOLUTE(.);
|
||||||
|
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||||
|
KEEP(*(.init_array .ctors))
|
||||||
|
_einit = ABSOLUTE(.);
|
||||||
|
} > kflash
|
||||||
|
|
||||||
|
.ARM.extab : {
|
||||||
|
*(.ARM.extab*)
|
||||||
|
} > kflash
|
||||||
|
|
||||||
|
__exidx_start = ABSOLUTE(.);
|
||||||
|
.ARM.exidx : {
|
||||||
|
*(.ARM.exidx*)
|
||||||
|
} > kflash
|
||||||
|
|
||||||
|
__exidx_end = ABSOLUTE(.);
|
||||||
|
|
||||||
|
_eronly = ABSOLUTE(.);
|
||||||
|
|
||||||
|
.data : {
|
||||||
|
_sdata = ABSOLUTE(.);
|
||||||
|
*(.data .data.*)
|
||||||
|
*(.gnu.linkonce.d.*)
|
||||||
|
CONSTRUCTORS
|
||||||
|
. = ALIGN(4);
|
||||||
|
_edata = ABSOLUTE(.);
|
||||||
|
} > ksram AT > kflash
|
||||||
|
|
||||||
|
.bss : {
|
||||||
|
_sbss = ABSOLUTE(.);
|
||||||
|
*(.bss .bss.*)
|
||||||
|
*(.gnu.linkonce.b.*)
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(4);
|
||||||
|
_ebss = ABSOLUTE(.);
|
||||||
|
} > ksram
|
||||||
|
|
||||||
|
/* Stabs debugging sections */
|
||||||
|
|
||||||
|
.stab 0 : { *(.stab) }
|
||||||
|
.stabstr 0 : { *(.stabstr) }
|
||||||
|
.stab.excl 0 : { *(.stab.excl) }
|
||||||
|
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||||
|
.stab.index 0 : { *(.stab.index) }
|
||||||
|
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||||
|
.comment 0 : { *(.comment) }
|
||||||
|
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||||
|
.debug_info 0 : { *(.debug_info) }
|
||||||
|
.debug_line 0 : { *(.debug_line) }
|
||||||
|
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||||
|
.debug_aranges 0 : { *(.debug_aranges) }
|
||||||
|
}
|
118
boards/arm/csk6/csk6011a-nano/scripts/ld.script
Normal file
118
boards/arm/csk6/csk6011a-nano/scripts/ld.script
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/csk6/csk6011a-nano/scripts/ld.script
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
flash (rx) : ORIGIN = 0x18000000, LENGTH = 8192K
|
||||||
|
sram (rwx) : ORIGIN = 0x80000, LENGTH = 320K
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT_ARCH(arm)
|
||||||
|
EXTERN(_vectors)
|
||||||
|
ENTRY(_stext)
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text : {
|
||||||
|
_stext = ABSOLUTE(.);
|
||||||
|
*(.vectors)
|
||||||
|
KEEP(*(.firmware_verification_table))
|
||||||
|
*(.text .text.*)
|
||||||
|
*(.fixup)
|
||||||
|
*(.gnu.warning)
|
||||||
|
*(.rodata .rodata.*)
|
||||||
|
*(.gnu.linkonce.t.*)
|
||||||
|
*(.glue_7)
|
||||||
|
*(.glue_7t)
|
||||||
|
*(.got)
|
||||||
|
*(.gcc_except_table)
|
||||||
|
*(.gnu.linkonce.r.*)
|
||||||
|
_etext = ABSOLUTE(.);
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
.init_section : ALIGN(4) {
|
||||||
|
_sinit = ABSOLUTE(.);
|
||||||
|
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||||
|
KEEP(*(.init_array .ctors))
|
||||||
|
_einit = ABSOLUTE(.);
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
.ARM.extab : ALIGN(4) {
|
||||||
|
*(.ARM.extab*)
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
.ARM.exidx : ALIGN(4) {
|
||||||
|
__exidx_start = ABSOLUTE(.);
|
||||||
|
*(.ARM.exidx*)
|
||||||
|
__exidx_end = ABSOLUTE(.);
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
.tdata : {
|
||||||
|
_stdata = ABSOLUTE(.);
|
||||||
|
*(.tdata .tdata.* .gnu.linkonce.td.*);
|
||||||
|
_etdata = ABSOLUTE(.);
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
.tbss : {
|
||||||
|
_stbss = ABSOLUTE(.);
|
||||||
|
*(.tbss .tbss.* .gnu.linkonce.tb.* .tcommon);
|
||||||
|
_etbss = ABSOLUTE(.);
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
_eronly = ABSOLUTE(.);
|
||||||
|
|
||||||
|
/* The RAM vector table (if present) should lie at the beginning of SRAM */
|
||||||
|
|
||||||
|
.ram_vectors : {
|
||||||
|
*(.ram_vectors)
|
||||||
|
} > sram
|
||||||
|
|
||||||
|
.data : ALIGN(4) {
|
||||||
|
_sdata = ABSOLUTE(.);
|
||||||
|
*(.data .data.*)
|
||||||
|
*(.gnu.linkonce.d.*)
|
||||||
|
CONSTRUCTORS
|
||||||
|
. = ALIGN(4);
|
||||||
|
_edata = ABSOLUTE(.);
|
||||||
|
} > sram AT > flash
|
||||||
|
|
||||||
|
.bss : ALIGN(4) {
|
||||||
|
_sbss = ABSOLUTE(.);
|
||||||
|
*(.bss .bss.*)
|
||||||
|
*(.gnu.linkonce.b.*)
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(4);
|
||||||
|
_ebss = ABSOLUTE(.);
|
||||||
|
} > sram
|
||||||
|
|
||||||
|
/* Stabs debugging sections. */
|
||||||
|
|
||||||
|
.stab 0 : { *(.stab) }
|
||||||
|
.stabstr 0 : { *(.stabstr) }
|
||||||
|
.stab.excl 0 : { *(.stab.excl) }
|
||||||
|
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||||
|
.stab.index 0 : { *(.stab.index) }
|
||||||
|
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||||
|
.comment 0 : { *(.comment) }
|
||||||
|
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||||
|
.debug_info 0 : { *(.debug_info) }
|
||||||
|
.debug_line 0 : { *(.debug_line) }
|
||||||
|
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||||
|
.debug_aranges 0 : { *(.debug_aranges) }
|
||||||
|
}
|
34
boards/arm/csk6/csk6011a-nano/scripts/memory.ld
Normal file
34
boards/arm/csk6/csk6011a-nano/scripts/memory.ld
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/csk6/csk6011a-nano/scripts/memory.ld
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
/* 1024Kb FLASH */
|
||||||
|
|
||||||
|
kflash (rx) : ORIGIN = 0x18000000, LENGTH = 128K
|
||||||
|
uflash (rx) : ORIGIN = 0x18020000, LENGTH = 128K
|
||||||
|
xflash (rx) : ORIGIN = 0x18040000, LENGTH = 7936K
|
||||||
|
|
||||||
|
/* 112Kb of contiguous SRAM */
|
||||||
|
|
||||||
|
ksram (rwx) : ORIGIN = 0x80000, LENGTH = 4K
|
||||||
|
usram (rwx) : ORIGIN = 0x81000, LENGTH = 4K
|
||||||
|
xsram (rwx) : ORIGIN = 0x82000, LENGTH = 312K
|
||||||
|
}
|
112
boards/arm/csk6/csk6011a-nano/scripts/user-space.ld
Normal file
112
boards/arm/csk6/csk6011a-nano/scripts/user-space.ld
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/csk6/csk6011a-nano/scripts/user-space.ld
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* NOTE: This depends on the memory.ld script having been included prior to
|
||||||
|
* this script.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Make sure that the critical memory management functions are in user-space.
|
||||||
|
* the user heap memory manager will reside in user-space but be usable both
|
||||||
|
* by kernel- and user-space code
|
||||||
|
*/
|
||||||
|
|
||||||
|
EXTERN(umm_initialize)
|
||||||
|
EXTERN(umm_addregion)
|
||||||
|
|
||||||
|
EXTERN(malloc)
|
||||||
|
EXTERN(realloc)
|
||||||
|
EXTERN(zalloc)
|
||||||
|
EXTERN(free)
|
||||||
|
|
||||||
|
OUTPUT_ARCH(arm)
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.userspace : {
|
||||||
|
*(.userspace)
|
||||||
|
} > uflash
|
||||||
|
|
||||||
|
.text : {
|
||||||
|
_stext = ABSOLUTE(.);
|
||||||
|
*(.text .text.*)
|
||||||
|
*(.fixup)
|
||||||
|
*(.gnu.warning)
|
||||||
|
*(.rodata .rodata.*)
|
||||||
|
*(.gnu.linkonce.t.*)
|
||||||
|
*(.glue_7)
|
||||||
|
*(.glue_7t)
|
||||||
|
*(.got)
|
||||||
|
*(.gcc_except_table)
|
||||||
|
*(.gnu.linkonce.r.*)
|
||||||
|
_etext = ABSOLUTE(.);
|
||||||
|
} > uflash
|
||||||
|
|
||||||
|
.init_section : {
|
||||||
|
_sinit = ABSOLUTE(.);
|
||||||
|
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||||
|
KEEP(*(.init_array .ctors))
|
||||||
|
_einit = ABSOLUTE(.);
|
||||||
|
} > uflash
|
||||||
|
|
||||||
|
.ARM.extab : {
|
||||||
|
*(.ARM.extab*)
|
||||||
|
} > uflash
|
||||||
|
|
||||||
|
__exidx_start = ABSOLUTE(.);
|
||||||
|
.ARM.exidx : {
|
||||||
|
*(.ARM.exidx*)
|
||||||
|
} > uflash
|
||||||
|
|
||||||
|
__exidx_end = ABSOLUTE(.);
|
||||||
|
|
||||||
|
_eronly = ABSOLUTE(.);
|
||||||
|
|
||||||
|
.data : {
|
||||||
|
_sdata = ABSOLUTE(.);
|
||||||
|
*(.data .data.*)
|
||||||
|
*(.gnu.linkonce.d.*)
|
||||||
|
CONSTRUCTORS
|
||||||
|
. = ALIGN(4);
|
||||||
|
_edata = ABSOLUTE(.);
|
||||||
|
} > usram AT > uflash
|
||||||
|
|
||||||
|
.bss : {
|
||||||
|
_sbss = ABSOLUTE(.);
|
||||||
|
*(.bss .bss.*)
|
||||||
|
*(.gnu.linkonce.b.*)
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(4);
|
||||||
|
_ebss = ABSOLUTE(.);
|
||||||
|
} > usram
|
||||||
|
|
||||||
|
/* Stabs debugging sections */
|
||||||
|
|
||||||
|
.stab 0 : { *(.stab) }
|
||||||
|
.stabstr 0 : { *(.stabstr) }
|
||||||
|
.stab.excl 0 : { *(.stab.excl) }
|
||||||
|
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||||
|
.stab.index 0 : { *(.stab.index) }
|
||||||
|
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||||
|
.comment 0 : { *(.comment) }
|
||||||
|
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||||
|
.debug_info 0 : { *(.debug_info) }
|
||||||
|
.debug_line 0 : { *(.debug_line) }
|
||||||
|
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||||
|
.debug_aranges 0 : { *(.debug_aranges) }
|
||||||
|
}
|
25
boards/arm/csk6/csk6011a-nano/src/CMakeLists.txt
Normal file
25
boards/arm/csk6/csk6011a-nano/src/CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# ##############################################################################
|
||||||
|
# boards/arm/csk6/csk6011a-nano/src/CMakeLists.txt
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
|
||||||
|
# license agreements. See the NOTICE file distributed with this work for
|
||||||
|
# additional information regarding copyright ownership. The ASF licenses this
|
||||||
|
# file to you under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
# use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
# the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations under
|
||||||
|
# the License.
|
||||||
|
#
|
||||||
|
# ##############################################################################
|
||||||
|
|
||||||
|
set(SRCS csk6011a_nano_appinit.c)
|
||||||
|
|
||||||
|
target_sources(board PRIVATE ${SRCS})
|
||||||
|
|
||||||
|
set_property(GLOBAL PROPERTY LD_SCRIPT "${NUTTX_BOARD_DIR}/scripts/ld.script")
|
25
boards/arm/csk6/csk6011a-nano/src/Makefile
Normal file
25
boards/arm/csk6/csk6011a-nano/src/Makefile
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
############################################################################
|
||||||
|
# boards/arm/csk6011a/csk6011a-nano/src/Makefile
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership. The
|
||||||
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance with the
|
||||||
|
# License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
include $(TOPDIR)/Make.defs
|
||||||
|
|
||||||
|
CSRCS = csk6011a_nano_appinit.c
|
||||||
|
|
||||||
|
include $(TOPDIR)/boards/Board.mk
|
103
boards/arm/csk6/csk6011a-nano/src/csk6011a_nano_appinit.c
Normal file
103
boards/arm/csk6/csk6011a-nano/src/csk6011a_nano_appinit.c
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/csk6/csk6011a-nano/src/csk6011a_nano_appinit.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <nuttx/board.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
#define VERIFICATION_TABLE_ATTR used_data locate_data(".firmware_verification_table")
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static const char verification_table[] VERIFICATION_TABLE_ATTR =
|
||||||
|
{
|
||||||
|
'H', 'r',
|
||||||
|
0x01, 0x00,
|
||||||
|
0, 0, 0, 0,
|
||||||
|
0x00, 0x00, 0x00, 0x18,
|
||||||
|
0x01, 0x00, 0x00,
|
||||||
|
0x00,
|
||||||
|
'V', 'E', 'N', 'U', 'S', '_', 'R', 'T', 'O', 'S', 0, 0,
|
||||||
|
0x00, 0x00,
|
||||||
|
0x00, 0x00,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0x00, 0x00,
|
||||||
|
0x00, 0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_app_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Perform application specific initialization. This function is never
|
||||||
|
* called directly from application code, but only indirectly via the
|
||||||
|
* (non-standard) boardctl() interface using the command BOARDIOC_INIT.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* arg - The boardctl() argument is passed to the board_app_initialize()
|
||||||
|
* implementation without modification. The argument has no
|
||||||
|
* meaning to NuttX; the meaning of the argument is a contract
|
||||||
|
* between the board-specific initialization logic and the
|
||||||
|
* matching application logic. The value could be such things as a
|
||||||
|
* mode enumeration value, a set of DIP switch switch settings, a
|
||||||
|
* pointer to configuration data read from a file or serial FLASH,
|
||||||
|
* or whatever you would like to do with it. Every implementation
|
||||||
|
* should accept zero/NULL as a default configuration.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||||
|
* any failure to indicate the nature of the failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int board_app_initialize(uintptr_t arg)
|
||||||
|
{
|
||||||
|
/* Perform board-specific initialization */
|
||||||
|
|
||||||
|
/* TODO */
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_BOARD_LATE_INITIALIZE
|
||||||
|
|
||||||
|
void board_late_initialize(void)
|
||||||
|
{
|
||||||
|
/* Perform board-specific initialization */
|
||||||
|
|
||||||
|
/* TODO */
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
95
boards/arm/csk6/tools/patch_header.py
Executable file
95
boards/arm/csk6/tools/patch_header.py
Executable file
@ -0,0 +1,95 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
############################################################################
|
||||||
|
# boards/arm/csk6/tools/patch_header.py
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership. The
|
||||||
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance with the
|
||||||
|
# License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
_IMAGE_START = 192
|
||||||
|
_IMAGE_SIZE_OFFSET = _IMAGE_START + 4
|
||||||
|
_IMAGE_HDR_CHK_OFFSET = _IMAGE_START + 60
|
||||||
|
_IMAGE_HEADER_SIZE = _IMAGE_HDR_CHK_OFFSET + 4
|
||||||
|
|
||||||
|
DEFAULT_INPUT_FILE = "nuttx.bin"
|
||||||
|
DEFAULT_OUTPUT_FILE = "nuttx.bin"
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser(description="Patch binary file header.")
|
||||||
|
parser.add_argument(
|
||||||
|
"--input",
|
||||||
|
help=f"The binary file to be patched (default: {DEFAULT_INPUT_FILE})",
|
||||||
|
default=DEFAULT_INPUT_FILE,
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--output",
|
||||||
|
help=f"The output patched binary file (default: {DEFAULT_OUTPUT_FILE})",
|
||||||
|
default=DEFAULT_OUTPUT_FILE,
|
||||||
|
)
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def _get_header_sum(header_bytes: bytearray):
|
||||||
|
header_sum = 0
|
||||||
|
for pos in range(_IMAGE_START, _IMAGE_HDR_CHK_OFFSET):
|
||||||
|
header_sum += header_bytes[pos]
|
||||||
|
|
||||||
|
vector_sum = 0
|
||||||
|
for pos in range(_IMAGE_HDR_CHK_OFFSET):
|
||||||
|
vector_sum += header_bytes[pos]
|
||||||
|
vector_sum += header_sum & 0xFF
|
||||||
|
vector_sum += (header_sum >> 8) & 0xFF
|
||||||
|
|
||||||
|
return header_sum, vector_sum
|
||||||
|
|
||||||
|
|
||||||
|
def patch_header(header_bytes: bytearray, image_size: int):
|
||||||
|
header_bytes[_IMAGE_SIZE_OFFSET : _IMAGE_SIZE_OFFSET + 4] = image_size.to_bytes(
|
||||||
|
4, "little"
|
||||||
|
)
|
||||||
|
|
||||||
|
header_sum, vector_sum = _get_header_sum(header_bytes)
|
||||||
|
header_bytes[_IMAGE_HDR_CHK_OFFSET : _IMAGE_HDR_CHK_OFFSET + 2] = (
|
||||||
|
header_sum.to_bytes(2, "little")
|
||||||
|
)
|
||||||
|
header_bytes[_IMAGE_HDR_CHK_OFFSET + 2 : _IMAGE_HDR_CHK_OFFSET + 4] = (
|
||||||
|
vector_sum.to_bytes(2, "little")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def patch_bin(input_filename: str, output_filename: str):
|
||||||
|
with open(input_filename, "rb") as bin_file:
|
||||||
|
content = bytearray(bin_file.read())
|
||||||
|
header = content[:_IMAGE_HEADER_SIZE]
|
||||||
|
image_size = len(content)
|
||||||
|
patch_header(header, image_size)
|
||||||
|
content[:_IMAGE_HEADER_SIZE] = header
|
||||||
|
|
||||||
|
with open(output_filename, "wb") as out_file:
|
||||||
|
out_file.write(content)
|
||||||
|
print(f"csk6 rom boot tag added successfully, file: {output_filename}")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = parse_args()
|
||||||
|
patch_bin(args.input, args.output)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
x
Reference in New Issue
Block a user