Browse Source

!133 issue fixed

* fix issue
pull/134/head
huanghe 7 months ago
parent
commit
eb784ab0df
  1. 61
      doc/ChangeLog.md
  2. 167
      doc/reference/usr/use_in_phytium_pi.md
  3. 79
      example/ai/tinymaix/src/tinymaix_mbnet_example.c
  4. 80
      example/ai/tinymaix/src/tinymaix_mnist_example.c
  5. 78
      example/ai/tinymaix/src/tinymaix_vww_example.c
  6. 29
      example/peripherals/i2s/i2s_play_from_record/src/i2s_example.c
  7. 2
      example/system/newlib_test/README.md
  8. 9
      third-party/fsl_sdmmc/host/fsdif/fsl_hc_fsdif.c
  9. 9
      third-party/lvgl-8.3/include.mk
  10. 14
      third-party/lvgl-8.3/src.mk

61
doc/ChangeLog.md

@ -1,3 +1,33 @@
# Phytium Standalone SDK 2024-04-02 ChangeLog
Change Log since 2024-04-02
## doc
- Update the download link in use_in_phytium_pi.md
# Phytium Standalone SDK 2024-04-01 ChangeLog
Change Log since 2024-04-01
## third-party
- Clear redundant codes in FSDIFHOST_TransferFunction_Irq
# Phytium Standalone SDK 2024-04-01 ChangeLog
Change Log since 2024-3-29
# example
- change ai example with format
- change i2s example with defined
# third-party
- change lvgl src.mk for solving issue 98
# Phytium Standalone SDK 2024-03-29 ChangeLog # Phytium Standalone SDK 2024-03-29 ChangeLog
Change Log since 2024-3-28 Change Log since 2024-3-28
@ -76,7 +106,7 @@ Change Log since 2024-3-25
## example ## example
- add i2s_play_from_recod example - add i2s_play_from_recod example
## driver ## driver
@ -123,7 +153,7 @@ Change Log since 2024-03-19
Change Log since 2024-03-13 Change Log since 2024-03-13
## example ## example
- update I2C, PIN, SD, SFUD, SPIFFS, SPI, SERIAL etc. examples to adapt to new auto test tool - update I2C, PIN, SD, SFUD, SPIFFS, SPI, SERIAL etc. examples to adapt to new auto test tool
@ -131,7 +161,7 @@ Change Log since 2024-03-13
Change Log since 2024-03-08 Change Log since 2024-03-08
## example ## example
- Modify gic and gpio example to fit pd2308 - Modify gic and gpio example to fit pd2308
@ -139,7 +169,7 @@ Change Log since 2024-03-08
Change Log since 2024-03-08 Change Log since 2024-03-08
## example ## example
- Modify can,i3c example to automate testing - Modify can,i3c example to automate testing
@ -147,11 +177,11 @@ Change Log since 2024-03-08
Change Log since 2024-03-12 Change Log since 2024-03-12
## soc ## soc
- delete the config of CONFIG_USE_SPINLOCK - delete the config of CONFIG_USE_SPINLOCK
## common ## common
- add exit func for loginfo to avoid spinlock locked in fdebug.c - add exit func for loginfo to avoid spinlock locked in fdebug.c
@ -163,7 +193,7 @@ Change Log since 2024-03-12
- Update L3 cache policy - Update L3 cache policy
## example ## example
- Update readme - Update readme
@ -179,16 +209,15 @@ Change Log since 2024-03-12
Change Log since 2024-03-11 Change Log since 2024-03-11
## example ## example
- Modify ipc && pcie && pmu && psci example to automate auto_testing. - Modify ipc && pcie && pmu && psci example to automate auto_testing.
# Phytium Standalone SDK 2024-03-11 ChangeLog # Phytium Standalone SDK 2024-03-11 ChangeLog
Change Log since 2024-03-11 Change Log since 2024-03-11
## example ## example
- Modify ipc example to automate auto_testing. - Modify ipc example to automate auto_testing.
- Modify network example to automate auto_testing. - Modify network example to automate auto_testing.
@ -197,7 +226,7 @@ Change Log since 2024-03-11
Change Log since 2024-03-08 Change Log since 2024-03-08
## example ## example
- Modify example to automate testing - Modify example to automate testing
@ -205,7 +234,7 @@ Change Log since 2024-03-08
Change Log since 2024-03-08 Change Log since 2024-03-08
## example ## example
- Fix some examples error and update default configs - Fix some examples error and update default configs
@ -222,7 +251,7 @@ Change Log since 2024-03-07
- Add i3c driver - Add i3c driver
- Modify gpio, spim driver - Modify gpio, spim driver
## example ## example
- Add i3c and pmbus examples - Add i3c and pmbus examples
- Modify i2c, gpio examples - Modify i2c, gpio examples
@ -239,7 +268,7 @@ Change Log since 2024-03-07
Change Log since 2024-03-02 Change Log since 2024-03-02
## common ## common
- Modify fdebug.c to avoid the stack overflow - Modify fdebug.c to avoid the stack overflow
@ -262,7 +291,7 @@ Change Log since 2024-03-01
## drivers ## drivers
- solve GDMA driver wr clerical error - solve GDMA driver wr clerical error
## arch ## arch
- add end print func - add end print func
@ -286,7 +315,7 @@ Change Log since 2024-02-28
## soc ## soc
- printf may not be use uart,so change the printf function and add *FPrintfCall - printf may not be use uart,so change the printf function and add *FPrintfCall
## third-party ## third-party

167
doc/reference/usr/use_in_phytium_pi.md

