Introduce a port for T-HEAD CK802. A simple demo for T-HEAD CB2201 is also included.

This commit is contained in:
Yuhui.Zheng 2020-01-10 07:53:14 +00:00
parent d2914041f8
commit 0d95aca202
125 changed files with 23809 additions and 0 deletions

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<Session Name="D:\Ubuntu-Share\FreeRTOS\Demo\T-HEAD_CB2201_CDK\RTOSDemo_CDK\RTOSDemo\RTOSDemo.cdkws">
<int Value="1" Name="m_selectedTab"/>
<wxString Value="D:\Ubuntu-Share\FreeRTOS\Demo\T-HEAD_CB2201_CDK\RTOSDemo_CDK\RTOSDemo\RTOSDemo.cdkws" Name="m_workspaceName"/>
<TabInfoArray Name="TabInfoArray">
<TabInfo>
<wxString Value="D:\Ubuntu-Share\FreeRTOS\Demo\T-HEAD_CB2201_CDK\RTOSDemo_CDK\RTOSDemo\gdb.init" Name="FileName"/>
<int Value="0" Name="FirstVisibleLine"/>
<int Value="0" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
<TabInfo>
<wxString Value="D:\Ubuntu-Share\FreeRTOS\Demo\T-HEAD_CB2201_CDK\RTOSDemo_CDK\RTOSDemo\main.c" Name="FileName"/>
<int Value="15" Name="FirstVisibleLine"/>
<int Value="29" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
<TabInfo>
<wxString Value="D:\Ubuntu-Share\FreeRTOS\Demo\T-HEAD_CB2201_CDK\driver\uart.c" Name="FileName"/>
<int Value="0" Name="FirstVisibleLine"/>
<int Value="19" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
<TabInfo>
<wxString Value="D:\Ubuntu-Share\FreeRTOS\Demo\T-HEAD_CB2201_CDK\csi\csi_driver\csky\hobbit1_2\devices.c" Name="FileName"/>
<int Value="6" Name="FirstVisibleLine"/>
<int Value="22" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
<TabInfo>
<wxString Value="d:\ubuntu-share\freertos\demo\t-head_cb2201_cdk\csi\csi_driver\include\config.h" Name="FileName"/>
<int Value="3" Name="FirstVisibleLine"/>
<int Value="19" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
<TabInfo>
<wxString Value="D:\Ubuntu-Share\FreeRTOS\Demo\T-HEAD_CB2201_CDK\RTOSDemo_CDK\RTOSDemo\chip_name.h" Name="FileName"/>
<int Value="21" Name="FirstVisibleLine"/>
<int Value="37" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
<TabInfo>
<wxString Value="d:\ubuntu-share\freertos\demo\t-head_cb2201_cdk\csi\csi_core\ck802\core_ck802.h" Name="FileName"/>
<int Value="44" Name="FirstVisibleLine"/>
<int Value="68" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
<IntVector Name="CollapsedFolds"/>
</TabInfo>
</TabInfoArray>
<SerializedObject Name="m_breakpoints">
<long Value="0" Name="Count"/>
</SerializedObject>
</Session>

View file

@ -0,0 +1,9 @@
.PHONY: clean All
All:
@echo "----------Building project:[ RTOSDemo - BuildSet ]----------"
@
@make -f "RTOSDemo.mk" MakeIntermediateDirs && make -f "RTOSDemo.mk" -j 8
clean:
@echo "----------Cleaning project:[ RTOSDemo - BuildSet ]----------"
@make -f "RTOSDemo.mk" clean

View file

