diff --git a/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/.cproject b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/.cproject
new file mode 100644
index 00000000..daa6d5b0
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/.cproject
@@ -0,0 +1,448 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/.gitignore b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/.gitignore
new file mode 100644
index 00000000..3df573fe
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/.gitignore
@@ -0,0 +1 @@
+/Debug/
diff --git a/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/.project b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/.project
new file mode 100644
index 00000000..a5400f89
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/.project
@@ -0,0 +1,154 @@
+
+
+ tencent_os_mqtt
+
+
+
+
+
+ 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
+ $%7BPARENT-2-PROJECT_LOC%7D/BSP/Inc
+
+
+ Application/Src
+ 2
+ $%7BPARENT-2-PROJECT_LOC%7D/BSP/Src
+
+
+ Application/tencent_os_mqtt
+ 2
+ /Users/ace/workspace/TencentOS-tiny/examples/tencent_os_mqtt
+
+
+ Application/tos_config.h
+ 1
+ $%7BPARENT-2-PROJECT_LOC%7D/TOS_CONFIG/tos_config.h
+
+
+ TencentOS_tiny/arch
+ 2
+ virtual:/virtual
+
+
+ TencentOS_tiny/components
+ 2
+ virtual:/virtual
+
+
+ TencentOS_tiny/devices
+ 2
+ virtual:/virtual
+
+
+ TencentOS_tiny/kernel
+ 2
+ $%7BPARENT-4-PROJECT_LOC%7D/kernel
+
+
+ TencentOS_tiny/net
+ 2
+ virtual:/virtual
+
+
+ TencentOS_tiny/platform
+ 2
+ virtual:/virtual
+
+
+ TencentOS_tiny/arch/risc-v
+ 2
+ virtual:/virtual
+
+
+ TencentOS_tiny/components/connectivity
+ 2
+ virtual:/virtual
+
+
+ TencentOS_tiny/devices/esp8266
+ 2
+ TOP_DIR/devices/esp8266
+
+
+ TencentOS_tiny/net/at
+ 2
+ TOP_DIR/net/at
+
+
+ TencentOS_tiny/net/sal_module_wrapper
+ 2
+ TOP_DIR/net/sal_module_wrapper
+
+
+ TencentOS_tiny/platform/hal
+ 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
+
+
+ TencentOS_tiny/components/connectivity/Eclipse-Paho-MQTT
+ 2
+ TOP_DIR/components/connectivity/Eclipse-Paho-MQTT
+
+
+ TencentOS_tiny/platform/hal/gd
+ 2
+ TOP_DIR/platform/hal/gd
+
+
+
+
+ TOP_DIR
+ $%7BPARENT-4-PROJECT_LOC%7D
+
+
+
diff --git a/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/gd32vf103_libopt.h b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/gd32vf103_libopt.h
new file mode 100644
index 00000000..875ff748
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/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/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/link.lds b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/link.lds
new file mode 100644
index 00000000..1c32e640
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/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/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/main.c b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/main.c
new file mode 100644
index 00000000..ac77b773
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/main.c
@@ -0,0 +1,41 @@
+#include "mcu_init.h"
+#include "tos_k.h"
+
+#define TASK_SIZE 1024
+k_task_t k_task_bled;
+k_task_t k_task_wifi;
+uint8_t k_bled_stk[TASK_SIZE];
+uint8_t k_wifi_stk[TASK_SIZE];
+
+void task_bled(void *pdata)
+{
+ int cnt = 0;
+ while (1) {
+ printf("blink led task cnt: %d\n", cnt++);
+ gpio_bit_write(LED_GPIO_PORT, LED_PIN,cnt % 2 ? SET : RESET);
+ tos_task_delay(1000);
+ }
+}
+
+extern void mqtt_demo();
+
+void task_wifi(void *pdata)
+{
+ while(1) {
+ mqtt_demo();
+ tos_task_delay(500);
+ }
+}
+
+
+void main(void) {
+ board_init();
+
+ tos_knl_init();
+
+ tos_task_create(&k_task_bled, "bled", task_bled, NULL, 5, k_bled_stk, TASK_SIZE, 0);
+ tos_task_create(&k_task_wifi, "wifi", task_wifi, NULL, 3, k_wifi_stk, TASK_SIZE, 0);
+
+ tos_knl_start();
+
+}
diff --git a/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/openocd_gdlink.cfg b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/openocd_gdlink.cfg
new file mode 100644
index 00000000..3ec85d42
--- /dev/null
+++ b/board/TencentOS_tiny_EVB_LX/eclipse/tencent_os_mqtt/openocd_gdlink.cfg
@@ -0,0 +1,45 @@
+adapter_khz 1000
+reset_config srst_only
+adapter_nsrst_assert_width 100
+
+
+
+interface cmsis-dap
+
+transport select jtag
+
+#autoexit true
+
+set _CHIPNAME riscv
+jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x1000563d
+
+set _TARGETNAME $_CHIPNAME.cpu
+target create $_TARGETNAME riscv -chain-position $_TARGETNAME
+$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 20480 -work-area-backup 0
+
+
+# Work-area is a space in RAM used for flash programming
+if { [info exists WORKAREASIZE] } {
+ set _WORKAREASIZE $WORKAREASIZE
+} else {
+ set _WORKAREASIZE 0x5000
+}
+
+# Allow overriding the Flash bank size
+if { [info exists FLASH_SIZE] } {
+ set _FLASH_SIZE $FLASH_SIZE
+} else {
+ # autodetect size
+ set _FLASH_SIZE 0
+}
+
+# flash size will be probed
+set _FLASHNAME $_CHIPNAME.flash
+
+flash bank $_FLASHNAME gd32vf103 0x08000000 0 0 0 $_TARGETNAME
+riscv set_reset_timeout_sec 1
+init
+
+halt
+
+
diff --git a/examples/tencent_os_mqtt/mqtt_example.c b/examples/tencent_os_mqtt/mqtt_example.c
index 9f44de28..2de33566 100644
--- a/examples/tencent_os_mqtt/mqtt_example.c
+++ b/examples/tencent_os_mqtt/mqtt_example.c
@@ -73,7 +73,7 @@ void mqtt_demo(void)
}
count++;
- osDelay(1000);
+ tos_task_delay(1000);
}
}
diff --git a/net/at/src/tos_at.c b/net/at/src/tos_at.c
index 95eca8a8..f632cbef 100644
--- a/net/at/src/tos_at.c
+++ b/net/at/src/tos_at.c
@@ -347,7 +347,7 @@ __STATIC_INLINE__ void at_echo_flush(at_echo_t *echo)
echo->__w_idx = 0;
}
-__STATIC_INLINE void at_echo_attach(at_echo_t *echo)
+__STATIC_INLINE__ void at_echo_attach(at_echo_t *echo)
{
at_echo_flush(echo);
AT_AGENT->echo = echo;
diff --git a/platform/hal/gd/gd32vf1xx/src/tos_hal_uart.c b/platform/hal/gd/gd32vf1xx/src/tos_hal_uart.c
new file mode 100644
index 00000000..f407e8d7
--- /dev/null
+++ b/platform/hal/gd/gd32vf1xx/src/tos_hal_uart.c
@@ -0,0 +1,81 @@
+#include "tos_k.h"
+#include "tos_hal.h"
+#include "gd32vf103.h"
+#include "usart.h"
+
+typedef struct __UART_HandleTypeDef {
+ hal_uart_port_t port;
+} UART_HandleTypeDef;
+
+
+UART_HandleTypeDef huart0 = { USART0 };
+UART_HandleTypeDef huart1 = { USART1 };
+UART_HandleTypeDef huart2 = { USART2 };
+
+__API__ int tos_hal_uart_init(hal_uart_t *uart, hal_uart_port_t port)
+{
+ if (!uart) {
+ return -1;
+ }
+
+ if (port == HAL_UART_PORT_0) {
+ usart0_init(115200);
+ } else if (port == HAL_UART_PORT_1) {
+ usart1_init(115200);
+ } else if (port == HAL_UART_PORT_2) {
+ usart2_init(115200);
+ } else {
+ return -1;
+ }
+
+ return 0;
+}
+
+__API__ int tos_hal_uart_write(hal_uart_t *uart, const uint8_t *buf, size_t size, uint32_t timeout)
+{
+ UART_HandleTypeDef *uart_handle;
+
+ if (!uart || !buf) {
+ return -1;
+ }
+
+ if (!uart->private_uart) {
+ return -1;
+ }
+
+ uart_handle = (UART_HandleTypeDef *)uart->private_uart;
+
+ for(size_t i=0; iport, buf[i]);
+ }
+
+
+ return 0;
+}
+
+__API__ int tos_hal_uart_read(hal_uart_t *uart, const uint8_t *buf, size_t size, uint32_t timeout)
+{
+ return 0;
+}
+
+__API__ int tos_hal_uart_deinit(hal_uart_t *uart)
+{
+ UART_HandleTypeDef *uart_handle;
+
+ if (!uart) {
+ return -1;
+ }
+
+ if (!uart->private_uart) {
+ return -1;
+ }
+
+ uart_handle = (UART_HandleTypeDef *)uart->private_uart;
+
+
+ usart_deinit(uart_handle->port);
+
+
+ return 0;
+}
+