From 31b94778c3ee4e1430e6d578bda1e233de05ae40 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 15 May 2021 15:30:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[bug][bsp][simulator]=20=E4=BF=AE=E5=A4=8Ds?= =?UTF-8?q?d=5Fsim.c=E7=BC=96=E8=AF=91=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E4=BD=BF=E7=94=A8rt=5Fdgb=E4=BB=A3=E6=9B=BF?= =?UTF-8?q?=E8=80=81=E6=97=A7=E7=9A=84debug=E8=BE=93=E5=87=BA=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/simulator/drivers/sd_sim.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/bsp/simulator/drivers/sd_sim.c b/bsp/simulator/drivers/sd_sim.c index adc489be20..bee76d8be7 100755 --- a/bsp/simulator/drivers/sd_sim.c +++ b/bsp/simulator/drivers/sd_sim.c @@ -13,11 +13,9 @@ #include #include -#ifdef DEBUG -# define SD_TRACE rt_kprintf -#else -# define SD_TRACE(...) -#endif +#define DBG_TAG "sd.sim" +#define DBG_LVL DBG_INFO +#include #define SDCARD_SIM "sd.bin" #define SDCARD_SIZE (16*1024*1024) //16M @@ -59,7 +57,7 @@ static rt_size_t rt_sdcard_read(rt_device_t device, rt_off_t position, void *buf struct sdcard_device *sd; int result = 0; - SD_TRACE("sd read: pos %d, size %d\n", position, size); + LOG_I("sd read: pos %d, size %d\n", position, size); rt_mutex_take(lock, RT_WAITING_FOREVER); sd = SDCARD_DEVICE(device); @@ -73,7 +71,7 @@ static rt_size_t rt_sdcard_read(rt_device_t device, rt_off_t position, void *buf return size; _err: - SD_TRACE("sd read errors!\n"); + LOG_E("sd read errors!\n"); rt_mutex_release(lock); return 0; } @@ -87,7 +85,7 @@ static rt_size_t rt_sdcard_write(rt_device_t device, rt_off_t position, const vo struct sdcard_device *sd; int result = 0; - SD_TRACE("sst write: pos %d, size %d\n", position, size); + LOG_I("sst write: pos %d, size %d\n", position, size); rt_mutex_take(lock, RT_WAITING_FOREVER); sd = SDCARD_DEVICE(device); @@ -101,7 +99,7 @@ static rt_size_t rt_sdcard_write(rt_device_t device, rt_off_t position, const vo return size; _err: - SD_TRACE("sd write errors!\n"); + LOG_E("sd write errors!\n"); rt_mutex_release(lock); return 0; } @@ -168,7 +166,7 @@ rt_err_t rt_hw_sdcard_init(const char *spi_device_name) ptr = (unsigned char *) malloc(1024 * 1024); if (ptr == NULL) { - SD_TRACE("malloc error, no memory!\n"); + LOG_E("malloc error, no memory!\n"); return RT_ERROR; } memset(ptr, 0x0, 1024 * 1024); From a00a463248bc66cff04e098c2440e90bf7ea273e Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 15 May 2021 15:35:45 +0800 Subject: [PATCH 2/3] format codes --- bsp/simulator/drivers/sd_sim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp/simulator/drivers/sd_sim.c b/bsp/simulator/drivers/sd_sim.c index bee76d8be7..8a7619fe7e 100755 --- a/bsp/simulator/drivers/sd_sim.c +++ b/bsp/simulator/drivers/sd_sim.c @@ -141,7 +141,7 @@ rt_err_t rt_hw_sdcard_init(const char *spi_device_name) device = &(sd->parent); lock = rt_mutex_create("lock", RT_IPC_FLAG_FIFO); - if (lock == RT_NULL) + if (lock == RT_NULL) { LOG_E("Create mutex in rt_hw_sdcard_init failed!"); return -RT_ERROR; From 1773908df80316be89a74010cb2c5bdda347313f Mon Sep 17 00:00:00 2001 From: Meco Jianting Man <920369182@qq.com> Date: Sat, 15 May 2021 16:16:34 +0800 Subject: [PATCH 3/3] remove \n from LOG_x --- bsp/simulator/drivers/sd_sim.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bsp/simulator/drivers/sd_sim.c b/bsp/simulator/drivers/sd_sim.c index 8a7619fe7e..7557fac12c 100755 --- a/bsp/simulator/drivers/sd_sim.c +++ b/bsp/simulator/drivers/sd_sim.c @@ -57,7 +57,7 @@ static rt_size_t rt_sdcard_read(rt_device_t device, rt_off_t position, void *buf struct sdcard_device *sd; int result = 0; - LOG_I("sd read: pos %d, size %d\n", position, size); + LOG_I("sd read: pos %d, size %d", position, size); rt_mutex_take(lock, RT_WAITING_FOREVER); sd = SDCARD_DEVICE(device); @@ -71,7 +71,7 @@ static rt_size_t rt_sdcard_read(rt_device_t device, rt_off_t position, void *buf return size; _err: - LOG_E("sd read errors!\n"); + LOG_E("sd read errors!"); rt_mutex_release(lock); return 0; } @@ -85,7 +85,7 @@ static rt_size_t rt_sdcard_write(rt_device_t device, rt_off_t position, const vo struct sdcard_device *sd; int result = 0; - LOG_I("sst write: pos %d, size %d\n", position, size); + LOG_I("sst write: pos %d, size %d", position, size); rt_mutex_take(lock, RT_WAITING_FOREVER); sd = SDCARD_DEVICE(device); @@ -99,7 +99,7 @@ static rt_size_t rt_sdcard_write(rt_device_t device, rt_off_t position, const vo return size; _err: - LOG_E("sd write errors!\n"); + LOG_E("sd write errors!"); rt_mutex_release(lock); return 0; } @@ -166,7 +166,7 @@ rt_err_t rt_hw_sdcard_init(const char *spi_device_name) ptr = (unsigned char *) malloc(1024 * 1024); if (ptr == NULL) { - LOG_E("malloc error, no memory!\n"); + LOG_E("malloc error, no memory!"); return RT_ERROR; } memset(ptr, 0x0, 1024 * 1024);