@ -0,0 +1,381 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project Name="RTOSDemo" Version="1" Language="C">
<Description/>
<Dependencies Name="Debug"/>
<VirtualDirectory Name="arch">
<File Name="crt0.S">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="inc">
<File Name="../../FreeRTOSConfig.h">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="script">
<File Name="ckcpu.ld">
<FileOption/>
</File>
<File Name="gdb.init">
<FileOption/>
</File>
<File Name="flash.init">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="src">
<File Name="main.c">
<FileOption/>
</File>
<File Name="../../driver/uart.c">
<FileOption/>
</File>
<File Name="../../Readme.txt">
<FileOption/>
</File>
</VirtualDirectory>
<MonitorProgress>
<FlashOperate>37</FlashOperate>
<DebugLaunch>47</DebugLaunch>
</MonitorProgress>
<VirtualDirectory Name="csi">
<File Name="../../csi/csi_driver/include/drv_usart.h">
<FileOption/>
</File>
<File Name="../../csi/csi_driver/csky/hobbit1_2/devices.c">
<FileOption/>
</File>
<File Name="../../csi/csi_driver/csky/hobbit1_2/isr.c">
<FileOption/>
</File>
<File Name="../../csi/csi_driver/csky/hobbit1_2/pinmux.c">
<FileOption/>
</File>
<File Name="../../csi/csi_driver/csky/hobbit1_2/include/pin_name.h">
<FileOption/>
</File>
<File Name="../../csi/csi_driver/csky/hobbit1_2/include/pinmux.h">
<FileOption/>
</File>
<File Name="../../csi/csi_driver/csky/hobbit1_2/include/soc.h">
<FileOption/>
</File>
<File Name="../../csi/csi_driver/csky/common/usart/dw_usart.c">
<FileOption/>
</File>
<File Name="../../csi/csi_driver/csky/common/usart/dw_usart.h">
<FileOption/>
</File>
<File Name="../../csi/csi_core/ck802/core_ck802.c">
<FileOption/>
</File>
<File Name="../../csi/csi_core/ck802/core_ck802.h">
<FileOption/>
</File>
<File Name="../../csi/csi_core/include/csi_core.h">
<FileOption/>
</File>
<File Name="../../csi/csi_core/include/csi-gcc/csi_gcc.h">
<FileOption/>
</File>
<File Name="../../csi/csi_core/include/csi-gcc/csi_instr.h">
<FileOption/>
</File>
<File Name="../../csi/csi_core/include/csi-gcc/csi_reg.h">
<FileOption/>
</File>
<File Name="../../csi/csi_core/include/csi-gcc/csi_simd.h">
<FileOption/>
</File>
<File Name="../../csi/csi_driver/include/system.c">
<FileOption/>
</File>
</VirtualDirectory>
<VirtualDirectory Name="FreeRTOS">
<File Name="../../../../Source/croutine.c">
<FileOption/>
</File>
<File Name="../../../../Source/event_groups.c">
<FileOption/>
</File>
<File Name="../../../../Source/list.c">
<FileOption/>
</File>
<File Name="../../../../Source/queue.c">
<FileOption/>
</File>
<File Name="../../../../Source/stream_buffer.c">
<FileOption/>
</File>
<File Name="../../../../Source/tasks.c">
<FileOption/>
</File>
<File Name="../../../../Source/timers.c">
<FileOption/>
</File>
<VirtualDirectory Name="inc">
<File Name="../../../../Source/include/atomic.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/croutine.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/deprecated_definitions.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/event_groups.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/FreeRTOS.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/list.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/message_buffer.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/mpu_prototypes.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/mpu_wrappers.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/portable.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/projdefs.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/queue.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/semphr.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/stack_macros.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/StackMacros.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/stdint.readme">
<FileOption/>
</File>
<File Name="../../../../Source/include/stream_buffer.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/task.h">
<FileOption/>
</File>
<File Name="../../../../Source/include/timers.h">
<FileOption/>
</File>
</VirtualDirectory>
<File Name="../../../../Source/portable/MemMang/heap_4.c">
<FileOption/>
</File>
<VirtualDirectory Name="port">
<File Name="../../../../Source/portable/ThirdParty/CDK/T-HEAD_CK802/port.c">
<FileOption/>
</File>
<File Name="../../../../Source/portable/ThirdParty/CDK/T-HEAD_CK802/portasm.S">
<FileOption/>
</File>
<File Name="../../../../Source/portable/ThirdParty/CDK/T-HEAD_CK802/portmacro.h">
<FileOption/>
</File>
</VirtualDirectory>
</VirtualDirectory>
<DebugSessions>
<watchExpressions>uxDeletedTasksWaitingCleanUp:0</watchExpressions>
<memoryExpressions>0xe000e100;;;</memoryExpressions>
<statistics>;;MHZ</statistics>
<peripheralTabs/>
<WatchDisplayFormat>0</WatchDisplayFormat>
<LocalDisplayFormat>0</LocalDisplayFormat>
<debugLayout/>
<memoryTabColSizeExpressions>100:8;100:8;100:8;100:8;</memoryTabColSizeExpressions>
</DebugSessions>
<BuildConfigs>
<BuildConfig Name="BuildSet">
<Target>
<ROMBank Selected="1">
<ROM1>
<InUse>yes</InUse>
<Start>0x60000000</Start>
<Size>0x4000</Size>
</ROM1>
<ROM2>
<InUse>no</InUse>
<Start/>
<Size/>
</ROM2>
<ROM3>
<InUse>no</InUse>
<Start/>
<Size/>
</ROM3>
<ROM4>
<InUse>no</InUse>
<Start/>
<Size/>
</ROM4>
<ROM5>
<InUse>no</InUse>
<Start/>
<Size/>
</ROM5>
</ROMBank>
<RAMBank>
<RAM1>
<InUse>no</InUse>
<Start>0x20000000</Start>
<Size>0x80000</Size>
<Init>yes</Init>
</RAM1>
<RAM2>
<InUse>no</InUse>
<Start>0x50000000</Start>
<Size>0x800000</Size>
<Init>yes</Init>
</RAM2>
<RAM3>
<InUse>yes</InUse>
<Start>0x60004000</Start>
<Size>0xc000</Size>
<Init>yes</Init>
</RAM3>
<RAM4>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM4>
<RAM5>
<InUse>no</InUse>
<Start/>
<Size/>
<Init>yes</Init>
</RAM5>
</RAMBank>
<CPU>ck802</CPU>
<UseMiniLib>yes</UseMiniLib>
<Endian>little</Endian>
<UseHardFloat>no</UseHardFloat>
<UseEnhancedLRW>yes</UseEnhancedLRW>
<UseContinueBuild>no</UseContinueBuild>
<UseSemiHost>no</UseSemiHost>
</Target>
<Output>
<OutputName>$(ProjectName)</OutputName>
<Type>Executable</Type>
<CreateHexFile>no</CreateHexFile>
<CreateBinFile>no</CreateBinFile>
<Preprocessor>no</Preprocessor>
<Disasm>yes</Disasm>
<CallGraph>no</CallGraph>
<Map>yes</Map>
</Output>
<User>
<BeforeCompile>
<RunUserProg>no</RunUserProg>
<UserProgName/>
</BeforeCompile>
<BeforeMake>
<RunUserProg>no</RunUserProg>
<UserProgName/>
</BeforeMake>
<AfterMake>
<RunUserProg>no</RunUserProg>
<UserProgName/>
</AfterMake>
</User>
<Compiler>
<Define/>
<Undefine/>
<Optim>Optimize size (-Os)</Optim>
<DebugLevel>Default (-g)</DebugLevel>
<IncludePath>$(ProjectPath);$(ProjectPath)/../../driver;$(ProjectPath)/../../csi/csi_driver/include;$(ProjectPath)/../../csi/csi_driver/csky/hobbit1_2/include;$(ProjectPath)/../../csi/csi_driver/csky/common/usart;$(ProjectPath)/../../csi/csi_core/include;$(ProjectPath)/../../csi/csi_core/include/csi-gcc;$(ProjectPath)/../../csi/csi_core/ck802;$(ProjectPath)/../../;$(ProjectPath)/../../../../Source/include;$(ProjectPath)/../../../../Source/portable/ThirdParty/CDK/T-HEAD_CK802;$(ProjectPath)/../../../../Demo/Common/include</IncludePath>
<OtherFlags>-ffunction-sections -fdata-sections -mistack</OtherFlags>
<Verbose>no</Verbose>
<Ansi>no</Ansi>
<Syntax>no</Syntax>
<Pedantic>no</Pedantic>
<PedanticErr>no</PedanticErr>
<InhibitWarn>no</InhibitWarn>
<AllWarn>yes</AllWarn>
<WarnErr>no</WarnErr>
<OneElfS>no</OneElfS>
<Fstrict>no</Fstrict>
</Compiler>
<Asm>
<Define/>
<Undefine/>
<IncludePath>$(ProjectPath);$(CDKPath)/CSKY/csi/csi_core/include/;$(CDKPath)/CSKY/csi/csi_core/csi_cdk/;$(CDKPath)/CSKY/csi/csi_driver/include/</IncludePath>
<OtherFlags/>
<DebugLevel>gdwarf2</DebugLevel>
</Asm>
<Linker>
<Garbage>yes</Garbage>
<LDFile>$(ProjectPath)/ckcpu.ld</LDFile>
<LibName/>
<LibPath/>
<OtherFlags/>
<AutoLDFile>no</AutoLDFile>
</Linker>
<Debug>
<LoadApplicationAtStartup>yes</LoadApplicationAtStartup>
<Connector>ICE</Connector>
<StopAt>yes</StopAt>
<StopAtText>main</StopAtText>
<InitFile>$(ProjectPath)/gdb.init</InitFile>
<AutoRun>yes</AutoRun>
<ResetType>Soft Reset</ResetType>
<SoftResetVal>60000000</SoftResetVal>
<ResetAfterLoad>no</ResetAfterLoad>
<Dumpcore>no</Dumpcore>
<DumpcoreText>$(ProjectPath)/$(ProjectName).cdkcore</DumpcoreText>
<ConfigICE>
<IP>localhost</IP>
<PORT>1025</PORT>
<Clock>12000</Clock>
<Delay>10</Delay>
<WaitReset>50</WaitReset>
<DDC>yes</DDC>
<TRST>no</TRST>
<DebugPrint>no</DebugPrint>
<Connect>Normal</Connect>
<ResetType>soft</ResetType>
<SoftResetVal>0</SoftResetVal>
<RTOSType>None</RTOSType>
<DownloadToFlash>no</DownloadToFlash>
<ResetAfterConnect>yes</ResetAfterConnect>
<GDBName/>
<GDBServerType>Local</GDBServerType>
<OtherFlags/>
</ConfigICE>
<ConfigSIM>
<SIMTarget/>
<OtherFlags/>
<NoGraphic>yes</NoGraphic>
<Log>no</Log>
<SimTrace>no</SimTrace>
</ConfigSIM>
</Debug>
<Flash>
<InitFile>$(ProjectPath)/flash.init</InitFile>
<Erase>Erase Sectors</Erase>
<Algorithms Path="">hobbit1_2_OTP_CDK.elf</Algorithms>
<Program>no</Program>
<Verify>no</Verify>
<ResetAndRun>no</ResetAndRun>
<ResetType>Soft Reset</ResetType>
<SoftResetVal/>
<External>no</External>
<Command/>
<Arguments/>
</Flash>
</BuildConfig>
</BuildConfigs>
</Project>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<CDK_Workspace Name="RTOSDemo" Database="">
<Project Name="RTOSDemo" Path="RTOSDemo.cdkproj" Active="Yes"/>
<BuildMatrix>
<WorkspaceConfiguration Name="Debug" Selected="yes">
<Environment/>
<Project Name="RTOSDemo" ConfigName="BuildSet"/>
</WorkspaceConfiguration>
</BuildMatrix>
</CDK_Workspace>

