Skip to content

Commit

Permalink
Merge pull request #68 from cruise2018/master
Browse files Browse the repository at this point in the history
fix:bootloader
  • Loading branch information
cruise2018 authored Apr 22, 2019
2 parents 00b184d + 790a443 commit 8501011
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 42 deletions.
8 changes: 6 additions & 2 deletions components/at/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

为了让at框架和硬件做解耦,特优化或者说是更新以前的版本,让AT框架的本质回归到AT。

#### 安装配置
#### 编译配置

在使用at框架之前,需要系统的配置文件配置LOSCFG_ENABLE_AT。

如果使用KEIL以及IAR等工具,建议在target_config.h文件中进行配置
```
如在target_config.h中配置
#define LOSCFG_ENABLE_AT 1
```

然后可以安装AT框架了。
如果使用MAKE,则建议在makefile文件中直接包含AT组件目录下的at.mk即可

#### 组件安装
安装该组件必须调用los_at_init进行初始化,需要使用者提供相关的AT通道设备

```
bool_t los_at_init(const char *devname); //install the at module
Expand Down
3 changes: 1 addition & 2 deletions components/at/at.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@
#if LOSCFG_ENABLE_AT

//these defines could be moved to the configuration of the at module
#define cn_at_oob_len 6 //only allow 6 oob command monitor here,you could configure it more
#define cn_at_oob_len 6 //only allow 6 oob command monitor here,you could configure it more
#define cn_at_resp_maxlen 768 //PROSING THAT COULD GET THE MOST REPSLENGTH


//at control block here
struct at_cmd
{
Expand Down
7 changes: 3 additions & 4 deletions components/at/at.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,23 @@
#include <stdio.h>
#include <osport.h>

#include <los_config.h>

typedef s32_t (*fnoob)(u8_t *data,s32_t datalen);

#if LOSCFG_ENABLE_AT
#if LOSCFG_ENABLE_AT
bool_t los_at_init(const char *devname); //install the at frame work,which binded to the device

bool_t at_oobregister(fnoob func,const char *index); //register a out of band data dealer
s32_t at_command(u8_t *cmd, s32_t cmdlen,const char *index,u8_t *respbuf,s32_t respbuflen,u32_t timeout); //send at command and receive response
bool_t at_workmode(bool_t passby,fnoob func); //use to set the at module work as the passer by
bool_t at_workmode(bool_t passby,fnoob func); //use to set the at module work as the passer by

#else

#define los_at_init(name) false
#define at_oobregister(x,y) false
#define at_command(a,b,c,d,e,f) 0
#define at_workmode(x,y) false


#endif


Expand Down
21 changes: 21 additions & 0 deletions components/at/at.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
################################################################################
# this is used for compile the at modules
# make sure that this module depends on the driver module
# make sure driver module is enabled
################################################################################

AT_MODULE_SRC = \
${wildcard $(TOP_DIR)/components/at/*.c}
C_SOURCES += $(AT_MODULE_SRC)

AT_MODULE_INC = \
-I $(TOP_DIR)/components/at

C_INCLUDES += $(AT_MODULE_INC)


AT_MODULE_DEF = \
-D LOSCFG_ENABLE_AT=1

C_DEFS += $(AT_MODULE_DEF)

16 changes: 11 additions & 5 deletions targets/IoTClub-BearPi/GCC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ include $(TOP_DIR)/components/huawei_cdp/lwm2m/oc_lwm2m_agent.mk
endif


WITH_AT_MODULE = yes
###############LOAD AT MODULE###################################################
#load the at if enabled
ifeq ($(WITH_AT_MODULE), yes)

include $(TOP_DIR)/components/at/at.mk

endif


######################################
# source
######################################
Expand Down Expand Up @@ -117,10 +127,7 @@ UTIL_SRC = \
$(TOP_DIR)/components/lib/libc/malloc.c
C_SOURCES += $(UTIL_SRC)

#AT FRAMEWORK
AT_SRC = \
${wildcard $(TOP_DIR)/components/at/*.c}
C_SOURCES += $(AT_SRC)

#driver hal
DIRVERHAL_SRC = \
$(TOP_DIR)/drivers/third_party/ST/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \
Expand Down Expand Up @@ -243,7 +250,6 @@ ARCH_INC = \

COMPONENTS_INC = \
-I $(TOP_DIR)/components/osport \
-I $(TOP_DIR)/components/at \
-I $(TOP_DIR)/components/shell \
-I $(TOP_DIR)/components/driver
C_INCLUDES += $(COMPONENTS_INC)
Expand Down
1 change: 0 additions & 1 deletion targets/IoTClub-BearPi/OS_CONFIG/target_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ extern "C" {
//component enable options

#define LOSCFG_ENABLE_SHELL 1
#define LOSCFG_ENABLE_AT 1
#define LOSCFG_ENABLE_VFS 1
#define LOSCFG_ENABLE_DRIVER 1

Expand Down
23 changes: 13 additions & 10 deletions targets/STM32F429IGTx_FIRE/GCC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,8 @@ HAL_DRIVER_SRC = \
HARDWARE_SRC = \
${wildcard $(TOP_DIR)/targets/STM32F429IGTx_FIRE/Hardware/Src/*.c}
C_SOURCES += $(HARDWARE_SRC)

ifeq ($(USE_BOOTLOADER), no)
HAL_DRIVER_SRC_NO_BOOTLOADER = \
$(TOP_DIR)/drivers/third_party/ST/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \
$(TOP_DIR)/drivers/third_party/ST/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \
$(TOP_DIR)/drivers/third_party/ST/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_eth.c \
$(TOP_DIR)/drivers/third_party/ST/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rng.c
C_SOURCES += $(HAL_DRIVER_SRC_NO_BOOTLOADER)


KERNEL_SRC = \
${wildcard $(TOP_DIR)/kernel/*.c} \
${wildcard $(TOP_DIR)/kernel/base/core/*.c} \
Expand All @@ -155,6 +149,15 @@ ARCH_SRC = \
${wildcard $(TOP_DIR)/arch/arm/arm-m/armv7-m/*.c} \
${wildcard $(TOP_DIR)/arch/arm/arm-m/armv7-m/gcc/*.c}
C_SOURCES += $(ARCH_SRC)

ifeq ($(USE_BOOTLOADER), no)
HAL_DRIVER_SRC_NO_BOOTLOADER = \
$(TOP_DIR)/drivers/third_party/ST/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \
$(TOP_DIR)/drivers/third_party/ST/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \
$(TOP_DIR)/drivers/third_party/ST/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_eth.c \
$(TOP_DIR)/drivers/third_party/ST/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rng.c
C_SOURCES += $(HAL_DRIVER_SRC_NO_BOOTLOADER)


ifeq ($(WITH_LWIP), yes)
LWIP_SRC = \
Expand Down Expand Up @@ -565,7 +568,6 @@ LITEOS_CMSIS = \
-I $(TOP_DIR)/osdepends/liteos/cmsis
C_INCLUDES += $(LITEOS_CMSIS)

ifeq ($(USE_BOOTLOADER), no)
OS_CONFIG_INC = \
-I $(TOP_DIR)/targets/STM32F429IGTx_FIRE/OS_CONFIG
C_INCLUDES += $(OS_CONFIG_INC)
Expand All @@ -579,7 +581,8 @@ ARCH_INC = \
-I $(TOP_DIR)/arch/arm/arm-m/include \
-I $(TOP_DIR)/arch/arm/arm-m/armv7-m
C_INCLUDES += $(ARCH_INC)


ifeq ($(USE_BOOTLOADER), no)

ifeq ($(WITH_LWIP), yes)
LWIP_INC = \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ WITH_LWIP := no
# (NB_NEUL95_NO_ATINY: nb without agenttiny)
# (NB_NEUL95: nb with agenttiny)
#######################################
WITH_AT_FRAMEWORK := yes
WITH_AT_FRAMEWORK := no
ifeq ($(WITH_AT_FRAMEWORK), yes)
#ESP8266 # SIM900A # NB_NEUL95 # NB_NEUL95_NO_ATINY
NETWORK_TYPE := NB_NEUL95
Expand Down Expand Up @@ -80,7 +80,7 @@ LWM2M_WITH_LOGS := no
#######################################
# Agenttiny log
#######################################
ATINY_DEBUG := yes
ATINY_DEBUG := no

#######################################
# File System
Expand Down
14 changes: 3 additions & 11 deletions targets/STM32F429IGTx_FIRE/Src/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#define OTA_COPY_BUF_SIZE 0x1000



#ifdef __CC_ARM
__asm void boot_app(uint32_t stack,uint32_t pc)
{
Expand All @@ -77,7 +78,6 @@ __attribute__((noreturn)) __attribute__((naked)) void boot_app(uint32_t stack,ui
}
#endif

typedef void (*jump_func)(void);

static int prv_spi2inner_copy(uint32_t addr_source, int32_t image_len)
{
Expand Down Expand Up @@ -169,15 +169,7 @@ int board_jump2app(void)

if ((pc & OTA_PC_MASK) == OTA_FLASH_BASE)
{
if ((stack & OTA_STACK_MASK) == OTA_MEMORY_BASE)
{
boot_app(stack,pc);
}
else
{
OTA_LOG("stack value(%lx) of the image is ilegal", stack);
return OTA_ERRNO_ILEGAL_STACK;
}
boot_app(stack,pc);
}
else
{
Expand Down Expand Up @@ -233,4 +225,4 @@ int board_rollback_copy(int32_t image_len)
}

return 0;
}
}
10 changes: 5 additions & 5 deletions targets/STM32F429IGTx_FIRE/Src/bootloader_recover.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
#include "board.h"
#include "ota/recover_image.h"

void SysTick_Handler(void)
{
HAL_IncTick();
}
//void SysTick_Handler(void)
//{
// HAL_IncTick();
//}

void _Error_Handler(char *file, int line)
{
Expand Down Expand Up @@ -249,4 +249,4 @@ int main(void)
ret = jump(oldbin_size);

return ret;
}
}

0 comments on commit 8501011

Please sign in to comment.