From 41051e1452e0ab8116dd4659757a80051ae77cad Mon Sep 17 00:00:00 2001 From: acevest Date: Thu, 10 Oct 2019 18:42:52 +0800 Subject: [PATCH] add risc-v board Sipeed Longan Nano support --- board/SipeedLonganNano/BSP/Inc/mcu_init.h | 18 + board/SipeedLonganNano/BSP/Inc/usart.h | 10 + board/SipeedLonganNano/BSP/Src/mcu_init.c | 17 + board/SipeedLonganNano/BSP/Src/usart.c | 28 ++ board/SipeedLonganNano/README.md | 12 + .../SipeedLonganNano/TOS_CONFIG/tos_config.h | 70 +++ .../eclipse/hello_world/.cproject | 438 ++++++++++++++++++ .../eclipse/hello_world/.gitignore | 1 + .../eclipse/hello_world/.project | 94 ++++ ....gnumcueclipse.debug.gdbjtag.openocd.prefs | 3 + ...umcueclipse.managedbuild.cross.riscv.prefs | 2 + .../.settings/language.settings.xml | 48 ++ .../org.eclipse.ltk.core.refactoring.prefs | 2 + .../eclipse/hello_world/gd32vf103_libopt.h | 61 +++ .../eclipse/hello_world/link.lds | 175 +++++++ .../eclipse/hello_world/main.c | 83 ++++ .../openocd_sipeed_rv_debugger.cfg | 39 ++ 17 files changed, 1101 insertions(+) create mode 100644 board/SipeedLonganNano/BSP/Inc/mcu_init.h create mode 100644 board/SipeedLonganNano/BSP/Inc/usart.h create mode 100644 board/SipeedLonganNano/BSP/Src/mcu_init.c create mode 100644 board/SipeedLonganNano/BSP/Src/usart.c create mode 100644 board/SipeedLonganNano/README.md create mode 100644 board/SipeedLonganNano/TOS_CONFIG/tos_config.h create mode 100644 board/SipeedLonganNano/eclipse/hello_world/.cproject create mode 100644 board/SipeedLonganNano/eclipse/hello_world/.gitignore create mode 100644 board/SipeedLonganNano/eclipse/hello_world/.project create mode 100644 board/SipeedLonganNano/eclipse/hello_world/.settings/ilg.gnumcueclipse.debug.gdbjtag.openocd.prefs create mode 100644 board/SipeedLonganNano/eclipse/hello_world/.settings/ilg.gnumcueclipse.managedbuild.cross.riscv.prefs create mode 100644 board/SipeedLonganNano/eclipse/hello_world/.settings/language.settings.xml create mode 100644 board/SipeedLonganNano/eclipse/hello_world/.settings/org.eclipse.ltk.core.refactoring.prefs create mode 100644 board/SipeedLonganNano/eclipse/hello_world/gd32vf103_libopt.h create mode 100644 board/SipeedLonganNano/eclipse/hello_world/link.lds create mode 100644 board/SipeedLonganNano/eclipse/hello_world/main.c create mode 100644 board/SipeedLonganNano/openocd_sipeed_rv_debugger.cfg diff --git a/board/SipeedLonganNano/BSP/Inc/mcu_init.h b/board/SipeedLonganNano/BSP/Inc/mcu_init.h new file mode 100644 index 00000000..45cc8711 --- /dev/null +++ b/board/SipeedLonganNano/BSP/Inc/mcu_init.h @@ -0,0 +1,18 @@ +#ifndef __MCU_INIT_H +#define __MCU_INIT_H + +#include "gd32vf103.h" +#include "usart.h" + + +#define LEDR_GPIO_PORT GPIOC +#define LEDG_GPIO_PORT GPIOA +#define LEDB_GPIO_PORT GPIOA + +#define LEDR_PIN GPIO_PIN_13 +#define LEDG_PIN GPIO_PIN_1 +#define LEDB_PIN GPIO_PIN_2 + +void board_init(); + +#endif //__MCU_INIT_H diff --git a/board/SipeedLonganNano/BSP/Inc/usart.h b/board/SipeedLonganNano/BSP/Inc/usart.h new file mode 100644 index 00000000..bb5f1594 --- /dev/null +++ b/board/SipeedLonganNano/BSP/Inc/usart.h @@ -0,0 +1,10 @@ +#ifndef __USART_H +#define __USART_H + +#define USART0_GPIO_TX_PIN GPIO_PIN_9 +#define USART0_GPIO_RX_PIN GPIO_PIN_10 +#define USART0_GPIO_PORT GPIOA + +void usart0_init(int baud); + +#endif // __USART_H diff --git a/board/SipeedLonganNano/BSP/Src/mcu_init.c b/board/SipeedLonganNano/BSP/Src/mcu_init.c new file mode 100644 index 00000000..42fa9320 --- /dev/null +++ b/board/SipeedLonganNano/BSP/Src/mcu_init.c @@ -0,0 +1,17 @@ +#include "mcu_init.h" + +void board_init() { + + SystemInit(); + + rcu_periph_clock_enable(RCU_GPIOA); + rcu_periph_clock_enable(RCU_GPIOC); + + gpio_init(LEDR_GPIO_PORT, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LEDR_PIN); + gpio_init(LEDG_GPIO_PORT, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LEDG_PIN); + gpio_init(LEDB_GPIO_PORT, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, LEDB_PIN); + + gpio_bit_set(LEDR_GPIO_PORT, LEDR_PIN); + gpio_bit_set(LEDG_GPIO_PORT, LEDG_PIN); + gpio_bit_set(LEDB_GPIO_PORT, LEDB_PIN); +} diff --git a/board/SipeedLonganNano/BSP/Src/usart.c b/board/SipeedLonganNano/BSP/Src/usart.c new file mode 100644 index 00000000..9d6c0d6f --- /dev/null +++ b/board/SipeedLonganNano/BSP/Src/usart.c @@ -0,0 +1,28 @@ +#include "gd32vf103.h" +#include "usart.h" +void usart0_init(int baud) +{ + /* enable GPIO clock */ + rcu_periph_clock_enable(RCU_GPIOA); + + /* enable USART0 clock */ + rcu_periph_clock_enable(RCU_USART0); + + /* connect port to USART0_Tx */ + gpio_init(USART0_GPIO_PORT, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, USART0_GPIO_TX_PIN); + + /* connect port to USART0_Rx */ + gpio_init(USART0_GPIO_PORT, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, USART0_GPIO_RX_PIN); + + /* USART0 configure */ + usart_deinit(USART0); + usart_baudrate_set(USART0, baud); + usart_word_length_set(USART0, USART_WL_8BIT); + usart_stop_bit_set(USART0, USART_STB_1BIT); + usart_parity_config(USART0, USART_PM_NONE); + usart_hardware_flow_rts_config(USART0, USART_RTS_DISABLE); + usart_hardware_flow_cts_config(USART0, USART_CTS_DISABLE); + usart_receive_config(USART0, USART_RECEIVE_ENABLE); + usart_transmit_config(USART0, USART_TRANSMIT_ENABLE); + usart_enable(USART0); +} diff --git a/board/SipeedLonganNano/README.md b/board/SipeedLonganNano/README.md new file mode 100644 index 00000000..f7ee74ea --- /dev/null +++ b/board/SipeedLonganNano/README.md @@ -0,0 +1,12 @@ +#使用openocd调试 + +需要编译特定的openocd + + +```git clone https://github.com/riscv-mcu/riscv-openocd.git``` + +如果用的是Sipeed USB-JTAG/TTL RISC-V Debugger,需要在编译的时候enable ftdi + +``` +./configure --enable-cmsis-dap --enable-ftdi +``` \ No newline at end of file diff --git a/board/SipeedLonganNano/TOS_CONFIG/tos_config.h b/board/SipeedLonganNano/TOS_CONFIG/tos_config.h new file mode 100644 index 00000000..6c096ebf --- /dev/null +++ b/board/SipeedLonganNano/TOS_CONFIG/tos_config.h @@ -0,0 +1,70 @@ +#ifndef INC_TOS_CONFIG_H_ +#define INC_TOS_CONFIG_H_ + +#include "gd32vf103.h" +#include "stddef.h" + +// 配置TencentOS tiny默认支持的最大优先级数量 +#define TOS_CFG_TASK_PRIO_MAX 10u + +// 配置TencentOS tiny的内核是否开启时间片轮转 +#define TOS_CFG_ROUND_ROBIN_EN 0u + +// 配置TencentOS tiny是否校验指针合法 +#define TOS_CFG_OBJECT_VERIFY 0u + +// TencentOS tiny 事件模块功能宏 +#define TOS_CFG_EVENT_EN 1u + +// 配置TencentOS tiny是否开启动态内存模块 +#define TOS_CFG_MMHEAP_EN 1u + +// 配置TencentOS tiny动态内存池大小 +#define TOS_CFG_MMHEAP_POOL_SIZE 8192 + +// 配置TencentOS tiny是否开启互斥锁模块 +#define TOS_CFG_MUTEX_EN 1u + +// 配置TencentOS tiny是否开启队列模块 +#define TOS_CFG_QUEUE_EN 1u + +// 配置TencentOS tiny是否开启软件定时器模块 +#define TOS_CFG_TIMER_EN 0u + +// 配置TencentOS tiny是否开启信号量模块 +#define TOS_CFG_SEM_EN 1u + +#define TOS_CFG_CPU_SYSTICK_PRIO 0xF + +#if (TOS_CFG_QUEUE_EN > 0u) +#define TOS_CFG_MSG_EN 1u +#else +#define TOS_CFG_MSG_EN 0u +#endif + +// 配置TencentOS tiny消息队列大小 +#define TOS_CFG_MSG_POOL_SIZE 10u + +// 配置TencentOS tiny空闲任务栈大小 +#define TOS_CFG_IDLE_TASK_STK_SIZE 512u + +// 配置TencentOS tiny中断栈大小 +#define TOS_CFG_IRQ_STK_SIZE 128u + +// 配置TencentOS tiny的tick频率 +#define TOS_CFG_CPU_TICK_PER_SECOND 1000u + +// 配置TencentOS tiny CPU频率 +// 除4的原因是,Bumblebee内核通过core_clk_aon四分频来更新mtime寄存器 +// 具体信息参见《Bumblebee内核简明数据手册》 +#define TOS_CFG_CPU_CLOCK (SystemCoreClock/4) + +// 配置是否将TIMER配置成函数模式 +#define TOS_CFG_TIMER_AS_PROC 1u + +#define TOS_CFG_VFS_EN 1u + +#define TOS_CFG_MMBLK_EN 1u + + +#endif /* INC_TOS_CONFIG_H_ */ diff --git a/board/SipeedLonganNano/eclipse/hello_world/.cproject b/board/SipeedLonganNano/eclipse/hello_world/.cproject new file mode 100644 index 00000000..3a71786d --- /dev/null +++ b/board/SipeedLonganNano/eclipse/hello_world/.cproject @@ -0,0 +1,438 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/board/SipeedLonganNano/eclipse/hello_world/.gitignore b/board/SipeedLonganNano/eclipse/hello_world/.gitignore new file mode 100644 index 00000000..3df573fe --- /dev/null +++ b/board/SipeedLonganNano/eclipse/hello_world/.gitignore @@ -0,0 +1 @@ +/Debug/ diff --git a/board/SipeedLonganNano/eclipse/hello_world/.project b/board/SipeedLonganNano/eclipse/hello_world/.project new file mode 100644 index 00000000..c5eb0fb6 --- /dev/null +++ b/board/SipeedLonganNano/eclipse/hello_world/.project @@ -0,0 +1,94 @@ + + + hello_world + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + Application + 2 + virtual:/virtual + + + GD32VF103_Firmware_Library + 2 + $%7BPARENT-4-PROJECT_LOC%7D/platform/vendor_bsp/gd/GD32VF103_Firmware_Library + + + TencentOS_tiny + 2 + virtual:/virtual + + + Application/Inc + 2 + TOP_DIR/board/SipeedLonganNano/BSP/Inc + + + Application/Src + 2 + TOP_DIR/board/SipeedLonganNano/BSP/Src + + + Application/tos_config.h + 1 + $%7BPARENT-2-PROJECT_LOC%7D/TOS_CONFIG/tos_config.h + + + TencentOS_tiny/arch + 2 + virtual:/virtual + + + TencentOS_tiny/kernel + 2 + $%7BPARENT-4-PROJECT_LOC%7D/kernel + + + TencentOS_tiny/arch/risc-v + 2 + virtual:/virtual + + + TencentOS_tiny/arch/risc-v/bumblebee + 2 + TOP_DIR/arch/risc-v/bumblebee/gcc + + + TencentOS_tiny/arch/risc-v/common + 2 + $%7BPARENT-4-PROJECT_LOC%7D/arch/risc-v/common + + + TencentOS_tiny/arch/risc-v/rv32i + 2 + TOP_DIR/arch/risc-v/rv32i/gcc + + + + + TOP_DIR + $%7BPARENT-4-PROJECT_LOC%7D + + + diff --git a/board/SipeedLonganNano/eclipse/hello_world/.settings/ilg.gnumcueclipse.debug.gdbjtag.openocd.prefs b/board/SipeedLonganNano/eclipse/hello_world/.settings/ilg.gnumcueclipse.debug.gdbjtag.openocd.prefs new file mode 100644 index 00000000..5ce8285b --- /dev/null +++ b/board/SipeedLonganNano/eclipse/hello_world/.settings/ilg.gnumcueclipse.debug.gdbjtag.openocd.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +executable.name=openocd +install.folder=/Users/ace/sys/gnu-mcu-eclipse/openocd/self/bin diff --git a/board/SipeedLonganNano/eclipse/hello_world/.settings/ilg.gnumcueclipse.managedbuild.cross.riscv.prefs b/board/SipeedLonganNano/eclipse/hello_world/.settings/ilg.gnumcueclipse.managedbuild.cross.riscv.prefs new file mode 100644 index 00000000..d5692f5e --- /dev/null +++ b/board/SipeedLonganNano/eclipse/hello_world/.settings/ilg.gnumcueclipse.managedbuild.cross.riscv.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +toolchain.path.512258282=/Users/ace/sys/gnu-mcu-eclipse/riscv-none-gcc/8.2.0-2.2-20190521-0004/bin diff --git a/board/SipeedLonganNano/eclipse/hello_world/.settings/language.settings.xml b/board/SipeedLonganNano/eclipse/hello_world/.settings/language.settings.xml new file mode 100644 index 00000000..cf5bdf78 --- /dev/null +++ b/board/SipeedLonganNano/eclipse/hello_world/.settings/language.settings.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/board/SipeedLonganNano/eclipse/hello_world/.settings/org.eclipse.ltk.core.refactoring.prefs b/board/SipeedLonganNano/eclipse/hello_world/.settings/org.eclipse.ltk.core.refactoring.prefs new file mode 100644 index 00000000..b196c64a --- /dev/null +++ b/board/SipeedLonganNano/eclipse/hello_world/.settings/org.eclipse.ltk.core.refactoring.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/board/SipeedLonganNano/eclipse/hello_world/gd32vf103_libopt.h b/board/SipeedLonganNano/eclipse/hello_world/gd32vf103_libopt.h new file mode 100644 index 00000000..c07eaa8c --- /dev/null +++ b/board/SipeedLonganNano/eclipse/hello_world/gd32vf103_libopt.h @@ -0,0 +1,61 @@ +/*! + \file gd32vf103_libopt.h + \brief library optional for gd32vf103 + + \version 2019-6-5, V1.0.0, demo for GD32VF103 +*/ + +/* + Copyright (c) 2019, GigaDevice Semiconductor Inc. + + Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + 3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +OF SUCH DAMAGE. +*/ + +#ifndef GD32VF103_LIBOPT_H +#define GD32VF103_LIBOPT_H + +#include "gd32vf103_adc.h" +#include "gd32vf103_bkp.h" +#include "gd32vf103_can.h" +#include "gd32vf103_crc.h" +#include "gd32vf103_dac.h" +#include "gd32vf103_dma.h" +#include "gd32vf103_eclic.h" +#include "gd32vf103_exmc.h" +#include "gd32vf103_exti.h" +#include "gd32vf103_fmc.h" +#include "gd32vf103_gpio.h" +#include "gd32vf103_i2c.h" +#include "gd32vf103_fwdgt.h" +#include "gd32vf103_dbg.h" +#include "gd32vf103_pmu.h" +#include "gd32vf103_rcu.h" +#include "gd32vf103_rtc.h" +#include "gd32vf103_spi.h" +#include "gd32vf103_timer.h" +#include "gd32vf103_usart.h" +#include "gd32vf103_wwdgt.h" +#include "n200_func.h" + +#endif /* GD32VF103_LIBOPT_H */ diff --git a/board/SipeedLonganNano/eclipse/hello_world/link.lds b/board/SipeedLonganNano/eclipse/hello_world/link.lds new file mode 100644 index 00000000..1c32e640 --- /dev/null +++ b/board/SipeedLonganNano/eclipse/hello_world/link.lds @@ -0,0 +1,175 @@ +OUTPUT_ARCH( "riscv" ) + +ENTRY( _start ) + +MEMORY +{ + /* Run in FLASH */ + flash (rxai!w) : ORIGIN = 0x08000000, LENGTH = 128k + ram (wxa!ri) : ORIGIN = 0x20000000, LENGTH = 32K + + /* Run in RAM */ +/* flash (rxai!w) : ORIGIN = 0x20000000, LENGTH = 24k + ram (wxa!ri) : ORIGIN = 0x20006000, LENGTH = 8K +*/ +} + + +SECTIONS +{ + __stack_size = DEFINED(__stack_size) ? __stack_size : 2K; + + + .init : + { + KEEP (*(SORT_NONE(.init))) + } >flash AT>flash + + .ilalign : + { + . = ALIGN(4); + PROVIDE( _ilm_lma = . ); + } >flash AT>flash + + .ialign : + { + PROVIDE( _ilm = . ); + } >flash AT>flash + + .text : + { + *(.rodata .rodata.*) + *(.text.unlikely .text.unlikely.*) + *(.text.startup .text.startup.*) + *(.text .text.*) + *(.gnu.linkonce.t.*) + } >flash AT>flash + + .fini : + { + KEEP (*(SORT_NONE(.fini))) + } >flash AT>flash + + . = ALIGN(4); + + PROVIDE (__etext = .); + PROVIDE (_etext = .);/*0x80022c8*/ + PROVIDE (etext = .);/*0x80022c8*/ + PROVIDE( _eilm = . ); + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >flash AT>flash + + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) + PROVIDE_HIDDEN (__init_array_end = .); + } >flash AT>flash + + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) + KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >flash AT>flash + + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } >flash AT>flash + + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } >flash AT>flash + + . = ALIGN(4); + PROVIDE( _eilm = . ); + + .lalign : + { + . = ALIGN(4); + PROVIDE( _data_lma = . ); + } >flash AT>flash + + .dalign : + { + . = ALIGN(4); + PROVIDE( _data = . ); + } >ram AT>flash + + + .data : + { + *(.rdata) + + *(.gnu.linkonce.r.*) + *(.data .data.*) + *(.gnu.linkonce.d.*) + . = ALIGN(8); + PROVIDE( __global_pointer$ = . + 0x800); + *(.sdata .sdata.*) + *(.gnu.linkonce.s.*) + . = ALIGN(8); + *(.srodata.cst16) + *(.srodata.cst8) + *(.srodata.cst4) + *(.srodata.cst2) + *(.srodata .srodata.*) + } >ram AT>flash + + . = ALIGN(4); + PROVIDE( _edata = . ); + PROVIDE( edata = . ); + + PROVIDE( _fbss = . ); /*0X200052A0 0X200002A0*/ + PROVIDE( __bss_start = . ); + .bss : + { + *(.sbss*) + *(.gnu.linkonce.sb.*) + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + } >ram AT>ram + + . = ALIGN(8); + PROVIDE( _end = . ); /*0X2000,0340*/ + PROVIDE( end = . ); + + .stack ORIGIN(ram) + LENGTH(ram) - __stack_size : + { + PROVIDE( _heap_end = . ); + . = __stack_size; + PROVIDE( _sp = . ); + } >ram AT>ram +} diff --git a/board/SipeedLonganNano/eclipse/hello_world/main.c b/board/SipeedLonganNano/eclipse/hello_world/main.c new file mode 100644 index 00000000..efc6462b --- /dev/null +++ b/board/SipeedLonganNano/eclipse/hello_world/main.c @@ -0,0 +1,83 @@ +#include "mcu_init.h" +#include "tos.h" + +#define TASK_SIZE 1024 +k_task_t k_task_task1; +k_task_t k_task_task2; +uint8_t k_task1_stk[TASK_SIZE]; +uint8_t k_task2_stk[TASK_SIZE]; + +int share = 0xCBA7F9; +k_sem_t sem; + +typedef struct { + int port; + int pin; +} Led_t; + +Led_t leds[] = { + { LEDR_GPIO_PORT, LEDR_PIN }, + { LEDG_GPIO_PORT, LEDG_PIN }, + { LEDB_GPIO_PORT, LEDB_PIN } +}; + +void task1(void *pdata) +{ + int task_cnt1 = 0; + while (1) { + printf("hello world from %s cnt: %d\n", __func__, task_cnt1++); + tos_sem_pend(&sem, ~0U); + + for(int i=0; i