View file

@ -0,0 +1,50 @@
/*============================================================================
* Name : chip_name.c
* Author : $(UserName)
* Copyright : Your copyright notice
* Description : System Initialization before main
* 1 CPU initialization
* 2 memory & IO base address initialization
* 3 flash size & address initialization
* 4 interrupt resource initialization for the soc
*============================================================================
*/
#include "chip_name.h"
/**
* @brief initial CPU based on user config in chip_name.h
*/
static void CPUInit(void)
{
/**
* Config CPU's Unit such as MGU, Cache...
*/
return;
}
/**
* @brief entry of whole chip initialization
* @Note anyone should not use any global variable in this function since this function is called
* at before data section's initialization.
* Since here SystemInit is a weak symbol, any vendor can override this symbol on its own wishes.
*/
#define CONFIG_SYSTICK_HZ 100
#define CONFIG_SYSTEM_FREQ 24000000
__attribute__((weak)) void SystemInit(void)
{
/**
* initial CPU based on the config in chip_name.h
*/
CPUInit();
/**
* TODO: initial IO, memory, flash...
*/
drv_coret_config(CONFIG_SYSTEM_FREQ / CONFIG_SYSTICK_HZ, CORET_IRQn); //10ms
csi_vic_enable_sirq(CORET_IRQn);
return;
}

