diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/.config b/bsp/bluetrum/ab32vg1-ab-prougen/.config
index c5bca5ae40..66209a1013 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/.config
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/.config
@@ -23,6 +23,7 @@ CONFIG_IDLE_THREAD_STACK_SIZE=512
CONFIG_RT_USING_TIMER_SOFT=y
CONFIG_RT_TIMER_THREAD_PRIO=4
CONFIG_RT_TIMER_THREAD_STACK_SIZE=256
+# CONFIG_RT_KSERVICE_USING_STDLIB is not set
CONFIG_RT_DEBUG=y
# CONFIG_RT_DEBUG_COLOR is not set
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
@@ -151,9 +152,9 @@ CONFIG_RT_USING_PIN=y
#
# POSIX layer and C standard library
#
-CONFIG_RT_USING_LIBC=y
+# CONFIG_RT_USING_LIBC is not set
# CONFIG_RT_USING_PTHREADS is not set
-# CONFIG_RT_USING_MODULE is not set
+CONFIG_RT_LIBC_USING_TIME=y
#
# Network
@@ -258,8 +259,6 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_LIBRWS is not set
# CONFIG_PKG_USING_TCPSERVER is not set
# CONFIG_PKG_USING_PROTOBUF_C is not set
-# CONFIG_PKG_USING_ONNX_PARSER is not set
-# CONFIG_PKG_USING_ONNX_BACKEND is not set
# CONFIG_PKG_USING_DLT645 is not set
# CONFIG_PKG_USING_QXWZ is not set
# CONFIG_PKG_USING_SMTP_CLIENT is not set
@@ -274,6 +273,12 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_BTSTACK is not set
# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
# CONFIG_PKG_USING_WAYZ_IOTKIT is not set
+# CONFIG_PKG_USING_MAVLINK is not set
+# CONFIG_PKG_USING_RAPIDJSON is not set
+# CONFIG_PKG_USING_BSAL is not set
+# CONFIG_PKG_USING_AGILE_MODBUS is not set
+# CONFIG_PKG_USING_AGILE_FTP is not set
+# CONFIG_PKG_USING_EMBEDDEDPROTO is not set
#
# security packages
@@ -332,6 +337,13 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_VCONSOLE is not set
# CONFIG_PKG_USING_KDB is not set
# CONFIG_PKG_USING_WAMR is not set
+# CONFIG_PKG_USING_MICRO_XRCE_DDS_CLIENT is not set
+# CONFIG_PKG_USING_LWLOG is not set
+# CONFIG_PKG_USING_ANV_TRACE is not set
+# CONFIG_PKG_USING_ANV_MEMLEAK is not set
+# CONFIG_PKG_USING_ANV_TESTSUIT is not set
+# CONFIG_PKG_USING_ANV_BENCH is not set
+# CONFIG_PKG_USING_DEVMEM is not set
#
# system packages
@@ -339,7 +351,6 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_GUIENGINE is not set
# CONFIG_PKG_USING_CAIRO is not set
# CONFIG_PKG_USING_PIXMAN is not set
-# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_PARTITION is not set
# CONFIG_PKG_USING_FAL is not set
# CONFIG_PKG_USING_FLASHDB is not set
@@ -349,6 +360,9 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_CMSIS is not set
# CONFIG_PKG_USING_DFS_YAFFS is not set
# CONFIG_PKG_USING_LITTLEFS is not set
+# CONFIG_PKG_USING_DFS_JFFS2 is not set
+# CONFIG_PKG_USING_DFS_UFFS is not set
+# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_THREAD_POOL is not set
# CONFIG_PKG_USING_ROBOTS is not set
# CONFIG_PKG_USING_EV is not set
@@ -370,12 +384,13 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_UC_MODBUS is not set
# CONFIG_PKG_USING_PPOOL is not set
# CONFIG_PKG_USING_OPENAMP is not set
-# CONFIG_PKG_USING_RT_PRINTF is not set
+# CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set
# CONFIG_PKG_USING_RT_MEMCPY_CM is not set
# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set
# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set
# CONFIG_PKG_USING_QFPLIB_M3 is not set
# CONFIG_PKG_USING_LPM is not set
+# CONFIG_PKG_USING_TLSF is not set
#
# peripheral libraries and drivers
@@ -438,6 +453,24 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
# CONFIG_PKG_USING_VDEVICE is not set
# CONFIG_PKG_USING_SGM706 is not set
+# CONFIG_PKG_USING_STM32WB55_SDK is not set
+# CONFIG_PKG_USING_RDA58XX is not set
+# CONFIG_PKG_USING_LIBNFC is not set
+# CONFIG_PKG_USING_MFOC is not set
+# CONFIG_PKG_USING_TMC51XX is not set
+
+#
+# AI packages
+#
+# CONFIG_PKG_USING_LIBANN is not set
+# CONFIG_PKG_USING_NNOM is not set
+# CONFIG_PKG_USING_ONNX_BACKEND is not set
+# CONFIG_PKG_USING_ONNX_PARSER is not set
+# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
+# CONFIG_PKG_USING_ELAPACK is not set
+# CONFIG_PKG_USING_ULAPACK is not set
+# CONFIG_PKG_USING_QUEST is not set
+# CONFIG_PKG_USING_NAXOS is not set
#
# miscellaneous packages
@@ -469,25 +502,24 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_HELLO is not set
# CONFIG_PKG_USING_VI is not set
# CONFIG_PKG_USING_KI is not set
-# CONFIG_PKG_USING_NNOM is not set
-# CONFIG_PKG_USING_LIBANN is not set
-# CONFIG_PKG_USING_ELAPACK is not set
# CONFIG_PKG_USING_ARMv7M_DWT is not set
# CONFIG_PKG_USING_VT100 is not set
-# CONFIG_PKG_USING_ULAPACK is not set
# CONFIG_PKG_USING_UKAL is not set
# CONFIG_PKG_USING_CRCLIB is not set
#
-# games: games run on RT-Thread console
+# entertainment: terminal games and other interesting software packages
#
# CONFIG_PKG_USING_THREES is not set
# CONFIG_PKG_USING_2048 is not set
# CONFIG_PKG_USING_SNAKE is not set
# CONFIG_PKG_USING_TETRIS is not set
+# CONFIG_PKG_USING_DONUT is not set
+# CONFIG_PKG_USING_ACLOCK is not set
# CONFIG_PKG_USING_LWGPS is not set
-# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
# CONFIG_PKG_USING_STATE_MACHINE is not set
+# CONFIG_PKG_USING_MCURSES is not set
+# CONFIG_PKG_USING_COWSAY is not set
#
# Hardware Drivers Config
@@ -496,14 +528,16 @@ CONFIG_RT_USING_LIBC=y
#
# Onboard Peripheral Drivers
#
-CONFIG_BSP_USING_USB_TO_USART=y
# CONFIG_BSP_USING_AUDIO is not set
# CONFIG_BSP_USING_SDCARD is not set
#
# On-chip Peripheral Drivers
#
+CONFIG_BSP_USING_UART=y
CONFIG_BSP_USING_UART0=y
+# CONFIG_BSP_USING_UART1 is not set
+# CONFIG_BSP_USING_UART2 is not set
# CONFIG_BSP_USING_SDIO is not set
# CONFIG_BSP_USING_I2C1 is not set
# CONFIG_BSP_USING_PWM is not set
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/.cproject b/bsp/bluetrum/ab32vg1-ab-prougen/.cproject
index 6e4d4ca5fe..9d6c45a102 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/.cproject
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/.cproject
@@ -1,158 +1,157 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/README.md b/bsp/bluetrum/ab32vg1-ab-prougen/README.md
index 1e56724f35..c108ff57ba 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/README.md
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/README.md
@@ -35,19 +35,20 @@ ab32vg1-prougen 是 中科蓝讯(Bluetrum) 推出的一款基于 RISC-V 内核
| USB 转串口 | 支持 | |
| SD卡 | 支持 | |
| IRDA | 即将支持 | |
-| 音频接口 | 支持 | |
+| 音频接口 | 支持 | 支持音频输出 |
| **片上外设** | **支持情况** | **备注** |
| GPIO | 支持 | PA PB PE PF |
| UART | 支持 | UART0/1/2 |
| SDIO | 支持 | |
-| ADC | 即将支持 | |
+| ADC | 支持 | 10bit ADC |
| SPI | 即将支持 | 软件 SPI |
| I2C | 支持 | 软件 I2C |
-| RTC | 即将支持 | |
+| RTC | 支持 | |
| WDT | 支持 | |
-| FLASH | 即将支持 | |
+| FLASH | 即将支持 | 对接 FAL |
| TIMER | 支持 | |
| PWM | 支持 | LPWM 的 G1 G2 G3 之间是互斥的,只能三选一 |
+| FM receive | 即将支持 | |
| USB Device | 暂不支持 | |
| USB Host | 暂不支持 | |
@@ -68,8 +69,6 @@ ab32vg1-prougen 是 中科蓝讯(Bluetrum) 推出的一款基于 RISC-V 内核
本 BSP 为开发者提供 GCC 开发环境。下面介绍如何将系统运行起来。
-教学视频:https://www.bilibili.com/video/BV1RV411v75P/
-
#### 硬件连接
使用数据线连接开发板到 PC,打开电源开关。
@@ -96,11 +95,12 @@ msh >
此 BSP 默认只开启了 GPIO 和 串口0 的功能,如果需使用 SD 卡、Flash 等更多高级功能,需要利用 ENV 工具对BSP 进行配置,步骤如下:
1. 在 bsp 下打开 env 工具。
-2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
-3. 输入`pkgs --update`命令更新软件包。
-4. 输入`scons` 命令重新编译工程。
-更多细节请参见使用指南:https://ab32vg1-example.readthedocs.io/zh/latest/introduction.html
+2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
+
+3. 输入`pkgs --update`命令更新软件包。
+
+4. 输入`scons` 命令重新编译工程。
## 注意事项
@@ -110,12 +110,26 @@ msh >
编译报错的时候,如果出现重复定义的报错,可能需要在 `cconfig.h` 中手动添加以下配置
-```
+``` c
#define HAVE_SIGEVENT 1
#define HAVE_SIGINFO 1
#define HAVE_SIGVAL 1
```
+所有在中断中使用的函数或数据需要放在 RAM 中,否则会导致系统运行报错。具体做法可以参考下面
+
+``` c
+RT_SECTION(".irq.example.str")
+static const char example_info[] = "example 0x%x";
+
+RT_SECTION(".irq.example")
+void example_isr(void)
+{
+ rt_kprintf(example_info, 11);
+ ...
+}
+```
+
## 维护人信息
- [greedyhao](https://github.com/greedyhao)
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/applications/main.c b/bsp/bluetrum/ab32vg1-ab-prougen/applications/main.c
index 4c330f0d44..9fa2a7204e 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/applications/main.c
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/applications/main.c
@@ -8,6 +8,12 @@
* 2020/12/10 greedyhao The first version
*/
+/**
+ * Notice!
+ * All functions or data that are called during an interrupt need to be in RAM.
+ * You can do it the way exception_isr() does.
+ */
+
#include
#include "board.h"
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig b/bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig
index 2bdce74a2d..89e651a996 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig
@@ -90,16 +90,16 @@ menu "On-chip Peripheral Drivers"
if BSP_USING_T4_PWM
config BSP_USING_T4_PWM1
bool "Enable Timer4 PWM1 (PA6)(Confit with uart0 rx)"
- default n
+ default y
endif
menuconfig BSP_USING_T5_PWM
bool "Enable Timer5 PWM"
- default n
+ default y
if BSP_USING_T5_PWM
config BSP_USING_T5_PWM0
bool "Enable Timer5 PWM2 (PE1)"
- default n
+ default y
endif
menuconfig BSP_USING_LPWM0
@@ -109,7 +109,7 @@ menu "On-chip Peripheral Drivers"
comment "G1, G2 and G3 are mutually exclusive"
config BSP_USING_LPWM0_G1
bool "Enable LPWM0 G1 (PE4)"
- default n
+ default y
endif
menuconfig BSP_USING_LPWM1
@@ -119,7 +119,7 @@ menu "On-chip Peripheral Drivers"
comment "G1, G2 and G3 are mutually exclusive"
config BSP_USING_LPWM1_G3
bool "Enable LPWM1 G3 (PA1)"
- default n
+ default y
endif
menuconfig BSP_USING_LPWM2
@@ -129,7 +129,7 @@ menu "On-chip Peripheral Drivers"
comment "G1, G2 and G3 are mutually exclusive"
config BSP_USING_LPWM2_G2
bool "Enable LPWM2 G2 (PE0)"
- default n
+ default y
config BSP_USING_LPWM2_G3
bool "Enable LPWM2 G3 (PA2)"
default n
@@ -148,7 +148,7 @@ menu "On-chip Peripheral Drivers"
if BSP_USING_TIM
config BSP_USING_TIM1
bool "Enable TIM1"
- default n
+ default y
config BSP_USING_TIM2
bool "Enable TIM2"
@@ -189,7 +189,7 @@ menu "On-chip Peripheral Drivers"
if BSP_USING_ADC
config BSP_USING_ADC0
bool "Enable ADC0"
- default n
+ default y
endif
endmenu
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c b/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c
index ec128bb1f0..f10ea4a6c8 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/board/board.c
@@ -13,10 +13,21 @@
int rt_hw_usart_init(void);
void my_printf(const char *format, ...);
+void my_print_r(const void *buf, uint16_t cnt);
void timer0_cfg(uint32_t ticks);
void rt_soft_isr(int vector, void *param);
void cpu_irq_comm(void);
void set_cpu_irq_comm(void (*irq_hook)(void));
+void load_cache();
+void sys_error_hook(uint8_t err_no);
+
+typedef void (*os_cache_setfunc_func)(void *load_cache_func, void *io_read);
+typedef void (*spiflash_init_func)(uint8_t sf_read, uint8_t dummy);
+
+#define os_cache_setfunc ((os_cache_setfunc_func) 0x84024)
+
+static struct rt_mutex mutex_spiflash = {0};
+extern volatile rt_uint8_t rt_interrupt_nest;
extern uint32_t __heap_start, __heap_end;
void hal_printf(const char *fmt, ...)
@@ -55,6 +66,7 @@ void hal_printf(const char *fmt, ...)
va_end(args);
}
+RT_SECTION(".irq.timer")
void timer0_isr(int vector, void *param)
{
rt_interrupt_enter();
@@ -132,3 +144,52 @@ void rt_hw_us_delay(rt_uint32_t us)
{
}
+
+RT_SECTION(".irq.cache")
+void cache_init(void)
+{
+ os_cache_setfunc(load_cache, NULL);
+ rt_mutex_init(&mutex_spiflash, "flash_mutex", RT_IPC_FLAG_FIFO);
+}
+
+RT_SECTION(".irq.cache")
+void os_spiflash_lock(void)
+{
+ // if (rt_thread_self()->stat == RT_THREAD_RUNNING) {
+ if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0)) {
+ rt_mutex_take(&mutex_spiflash, RT_WAITING_FOREVER);
+ }
+}
+
+RT_SECTION(".irq.cache")
+void os_spiflash_unlock(void)
+{
+ // if (rt_thread_self()->stat == RT_THREAD_RUNNING) {
+ if ((rt_thread_self() != RT_NULL) && (rt_interrupt_nest == 0)) {
+ rt_mutex_release(&mutex_spiflash);
+ }
+}
+
+RT_SECTION(".irq.err.str")
+static const char stack_info[] = "thread sp=0x%x name=%s";
+
+void rt_hw_console_output(const char *str)
+{
+ my_printf(str);
+}
+
+/**
+ * @brief print exception error
+ * @note Every message needed to print, must put in .comm exction.
+ */
+RT_SECTION(".irq.err")
+void exception_isr(void)
+{
+ extern long list_thread(void);
+ sys_error_hook(1);
+
+ rt_console_set_device(RT_NULL);
+ rt_kprintf(stack_info, rt_thread_self()->sp, rt_thread_self()->name);
+
+ while(1);
+}
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/board/ports/audio/drv_sound.c b/bsp/bluetrum/ab32vg1-ab-prougen/board/ports/audio/drv_sound.c
index 10dbcf63fb..d250a3fc94 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/board/ports/audio/drv_sound.c
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/board/ports/audio/drv_sound.c
@@ -15,15 +15,17 @@
#define SAI_AUDIO_FREQUENCY_44K ((uint32_t)44100u)
#define SAI_AUDIO_FREQUENCY_48K ((uint32_t)48000u)
-#define TX_FIFO_SIZE (1024)
+#define TX_FIFO_SIZE (1024)
struct sound_device
{
struct rt_audio_device audio;
struct rt_audio_configure replay_config;
+ rt_sem_t semaphore;
+ rt_thread_t thread;
rt_uint8_t *tx_fifo;
rt_uint8_t *rx_fifo;
- rt_uint8_t volume;
+ rt_uint8_t volume;
};
static struct sound_device snd_dev = {0};
@@ -105,6 +107,17 @@ void dac_start(void)
//AUANGCON1 |= BIT(3); // pa mute
}
+RT_SECTION(".irq.audio")
+void audio_sem_post(void)
+{
+ rt_sem_release(snd_dev.semaphore);
+}
+
+void audio_sem_pend(void)
+{
+ rt_sem_take(snd_dev.semaphore, RT_WAITING_FOREVER);
+}
+
void saia_frequency_set(uint32_t frequency)
{
if (frequency == SAI_AUDIO_FREQUENCY_48K) {
@@ -359,7 +372,7 @@ static rt_err_t sound_start(struct rt_audio_device *audio, int stream)
DACVOLCON = 0x7fff; // -60DB
DACVOLCON |= BIT(20);
- AUBUFCON |= BIT(1) | BIT(4);
+ AUBUFCON |= BIT(1);
}
return RT_EOK;
@@ -391,7 +404,10 @@ rt_size_t sound_transmit(struct rt_audio_device *audio, const void *writeBuf, vo
snd_dev = (struct sound_device *)audio->parent.user_data;
while (tmp_size-- > 0) {
- while(AUBUFCON & BIT(8)); // aubuf full
+ if (AUBUFCON & BIT(8)) { // aubuf full
+ AUBUFCON |= BIT(1) | BIT(4);
+ audio_sem_pend();
+ }
AUBUFDATA = ((const uint32_t *)writeBuf)[count++];
}
@@ -429,18 +445,32 @@ static struct rt_audio_ops ops =
.buffer_info = sound_buffer_info,
};
-void audio_isr(int vector, void *param)
+RT_SECTION(".irq.audio")
+static void audio_isr(int vector, void *param)
{
rt_interrupt_enter();
//Audio buffer pend
if (AUBUFCON & BIT(5)) {
AUBUFCON |= BIT(1); //Audio Buffer Pend Clear
- rt_audio_tx_complete(&snd_dev.audio);
+ AUBUFCON &= ~BIT(4);
+ audio_sem_post();
}
rt_interrupt_leave();
}
+static void audio_thread_entry(void *parameter)
+{
+ while (1)
+ {
+ if (snd_dev.audio.replay->activated == RT_TRUE) {
+ rt_audio_tx_complete(&snd_dev.audio);
+ } else {
+ rt_thread_mdelay(50);
+ }
+ }
+}
+
static int rt_hw_sound_init(void)
{
rt_uint8_t *tx_fifo = RT_NULL;
@@ -464,6 +494,26 @@ static int rt_hw_sound_init(void)
snd_dev.rx_fifo = rx_fifo;
+ snd_dev.semaphore = rt_sem_create("snd", 0, RT_IPC_FLAG_FIFO);
+ if (snd_dev.semaphore == RT_NULL)
+ {
+ return -RT_ENOMEM;
+ }
+
+ snd_dev.thread = rt_thread_create(
+ "audio",
+ audio_thread_entry,
+ RT_NULL,
+ 1024,
+ 20, // must equal or lower than tshell priority
+ 5
+ );
+
+ if (snd_dev.thread != RT_NULL)
+ {
+ rt_thread_startup(snd_dev.thread);
+ }
+
/* init default configuration */
{
snd_dev.replay_config.samplerate = 48000;
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/link.lds b/bsp/bluetrum/ab32vg1-ab-prougen/link.lds
index 4f79ad883a..d785c3d92c 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/link.lds
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/link.lds
@@ -3,8 +3,8 @@ __max_flash_size = 1024k;
__data_ram_size = 8k;
__stack_ram_size = 4k;
-__comm_ram_size = 83k;
-__heap_ram_size = 29k;
+__comm_ram_size = 42k;
+__heap_ram_size = 70k;
__base = 0x10000000;
@@ -47,26 +47,43 @@ SECTIONS
PROVIDE(__ctors_end__ = .);
. = ALIGN(4);
- *components*drivers**.o (.text*)
- *components.o (.text*)
+ *save-restore.o (.text* .rodata*)
+ *libcpu*cpu*context_gcc.o (.text* .rodata*)
+ *libcpu*cpu*interrupt.o (.text* .rodata*)
+ *libcpu**.o (.rodata*)
+
+ *components*drivers*misc*pin.o(.text*)
+ *components*drivers*misc*adc.o(.text*)
+
+ . = ALIGN(4);
+ *src*ipc.o (.text* .rodata*)
+ *src*irq.o (.text* .rodata*)
+ *src*object.o (.text* .rodata*)
+ *src*thread.o (.text* .rodata*)
+ *src*timer.o (.text* .rodata*)
+ *src*mempool.o (.text* .rodata*)
+ *src*scheduler.o (.text* .rodata*)
+ *src*clock.o (.text* .rodata*)
+ *src*kservice.o (.text* .rodata*)
+ *src*device.o (.text* .rodata*)
+ *src*idle.o (.text* .rodata*)
+ *src*components.o (.text* .rodata*)
} > ram1 AT > flash
.comm __comm_vma : {
. = ALIGN(4);
KEEP(*(.vector))
- EXCLUDE_FILE(*components*finsh**.o *components*libc**.o *dfs*filesystems**.o
- *romfs.o *lib_a**.o *divdi3.o *moddi3.o *divdf3.o *muldf3.o *eqtf2.o *getf2.o
- *letf2.o *multf3.o *subtf3.o *fixtfsi.o *floatsitf.o *extenddftf2.o
- *trunctfdf2.o *_clzsi2.o *cp-demangle.o *unwind*.o
- *fixdfsi.o *addsf3.o *divsf3.o *eqsf2.o *gesf2.o *float*.o
- *lesf2.o *mulsf3.o *subsf3.o *fixsfsi.o *fixunssfsi.o) *(.text)
- *finsh*shell.o (.text*)
+ *(.irq*)
+ /*applications**.o (.text .rodata)*/
+ *hal_libraries*ab32vg1_hal**.o (.text .rodata)
*(.text.unlikely)
*(.text.startup)
- EXCLUDE_FILE (*components*libc**.o *dfs*filesystems**.o *romfs.o *lib_a**.o
- *cp-demangle.o *divdf3.o *muldf3.o *multf3.o *unwind*.o *_clz.o) *(.rodata)
- *(.rodata.name)
- EXCLUDE_FILE(*lib_a**.o *cp-demangle.o *cp-demangle.o) *(.rodata.str1.4)
+ *hal_drivers**.o (.rodata)
+ *audio*drv_sound.o (.rodata)
+ *system_ab32vgx.o (.rodata)
+ EXCLUDE_FILE(*lib_a**.o *cp-demangle.o *cp-demangle.o
+ *src*mem.o *src*memheap.o *dfs**.o *components.o *drivers*sdio**.o *cmd.o *msh_file.o
+ *drv_sdio.o *drv_wdt.o) *(.rodata.str1.4)
EXCLUDE_FILE(*lib_a**.o *unwind*.o) *(.srodata)
*(.rela*)
*(.data*)
@@ -98,7 +115,6 @@ SECTIONS
} > heap
.flash : {
-
. = ALIGN(4);
__fsymtab_start = .;
KEEP(*(FSymTab))
@@ -109,6 +125,7 @@ SECTIONS
KEEP(*(VSymTab))
__vsymtab_end = .;
+ . = ALIGN(4);
*(.text*)
*(.rodata*)
*(.srodata*)
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h b/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h
index 272966b74c..2af221f294 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.h
@@ -86,7 +86,7 @@
/* POSIX layer and C standard library */
-#define RT_USING_LIBC
+#define RT_LIBC_USING_TIME
/* Network */
@@ -145,23 +145,26 @@
/* peripheral libraries and drivers */
+/* AI packages */
+
+
/* miscellaneous packages */
/* samples: kernel and components samples */
-/* games: games run on RT-Thread console */
+/* entertainment: terminal games and other interesting software packages */
/* Hardware Drivers Config */
/* Onboard Peripheral Drivers */
-#define BSP_USING_USB_TO_USART
/* On-chip Peripheral Drivers */
+#define BSP_USING_UART
#define BSP_USING_UART0
/* Board extended module Drivers */
diff --git a/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.py b/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.py
index 0642f6429a..5afb84e1ba 100644
--- a/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.py
+++ b/bsp/bluetrum/ab32vg1-ab-prougen/rtconfig.py
@@ -15,7 +15,7 @@ if os.getenv('RTT_CC'):
if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
- EXEC_PATH = r'D:/Softwares/RT-ThreadStudio/repo/Extract/ToolChain_Support_Packages/RISC-V/RISC-V-GCC/10.1.0/bin'
+ EXEC_PATH = r'D:/program_files/programming/RT-ThreadStudio/repo/Extract/ToolChain_Support_Packages/RISC-V/RISC-V-GCC/10.1.0/bin'
else:
print('Please make sure your toolchains is GNU GCC!')
exit(0)
@@ -39,7 +39,7 @@ if PLATFORM == 'gcc':
OBJCPY = PREFIX + 'objcopy'
# DEVICE = ' -mcmodel=medany -march=rv32imc -mabi=ilp32 -fsingle-precision-constant'
- DEVICE = ' -mcmodel=medany -march=rv32imc -mabi=ilp32'
+ DEVICE = ' -mcmodel=medany -march=rv32imc -mabi=ilp32 -msave-restore'
# CFLAGS = DEVICE + ' -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields'
CFLAGS = DEVICE + ' -D_USE_LONG_TIME_T'
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
diff --git a/bsp/bluetrum/libraries/hal_drivers/drv_hwtimer.c b/bsp/bluetrum/libraries/hal_drivers/drv_hwtimer.c
index aaa3ddbea2..856307e0db 100644
--- a/bsp/bluetrum/libraries/hal_drivers/drv_hwtimer.c
+++ b/bsp/bluetrum/libraries/hal_drivers/drv_hwtimer.c
@@ -68,6 +68,37 @@ static struct ab32_hwtimer ab32_hwtimer_obj[] =
#endif
};
+RT_SECTION(".irq.timer")
+static void _rt_device_hwtimer_isr(rt_hwtimer_t *timer)
+{
+ RT_ASSERT(timer != RT_NULL);
+
+ timer->overflow ++;
+
+ if (timer->cycles != 0)
+ {
+ timer->cycles --;
+ }
+
+ if (timer->cycles == 0)
+ {
+ timer->cycles = timer->reload;
+
+ if (timer->mode == HWTIMER_MODE_ONESHOT)
+ {
+ if (timer->ops->stop != RT_NULL)
+ {
+ timer->ops->stop(timer);
+ }
+ }
+
+ if (timer->parent.rx_indicate != RT_NULL)
+ {
+ timer->parent.rx_indicate(&timer->parent, sizeof(struct rt_hwtimerval));
+ }
+ }
+}
+
static void timer_init(struct rt_hwtimer_device *timer, rt_uint32_t state)
{
uint32_t prescaler_value = 0;
@@ -185,25 +216,26 @@ static const struct rt_hwtimer_ops _ops =
};
#if defined(BSP_USING_TIM2) || defined(BSP_USING_TIM4) || defined(BSP_USING_TIM5)
+RT_SECTION(".irq.timer")
void timer2_4_5_isr(int vector, void *param)
{
rt_interrupt_enter();
#ifdef BSP_USING_TIM2
if (ab32_hwtimer_obj[TIM2_INDEX].tim_handle[TMRxCON] != 0) {
ab32_hwtimer_obj[TIM2_INDEX].tim_handle[TMRxCPND] = BIT(9);
- rt_device_hwtimer_isr(&ab32_hwtimer_obj[TIM2_INDEX].time_device);
+ _rt_device_hwtimer_isr(&ab32_hwtimer_obj[TIM2_INDEX].time_device);
}
#endif
#ifdef BSP_USING_TIM4
if (ab32_hwtimer_obj[TIM4_INDEX].tim_handle[TMRxCON] != 0) {
ab32_hwtimer_obj[TIM4_INDEX].tim_handle[TMRxCPND] = BIT(9);
- rt_device_hwtimer_isr(&ab32_hwtimer_obj[TIM4_INDEX].time_device);
+ _rt_device_hwtimer_isr(&ab32_hwtimer_obj[TIM4_INDEX].time_device);
}
#endif
#ifdef BSP_USING_TIM5
if (ab32_hwtimer_obj[TIM5_INDEX].tim_handle[TMRxCON] != 0) {
ab32_hwtimer_obj[TIM5_INDEX].tim_handle[TMRxCPND] = BIT(9);
- rt_device_hwtimer_isr(&ab32_hwtimer_obj[TIM5_INDEX].time_device);
+ _rt_device_hwtimer_isr(&ab32_hwtimer_obj[TIM5_INDEX].time_device);
}
#endif
rt_interrupt_leave();
@@ -211,21 +243,23 @@ void timer2_4_5_isr(int vector, void *param)
#endif
#ifdef BSP_USING_TIM3
+RT_SECTION(".irq.timer")
void timer3_isr(int vector, void *param)
{
rt_interrupt_enter();
ab32_hwtimer_obj[TIM3_INDEX].tim_handle[TMRxCPND] = BIT(9);
- rt_device_hwtimer_isr(&ab32_hwtimer_obj[TIM3_INDEX].time_device);
+ _rt_device_hwtimer_isr(&ab32_hwtimer_obj[TIM3_INDEX].time_device);
rt_interrupt_leave();
}
#endif
#ifdef BSP_USING_TIM1
+RT_SECTION(".irq.timer")
void timer1_isr(int vector, void *param)
{
rt_interrupt_enter();
ab32_hwtimer_obj[TIM1_INDEX].tim_handle[TMRxCPND] = BIT(9);
- rt_device_hwtimer_isr(&ab32_hwtimer_obj[TIM1_INDEX].time_device);
+ _rt_device_hwtimer_isr(&ab32_hwtimer_obj[TIM1_INDEX].time_device);
rt_interrupt_leave();
}
#endif
diff --git a/bsp/bluetrum/libraries/hal_drivers/drv_rtc.c b/bsp/bluetrum/libraries/hal_drivers/drv_rtc.c
index 9b4eb0a15f..ccbaac1909 100644
--- a/bsp/bluetrum/libraries/hal_drivers/drv_rtc.c
+++ b/bsp/bluetrum/libraries/hal_drivers/drv_rtc.c
@@ -253,6 +253,7 @@ static rt_err_t rt_hw_rtc_register(rt_device_t device, const char *name, rt_uint
}
#ifdef RT_USING_ALARM
+RT_SECTION(".irq.rtc")
static void rtc_isr(int vector, void *param)
{
rt_interrupt_enter();
diff --git a/bsp/bluetrum/libraries/hal_drivers/drv_sdio.c b/bsp/bluetrum/libraries/hal_drivers/drv_sdio.c
index a9ca1a2b6d..fed9eae2d4 100644
--- a/bsp/bluetrum/libraries/hal_drivers/drv_sdio.c
+++ b/bsp/bluetrum/libraries/hal_drivers/drv_sdio.c
@@ -496,6 +496,7 @@ static rt_int32_t rthw_sd_detect(struct rt_mmcsd_host *host)
* @param host rt_mmcsd_host
* @retval None
*/
+RT_SECTION(".irq.sdio")
void rthw_sdio_irq_process(struct rt_mmcsd_host *host)
{
int complete = 0;
@@ -616,6 +617,7 @@ static rt_err_t _dma_rxconfig(rt_uint32_t *dst, int Size)
return RT_EOK;
}
+RT_SECTION(".irq.sdio")
void sdio_isr(int vector, void *param)
{
/* enter interrupt */
diff --git a/bsp/bluetrum/libraries/hal_drivers/drv_usart.c b/bsp/bluetrum/libraries/hal_drivers/drv_usart.c
index 4b790830fc..f09cffee61 100644
--- a/bsp/bluetrum/libraries/hal_drivers/drv_usart.c
+++ b/bsp/bluetrum/libraries/hal_drivers/drv_usart.c
@@ -10,6 +10,7 @@
#include "board.h"
#include "drv_usart.h"
+#include
#ifdef RT_USING_SERIAL
@@ -147,6 +148,7 @@ static int ab32_putc(struct rt_serial_device *serial, char ch)
return 1;
}
+RT_SECTION(".irq.usart")
static int ab32_getc(struct rt_serial_device *serial)
{
int ch;
@@ -168,6 +170,72 @@ static rt_size_t ab32_dma_transmit(struct rt_serial_device *serial, rt_uint8_t *
return -1;
}
+extern struct finsh_shell *shell;
+
+RT_SECTION(".irq.usart")
+static rt_err_t shell_rx_ind(void)
+{
+ RT_ASSERT(shell != RT_NULL);
+
+ /* release semaphore to let finsh thread rx data */
+ rt_sem_release(&shell->rx_sem);
+
+ return RT_EOK;
+}
+
+RT_SECTION(".irq.usart")
+void uart_irq_process(struct rt_serial_device *serial)
+{
+ int ch = -1;
+ rt_base_t level;
+ struct rt_serial_rx_fifo* rx_fifo;
+
+ /* interrupt mode receive */
+ rx_fifo = (struct rt_serial_rx_fifo*)serial->serial_rx;
+ RT_ASSERT(rx_fifo != RT_NULL);
+
+ while (1)
+ {
+ ch = serial->ops->getc(serial);
+ if (ch == -1) break;
+
+
+ /* disable interrupt */
+ level = rt_hw_interrupt_disable();
+
+ rx_fifo->buffer[rx_fifo->put_index] = ch;
+ rx_fifo->put_index += 1;
+ if (rx_fifo->put_index >= serial->config.bufsz) rx_fifo->put_index = 0;
+
+ /* if the next position is read index, discard this 'read char' */
+ if (rx_fifo->put_index == rx_fifo->get_index)
+ {
+ rx_fifo->get_index += 1;
+ rx_fifo->is_full = RT_TRUE;
+ if (rx_fifo->get_index >= serial->config.bufsz) rx_fifo->get_index = 0;
+
+ // _serial_check_buffer_size();
+ }
+
+ /* enable interrupt */
+ rt_hw_interrupt_enable(level);
+ }
+
+ rt_size_t rx_length;
+
+ /* get rx length */
+ level = rt_hw_interrupt_disable();
+ rx_length = (rx_fifo->put_index >= rx_fifo->get_index)? (rx_fifo->put_index - rx_fifo->get_index):
+ (serial->config.bufsz - (rx_fifo->get_index - rx_fifo->put_index));
+ rt_hw_interrupt_enable(level);
+
+ if (rx_length)
+ {
+ shell_rx_ind();
+ }
+}
+
+RT_SECTION(".irq.usart")
static void uart_isr(int vector, void *param)
{
rt_interrupt_enter();
@@ -175,19 +243,19 @@ static void uart_isr(int vector, void *param)
#ifdef BSP_USING_UART0
if(hal_uart_getflag(UART0_BASE, UART_FLAG_RXPND)) //RX one byte finish
{
- rt_hw_serial_isr(&(uart_obj[UART0_INDEX].serial), RT_SERIAL_EVENT_RX_IND);
+ uart_irq_process(&(uart_obj[UART0_INDEX].serial));
}
#endif
#ifdef BSP_USING_UART1
if(hal_uart_getflag(UART1_BASE, UART_FLAG_RXPND)) //RX one byte finish
{
- rt_hw_serial_isr(&(uart_obj[UART1_INDEX].serial), RT_SERIAL_EVENT_RX_IND);
+ uart_irq_process(&(uart_obj[UART1_INDEX].serial));
}
#endif
#ifdef BSP_USING_UART2
if(hal_uart_getflag(UART2_BASE, UART_FLAG_RXPND)) //RX one byte finish
{
- rt_hw_serial_isr(&(uart_obj[UART2_INDEX].serial), RT_SERIAL_EVENT_RX_IND);
+ uart_irq_process(&(uart_obj[UART2_INDEX].serial));
}
#endif
diff --git a/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_adc.h b/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_adc.h
index b1b68b844b..0329c5ff20 100644
--- a/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_adc.h
+++ b/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_adc.h
@@ -13,22 +13,22 @@
* @defgroup ADC_channels
* @{
*/
-#define ADC_CHANNEL_0 (1u << 0)
-#define ADC_CHANNEL_1 (1u << 1)
-#define ADC_CHANNEL_2 (1u << 2)
-#define ADC_CHANNEL_3 (1u << 3)
-#define ADC_CHANNEL_4 (1u << 4)
-#define ADC_CHANNEL_5 (1u << 5)
-#define ADC_CHANNEL_6 (1u << 6)
-#define ADC_CHANNEL_7 (1u << 7)
-#define ADC_CHANNEL_8 (1u << 8)
-#define ADC_CHANNEL_9 (1u << 9)
-#define ADC_CHANNEL_10 (1u << 10)
-#define ADC_CHANNEL_11 (1u << 11)
-#define ADC_CHANNEL_12 (1u << 12)
-#define ADC_CHANNEL_13 (1u << 13)
-#define ADC_CHANNEL_14 (1u << 14)
-#define ADC_CHANNEL_15 (1u << 15)
+#define ADC_CHANNEL_0 (1u << 0) /* PA5 */
+#define ADC_CHANNEL_1 (1u << 1) /* PA6 */
+#define ADC_CHANNEL_2 (1u << 2) /* PA7 */
+#define ADC_CHANNEL_3 (1u << 3) /* PB1 */
+#define ADC_CHANNEL_4 (1u << 4) /* PB2 */
+#define ADC_CHANNEL_5 (1u << 5) /* PB3 */
+#define ADC_CHANNEL_6 (1u << 6) /* PB4 */
+#define ADC_CHANNEL_7 (1u << 7) /* PE5 */
+#define ADC_CHANNEL_8 (1u << 8) /* PE6 */
+#define ADC_CHANNEL_9 (1u << 9) /* PE7 */
+#define ADC_CHANNEL_10 (1u << 10) /* PF2 */
+#define ADC_CHANNEL_11 (1u << 11) /* VRTC */
+#define ADC_CHANNEL_12 (1u << 12) /* WKO */
+#define ADC_CHANNEL_13 (1u << 13) /* BGOP */
+#define ADC_CHANNEL_14 (1u << 14) /* VBAT */
+#define ADC_CHANNEL_15 (1u << 15) /* VUSB */
/**
* @}
*
diff --git a/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_rtc.h b/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_rtc.h
index 6961d8da90..3bb686e593 100644
--- a/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_rtc.h
+++ b/bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_rtc.h
@@ -34,7 +34,7 @@ enum
// RTCCPND
#define RTC_CPND_1S (0x1u << 18) /*!< Clear RTC 1S pending */
-#define RTC_CPND_ALM (0x1u << 17) /*!< Clear RTC alarm pendind */
+#define RTC_CPND_ALM (0x1u << 17) /*!< Clear RTC alarm pendind */
// RTCCON0
#define RTC_CON0_PWRUP_FIRST (0x01u << 7) /*!< RTC first power up flag */
diff --git a/bsp/bluetrum/libraries/hal_libraries/bmsis/source/startup.S b/bsp/bluetrum/libraries/hal_libraries/bmsis/source/startup.S
index fe42435c07..3245135038 100644
--- a/bsp/bluetrum/libraries/hal_libraries/bmsis/source/startup.S
+++ b/bsp/bluetrum/libraries/hal_libraries/bmsis/source/startup.S
@@ -37,20 +37,22 @@ _start:
la a2, __bss_size
call memset
+ call cache_init
+
la a0, __comm_vma
sw a0, PICADR(zero)
call entry
-// la ra, __exception
-// jr ra
+ la ra, __exception
+ jr ra
.section .vector, "ax"
-// .org 0x10
-//__exception:
-// li sp, 0x10600 //出错后,不破坏错误点的堆栈数据
-// jal exception_isr
-// 1: j 1b
-// mret
+ .org 0x10
+__exception:
+ li sp, 0x10600 //出错后,不破坏错误点的堆栈数据
+ jal exception_isr
+ 1: j 1b
+ mret
.org 0x40
jal x0, low_prio_irq