From a3947877d620cabb80fd2251e411d4c3a148219a Mon Sep 17 00:00:00 2001 From: armink Date: Thu, 31 Jan 2019 23:16:47 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91stm32f10x?= =?UTF-8?q?=20flash=20=E9=A9=B1=E5=8A=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: armink --- .../non_os/components/easyflash/port/ef_port.c | 10 ++++++---- demo/env/stm32f10x/rtt/app/src/app_task.c | 2 +- .../stm32f10x/rtt/components/easyflash/port/ef_port.c | 10 ++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/demo/env/stm32f10x/non_os/components/easyflash/port/ef_port.c b/demo/env/stm32f10x/non_os/components/easyflash/port/ef_port.c index 36ae79c..1a12f70 100644 --- a/demo/env/stm32f10x/non_os/components/easyflash/port/ef_port.c +++ b/demo/env/stm32f10x/non_os/components/easyflash/port/ef_port.c @@ -71,12 +71,14 @@ EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) { */ EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) { EfErrCode result = EF_NO_ERR; + uint8_t *buf_8 = (uint8_t *)buf; + size_t i; - EF_ASSERT(size % 4 == 0); + EF_ASSERT(addr % 4 == 0); /*copy from flash to ram */ - for (; size > 0; size -= 4, addr += 4, buf++) { - *buf = *(uint32_t *) addr; + for (i = 0; i < size; i++, addr ++, buf_8++) { + *buf_8 = *(uint8_t *) addr; } return result; @@ -136,7 +138,7 @@ EfErrCode ef_port_write(uint32_t addr, const uint32_t *buf, size_t size) { size_t i; uint32_t read_data; - EF_ASSERT(size % 4 == 0); + EF_ASSERT(addr % 4 == 0); FLASH_Unlock(); FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR); diff --git a/demo/env/stm32f10x/rtt/app/src/app_task.c b/demo/env/stm32f10x/rtt/app/src/app_task.c index e8456df..944f93e 100644 --- a/demo/env/stm32f10x/rtt/app/src/app_task.c +++ b/demo/env/stm32f10x/rtt/app/src/app_task.c @@ -112,7 +112,7 @@ int rt_application_init(void) rt_thread_startup(&thread_sys_monitor); init_thread = rt_thread_create("sys init", sys_init_thread, - NULL, 512, 10, 10); + NULL, 1024, 10, 10); if (init_thread != NULL) { rt_thread_startup(init_thread); } diff --git a/demo/env/stm32f10x/rtt/components/easyflash/port/ef_port.c b/demo/env/stm32f10x/rtt/components/easyflash/port/ef_port.c index 0729666..2f404be 100644 --- a/demo/env/stm32f10x/rtt/components/easyflash/port/ef_port.c +++ b/demo/env/stm32f10x/rtt/components/easyflash/port/ef_port.c @@ -74,12 +74,14 @@ EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) { */ EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) { EfErrCode result = EF_NO_ERR; + uint8_t *buf_8 = (uint8_t *)buf; + size_t i; - EF_ASSERT(size % 4 == 0); + EF_ASSERT(addr % 4 == 0); /*copy from flash to ram */ - for (; size > 0; size -= 4, addr += 4, buf++) { - *buf = *(uint32_t *) addr; + for (i = 0; i < size; i++, addr ++, buf_8++) { + *buf_8 = *(uint8_t *) addr; } return result; @@ -139,7 +141,7 @@ EfErrCode ef_port_write(uint32_t addr, const uint32_t *buf, size_t size) { size_t i; uint32_t read_data; - EF_ASSERT(size % 4 == 0); + EF_ASSERT(addr % 4 == 0); FLASH_Unlock(); FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);