View file

@ -0,0 +1,45 @@
/*
* Description : chip_name.h - Define the system configuration such as:
* 1 CPU base config
* 2 memory & IO base address
* 3 flash size & address
* 4 interrupt resource for the soc.
*
* Copyright (C) : Hangzhou C-SKY Microsystems Co.,LTD.
* Date: 2016-08-22
*/
#ifndef __INCLUDE_CHIP_NAME_H__
#define __INCLUDE_CHIP_NAME_H__
typedef enum IRQn
{
/* ---------------------- CK801CM0 Specific Interrupt Numbers --------------------- */
CORET_IRQn = 0,
} IRQn_Type;
/* Configuration of the CK80# Processor and Core Peripherals */
/* ToDo: set the defines according your Device */
/* ToDo: define the correct core revision
__CK801_REV if your device is a CK801 device
__CK802_REV if your device is a CK802 device
__CK803S_REV if your device is a CK803S device */
#define __NVIC_PRIO_BITS 2 /*!< Number of Bits used for Priority Levels */
#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
#define __MGU_PRESENT 0 /*!< MGU present or not */
/* Soft reset address */
#define __RESET_CONST 0xabcd1234
/**********************************************
* Config CPU
* Define the attribute for your CPU
*********************************************/
//#include "CSICORE_CK802.H"
/*******************************
* Config IO base address
******************************/
#endif /* __INCLUDE_CHIP_NAME_H__ */