@ -3,7 +3,7 @@
> 本文主要介绍如何在飞腾派中进行裸机程序的开发和固化 > 本文主要介绍如何在飞腾派中进行裸机程序的开发和固化
- 飞腾派开发板是一款面向广大工程师和爱好者的开源硬件。主板处理器采用飞腾四核处理器,兼容 - 飞腾派开发板是一款面向广大工程师和爱好者的开源硬件。主板处理器采用飞腾四核处理器,兼容
ARM v8 指令集,主频最高可达 1.8GHz ARM v8 指令集,主频最高可达 1.8GHz
- 由于默认系统需要 16G 的空间,推荐使用 32G 的 SD 卡开发裸机程序 - 由于默认系统需要 16G 的空间,推荐使用 32G 的 SD 卡开发裸机程序
## 开发和调试程序 ## 开发和调试程序
@ -12,56 +12,53 @@ ARM v8 指令集,主频最高可达 1.8GHz
## 使用飞腾派裸机镜像 ## 使用飞腾派裸机镜像
- 下载 [镜像](https://pan.baidu.com/s/1CTP3eWvK-H3-Mb72xs__VQ#list/path=%2F),提取码 tei2 - 下载 [镜像](https://pan.baidu.com/s/12x_ZUao4AYL5_B8GxjOLFA),提取码 phyt
- 下载之后解压,使用 sdcard.img-rtos-4g,注意 2G 版本的飞腾派只能使用 2G 版本的镜像 sdcard.img-rtos-2g - 下载之后解压,使用 sdcard.img-rtos-4g,注意 2G 版本的飞腾派只能使用 2G 版本的镜像 sdcard.img-rtos-2g
- Windows 上使用 balenaEtcher 工具烧入一张 SD 卡(>= 32G),镜像的格式如下图所示,由3个分区组成,前 64MB 是二进制无格式的启动镜像,然后 16G 是 Phytium Pi OS 的根文件系统,格式为 ext4,最后 4G 是裸机文件系统,格式为 fat32, - Windows 上使用 balenaEtcher 工具烧入一张 SD 卡(>= 32G),镜像的格式如下图所示,由3个分区组成,前 64MB 是二进制无格式的启动镜像,然后 16G 是 Phytium Pi OS 的根文件系统,格式为 ext4,最后 4G 是裸机文件系统,格式为 fat32,
![balena_etcher](./image/balena_etcher_flash.png) ![balena_etcher](./image/balena_etcher_flash.png)
```
-----------------------------------------------------------------------------------
| | | |
| 64MB (系统镜像) | 16G (Phytium Pi OS 根文件系统) | 4G (裸机文件系统) |
| (无格式) | (ext4格式) | (fat32格式) |
----------------------------------------------------------------------------------
```
```
-----------------------------------------------------------------------------------
| | | |
| 64MB (系统镜像) | 16G (Phytium Pi OS 根文件系统) | 4G (裸机文件系统) |
| (无格式) | (ext4格式) | (fat32格式) |
----------------------------------------------------------------------------------
```
- 在 linux 系统上,可以使用 dd 命令将镜像写入 SD 卡 (/dev/sdd) - 在 linux 系统上,可以使用 dd 命令将镜像写入 SD 卡 (/dev/sdd)
``` ```
sudo dd if=./sdcard.img-rtos-4g of=/dev/sdd bs=1M count=20000 status=progress sudo dd if=./sdcard.img-rtos-4g of=/dev/sdd bs=1M count=20000 status=progress
``` ```
- SD 卡烧入完成之后插入飞腾派 SD 卡槽,重启飞腾派就会自动进入裸机程序, - SD 卡烧入完成之后插入飞腾派 SD 卡槽,重启飞腾派就会自动进入裸机程序,
``` ```
N: runtime setup N: runtime setup
N: 5: c0000000; 6: c0000000; 7: c0000003; 4: 80000002 N: 5: c0000000; 6: c0000000; 7: c0000003; 4: 80000002
N: wait for scp ready N: wait for scp ready
N: 5: c0000000; 6: c0000000; 7: c0000003; 4: 80000002 N: 5: c0000000; 6: c0000000; 7: c0000003; 4: 80000002
N: enable scp->ap os chanel interrupt. N: enable scp->ap os chanel interrupt.
N: [os chanel] = 1 N: [os chanel] = 1
N: enable ap->scp os chanle interrupt. N: enable ap->scp os chanle interrupt.
N: [os chanel] = 1 N: [os chanel] = 1
N: scmi_core_reset_addr_set. N: scmi_core_reset_addr_set.
_____ _ _ _ _____ _ _ _
| __ \ | | | | (_) | __ \ | | | | (_)
| |__) | | |__ _ _ | |_ _ _ _ _ __ ___ | |__) | | |__ _ _ | |_ _ _ _ _ __ ___
| ___/ | '_ \ | | | | | __| | | | | | | | '_ ` _ \ | ___/ | '_ \ | | | | | __| | | | | | | | '_ ` _ \
| | | | | | | |_| | | |_ | | | |_| | | | | | | | | | | | | | | |_| | | |_ | | | |_| | | | | | | |
|_| |_| |_| \ __, | \__| |_| \__,_| |_| |_| |_| |_| |_| |_| \ __, | \__| |_| \__,_| |_| |_| |_|
__/ | __/ |
|___/ |___/
================ Baremetal Letter Shell================ ================ Baremetal Letter Shell================
Build: Sep 5 2023 13:29:04 Build: Sep 5 2023 13:29:04
Version: 3.0.5 Version: 3.0.5
Platform: PhytiumPI Armv8-aarch64 Platform: PhytiumPI Armv8-aarch64
======================================================= =======================================================
phytium:/$ phytium:/$
``` ```
## 更新飞腾派裸机程序 ## 更新飞腾派裸机程序
@ -69,58 +66,58 @@ ARM v8 指令集,主频最高可达 1.8GHz
- 1. 将 SD 卡插入一台能识别第三个分区的电脑 (Ubuntu 系统能识别,Windows 可能不能识别),直接进裸机程序复制入 SD 卡 - 1. 将 SD 卡插入一台能识别第三个分区的电脑 (Ubuntu 系统能识别,Windows 可能不能识别),直接进裸机程序复制入 SD 卡
- 2. 可以通过 u-boot 上传裸机程序,然后保存在 SD 卡第三个分区中,注意保存文件的大小 (0xb0000),要超过 tftpboot 加载的文件大小 - 2. 可以通过 u-boot 上传裸机程序,然后保存在 SD 卡第三个分区中,注意保存文件的大小 (0xb0000),要超过 tftpboot 加载的文件大小
``` ```
Phytium-Pi#setenv ipaddr 10.31.94.219;setenv serverip 10.31.94.103;setenv gatewayip 10.31.94.254; Phytium-Pi#setenv ipaddr 10.31.94.219;setenv serverip 10.31.94.103;setenv gatewayip 10.31.94.254;
Phytium-Pi#tftpboot 0x90100000 baremetal.elf Phytium-Pi#tftpboot 0x90100000 baremetal.elf
ethernet@3200c000: PHY present at 0 ethernet@3200c000: PHY present at 0
ethernet@3200c000: Starting autonegotiation... ethernet@3200c000: Starting autonegotiation...
ethernet@3200c000: Autonegotiation complete ethernet@3200c000: Autonegotiation complete
ethernet@3200c000: link up, 1000Mbps full-duplex (lpa: 0x6800) ethernet@3200c000: link up, 1000Mbps full-duplex (lpa: 0x6800)
ft sgmii speed 1000M! ft sgmii speed 1000M!
Using ethernet@3200c000 device Using ethernet@3200c000 device
TFTP from server 10.31.94.103; our IP address is 10.31.94.219 TFTP from server 10.31.94.103; our IP address is 10.31.94.219
Filename 'baremetal.elf'. Filename 'baremetal.elf'.
Load address: 0x90100000 Load address: 0x90100000
Loading: ############################################## Loading: ##############################################
127.9 KiB/s 127.9 KiB/s
done done
Bytes transferred = 669448 (a3708 hex) Bytes transferred = 669448 (a3708 hex)
``` ```
``` ```
Phytium-Pi#fatls mmc 0:2 Phytium-Pi#fatls mmc 0:2
6 hello.txt 6 hello.txt
1 file(s), 0 dir(s) 1 file(s), 0 dir(s)
Phytium-Pi#fatwrite mmc 0:2 0x90100000 standalone-images/baremetal.elf 0xb0000 Phytium-Pi#fatwrite mmc 0:2 0x90100000 standalone-images/baremetal.elf 0xb0000
65536 bytes written in 29 ms (2.2 MiB/s) 65536 bytes written in 29 ms (2.2 MiB/s)
Phytium-Pi#fatls mmc 0:2 Phytium-Pi#fatls mmc 0:2
6 hello.txt 6 hello.txt
65536 baremetal.elf 65536 baremetal.elf
2 file(s), 0 dir(s) 2 file(s), 0 dir(s)
``` ```
## 修改自启动的裸机程序 ## 修改自启动的裸机程序
- 通过在 u-boot 控制台修改 bootcmd,可以指定不同的裸机程序自启动,如下所示,指定启动 `phytiumpi_aarch64_firefly_shell.elf` - 通过在 u-boot 控制台修改 bootcmd,可以指定不同的裸机程序自启动,如下所示,指定启动 `phytiumpi_aarch64_firefly_shell.elf`
``` ```
Phytium-Pi#printenv bootcmd Phytium-Pi#printenv bootcmd
bootcmd=mw 0x32b301a8 0x275;mmc dev 0;mmc read 0x90000000 0x2000 0x10000;bootm 0x90000000#phytium bootcmd=mw 0x32b301a8 0x275;mmc dev 0;mmc read 0x90000000 0x2000 0x10000;bootm 0x90000000#phytium
Phytium-Pi#setenv bootcmd "fatload mmc 0:2 0xa0100000 standalone-images/phytiumpi_aarch64_firefly_shell.elf;dcache flush;bootelf -p 0xa0100000;" Phytium-Pi#setenv bootcmd "fatload mmc 0:2 0xa0100000 standalone-images/phytiumpi_aarch64_firefly_shell.elf;dcache flush;bootelf -p 0xa0100000;"
Phytium-Pi#saveenv Phytium-Pi#saveenv
``` ```
## 切换成 linux 开发模式 ## 切换成 linux 开发模式
- 本文提供的裸机开发镜像中,有一个 linux 系统,需要的时候可以修改 bootcmd,切换成自启动 linux 系统 - 本文提供的裸机开发镜像中,有一个 linux 系统,需要的时候可以修改 bootcmd,切换成自启动 linux 系统
``` ```
Phytium-Pi#setenv bootcmd "mw 0x32b301a8 0x275;mmc dev 0;mmc read 0x90000000 0x2000 0x10000;bootm 0x90000000#phytium" Phytium-Pi#setenv bootcmd "mw 0x32b301a8 0x275;mmc dev 0;mmc read 0x90000000 0x2000 0x10000;bootm 0x90000000#phytium"
Phytium-Pi#saveenv Phytium-Pi#saveenv
Saving Environment to MMC... Writing to MMC(0)... OK Saving Environment to MMC... Writing to MMC(0)... OK
``` ```
## 在裸机应用中访问 SD 卡分区 ## 在裸机应用中访问 SD 卡分区

