Browse Source

[bsp][k210] Add get_free_heap_size function.

* Add get_free_heap_size function;
* Increase shell stack for KPU module.
Bernard Xiong 6 years ago
parent
commit
597d71cc03

+ 35 - 1
bsp/k210/.config

@@ -93,7 +93,7 @@ CONFIG_FINSH_USING_SYMTAB=y
 CONFIG_FINSH_USING_DESCRIPTION=y
 # CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
 CONFIG_FINSH_THREAD_PRIORITY=20
-CONFIG_FINSH_THREAD_STACK_SIZE=4096
+CONFIG_FINSH_THREAD_STACK_SIZE=16384
 CONFIG_FINSH_CMD_SIZE=80
 # CONFIG_FINSH_USING_AUTH is not set
 CONFIG_FINSH_USING_MSH=y
@@ -325,6 +325,40 @@ CONFIG_PKG_KENDRYTE_SDK_VER="v0.5.2"
 # CONFIG_PKG_USING_ZLIB is not set
 # CONFIG_PKG_USING_DSTR is not set
 # CONFIG_PKG_USING_TINYFRAME is not set
+# CONFIG_PKG_USING_KENDRYTE_DEMO is not set
+# CONFIG_PKG_USING_KENDRYTE_DEMO_V001 is not set
+# CONFIG_PKG_USING_KENDRYTE_DEMO_LATEST_VERSION is not set
+# CONFIG_KENDRYTE_DEMO_NONE is not set
+# CONFIG_KENDRYTE_DEMO_AES_128_TEST is not set
+# CONFIG_KENDRYTE_DEMO_AES_192_TEST is not set
+# CONFIG_KENDRYTE_DEMO_AES_256_TEST is not set
+# CONFIG_KENDRYTE_DEMO_AI_DEMO_SIM is not set
+# CONFIG_KENDRYTE_DEMO_DVP_OV is not set
+# CONFIG_KENDRYTE_DEMO_FACE_DETECT is not set
+# CONFIG_KENDRYTE_DEMO_FFT_TEST is not set
+# CONFIG_KENDRYTE_DEMO_FLASH_W25QXX is not set
+# CONFIG_KENDRYTE_DEMO_FLASH_W25QXX_DMA_TEST is not set
+# CONFIG_KENDRYTE_DEMO_FLASH_W25QXX_TEST is not set
+# CONFIG_KENDRYTE_DEMO_GPIOHS_LED is not set
+# CONFIG_KENDRYTE_DEMO_GPIO_LED is not set
+# CONFIG_KENDRYTE_DEMO_HELLO_WORLD is not set
+# CONFIG_KENDRYTE_DEMO_I2C_SLAVE is not set
+# CONFIG_KENDRYTE_DEMO_KPU is not set
+# CONFIG_KENDRYTE_DEMO_LCD is not set
+# CONFIG_KENDRYTE_DEMO_MIC_PLAY is not set
+# CONFIG_KENDRYTE_DEMO_PLAY_PCM is not set
+# CONFIG_KENDRYTE_DEMO_PWM is not set
+# CONFIG_KENDRYTE_DEMO_RTC is not set
+# CONFIG_KENDRYTE_DEMO_RTC_SD3068 is not set
+# CONFIG_KENDRYTE_DEMO_SD_CARD is not set
+# CONFIG_KENDRYTE_DEMO_SERVO is not set
+# CONFIG_KENDRYTE_DEMO_SHA256_TEST is not set
+# CONFIG_KENDRYTE_DEMO_TIMER is not set
+# CONFIG_KENDRYTE_DEMO_UART is not set
+# CONFIG_KENDRYTE_DEMO_UART_DMA is not set
+# CONFIG_KENDRYTE_DEMO_UART_DMA_IRQ is not set
+# CONFIG_KENDRYTE_DEMO_UART_INTERRUPT is not set
+# CONFIG_KENDRYTE_DEMO_WATCHDOG is not set
 
 #
 # samples: kernel and components samples

+ 4 - 0
bsp/k210/README.md

@@ -64,6 +64,10 @@ Kendryte中文含义为勘智,而勘智取自勘物探智。这颗芯片主要
 
 ![terminal](images/k210.png)
 
+如果是K210-test_v0.2开发板,可以用如下命令来打开串口:
+
+    python -m serial.tools.miniterm --rts 0 --dtr 0 COM9 115200
+
 ## 4. 驱动支持情况及计划
 
 | 驱动 | 支持情况  |  备注  |

+ 1 - 0
bsp/k210/driver/SConscript

@@ -5,6 +5,7 @@ from building import *
 cwd     = GetCurrentDir()
 src     = Split('''
 board.c
+heap.c
 drv_uart.c
 ''')
 CPPPATH = [cwd]

+ 11 - 0
bsp/k210/driver/heap.c

@@ -0,0 +1,11 @@
+#include <rtthread.h>
+#include <stdlib.h>
+
+size_t get_free_heap_size(void)
+{
+    rt_uint32_t total, used, max;
+
+    rt_memory_info(&total, &used, &max);
+
+    return total - used;
+}

+ 1 - 1
bsp/k210/rtconfig.h

@@ -64,7 +64,7 @@
 #define FINSH_USING_SYMTAB
 #define FINSH_USING_DESCRIPTION
 #define FINSH_THREAD_PRIORITY 20
-#define FINSH_THREAD_STACK_SIZE 4096
+#define FINSH_THREAD_STACK_SIZE 16384
 #define FINSH_CMD_SIZE 80
 #define FINSH_USING_MSH
 #define FINSH_USING_MSH_DEFAULT

+ 1 - 1
bsp/k210/rtconfig.py

@@ -50,7 +50,7 @@ if PLATFORM == 'gcc':
         CFLAGS += ' -O0 -ggdb'
         AFLAGS += ' -ggdb'
     else:
-        CFLAGS += ' -O2'
+        CFLAGS += ' -O2 -Os'
 
     CXXFLAGS = CFLAGS
 

+ 13 - 1
libcpu/risc-v/k210/interrupt.c

@@ -114,6 +114,13 @@ rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
     return old_handler;
 }
 
+RT_WEAK
+void plic_irq_handle(plic_irq_t irq)
+{
+    rt_kprintf("UN-handled interrupt %d occurred!!!\n", irq);
+    return ;
+}
+
 uintptr_t handle_irq_m_ext(uintptr_t cause, uintptr_t epc)
 {
     /*
@@ -142,7 +149,12 @@ uintptr_t handle_irq_m_ext(uintptr_t cause, uintptr_t epc)
         /* Disable software interrupt and timer interrupt */
         clear_csr(mie, MIP_MTIP | MIP_MSIP);
 
-        if (irq_desc[core_id][int_num].handler)
+        if (irq_desc[core_id][int_num].handler == (rt_isr_handler_t)rt_hw_interrupt_handle)
+        {
+            /* default handler, route to kendryte bsp plic driver */
+            plic_irq_handle(int_num);
+        }
+        else if (irq_desc[core_id][int_num].handler)
         {
             irq_desc[core_id][int_num].handler(int_num, irq_desc[core_id][int_num].param);
         }

+ 5 - 0
libcpu/risc-v/k210/startup_gcc.S

@@ -16,6 +16,11 @@
 _start:
   j 1f
   .word 0xdeadbeef
+  .align 3
+  .global g_wake_up
+  g_wake_up:
+      .dword 1
+      .dword 0
 1:
   csrw mideleg, 0
   csrw medeleg, 0