View file

@ -0,0 +1,150 @@
/*************************************************************
// <<< Use Configuration Wizard in Context Menu >>>
*************************************************************/
/*************************************************************
// <m> Entry Point <2>
// <i> config start function for this application
*************************************************************/
MEMORY
{
ROM : ORIGIN = 0x0 , LENGTH = 0x2000 /* ROM 8KB*/
EFLASH : ORIGIN = 0x60000000 , LENGTH = 0x4000 /* E-FLASH 252KB*/
SRAM : ORIGIN = 0x60004000 , LENGTH = 0xC000 /* on-chip SRAM 80KB*/
}
__min_heap_size = 0x200;
PROVIDE (__ram_end = 0x60014000);
PROVIDE (__heap_end = __ram_end);
REGION_ALIAS("REGION_TEXT", EFLASH);
REGION_ALIAS("REGION_RODATA", EFLASH);
REGION_ALIAS("REGION_DATA", SRAM);
REGION_ALIAS("REGION_BSS", SRAM);
ENTRY(Reset_Handler)
SECTIONS
{
.text : {
. = ALIGN(0x4) ;
*startup.o(*.text)
__stext = . ;
*(.text)
*(.text*)
*(.text.*)
*(.gnu.warning)
*(.stub)
*(.gnu.linkonce.t*)
*(.glue_7t)
*(.glue_7)
*(.jcr)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN (4) ;
PROVIDE(__ctbp = .);
*(.call_table_data)
*(.call_table_text)
. = ALIGN(0x10) ;
__etext = . ;
} > REGION_TEXT
.eh_frame_hdr : {
*(.eh_frame_hdr)
} > REGION_TEXT
.eh_frame : ONLY_IF_RO {
KEEP (*(.eh_frame))
} > REGION_TEXT
.gcc_except_table : ONLY_IF_RO {
*(.gcc_except_table .gcc_except_table.*)
} > REGION_TEXT
.rodata : {
. = ALIGN(0x4) ;
__srodata = .;
*(.rdata)
*(.rdata*)
*(.rdata1)
*(.rdata.*)
*(.rodata)
*(.rodata1)
*(.rodata*)
*(.rodata.*)
*(.rodata.str1.4)
. = ALIGN(0x4) ;
__ctor_start__ = .;
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
__ctor_end__ = .;
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
__dtor_end__ = .;
. = ALIGN(0x4) ;
__erodata = .;
__rodata_end__ = .;
} > REGION_RODATA
.data : {
. = ALIGN(0x4) ;
__sdata = . ;
__data_start__ = . ;
data_start = . ;
KEEP(*startup.o(.vectors))
*(.got.plt)
*(.got)
*(.gnu.linkonce.r*)
*(.data)
*(.data*)
*(.data1)
*(.data.*)
*(.gnu.linkonce.d*)
*(.data1)
*(.gcc_except_table)
*(.gcc_except_table*)
__start_init_call = .;
*(.initcall.init)
__stop_init_call = .;
__start_cmd = .;
*(.bootloaddata.cmd)
. = ALIGN(4) ;
__stop_cmd = .;
*(.sdata)
*(.sdata.*)
*(.gnu.linkonce.s.*)
*(__libc_atexit)
*(__libc_subinit)
*(__libc_subfreeres)
*(.note.ABI-tag)
__edata = .;
__data_end__ = .;
. = ALIGN(0x4) ;
} > REGION_DATA AT > REGION_RODATA
.eh_frame : ONLY_IF_RW {
KEEP (*(.eh_frame))
} > REGION_DATA AT > REGION_RODATA
.gcc_except_table : ONLY_IF_RW {
*(.gcc_except_table .gcc_except_table.*)
__edata = .;
__data_end__ = .;
} > REGION_DATA AT > REGION_RODATA
.bss : {
. = ALIGN(0x4) ;
__sbss = ALIGN(0x4) ;
__bss_start__ = . ;
*(.dynsbss)
*(.sbss)
*(.sbss.*)
*(.scommon)
*(.dynbss)
*(.bss)
*(.bss.*)
*(COMMON)
. = ALIGN(0x4) ;
__ebss = . ;
__bss_end__ = .;
__end = . ;
end = . ;
} > REGION_BSS AT > REGION_BSS
._user_heap : {
. = ALIGN(0x4) ;
__heap_start = .;
. += __min_heap_size;
. = ALIGN(0x4) ;
} > REGION_BSS AT > REGION_BSS
}