79
example/ai/tinymaix/src/tinymaix_mbnet_example.c

@ -36,18 +36,18 @@
#if IMG_L==128 #if IMG_L==128
#if TM_MDL_TYPE==TM_MDL_FP32 #if TM_MDL_TYPE==TM_MDL_FP32
#include "mbnet128_0.25_f.h" #include "mbnet128_0.25_f.h"
#else #else
#error "wrong mdl type!" #error "wrong mdl type!"
#endif #endif
#elif IMG_L==96 #elif IMG_L==96
#if TM_MDL_TYPE==TM_MDL_FP32 #if TM_MDL_TYPE==TM_MDL_FP32
#include "mbnet96_0.25_f.h" #include "mbnet96_0.25_f.h"
#elif TM_MDL_TYPE==TM_MDL_INT8 #elif TM_MDL_TYPE==TM_MDL_INT8
#include "mbnet96_0.25_q.h" #include "mbnet96_0.25_q.h"
#else #else
#error "wrong mdl type!" #error "wrong mdl type!"
#endif #endif
#else #else
#error "err pic size" #error "err pic size"
#endif #endif
@ -56,23 +56,27 @@
#include "mbnet_test_pic.h" #include "mbnet_test_pic.h"
#include "tinymaix_mbnet_example.h" #include "tinymaix_mbnet_example.h"
static tm_err_t layer_cb(tm_mdl_t* mdl, tml_head_t* lh) static tm_err_t layer_cb(tm_mdl_t *mdl, tml_head_t *lh)
{ //dump middle result {
//dump middle result
int h = lh->out_dims[1]; int h = lh->out_dims[1];
int w = lh->out_dims[2]; int w = lh->out_dims[2];
int ch= lh->out_dims[3]; int ch = lh->out_dims[3];
mtype_t* output = TML_GET_OUTPUT(mdl, lh); mtype_t *output = TML_GET_OUTPUT(mdl, lh);
TM_DBG("Layer %d callback ========\n", mdl->layer_i); TM_DBG("Layer %d callback ========\n", mdl->layer_i);
for(int y=0; y<h; y++){ for (int y = 0; y < h; y++)
{
TM_DBG("["); TM_DBG("[");
for(int x=0; x<w; x++){ for (int x = 0; x < w; x++)
{
TM_DBG("["); TM_DBG("[");
for(int c=0; c<ch; c++){ for (int c = 0; c < ch; c++)
#if TM_MDL_TYPE == TM_MDL_FP32 {
TM_DBG("%.3f,", output[(y*w+x)*ch+c]); #if TM_MDL_TYPE == TM_MDL_FP32
#else TM_DBG("%.3f,", output[(y * w + x)*ch + c]);
TM_DBG("%.4f,", TML_DEQUANT(lh,output[(y*w+x)*ch+c])); #else
#endif TM_DBG("%.4f,", TML_DEQUANT(lh, output[(y * w + x)*ch + c]));
#endif
} }
TM_DBG("],"); TM_DBG("],");
} }
@ -83,14 +87,16 @@ static tm_err_t layer_cb(tm_mdl_t* mdl, tml_head_t* lh)
return TM_OK; return TM_OK;
} }
static void parse_output(tm_mat_t* outs) static void parse_output(tm_mat_t *outs)
{ {
tm_mat_t out = outs[0]; tm_mat_t out = outs[0];
float* data = out.dataf; float *data = out.dataf;
float maxp = 0; float maxp = 0;
int maxi = -1; int maxi = -1;
for(int i=0; i<1000; i++){ for (int i = 0; i < 1000; i++)
if(data[i] > maxp) { {
if (data[i] > maxp)
{
maxi = i; maxi = i;
maxp = data[i]; maxp = data[i];
} }
@ -101,44 +107,45 @@ static void parse_output(tm_mat_t* outs)
} }
int FTinyMaixMbnetExample() int FTinyMaixMbnetExample()
{ {
TM_DBGT_INIT(); TM_DBGT_INIT();
TM_PRINTF("mbnet demo\n"); TM_PRINTF("mbnet demo\n");
tm_mdl_t mdl; tm_mdl_t mdl;
tm_err_t res; tm_err_t res;
tm_stat((tm_mdlbin_t*)mbnet_mdl_data); tm_stat((tm_mdlbin_t *)mbnet_mdl_data);
for (u32 i = 0; i < 3; i++) for (u32 i = 0; i < 3; i++)
{ {
tm_mat_t in_uint8 = {3,IMG_L,IMG_L,3, {(mtype_t*)mbnet_pic[i]}}; tm_mat_t in_uint8 = {3, IMG_L, IMG_L, 3, {(mtype_t *)mbnet_pic[i]}};
tm_mat_t in = {3,IMG_L,IMG_L,3, {NULL}}; tm_mat_t in = {3, IMG_L, IMG_L, 3, {NULL}};
tm_mat_t outs[1]; tm_mat_t outs[1];
res = tm_load(&mdl, mbnet_mdl_data, NULL, layer_cb, &in); res = tm_load(&mdl, mbnet_mdl_data, NULL, layer_cb, &in);
if(res != TM_OK) if (res != TM_OK)
{ {
TM_PRINTF("tm model load err %d\n", res); TM_PRINTF("tm model load err %d\n", res);
return -1; return -1;
} }
#if (TM_MDL_TYPE == TM_MDL_INT8)||(TM_MDL_TYPE == TM_MDL_INT16) #if (TM_MDL_TYPE == TM_MDL_INT8)||(TM_MDL_TYPE == TM_MDL_INT16)
res = tm_preprocess(&mdl, TMPP_UINT2INT, &in_uint8, &in); res = tm_preprocess(&mdl, TMPP_UINT2INT, &in_uint8, &in);
#else #else
res = tm_preprocess(&mdl, TMPP_UINT2FP01, &in_uint8, &in); res = tm_preprocess(&mdl, TMPP_UINT2FP01, &in_uint8, &in);
#endif #endif
TM_DBGT_START(); TM_DBGT_START();
res = tm_run(&mdl, &in, outs); res = tm_run(&mdl, &in, outs);
TM_DBGT("tm_run"); TM_DBGT("tm_run");
if(res==TM_OK) if (res == TM_OK)
{ {
parse_output(outs); parse_output(outs);
} }
else else
{ {
printf("tm run error: %d\n", res); printf("tm run error: %d\n", res);
} }
} tm_unload(&mdl);
tm_unload(&mdl); }
if (res == TM_OK) if (res == TM_OK)
{ {

80
example/ai/tinymaix/src/tinymaix_mnist_example.c

@ -36,9 +36,9 @@
#endif #endif
#if TM_MDL_TYPE == TM_MDL_INT8 #if TM_MDL_TYPE == TM_MDL_INT8
#include "mnist_valid_q.h" #include "mnist_valid_q.h"
#elif TM_MDL_TYPE == TM_MDL_FP32 #elif TM_MDL_TYPE == TM_MDL_FP32
#include "mnist_valid_f.h" #include "mnist_valid_f.h"
#endif #endif
#include "tinymaix_mnist_example.h" #include "tinymaix_mnist_example.h"
@ -56,24 +56,28 @@
/************************** Function *****************************************/ /************************** Function *****************************************/
static tm_err_t layer_cb(tm_mdl_t* mdl, tml_head_t* lh) static tm_err_t layer_cb(tm_mdl_t *mdl, tml_head_t *lh)
{ //dump middle result {
//dump middle result
int h = lh->out_dims[1]; int h = lh->out_dims[1];
int w = lh->out_dims[2]; int w = lh->out_dims[2];
int ch= lh->out_dims[3]; int ch = lh->out_dims[3];
mtype_t* output = TML_GET_OUTPUT(mdl, lh); mtype_t *output = TML_GET_OUTPUT(mdl, lh);
TM_DBG("Layer %d callback ========\n", mdl->layer_i); TM_DBG("Layer %d callback ========\n", mdl->layer_i);
for(int y=0; y<h; y++){ for (int y = 0; y < h; y++)
{
TM_DBG("["); TM_DBG("[");
for(int x=0; x<w; x++){ for (int x = 0; x < w; x++)
{
TM_DBG("["); TM_DBG("[");
for(int c=0; c<ch; c++){ for (int c = 0; c < ch; c++)
#if TM_MDL_TYPE == TM_MDL_FP32 {
TM_DBG("%.3f,", output[(y*w+x)*ch+c]); #if TM_MDL_TYPE == TM_MDL_FP32
#else TM_DBG("%.3f,", output[(y * w + x)*ch + c]);
TM_DBG("%.3f,", TML_DEQUANT(lh,output[(y*w+x)*ch+c])); #else
#endif TM_DBG("%.3f,", TML_DEQUANT(lh, output[(y * w + x)*ch + c]));
#endif
} }
TM_DBG("],"); TM_DBG("],");
} }
@ -84,15 +88,17 @@ static tm_err_t layer_cb(tm_mdl_t* mdl, tml_head_t* lh)
return TM_OK; return TM_OK;
} }
static void parse_output(tm_mat_t* outs) static void parse_output(tm_mat_t *outs)
{ {
tm_mat_t out = outs[0]; tm_mat_t out = outs[0];
float* data = out.dataf; float *data = out.dataf;
float maxp = 0; float maxp = 0;
int maxi = -1; int maxi = -1;
for(int i=0; i<10; i++){ for (int i = 0; i < 10; i++)
{
TM_DBG("%d: %.3f\n", i, data[i]); TM_DBG("%d: %.3f\n", i, data[i]);
if(data[i] > maxp) { if (data[i] > maxp)
{
maxi = i; maxi = i;
maxp = data[i]; maxp = data[i];
} }
@ -124,47 +130,49 @@ int FTinyMaixMnistExample()
OPS: MACs OPS: MACs
*/ */
tm_stat((tm_mdlbin_t*)mnist_mdl_data); tm_stat((tm_mdlbin_t *)mnist_mdl_data);
for (u32 j = 0; j < 10; j++) for (u32 j = 0; j < 10; j++)
{ {
for(int i=0; i<28*28; i++) for (int i = 0; i < 28 * 28; i++)
{ {
TM_DBG("%3d,", mnist_pic[j][i]); TM_DBG("%3d,", mnist_pic[j][i]);
if(i%28==27)TM_DBG("\n"); if (i % 28 == 27)
{
TM_DBG("\n");
}
} }
tm_mat_t in_uint8 = {3,28,28,1, {(mtype_t*)mnist_pic[j]}}; tm_mat_t in_uint8 = {3, 28, 28, 1, {(mtype_t *)mnist_pic[j]}};
tm_mat_t in = {3,28,28,1, {NULL}}; tm_mat_t in = {3, 28, 28, 1, {NULL}};
tm_mat_t outs[1]; tm_mat_t outs[1];
/*加载模型,*/ /*加载模型,*/
res = tm_load(&mdl, mnist_mdl_data, NULL, layer_cb, &in); res = tm_load(&mdl, mnist_mdl_data, NULL, layer_cb, &in);
if(res != TM_OK) if (res != TM_OK)
{ {
printf("tm model load err %d\n", res); printf("tm model load err %d\n", res);
return -1; return -1;
} }
#if (TM_MDL_TYPE == TM_MDL_INT8) #if (TM_MDL_TYPE == TM_MDL_INT8)
res = tm_preprocess(&mdl, TMPP_UINT2INT, &in_uint8, &in); res = tm_preprocess(&mdl, TMPP_UINT2INT, &in_uint8, &in);
#else #else
/*将输入图片按照预设的精度值进行数据处理*/ /*将输入图片按照预设的精度值进行数据处理*/
res = tm_preprocess(&mdl, TMPP_UINT2FP01, &in_uint8, &in); res = tm_preprocess(&mdl, TMPP_UINT2FP01, &in_uint8, &in);
#endif #endif
TM_DBGT_START(); TM_DBGT_START();
/*运行模型*/ /*运行模型*/
res = tm_run(&mdl, &in, outs); res = tm_run(&mdl, &in, outs);
TM_DBGT("tm_run"); TM_DBGT("tm_run");
if(res==TM_OK) if (res == TM_OK)
{ {
parse_output(outs); parse_output(outs);
} }
else else
{ {
printf("tm run error: %d\n", res); printf("tm run error: %d\n", res);
} }
/* code */ tm_unload(&mdl);
} }
tm_unload(&mdl);
if (res == TM_OK) if (res == TM_OK)
{ {

78
example/ai/tinymaix/src/tinymaix_vww_example.c

@ -35,11 +35,11 @@
#endif #endif
#if TM_MDL_TYPE == TM_MDL_INT8 #if TM_MDL_TYPE == TM_MDL_INT8
#include "vww96_q.h" #include "vww96_q.h"
#elif TM_MDL_TYPE == TM_MDL_FP32 #elif TM_MDL_TYPE == TM_MDL_FP32
#include "vww96_f.h" #include "vww96_f.h"
#else #else
#error "fill your modl path here" #error "fill your modl path here"
#endif #endif
#include "tinymaix_vww_example.h" #include "tinymaix_vww_example.h"
@ -53,32 +53,35 @@
/**************************** Type Definitions *******************************/ /**************************** Type Definitions *******************************/
/************************** Variable Definitions *****************************/ /************************** Variable Definitions *****************************/
char* labels[CLASS_NUM] = {"no-person", "person"}; char *labels[CLASS_NUM] = {"no-person", "person"};
/***************** Macros (Inline Functions) Definitions *********************/ /***************** Macros (Inline Functions) Definitions *********************/
/************************** Function Prototypes ******************************/ /************************** Function Prototypes ******************************/
/************************** Function *****************************************/ /************************** Function *****************************************/
static tm_err_t layer_cb(tm_mdl_t* mdl, tml_head_t* lh) static tm_err_t layer_cb(tm_mdl_t *mdl, tml_head_t *lh)
{ {
//dump middle result //dump middle result
int h = lh->out_dims[1]; int h = lh->out_dims[1];
int w = lh->out_dims[2]; int w = lh->out_dims[2];
int ch= lh->out_dims[3]; int ch = lh->out_dims[3];
mtype_t* output = TML_GET_OUTPUT(mdl, lh); mtype_t *output = TML_GET_OUTPUT(mdl, lh);
return TM_OK; return TM_OK;
TM_DBG("Layer %d callback ========\n", mdl->layer_i); TM_DBG("Layer %d callback ========\n", mdl->layer_i);
for(int y=0; y<h; y++){ for (int y = 0; y < h; y++)
{
TM_DBG("["); TM_DBG("[");
for(int x=0; x<w; x++){ for (int x = 0; x < w; x++)
{
TM_DBG("["); TM_DBG("[");
for(int c=0; c<ch; c++){ for (int c = 0; c < ch; c++)
#if TM_MDL_TYPE == TM_MDL_FP32 {
TM_DBG("%.3f,", output[(y*w+x)*ch+c]); #if TM_MDL_TYPE == TM_MDL_FP32
#else TM_DBG("%.3f,", output[(y * w + x)*ch + c]);
TM_DBG("%.3f,", TML_DEQUANT(lh,output[(y*w+x)*ch+c])); #else
#endif TM_DBG("%.3f,", TML_DEQUANT(lh, output[(y * w + x)*ch + c]));
#endif
} }
TM_DBG("],"); TM_DBG("],");
} }
@ -89,15 +92,17 @@ static tm_err_t layer_cb(tm_mdl_t* mdl, tml_head_t* lh)
return TM_OK; return TM_OK;
} }
static void parse_output(tm_mat_t* outs) static void parse_output(tm_mat_t *outs)
{ {
tm_mat_t out = outs[0]; tm_mat_t out = outs[0];
float* data = out.dataf; float *data = out.dataf;
float maxp = 0; float maxp = 0;
int maxi = -1; int maxi = -1;
for(int i=0; i<CLASS_NUM; i++){ for (int i = 0; i < CLASS_NUM; i++)
{
printf("%d: %.3f\n", i, data[i]); printf("%d: %.3f\n", i, data[i]);
if(data[i] > maxp) { if (data[i] > maxp)
{
maxi = i; maxi = i;
maxp = data[i]; maxp = data[i];
} }
@ -108,43 +113,44 @@ static void parse_output(tm_mat_t* outs)
} }
int FTinyMaixVwwExample() int FTinyMaixVwwExample()
{ {
TM_DBGT_INIT(); TM_DBGT_INIT();
printf("vww demo\n"); printf("vww demo\n");
tm_mdl_t mdl; tm_mdl_t mdl;
tm_err_t res; tm_err_t res;
tm_stat((tm_mdlbin_t*)vww_mdl_data); tm_stat((tm_mdlbin_t *)vww_mdl_data);
for (u32 i = 0; i < 2; i++) for (u32 i = 0; i < 2; i++)
{ {
tm_mat_t in_uint8 = {3,IMG_L,IMG_L,IMG_CH, {(mtype_t*)vww_pic[i]}}; tm_mat_t in_uint8 = {3, IMG_L, IMG_L, IMG_CH, {(mtype_t *)vww_pic[i]}};
tm_mat_t outs[1]; tm_mat_t outs[1];
tm_mat_t in = {3,IMG_L,IMG_L,IMG_CH, {NULL}}; tm_mat_t in = {3, IMG_L, IMG_L, IMG_CH, {NULL}};
res = tm_load(&mdl, vww_mdl_data, NULL, layer_cb, &in); res = tm_load(&mdl, vww_mdl_data, NULL, layer_cb, &in);
if(res != TM_OK) if (res != TM_OK)
{ {
TM_PRINTF("tm model load err %d\n", res); TM_PRINTF("tm model load err %d\n", res);
return -1; return -1;
} }
#if (TM_MDL_TYPE == TM_MDL_INT8) || (TM_MDL_TYPE == TM_MDL_INT16) #if (TM_MDL_TYPE == TM_MDL_INT8) || (TM_MDL_TYPE == TM_MDL_INT16)
res = tm_preprocess(&mdl, TMPP_UINT2INT, &in_uint8, &in); res = tm_preprocess(&mdl, TMPP_UINT2INT, &in_uint8, &in);
#else #else
res = tm_preprocess(&mdl, TMPP_UINT2FP01, &in_uint8, &in); res = tm_preprocess(&mdl, TMPP_UINT2FP01, &in_uint8, &in);
#endif #endif
TM_DBGT_START(); TM_DBGT_START();
res = tm_run(&mdl, &in, outs); res = tm_run(&mdl, &in, outs);
TM_DBGT("tm_run"); TM_DBGT("tm_run");
if(res==TM_OK) if (res == TM_OK)
{ {
parse_output(outs); parse_output(outs);
} }
else else
{ {
printf("tm run error: %d\n", res); printf("tm run error: %d\n", res);
} }
} tm_unload(&mdl);
tm_unload(&mdl); }
if (res == TM_OK) if (res == TM_OK)
{ {
printf("%s@%d: TinyMaix vww example [success].\r\n", __func__, __LINE__); printf("%s@%d: TinyMaix vww example [success].\r\n", __func__, __LINE__);

29
example/peripherals/i2s/i2s_play_from_record/src/i2s_example.c

@ -13,7 +13,7 @@
* *
* FilePath: i2s_rx_example.c * FilePath: i2s_rx_example.c
* Created Date: 2023-07-10 10:25:00 * Created Date: 2023-07-10 10:25:00
* Last Modified: 2024-03-22 14:51:22 * Last Modified: 2024-03-29 15:22:41
* Description: This file is for I2S RX example function implmentation. * Description: This file is for I2S RX example function implmentation.
* *
* Modify History: * Modify History:
@ -58,7 +58,8 @@ static FDdmaChanConfig rx_config = {0};
static FDdmaChanConfig tx_config = {0}; static FDdmaChanConfig tx_config = {0};
/* 音频文件存放地址 */ /* 音频文件存放地址 */
#define buffer_length 16384 #define buffer_length 16384
static u32 rx_buf = 0xa0000000; static u32 rx_channel = 1; /* 接收通道为DDMA通道1 */
static u32 tx_channel = 0; /* 接收通道为DDMA通道0 */
static uint8_t Data_Buff[2][buffer_length]; static uint8_t Data_Buff[2][buffer_length];
volatile static uint8_t buff_using_num = 0; volatile static uint8_t buff_using_num = 0;
@ -68,8 +69,8 @@ FError FI2sDdmaDeviceTx(u32 chan_id, u32 work_mode, uintptr src, fsize_t total_b
/************************** Function *****************************************/ /************************** Function *****************************************/
static void FDdmaRxDMADone() static void FDdmaRxDMADone()
{ {
FI2sDdmaDeviceRX(1, 0, (uintptr)Data_Buff[!buff_using_num], buffer_length, buffer_length); FI2sDdmaDeviceRX(rx_channel, AUDIO_PCM_STREAM_CAPTURE, (uintptr)Data_Buff[!buff_using_num], buffer_length, buffer_length);
FI2sDdmaDeviceTx(0, 1, (uintptr)Data_Buff[buff_using_num], buffer_length, buffer_length); FI2sDdmaDeviceTx(tx_channel, AUDIO_PCM_STREAM_PLAYBACK, (uintptr)Data_Buff[buff_using_num], buffer_length, buffer_length);
buff_using_num = !buff_using_num; buff_using_num = !buff_using_num;
return; return;
} }
@ -213,7 +214,7 @@ FError FI2sDdmaDeviceTx(u32 chan_id, u32 work_mode, uintptr src, fsize_t total_b
} }
tx_config.slave_id = 0U, tx_config.slave_id = 0U,
tx_config.req_mode = 1; tx_config.req_mode = AUDIO_PCM_STREAM_PLAYBACK;
tx_config.ddr_addr = (uintptr)src; tx_config.ddr_addr = (uintptr)src;
tx_config.dev_addr = i2s_config.base_addr + FI2S_TXDMA ; tx_config.dev_addr = i2s_config.base_addr + FI2S_TXDMA ;
tx_config.trans_len = total_bytes; tx_config.trans_len = total_bytes;
@ -221,7 +222,7 @@ FError FI2sDdmaDeviceTx(u32 chan_id, u32 work_mode, uintptr src, fsize_t total_b
tx_config.first_desc_addr = (uintptr)bdl_desc_list; tx_config.first_desc_addr = (uintptr)bdl_desc_list;
tx_config.valid_desc_num = bdl_num; tx_config.valid_desc_num = bdl_num;
ret = FDdmaChanBdlConfigure(&ddmac, 0, &tx_config); ret = FDdmaChanBdlConfigure(&ddmac, tx_channel, &tx_config);
if (ret != FI2S_SUCCESS) if (ret != FI2S_SUCCESS)
{ {
printf("DDMA BDL configure failer.\r\n"); printf("DDMA BDL configure failer.\r\n");
@ -278,7 +279,7 @@ FError FI2sDdmaDeviceRX(u32 chan_id, u32 work_mode, uintptr src, fsize_t total_b
} }
rx_config.slave_id = 0U, rx_config.slave_id = 0U,
rx_config.req_mode = 0; rx_config.req_mode = AUDIO_PCM_STREAM_CAPTURE;
rx_config.ddr_addr = (uintptr)src; rx_config.ddr_addr = (uintptr)src;
rx_config.dev_addr = i2s_config.base_addr + FI2S_RXDMA ; rx_config.dev_addr = i2s_config.base_addr + FI2S_RXDMA ;
rx_config.trans_len = total_bytes; rx_config.trans_len = total_bytes;
@ -286,7 +287,7 @@ FError FI2sDdmaDeviceRX(u32 chan_id, u32 work_mode, uintptr src, fsize_t total_b
rx_config.first_desc_addr = (uintptr)bdl_desc_list; rx_config.first_desc_addr = (uintptr)bdl_desc_list;
rx_config.valid_desc_num = bdl_num; rx_config.valid_desc_num = bdl_num;
ret = FDdmaChanBdlConfigure(&ddmac, 1, &rx_config); ret = FDdmaChanBdlConfigure(&ddmac, rx_channel, &rx_config);
if (ret != FI2S_SUCCESS) if (ret != FI2S_SUCCESS)
{ {
@ -301,10 +302,8 @@ FError FI2sDdmaPlayExample(void)
{ {
FError ret = FES8336_SUCCESS; FError ret = FES8336_SUCCESS;
const u32 ddma_id = FDDMA2_I2S_ID; /* I2S所绑定的DDMA默认是DDMA-2 */ const u32 ddma_id = FDDMA2_I2S_ID; /* I2S所绑定的DDMA默认是DDMA-2 */
const u32 channel = 1; /* 接收通道为DDMA通道1 */
u32 total_byte = buffer_length; /* 接收音频的最大长度,超过此长度将覆盖原有音频,此值为自定义 */ u32 total_byte = buffer_length; /* 接收音频的最大长度,超过此长度将覆盖原有音频,此值为自定义 */
u32 per_buffer_len = buffer_length; /* 每一个BDL描述符所负责的数据长度,请保持total_byte是per_buffer_len的倍数 */ u32 per_buffer_len = buffer_length; /* 每一个BDL描述符所负责的数据长度,请保持total_byte是per_buffer_len的倍数 */
u32 work_mode = AUDIO_PCM_STREAM_CAPTURE; /* capture mode */
u32 word_length = AUDIO_PCM_STREAM_WORD_LENGTH_16; /* 16-bits word length */ u32 word_length = AUDIO_PCM_STREAM_WORD_LENGTH_16; /* 16-bits word length */
ret = FI2sRxEs8336Init(word_length); ret = FI2sRxEs8336Init(word_length);
@ -327,17 +326,17 @@ FError FI2sDdmaPlayExample(void)
printf("Init the I2S failed.\r\n"); printf("Init the I2S failed.\r\n");
return ret; return ret;
} }
ret = FI2sDdmaDeviceRX(1, 0, (uintptr)Data_Buff[0], total_byte, per_buffer_len); ret = FI2sDdmaDeviceRX(rx_channel, AUDIO_PCM_STREAM_CAPTURE, (uintptr)Data_Buff[0], total_byte, per_buffer_len);
ret = FI2sDdmaDeviceTx(0, 1, (uintptr)Data_Buff[1], total_byte, per_buffer_len); ret = FI2sDdmaDeviceTx(tx_channel, AUDIO_PCM_STREAM_PLAYBACK, (uintptr)Data_Buff[1], total_byte, per_buffer_len);
if (FI2S_SUCCESS != ret) if (FI2S_SUCCESS != ret)
{ {
printf("I2S trans failed.\r\n"); printf("I2S trans failed.\r\n");
return ret; return ret;
} }
FDdmaSetupInterrupt(&ddmac); FDdmaSetupInterrupt(&ddmac);
FDdmaRegisterChanEvtHandler(&ddmac, 1, FDDMA_CHAN_EVT_REQ_DONE, FDdmaRxDMADone, NULL); FDdmaRegisterChanEvtHandler(&ddmac, rx_channel, FDDMA_CHAN_EVT_REQ_DONE, FDdmaRxDMADone, NULL);
FDdmaChanActive(&ddmac, 1); FDdmaChanActive(&ddmac, rx_channel);
FDdmaChanActive(&ddmac, 0); FDdmaChanActive(&ddmac, tx_channel);
FDdmaStart(&ddmac); FDdmaStart(&ddmac);
return ret; return ret;
} }

2
example/system/newlib_test/README.md

@ -48,7 +48,7 @@ Newlib是一个面向嵌入式系统的c运行库。
> 配置成E2000D,对于其它平台,使用对应的默认配置,如E2000d 32位: > 配置成E2000D,对于其它平台,使用对应的默认配置,如E2000d 32位:
``` ```
$ make load_kconfig LOAD_CONFIG_NAME=e2000d_aarch32_demo_template $ make load_kconfig LOAD_CONFIG_NAME=e2000d_aarch32_demo_newlib
``` ```
- 在host侧完成构建 - 在host侧完成构建

9
third-party/fsl_sdmmc/host/fsdif/fsl_hc_fsdif.c

@ -541,15 +541,6 @@ static status_t FSDIFHOST_TransferFunction_Irq(sdmmchost_t *host, sdmmchost_tran
if (!dev->err_occur) if (!dev->err_occur)
{ {
/* in IRQ mode, read PIO data after recv DTO flag */ /* in IRQ mode, read PIO data after recv DTO flag */
if (!(host->config.enableDMA) && (NULL != content->data) && (NULL != content->data->rxData))
{
assert (FSDIF_PIO_TRANS_MODE == dev->hc.config.trans_mode);
if (FSDIF_SUCCESS != FSdifPIOReadData(&dev->hc, cmd_data->data_p))
{
status = kStatus_NoData;
return status;
}
}
if (FSDIF_SUCCESS != FSdifGetCmdResponse(&dev->hc, cmd_data)) if (FSDIF_SUCCESS != FSdifGetCmdResponse(&dev->hc, cmd_data))
{ {

9
third-party/lvgl-8.3/include.mk

@ -4,20 +4,11 @@ ifdef CONFIG_USE_LVGL
$(SDK_DIR)/third-party/lvgl-8.3\ $(SDK_DIR)/third-party/lvgl-8.3\
$(SDK_DIR)/third-party/lvgl-8.3/src \ $(SDK_DIR)/third-party/lvgl-8.3/src \
$(SDK_DIR)/third-party/lvgl-8.3/src/core \ $(SDK_DIR)/third-party/lvgl-8.3/src/core \
$(SDK_DIR)/third-party/lvgl-8.3/src/draw \
$(SDK_DIR)/third-party/lvgl-8.3/src/extra \
$(SDK_DIR)/third-party/lvgl-8.3/src/font \ $(SDK_DIR)/third-party/lvgl-8.3/src/font \
$(SDK_DIR)/third-party/lvgl-8.3/src/hal \ $(SDK_DIR)/third-party/lvgl-8.3/src/hal \
$(SDK_DIR)/third-party/lvgl-8.3/src/misc \ $(SDK_DIR)/third-party/lvgl-8.3/src/misc \
$(SDK_DIR)/third-party/lvgl-8.3/src/font \
$(SDK_DIR)/third-party/lvgl-8.3/src/draw/sdl \
$(SDK_DIR)/third-party/lvgl-8.3/src/draw/sw \ $(SDK_DIR)/third-party/lvgl-8.3/src/draw/sw \
$(SDK_DIR)/third-party/lvgl-8.3/src/layouts \
$(SDK_DIR)/third-party/lvgl-8.3/src/libs \
$(SDK_DIR)/third-party/lvgl-8.3/src/others \
$(SDK_DIR)/third-party/lvgl-8.3/src/themes \
$(SDK_DIR)/third-party/lvgl-8.3/src/widgets \ $(SDK_DIR)/third-party/lvgl-8.3/src/widgets \
$(SDK_DIR)/third-party/lvgl-8.3/src/libs \
$(SDK_DIR)/third-party/lvgl-8.3/demos/benchmark/assets \ $(SDK_DIR)/third-party/lvgl-8.3/demos/benchmark/assets \
$(SDK_DIR)/third-party/lvgl-8.3/demos/benchmark\ $(SDK_DIR)/third-party/lvgl-8.3/demos/benchmark\
$(SDK_DIR)/third-party/lvgl-8.3/demos/widgets/assets\ $(SDK_DIR)/third-party/lvgl-8.3/demos/widgets/assets\

14
third-party/lvgl-8.3/src.mk

@ -1,17 +1,15 @@
CSRCS_RELATIVE_FILES += $(wildcard src/*.c) \ CSRCS_RELATIVE_FILES +=$(wildcard src/core/*.c) \
$(wildcard src/core/*.c) \
$(wildcard src/draw/*.c) \ $(wildcard src/draw/*.c) \
$(wildcard src/extra/*.c) \ $(wildcard src/font/lv_font_loader.c) \
$(wildcard src/font/*.c) \ $(wildcard src/font/lv_font.c) \
$(wildcard src/font/lv_font_fmt_txt.c) \
$(wildcard src/font/lv_font_montserrat_14.c) \
$(wildcard src/hal/*.c) \ $(wildcard src/hal/*.c) \
$(wildcard src/draw/sdl/*.c) \
$(wildcard src/draw/sw/*.c) \ $(wildcard src/draw/sw/*.c) \
$(wildcard src/draw/hal/*.c) \
$(wildcard src/layouts/*.c) \ $(wildcard src/layouts/*.c) \
$(wildcard src/libs/*.c) \ $(wildcard src/libs/*.c) \
$(wildcard src/misc/*.c)\ $(wildcard src/misc/*.c)\
$(wildcard src/others/*.c) \
$(wildcard src/themes/*.c) \ $(wildcard src/themes/*.c) \
$(wildcard src/widgets/*.c) \ $(wildcard src/widgets/*.c) \
$(wildcard demos/benchmark/assets/*.c) \ $(wildcard demos/benchmark/assets/*.c) \
@ -20,8 +18,6 @@
$(wildcard demos/widgets/*.c)\ $(wildcard demos/widgets/*.c)\
$(wildcard demos/stress/*.c)\ $(wildcard demos/stress/*.c)\
ifdef CONFIG_USE_BAREMETAL ifdef CONFIG_USE_BAREMETAL
CSRCS_RELATIVE_FILES += $(wildcard port/*.c) CSRCS_RELATIVE_FILES += $(wildcard port/*.c)

Loading…
Cancel
Save