View file

@ -0,0 +1,195 @@
/*
* crt0.S
* 1 define and initial the stack pointer
* 2 exception handler table
* 3 call SystemInit
* 4 go to __main in entry.o
*
* Copyright (C) 2016~2017 Hangzhou C-SKY Microsystems Co., Ltd
* Modify by Jiang Long on 2016-09-14
*/
// <<< Use Configuration Wizard in Context Menu >>>
/*
* For importing variable or functions from other c or assemble files.
*/
.import main
/*
* default service routine
*/
.global Reset_Handler
.global Misaligned_Access_Handler
.global Access_Error_Handler
.global Divided_By_Zero_Handler
.global Illegal_Handler
.global Privlege_Violation_Handler
.global Trace_Exection_Handler
.global Breakpoint_Exception_Handler
.global Unrecoverable_Error_Handler
.global Idly4_Error_Handler
.global Auto_INT_Handler
.global Auto_FINT_Handler
.global Reserved_HAI_Handler
.global Reserved_FP_Handler
.global TLB_Ins_Empty_Handler
.global TLB_Data_Empty_Handler
.global Default_handler
.weak Reset_Handler
.weak Misaligned_Access_Handler
.weak Access_Error_Handler
.weak Divided_By_Zero_Handler
.weak Illegal_Handler
.weak Privlege_Violation_Handler
.weak Trace_Exection_Handler
.weak Breakpoint_Exception_Handler
.weak Unrecoverable_Error_Handler
.weak Idly4_Error_Handler
.weak Auto_INT_Handler
.weak Auto_FINT_Handler
.weak Reserved_HAI_Handler
.weak Reserved_FP_Handler
.weak TLB_Ins_Empty_Handler
.weak TLB_Data_Empty_Handler
.weak Default_handler
.export ckcpu_vsr_table /* Vector table base address. */
.section .exp_table,"ax",@progbits
/* Vector table space. */
$d:
.align 10
ckcpu_vsr_table:
.long Reset_Handler
.long Misaligned_Access_Handler
.long Access_Error_Handler
.long Divided_By_Zero_Handler
.long Illegal_Handler
.long Privlege_Violation_Handler
.long Trace_Exection_Handler
.long Breakpoint_Exception_Handler
.long Unrecoverable_Error_Handler
.long Idly4_Error_Handler
.long Auto_INT_Handler
.long Auto_FINT_Handler
.long Reserved_HAI_Handler
.long Reserved_FP_Handler
.long TLB_Ins_Empty_Handler
.long TLB_Data_Empty_Handler
.rept 32
.long NOVIC_IRQ_Default_Handler
.endr
$t:
/* The ckcpu startup codes. */
.text
.align 2
/*
* This is the codes first entry point. This is where it all begins...
*/
Reset_Handler:
/*
* Init psr value, enable exception, disable interrupt and fast interrupt.
* psr = 0x80000100
*/
bgeni r7, 31
bseti r7, 30
bseti r7, 29
bseti r7, 8
mtcr r7, psr
/*
* Setup initial vector base table for interrupts and exceptions
*/
lrw a3, ckcpu_vsr_table
mtcr a3, vbr
/* Initialize the normal stack pointer from the linker definition. */
lrw r0, g_top_irqstack
mov sp, r0
/*
* The ranges of copy from/to are specified by following symbols
* __etext: LMA of start of the section to copy from. Usually end of text
* __data_start__: VMA of start of the section to copy to
* __data_end__: VMA of end of the section to copy to
*
* All addresses must be aligned to 4 bytes boundary.
*/
lrw r1, __erodata
lrw r2, __data_start__
lrw r3, __data_end__
subu r3, r2
cmpnei r3, 0
bf .L_loop0_done
.L_loop0:
ldw r0, (r1, 0)
stw r0, (r2, 0)
addi r1, 4
addi r2, 4
subi r3, 4
cmpnei r3, 0
bt .L_loop0
.L_loop0_done:
/*
* The BSS section is specified by following symbols
* __bss_start__: start of the BSS section.
* __bss_end__: end of the BSS section.
*
* Both addresses must be aligned to 4 bytes boundary.
*/
lrw r1, __bss_start__
lrw r2, __bss_end__
movi r0, 0
subu r2, r1
cmpnei r2, 0
bf .L_loop1_done
.L_loop1:
stw r0, (r1, 0)
addi r1, 4
subi r2, 4
cmpnei r2, 0
bt .L_loop1
.L_loop1_done:
jbsr main
/* Should never get here. */
1:
br 1b
Misaligned_Access_Handler:
Access_Error_Handler:
Divided_By_Zero_Handler:
Illegal_Handler:
Privlege_Violation_Handler:
Trace_Exection_Handler:
Breakpoint_Exception_Handler:
Unrecoverable_Error_Handler:
Idly4_Error_Handler:
Auto_INT_Handler:
Auto_FINT_Handler:
Reserved_HAI_Handler:
Reserved_FP_Handler:
TLB_Ins_Empty_Handler:
TLB_Data_Empty_Handler:
Default_handler:
br Default_handler
rte
.section .bss
.align 2
.global g_intstackalloc
.global g_intstackbase
.global g_top_irqstack
g_intstackalloc:
g_intstackbase:
.space 4096
g_top_irqstack:

View file

@ -0,0 +1,6 @@
set *0x4000202c=0xc0206
set *0x40002004=0x8
set $pc=0x60000000
set $psr=0xe0000000

View file

@ -0,0 +1,123 @@
/*============================================================================
* Name : main.c
* Author : $(username)
* Version : 0.0.0
* Copyright : Your copyright notice
* Description : Simple function in C, Ansi-style
*============================================================================
*/
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
extern void SystemInit(void);
#define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainQUEUE_SEND_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainQUEUE_SEND_FREQUENCY_MS ( 200 / portTICK_PERIOD_MS )
/* The number of items the queue can hold. This is 1 as the receive task
will remove items as they are added, meaning the send task should always find
the queue empty. */
#define mainQUEUE_LENGTH ( 1 )
static QueueHandle_t xQueue = NULL;
static void prvQueueSendTask( void *pvParameters )
{
TickType_t xNextWakeTime;
const unsigned long ulValueToSend = 100UL;
/* Initialise xNextWakeTime - this only needs to be done once. */
xNextWakeTime = xTaskGetTickCount();
for( ;; )
{
/* Place this task in the blocked state until it is time to run again.
The block time is specified in ticks, the constant used converts ticks
to ms. While in the Blocked state this task will not consume any CPU
time. */
vTaskDelayUntil( &xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS );
/* Send to the queue - causing the queue receive task to unblock and
toggle an LED. 0 is used as the block time so the sending operation
will not block - it shouldn't need to block as the queue should always
be empty at this point in the code. */
xQueueSend( xQueue, &ulValueToSend, 0 );
}
}
static void prvQueueReceiveTask( void *pvParameters )
{
unsigned int ulReceivedValue;
for( ;; )
{
/* Wait until something arrives in the queue - this task will block
indefinitely provided INCLUDE_vTaskSuspend is set to 1 in
FreeRTOSConfig.h. */
xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );
/* To get here something must have been received from the queue, but
is it the expected value? If it is, toggle the green LED. */
if( ulReceivedValue == 100UL )
{
printf("Recieve expected value : %d\n", ulReceivedValue);
}
else
{
printf("Recieve unexpected value : %d\n", ulReceivedValue);
}
}
}
int main()
{
SystemInit();
xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );
if (xQueue != NULL)
{
xTaskCreate( prvQueueReceiveTask, "Rx", configMINIMAL_STACK_SIZE, NULL, mainQUEUE_RECEIVE_TASK_PRIORITY, NULL );
xTaskCreate( prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE, NULL, mainQUEUE_SEND_TASK_PRIORITY, NULL );
vTaskStartScheduler();
}
return 0;
}