!5 更新beken sdk

* add back sdk 3.0.X
* purge old stuff
* add bk7231u support
* update libs
* update bk sdk to 3.0.0
This commit is contained in:
xxkit
2021-09-24 05:29:45 +00:00
parent a176e2b9c2
commit 6521e40fc8
3178 changed files with 150171 additions and 238892 deletions
+5
View File
@@ -0,0 +1,5 @@
group("bk7231") {
deps = [
"${device_path}:bk_sdk"
]
}
@@ -0,0 +1,36 @@
import("//build/lite/ndk/ndk.gni")
static_library("bluetooth") {
sources = [
"src/ohos_bt_hal.c",
"src/ble_test.c",
]
include_dirs = [
"//foundation/communication/bluetooth/interfaces/innerkits/native_c/include",
"//kernel/liteos_m/kal",
"//kernel/liteos_m/kernel/include",
"${beken_sdk_dir}/beken378/driver/ble_5_x_rw/ble_pub/app/api",
"${beken_sdk_dir}/beken378/driver/ble_5_x_rw/platform/7231n/config",
"${beken_sdk_dir}/beken378/driver/ble_5_x_rw/arch/armv5",
"${beken_sdk_dir}/beken378/driver/ble_5_x_rw/arch/armv5/ll",
"${beken_sdk_dir}/beken378/driver/ble_5_x_rw/platform/7231n/entry",
"${beken_sdk_dir}/beken378/driver/ble_5_x_rw/ble_lib/ip/ble/ll/api",
"${beken_sdk_dir}/beken378/driver/ble_5_x_rw/ble_lib/ip/ble/hl/inc",
"${beken_sdk_dir}/beken378/driver/ble_5_x_rw/ble_lib/ip/ble/hl/api",
"${beken_sdk_dir}/beken378/driver/ble_5_x_rw/ble_lib/modules/common/api",
"${beken_sdk_dir}/beken378/driver/ble_5_x_rw/platform/7231n/rwip/api",
"${beken_sdk_dir}/beken378/driver/ble_5_x_rw/ble_lib/modules/ke/api",
"${beken_sdk_dir}/beken378/driver/ble_5_x_rw/ble_pub/ui",
"${beken_sdk_dir}/beken378/driver/ble_5_x_rw/ble_pub/profiles/comm/api",
]
}
if (ohos_kernel_type == "liteos_m") {
ndk_lib("bluetooth_ndk") {
deps = [ ":bluetooth" ]
head_files =
[ "//foundation/communication/bluetooth/interfaces/innerkits/native_c/include" ]
}
}
@@ -0,0 +1,335 @@
#include <string.h>
#include <stdio.h>
#include "ohos_bt_def.h"
#include "ohos_bt_gatt.h"
#include "ohos_bt_gatt_server.h"
#include "uart_pub.h"
#include "include.h"
#include "mem_pub.h"
#include "rtos_pub.h"
static const uint8_t ohos_adv_data[]={0x02,0x01,0x06,0xb,0x9,'7','2','3','1','N','_','B','L','E',0x0};
static const uint8_t ohos_adv_rsp_data[]={0x7,0x8,'7','2','3','1','N',0x0};
static const uint8_t ntf_ind_data[6]={0x11,0x22,0x33,0x44,0x55,0x66};
#define BK_ATT_DECL_PRIMARY_SERVICE {0x00,0x28,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
#define BK_ATT_DECL_CHARACTERISTIC {0x03,0x28,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
#define BK_ATT_DESC_CLIENT_CHAR_CFG {0x02,0x29,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
#define WRITE_REQ_CHARACTERISTIC {0x01,0xFF,0,0,0x34,0x56,0,0,0,0,0x28,0x37,0,0,0,0}
#define INDICATE_CHARACTERISTIC {0x02,0xFF,0,0,0x34,0x56,0,0,0,0,0x28,0x37,0,0,0,0}
#define NOTIFY_CHARACTERISTIC {0x03,0xFF,0,0,0x34,0x56,0,0,0,0,0x28,0x37,0,0,0,0}
#define BLE_ADV_ENABLE 1
enum
{
TEST_IDX_SVC,
TEST_IDX_FF01_VAL_CHAR,
TEST_IDX_FF01_VAL_VALUE,
TEST_IDX_FF02_VAL_CHAR,
TEST_IDX_FF02_VAL_VALUE,
TEST_IDX_FF02_VAL_IND_CFG,
TEST_IDX_FF03_VAL_CHAR,
TEST_IDX_FF03_VAL_VALUE,
TEST_IDX_FF03_VAL_NTF_CFG,
TEST_IDX_NB,
};
BleGattAttr attrList[TEST_IDX_NB]={
// Service Declaration
[TEST_IDX_SVC] = {OHOS_BLE_ATTRIB_TYPE_SERVICE, OHOS_GATT_PERMISSION_READ, OHOS_UUID_TYPE_16_BIT, BK_ATT_DECL_PRIMARY_SERVICE,0,0,0,{0}},
// Level Characteristic Declaration
[TEST_IDX_FF01_VAL_CHAR] = {OHOS_BLE_ATTRIB_TYPE_CHAR, OHOS_GATT_PERMISSION_READ, OHOS_UUID_TYPE_16_BIT, BK_ATT_DECL_CHARACTERISTIC, 0,0,0,{0}},
// Level Characteristic Value
[TEST_IDX_FF01_VAL_VALUE] = {OHOS_BLE_ATTRIB_TYPE_CHAR_VALUE, OHOS_GATT_PERMISSION_READ, OHOS_UUID_TYPE_16_BIT, WRITE_REQ_CHARACTERISTIC, 0,0,OHOS_GATT_CHARACTER_PROPERTY_BIT_READ|OHOS_GATT_CHARACTER_PROPERTY_BIT_WRITE,{0}},
// Level Characteristic Declaration
[TEST_IDX_FF02_VAL_CHAR] = {OHOS_BLE_ATTRIB_TYPE_CHAR, OHOS_GATT_PERMISSION_READ, OHOS_UUID_TYPE_16_BIT, BK_ATT_DECL_CHARACTERISTIC, 0,0,0,{0}},
// Level Characteristic Value
[TEST_IDX_FF02_VAL_VALUE] = {OHOS_BLE_ATTRIB_TYPE_CHAR_VALUE, OHOS_GATT_PERMISSION_READ, OHOS_UUID_TYPE_16_BIT, INDICATE_CHARACTERISTIC, 0,0,OHOS_GATT_CHARACTER_PROPERTY_BIT_INDICATE,{0}},
// Level Characteristic - Client Characteristic Configuration Descriptor
[TEST_IDX_FF02_VAL_IND_CFG] = {OHOS_BLE_ATTRIB_TYPE_CHAR_CLIENT_CONFIG, OHOS_GATT_PERMISSION_READ|OHOS_GATT_PERMISSION_WRITE, OHOS_UUID_TYPE_16_BIT, BK_ATT_DESC_CLIENT_CHAR_CFG, 0,0,0,{0}},
// Level Characteristic Declaration
[TEST_IDX_FF03_VAL_CHAR] = {OHOS_BLE_ATTRIB_TYPE_CHAR, OHOS_GATT_PERMISSION_READ, OHOS_UUID_TYPE_16_BIT, BK_ATT_DECL_CHARACTERISTIC, 0,0,0,{0}},
// Level Characteristic Value
[TEST_IDX_FF03_VAL_VALUE] = {OHOS_BLE_ATTRIB_TYPE_CHAR_VALUE, OHOS_GATT_PERMISSION_READ, OHOS_UUID_TYPE_16_BIT, NOTIFY_CHARACTERISTIC, 0,0,OHOS_GATT_CHARACTER_PROPERTY_BIT_NOTIFY,{0}},
// Level Characteristic - Client Characteristic Configuration Descriptor
[TEST_IDX_FF03_VAL_NTF_CFG] = {OHOS_BLE_ATTRIB_TYPE_CHAR_CLIENT_CONFIG, OHOS_GATT_PERMISSION_READ|OHOS_GATT_PERMISSION_WRITE, OHOS_UUID_TYPE_16_BIT, BK_ATT_DESC_CLIENT_CHAR_CFG, 0,0,0,{0}},
};
void ohos_advEnable_callback(int advId, int status)
{
bk_printf("fun:%s,advId:%d,status:%d\r\n",__FUNCTION__,advId,status);
}
void ohos_advDisable_callback(int advId, int status)
{
bk_printf("fun:%s,advId:%d,status:%d\r\n",__FUNCTION__,advId,status);
}
void ohos_advData_callback(int advId, int status)
{
bk_printf("fun:%s,advId:%d,status:%d\r\n",__FUNCTION__,advId,status);
}
void ohos_advUpdate_callback(int advId, int status)
{
bk_printf("fun:%s,advId:%d,status:%d\r\n",__FUNCTION__,advId,status);
}
void ohos_securityRespond_callback(const BdAddr *bdAddr)
{
bk_printf("fun:%s,line:%d\r\n",__FUNCTION__,__LINE__);
}
void ohos_scanResult_callback(BtScanResultData *scanResultdata)
{
bk_printf("fun:%s,line:%d\r\n",__FUNCTION__,__LINE__);
}
void ohos_scanParamSet_callback(int clientId, int status)
{
bk_printf("fun:%s,line:%d,status:%d\r\n",__FUNCTION__,__LINE__,status);
}
void ohos_registerServerCb_callback(int status, int serverId, BtUuid *appUuid)
{
bk_printf("fun:%s,serverId:%d,status:%d\r\n",__FUNCTION__,serverId,status);
}
void ohos_connectServerCb_callback(int connId, int serverId, const BdAddr *bdAddr)
{
bk_printf("fun:%s,serverId:%d,connId:%d\r\n",__FUNCTION__,serverId,connId);
}
void ohos_disconnectServerCb_callback(int connId, int serverId, const BdAddr *bdAddr)
{
bk_printf("fun:%s,serverId:%d,connId:%d\r\n",__FUNCTION__,serverId,connId);
}
void ohos_ServiceAdd_callback(int status, int serverId, BtUuid *appUuid,int srvcHandle)
{
bk_printf("fun:%s,serverId:%d,status:%d\r\n",__FUNCTION__,serverId,status);
}
void ohos_characteristicAddCb_callback(int status, int serverId, BtUuid *uuid,int srvcHandle, int characteristicHandle)
{
bk_printf("fun:%s,serverId:%d,status:%d\r\n",__FUNCTION__,serverId,status);
}
void ohos_descriptorAddCb_callback(int status, int serverId, BtUuid *uuid,int srvcHandle, int descriptorHandle)
{
bk_printf("fun:%s,serverId:%d,status:%d\r\n",__FUNCTION__,serverId,status);
}
void ohos_serviceStartCb_callback(int status, int serverId, int srvcHandle)
{
bk_printf("fun:%s,serverId:%d,status:%d\r\n",__FUNCTION__,serverId,status);
}
void ohos_requestReadCb_callback(BtReqReadCbPara readCbPara)
{
bk_printf("fun:%s\r\n",__FUNCTION__);
}
void ohos_requestWriteCb_callback(BtReqWriteCbPara writeCbPara)
{
bk_printf("fun:%s,peer_addr:%02x:%02x:%02x:%02x:%02x:%02x\r\n",__FUNCTION__,writeCbPara.bdAddr->addr[0], writeCbPara.bdAddr->addr[1],writeCbPara.bdAddr->addr[2], writeCbPara.bdAddr->addr[3], writeCbPara.bdAddr->addr[4], writeCbPara.bdAddr->addr[5]);
for(int index=0;index<writeCbPara.length;index++)
{
bk_printf("%02x ",writeCbPara.value[index]);
}
bk_printf("\r\n");
}
void ohos_responseConfirmationCb_callback(int status, int handle)
{
bk_printf("fun:%s,handle:%d,status:%d\r\n",__FUNCTION__,handle,status);
}
void ohos_indicationSentCb_callback(int connId, int status)
{
bk_printf("fun:%s,serverId:%d,connId:%d\r\n",__FUNCTION__,connId,status);
}
void ble_test_main(void)
{
/******* init ble stack **********/
InitBtStack();
#if 1
EnableBtStack();
BtGattCallbacks gatt_func={
.advEnableCb=ohos_advEnable_callback,
.advDisableCb=ohos_advDisable_callback,
.advDataCb=ohos_advData_callback,
.advUpdateCb=ohos_advUpdate_callback,
.securityRespondCb=ohos_securityRespond_callback,
.scanResultCb=ohos_scanResult_callback,
.scanParamSetCb=ohos_scanParamSet_callback
};
BleGattRegisterCallbacks(&gatt_func);
#if 1
BtGattServerCallbacks gatt_server_func={
.registerServerCb=ohos_registerServerCb_callback,
.connectServerCb=ohos_connectServerCb_callback,
.disconnectServerCb=ohos_disconnectServerCb_callback,
.serviceAddCb=ohos_ServiceAdd_callback,
.characteristicAddCb=ohos_characteristicAddCb_callback,
.descriptorAddCb=ohos_descriptorAddCb_callback,
.serviceStartCb=ohos_serviceStartCb_callback,
.requestReadCb=ohos_requestReadCb_callback,
.requestWriteCb=ohos_requestWriteCb_callback,
.responseConfirmationCb=ohos_responseConfirmationCb_callback,
.indicationSentCb=ohos_indicationSentCb_callback
};
#endif
BleGattsRegisterCallbacks(&gatt_server_func);
/******* create db server **********/
BtUuid server_uuid;
server_uuid.uuidLen=2;
server_uuid.uuid=os_malloc(server_uuid.uuidLen);
server_uuid.uuid[0]=0xee;
server_uuid.uuid[1]=0xff;
#if 1
BleGattsRegister(server_uuid);
BleGattService srvcInfo;
srvcInfo.attrNum=9;
srvcInfo.attrList=attrList;
BleGattsStartServiceEx(NULL, &srvcInfo);
#else
server_uuid.uuid[0]=0xaa;
server_uuid.uuid[1]=0xbb;
BleGattsAddService(0,server_uuid,0,9);
server_uuid.uuid[0]=0x11;
server_uuid.uuid[1]=0x22;
BleGattsAddCharacteristic(0,0,server_uuid,OHOS_GATT_CHARACTER_PROPERTY_BIT_READ|OHOS_GATT_CHARACTER_PROPERTY_BIT_WRITE,0);
server_uuid.uuid[0]=0x33;
server_uuid.uuid[1]=0x44;
BleGattsAddCharacteristic(0,0,server_uuid,OHOS_GATT_CHARACTER_PROPERTY_BIT_INDICATE,0);
server_uuid.uuid[0]=0x02;
server_uuid.uuid[1]=0x29;
BleGattsAddDescriptor(0,0,server_uuid,OHOS_GATT_PERMISSION_READ|OHOS_GATT_PERMISSION_WRITE);
server_uuid.uuid[0]=0x55;
server_uuid.uuid[1]=0x66;
BleGattsAddCharacteristic(0,0,server_uuid,OHOS_GATT_CHARACTER_PROPERTY_BIT_NOTIFY,0);
server_uuid.uuid[0]=0x02;
server_uuid.uuid[1]=0x29;
BleGattsAddDescriptor(0,0,server_uuid,OHOS_GATT_PERMISSION_READ|OHOS_GATT_PERMISSION_WRITE);
BleGattsStartService(0,0);
#endif
#if BLE_ADV_ENABLE
#if 0
/*****set adv data */
BleConfigAdvData adv;
adv.advLength=sizeof(ohos_adv_data);
adv.scanRspLength=sizeof(ohos_adv_rsp_data);
adv.advData= malloc(adv.advLength);
memcpy(adv.advData,ohos_adv_data,adv.advLength);
adv.scanRspData= malloc(adv.scanRspLength);
memcpy(adv.scanRspData,ohos_adv_rsp_data,adv.scanRspLength);
BleSetAdvData(0,&adv);
/******* start ble adv **********/
BleAdvParams adv_para;
adv_para.minInterval=160;
adv_para.maxInterval=160;
adv_para.channelMap=7;
adv_para.duration = 0;
BleStartAdv(0,&adv_para);
#else
int advId=0;
StartAdvRawData rawData;
rawData.advDataLen=sizeof(ohos_adv_data);
rawData.rspDataLen=sizeof(ohos_adv_rsp_data);
rawData.advData= os_malloc(rawData.advDataLen);
memcpy(rawData.advData,ohos_adv_data,rawData.advDataLen);
rawData.rspData= os_malloc(rawData.rspDataLen);
memcpy(rawData.rspData,ohos_adv_rsp_data,rawData.rspDataLen);
BleAdvParams advParam;
advParam.minInterval=160;
advParam.maxInterval=160;
advParam.channelMap=7;
advParam.duration = 0;
BleStartAdvEx(&advId, rawData, advParam);
#endif
#endif
#if BLE_SCAN_ENABLE
BleScanParams scan_param={.scanInterval=100,.scanWindow=50};
BleSetScanParameters(0, &scan_param);
BleStartScan();
rtos_delay_milliseconds(5000);
BleStopScan();
#endif
rtos_delay_milliseconds(20000);
GattsSendIndParam send_param;
send_param.confirm=1;
send_param.valueLen=sizeof(ntf_ind_data);
send_param.value=(char *)ntf_ind_data;
send_param.attrHandle=TEST_IDX_FF02_VAL_VALUE;
BleGattsSendIndication(0, &send_param);
rtos_delay_milliseconds(2000);
send_param.confirm=0;
send_param.valueLen=sizeof(ntf_ind_data);
send_param.value=(char *)ntf_ind_data;
send_param.attrHandle=TEST_IDX_FF03_VAL_VALUE;
BleGattsSendIndication(0, &send_param);
#endif
}
@@ -0,0 +1,880 @@
#include <string.h>
#include <stdio.h>
#include "ohos_bt_gatt.h"
#include "ohos_bt_gatt_server.h"
#include "ohos_bt_def.h"
#include "ble_api_5_x.h"
#include "app_ble.h"
#include "app_sdp.h"
#include "app_ble_init.h"
#include "comm_task.h"
#include "ble_api_5_x.h"
#include "uart_pub.h"
#include "include.h"
#include "ble_pub.h"
#include "ble_api.h"
#include "mem_pub.h"
#include "app_ble_task.h"
extern void ble_entry(void);
extern struct app_env_tag app_ble_env;
extern ble_err_t bk_ble_send_ntf_value(uint32_t len, uint8_t *buf, uint16_t prf_id, uint16_t att_idx);
extern ble_err_t bk_ble_send_ind_value(uint32_t len, uint8_t *buf, uint16_t prf_id, uint16_t att_idx);
static BtGattCallbacks *gatt_callbackfunc=NULL;
static BtGattServerCallbacks * gatt_server_callbackfunc=NULL;
#define MAX_SERVER_NUM 5
enum
{
TEST_IDX_SVC,
TEST_IDX_FF01_VAL_CHAR,
TEST_IDX_FF01_VAL_VALUE,
TEST_IDX_FF02_VAL_CHAR,
TEST_IDX_FF02_VAL_VALUE,
TEST_IDX_FF02_VAL_IND_CFG,
TEST_IDX_FF03_VAL_CHAR,
TEST_IDX_FF03_VAL_VALUE,
TEST_IDX_FF03_VAL_NTF_CFG,
TEST_IDX_NB,
};
typedef struct{
unsigned char adv_idx;
unsigned char connidx;
unsigned char scan_idx;
unsigned char peer_addr[6];
unsigned char adv_type;
unsigned char advDataLen;
unsigned char respDataLen;
unsigned char advData[MAX_ADV_DATA_LEN];
unsigned char respData[MAX_ADV_DATA_LEN];
} BT_HAL_ENV_T;
typedef struct {
/** UUID length */
unsigned char uuidLen;
/** Server UUID ID**/
unsigned char server_id;
unsigned char max_att_handle;
unsigned char next_att_handle;
/** UUID field */
char *uuid;
bk_attm_desc_t *ohos_att_db;
} BtServer;
BtServer *ohos_server_uuid_para[MAX_SERVER_NUM];
BT_HAL_ENV_T hal_bt_env;
struct scan_param ohos_scan_info;
static void ble_notice_cb(ble_notice_t notice, void *param)
{
switch (notice) {
case BLE_5_STACK_OK:
bk_printf("ble stack ok");
break;
case BLE_5_WRITE_EVENT:
{
write_req_t *w_req = (write_req_t *)param;
bk_printf("write_cb:conn_idx:%d, prf_id:%d, add_id:%d, len:%d, data[0]:%02x\r\n",
w_req->conn_idx, w_req->prf_id, w_req->att_idx, w_req->len, w_req->value[0]);
BtReqWriteCbPara writeCbPara;
writeCbPara.connId=w_req->conn_idx;
writeCbPara.transId=OHOS_BT_TRANSPORT_LE;
writeCbPara.bdAddr=(BdAddr *)(&hal_bt_env.peer_addr[0]);
writeCbPara.attrHandle=w_req->att_idx;
writeCbPara.offset=0;
writeCbPara.length=w_req->len;
writeCbPara.value=w_req->value;
writeCbPara.needRsp=false;
writeCbPara.isPrep=false;
if(gatt_server_callbackfunc&&gatt_server_callbackfunc->requestWriteCb)
gatt_server_callbackfunc->requestWriteCb(writeCbPara);
break;
}
case BLE_5_READ_EVENT:
{
read_req_t *r_req = (read_req_t *)param;
bk_printf("read_cb:conn_idx:%d, prf_id:%d, add_id:%d\r\n",
r_req->conn_idx, r_req->prf_id, r_req->att_idx);
r_req->value[0] = 0x12;
r_req->value[1] = 0x34;
r_req->value[2] = 0x56;
r_req->length = 3;
BtReqReadCbPara readCbPara;
readCbPara.connId=r_req->conn_idx;
readCbPara.transId=OHOS_BT_TRANSPORT_LE;
readCbPara.bdAddr=(BdAddr *)(&hal_bt_env.peer_addr[0]);
readCbPara.attrHandle=r_req->att_idx;
readCbPara.offset=0;
readCbPara.isLong=0;
if(gatt_server_callbackfunc&&gatt_server_callbackfunc->requestReadCb)
gatt_server_callbackfunc->requestReadCb(readCbPara);
break;
}
case BLE_5_REPORT_ADV:
{
recv_adv_t *r_ind = (recv_adv_t *)param;
bk_printf("r_ind:actv_idx:%d, adv_addr:%02x:%02x:%02x:%02x:%02x:%02x\r\n",
r_ind->actv_idx, r_ind->adv_addr[0], r_ind->adv_addr[1], r_ind->adv_addr[2],
r_ind->adv_addr[3], r_ind->adv_addr[4], r_ind->adv_addr[5]);
break;
}
case BLE_5_MTU_CHANGE:
{
mtu_change_t *m_ind = (mtu_change_t *)param;
bk_printf("m_ind:conn_idx:%d, mtu_size:%d\r\n", m_ind->conn_idx, m_ind->mtu_size);
if(gatt_server_callbackfunc&&gatt_server_callbackfunc->mtuChangeCb)
gatt_server_callbackfunc->mtuChangeCb(m_ind->conn_idx, m_ind->mtu_size);
break;
}
case BLE_5_CONNECT_EVENT:
{
conn_ind_t *c_ind = (conn_ind_t *)param;
bk_printf("c_ind:conn_idx:%d, addr_type:%d, peer_addr:%02x:%02x:%02x:%02x:%02x:%02x\r\n",
c_ind->conn_idx, c_ind->peer_addr_type, c_ind->peer_addr[0], c_ind->peer_addr[1],
c_ind->peer_addr[2], c_ind->peer_addr[3], c_ind->peer_addr[4], c_ind->peer_addr[5]);
memcpy(&hal_bt_env.peer_addr, c_ind->peer_addr, GAP_BD_ADDR_LEN);
BdAddr bdAddr;
memcpy(bdAddr.addr,c_ind->peer_addr,GAP_BD_ADDR_LEN);
if(gatt_server_callbackfunc&&gatt_server_callbackfunc->connectServerCb)
gatt_server_callbackfunc->connectServerCb(c_ind->conn_idx, 0, &bdAddr);
break;
}
case BLE_5_DISCONNECT_EVENT:
{
discon_ind_t *d_ind = (discon_ind_t *)param;
bk_printf("d_ind:conn_idx:%d,reason:%d\r\n", d_ind->conn_idx,d_ind->reason);
BdAddr bdAddr;
memcpy(bdAddr.addr,hal_bt_env.peer_addr,GAP_BD_ADDR_LEN);
if(gatt_server_callbackfunc&&gatt_server_callbackfunc->disconnectServerCb)
gatt_server_callbackfunc->disconnectServerCb(d_ind->conn_idx, 0, &bdAddr);;
break;
}
case BLE_5_ATT_INFO_REQ:
{
att_info_req_t *a_ind = (att_info_req_t *)param;
bk_printf("a_ind:conn_idx:%d\r\n", a_ind->conn_idx);
a_ind->length = 128;
a_ind->status = ERR_SUCCESS;
break;
}
case BLE_5_TX_DONE:
{
bk_printf("BLE_5_TX_DONE\r\n");
if(gatt_server_callbackfunc&&gatt_server_callbackfunc->indicationSentCb)
gatt_server_callbackfunc->indicationSentCb(0, 0);
}
case BLE_5_CREATE_DB:
{
create_db_t *cd_ind = (create_db_t *)param;
bk_printf("cd_ind:prf_id:%d, status:%d\r\n", cd_ind->prf_id, cd_ind->status);
if(gatt_server_callbackfunc&&gatt_server_callbackfunc->serviceStartCb)
gatt_server_callbackfunc->serviceStartCb(cd_ind->status,cd_ind->prf_id, 0);
break;
}
case BLE_5_INIT_CONNECT_EVENT:
{
conn_ind_t *c_ind = (conn_ind_t *)param;
bk_printf("BLE_5_INIT_CONNECT_EVENT:conn_idx:%d, addr_type:%d, peer_addr:%02x:%02x:%02x:%02x:%02x:%02x\r\n",
c_ind->conn_idx, c_ind->peer_addr_type, c_ind->peer_addr[0], c_ind->peer_addr[1],
c_ind->peer_addr[2], c_ind->peer_addr[3], c_ind->peer_addr[4], c_ind->peer_addr[5]);
break;
}
case BLE_5_INIT_DISCONNECT_EVENT:
{
discon_ind_t *d_ind = (discon_ind_t *)param;
bk_printf("BLE_5_INIT_DISCONNECT_EVENT:conn_idx:%d,reason:%d\r\n", d_ind->conn_idx,d_ind->reason);
break;
}
case BLE_5_SDP_REGISTER_FAILED:
bk_printf("BLE_5_SDP_REGISTER_FAILED\r\n");
break;
default:
break;
}
}
static void HAL_ble_cmd_cb(ble_cmd_t cmd, ble_cmd_param_t *param)
{
bk_printf("cmd:%d idx:%d status:%d\r\n", cmd, param->cmd_idx, param->status);
switch(cmd){
case BLE_INIT_ADV:
if(gatt_callbackfunc&&gatt_callbackfunc->advEnableCb)
gatt_callbackfunc->advEnableCb(0,param->status);
break;
case BLE_DEINIT_ADV:
if(gatt_callbackfunc&&gatt_callbackfunc->advDisableCb)
gatt_callbackfunc->advDisableCb(0,param->status);
break;
case BLE_SET_ADV_DATA:
if(gatt_callbackfunc&&gatt_callbackfunc->advUpdateCb)
gatt_callbackfunc->advUpdateCb(0,param->status);
break;
default:
break;
}
}
static void ble_stack_init(void)
{
ble_set_notice_cb(ble_notice_cb);
}
int InitBtStack(void)
{
ble_entry();
return OHOS_BT_STATUS_SUCCESS;
}
int EnableBtStack(void)
{
ble_stack_init();
return OHOS_BT_STATUS_SUCCESS;
}
int DisableBtStack(void)
{
bk_printf("DisableBtStack NOT SUPPORT!!");
return OHOS_BT_STATUS_FAIL;
}
int SetDeviceName(const char *name, unsigned int len)
{
ble_appm_set_dev_name(len,(uint8_t*)name);
return OHOS_BT_STATUS_SUCCESS;
}
int BleSetAdvData(int advId, const BleConfigAdvData *data)
{
memcpy(&(hal_bt_env.advData[0]), &(data->advData[0]), data->advLength);
hal_bt_env.advDataLen = data->advLength;
memcpy(&(hal_bt_env.respData[0]), &(data->scanRspData[0]), data->scanRspLength);
hal_bt_env.respDataLen = data->scanRspLength;
if(gatt_callbackfunc&&gatt_callbackfunc->advDataCb)
gatt_callbackfunc->advDataCb(0,0);
return OHOS_BT_STATUS_SUCCESS;
}
int BleUpdateAdv(int advId, const BleAdvParams *param)
{
bk_ble_adv_stop(advId, HAL_ble_cmd_cb);
BleStartAdv(advId,param);
return OHOS_BT_STATUS_SUCCESS;
}
int BleStartAdv(int advId, const BleAdvParams *param)
{
struct adv_param hal_adv;
hal_adv.channel_map=param->channelMap;
hal_adv.interval_min=param->minInterval;
hal_adv.interval_max=param->maxInterval;
hal_adv.duration=param->duration;
memcpy(&(hal_adv.advData[0]), &(hal_bt_env.advData[0]), hal_bt_env.advDataLen);
hal_adv.advDataLen = hal_bt_env.advDataLen;
memcpy(&(hal_adv.respData[0]), &(hal_bt_env.respData[0]), hal_bt_env.respDataLen);
hal_adv.respDataLen = hal_bt_env.respDataLen;
#if 1
bk_printf("respDataLen:%d,advDataLen:%d,duration:%d,interval_min:%d,interval_max:%d,channel_map:%d\r\n",hal_adv.respDataLen,hal_adv.advDataLen,hal_adv.duration,hal_adv.interval_min,hal_adv.interval_max,hal_adv.channel_map);
for(int i=0;i<hal_adv.advDataLen;i++)
{
bk_printf("%x ",hal_adv.advData[i]);
}
bk_printf("\r\n");
for(int i=0;i<hal_adv.respDataLen;i++)
{
bk_printf("%x ",hal_adv.respData[i]);
}
bk_printf("\r\n");
#endif
hal_bt_env.adv_idx=app_ble_get_idle_actv_idx_handle();
bk_ble_adv_start(hal_bt_env.adv_idx,&hal_adv,HAL_ble_cmd_cb);
return OHOS_BT_STATUS_SUCCESS;
}
int BleStartAdvEx(int *advId, const StartAdvRawData rawData, BleAdvParams advParam)
{
struct adv_param hal_adv;
*advId=0;
hal_adv.channel_map=advParam.channelMap;
hal_adv.interval_min=advParam.minInterval;
hal_adv.interval_max=advParam.maxInterval;
hal_adv.duration=advParam.duration;
//advParam.advType;
memcpy(&(hal_adv.advData[0]), &(rawData.advData[0]), rawData.advDataLen);
hal_adv.advDataLen = rawData.advDataLen;
memcpy(&(hal_adv.respData[0]), &(rawData.rspData[0]), rawData.rspDataLen);
hal_adv.respDataLen = rawData.rspDataLen;
#if 1
bk_printf("respDataLen:%d,advDataLen:%d,duration:%d,interval_min:%d,interval_max:%d,channel_map:%d\r\n",hal_adv.respDataLen,hal_adv.advDataLen,hal_adv.duration,hal_adv.interval_min,hal_adv.interval_max,hal_adv.channel_map);
for(int i=0;i<hal_adv.advDataLen;i++)
{
bk_printf("%x ",hal_adv.advData[i]);
}
bk_printf("\r\n");
for(int i=0;i<hal_adv.respDataLen;i++)
{
bk_printf("%x ",hal_adv.respData[i]);
}
bk_printf("\r\n");
#endif
hal_bt_env.adv_idx=app_ble_get_idle_actv_idx_handle();
bk_ble_adv_start(hal_bt_env.adv_idx,&hal_adv,HAL_ble_cmd_cb);
return OHOS_BT_STATUS_SUCCESS;
}
int BleStopAdv(int advId)
{
bk_ble_adv_stop(hal_bt_env.adv_idx, HAL_ble_cmd_cb);
return OHOS_BT_STATUS_SUCCESS;
}
int BleSetSecurityIoCap(BleIoCapMode mode)
{
return OHOS_BT_STATUS_SUCCESS;
}
int BleSetSecurityAuthReq(BleAuthReqMode mode)
{
return OHOS_BT_STATUS_SUCCESS;
}
int BleGattSecurityRsp(BdAddr bdAddr, bool accept)
{
return OHOS_BT_STATUS_SUCCESS;
}
int ReadBtMacAddr(unsigned char *mac, unsigned int len)
{
memcpy(mac,ble_get_mac_addr(),6);
return OHOS_BT_STATUS_SUCCESS;
}
int BleSetScanParameters(int clientId, BleScanParams *param)
{
ohos_scan_info.channel_map = 7;
ohos_scan_info.interval = param->scanInterval;
ohos_scan_info.window = param->scanWindow;
hal_bt_env.scan_idx = app_ble_get_idle_actv_idx_handle();
memcpy(&(app_ble_env.actvs[hal_bt_env.scan_idx].param.scan), &ohos_scan_info, sizeof(struct scan_param));
if(gatt_callbackfunc&&gatt_callbackfunc->scanParamSetCb)
gatt_callbackfunc->scanParamSetCb(0,0);
return OHOS_BT_STATUS_SUCCESS;
}
int BleStartScan(void)
{
bk_ble_scan_start(hal_bt_env.scan_idx, &ohos_scan_info, HAL_ble_cmd_cb);
return OHOS_BT_STATUS_SUCCESS;
}
int BleStopScan(void)
{
bk_ble_stop_scaning(hal_bt_env.scan_idx, HAL_ble_cmd_cb);
return OHOS_BT_STATUS_SUCCESS;
}
int BleGattRegisterCallbacks(BtGattCallbacks *func)
{
gatt_callbackfunc=func;
return OHOS_BT_STATUS_SUCCESS;
}
int BleGattsRegister(BtUuid appUuid)
{
if(ohos_server_uuid_para[0]==NULL)
{
bk_printf("%s:%d\r\n",__FUNCTION__,__LINE__);
ohos_server_uuid_para[0]=os_malloc(sizeof(BtServer));
ohos_server_uuid_para[0]->uuid=os_malloc(appUuid.uuidLen);
memcpy(ohos_server_uuid_para[0]->uuid,appUuid.uuid,appUuid.uuidLen);
ohos_server_uuid_para[0]->uuidLen=appUuid.uuidLen;
if(gatt_server_callbackfunc&&gatt_server_callbackfunc->registerServerCb)
gatt_server_callbackfunc->registerServerCb(0, 0, &appUuid);
}
return OHOS_BT_STATUS_SUCCESS;
}
int BleGattsUnRegister(int serverId)
{
return OHOS_BT_STATUS_SUCCESS;
}
int BleGattsDisconnect(int serverId, BdAddr bdAddr, int connId)
{
appm_disconnect(0x13);
return OHOS_BT_STATUS_SUCCESS;
}
int BleGattsAddService(int serverId, BtUuid srvcUuid, bool isPrimary, int number)
{
if(serverId>=5)
{
bk_printf("add server failed ,max serverId is %d\r\n",MAX_SERVER_NUM-1);
return OHOS_BT_STATUS_FAIL;
}
if(ohos_server_uuid_para[serverId]==NULL)
{
ohos_server_uuid_para[serverId]=os_malloc(sizeof(BtServer));
ohos_server_uuid_para[serverId]->uuid=os_malloc(srvcUuid.uuidLen);
ohos_server_uuid_para[serverId]->ohos_att_db=os_malloc(sizeof(bk_attm_desc_t)*number);
memcpy(ohos_server_uuid_para[serverId]->uuid,srvcUuid.uuid,srvcUuid.uuidLen);
ohos_server_uuid_para[serverId]->ohos_att_db[0].uuid[0]=0x00;
ohos_server_uuid_para[serverId]->ohos_att_db[0].uuid[1]=0x28;
ohos_server_uuid_para[serverId]->ohos_att_db[0].perm=BK_PERM_SET(RD, ENABLE);
ohos_server_uuid_para[serverId]->ohos_att_db[0].ext_perm=0;
ohos_server_uuid_para[serverId]->ohos_att_db[0].max_size=0;
ohos_server_uuid_para[serverId]->uuidLen=srvcUuid.uuidLen;
ohos_server_uuid_para[serverId]->server_id=serverId;
ohos_server_uuid_para[serverId]->max_att_handle=number;
ohos_server_uuid_para[serverId]->next_att_handle=1;
if(gatt_server_callbackfunc&&gatt_server_callbackfunc->serviceAddCb)
gatt_server_callbackfunc->serviceAddCb(0, serverId, &srvcUuid, 0);
return OHOS_BT_STATUS_SUCCESS;
}
return OHOS_BT_STATUS_FAIL;
}
/* 添加特征值 */
int BleGattsAddCharacteristic(int serverId, int srvcHandle, BtUuid characUuid, int properties, int permissions)
{
int index;
int max_index;
uint32_t mode=0;
if(ohos_server_uuid_para[serverId])
{
index=ohos_server_uuid_para[serverId]->next_att_handle;
max_index=ohos_server_uuid_para[serverId]->max_att_handle;
if(index<max_index-1)
{
ohos_server_uuid_para[serverId]->ohos_att_db[index].uuid[0]=0x03;
ohos_server_uuid_para[serverId]->ohos_att_db[index].uuid[1]=0x28;
//memcpy(ohos_server_uuid_para[serverId]->ohos_att_db[index].uuid,BK_ATT_DECL_CHARACTERISTIC_128,2);
//bk_printf("1att uuid:%x %x\r\n",ohos_server_uuid_para[serverId]->ohos_att_db[index].uuid[0],ohos_server_uuid_para[serverId]->ohos_att_db[index].uuid[1]);
ohos_server_uuid_para[serverId]->ohos_att_db[index].perm=BK_PERM_SET(RD, ENABLE);
ohos_server_uuid_para[serverId]->ohos_att_db[index].ext_perm=0;
ohos_server_uuid_para[serverId]->ohos_att_db[index].max_size=0;
index++;
ohos_server_uuid_para[serverId]->next_att_handle++;
memcpy(ohos_server_uuid_para[serverId]->ohos_att_db[index].uuid,characUuid.uuid,characUuid.uuidLen);
if(properties&OHOS_GATT_CHARACTER_PROPERTY_BIT_READ)
{
mode|=BK_PERM_SET(RD, ENABLE);
}
if(properties&OHOS_GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP)
{
mode|=BK_PERM_SET(WRITE_COMMAND,ENABLE);
}
if(properties&OHOS_GATT_CHARACTER_PROPERTY_BIT_WRITE)
{
mode|=BK_PERM_SET(WRITE_REQ,ENABLE);
}
if(properties&OHOS_GATT_CHARACTER_PROPERTY_BIT_NOTIFY)
{
mode|=BK_PERM_SET(NTF,ENABLE);
}
if(properties&OHOS_GATT_CHARACTER_PROPERTY_BIT_INDICATE)
{
mode|=BK_PERM_SET(IND,ENABLE);
}
ohos_server_uuid_para[serverId]->ohos_att_db[index].perm=mode;
if(characUuid.uuidLen==2)
{
ohos_server_uuid_para[serverId]->ohos_att_db[index].ext_perm=BK_PERM_SET(RI, ENABLE)|BK_PERM_SET(UUID_LEN, UUID_16);
}
else if(characUuid.uuidLen==16)
{
ohos_server_uuid_para[serverId]->ohos_att_db[index].ext_perm=BK_PERM_SET(RI, ENABLE)|BK_PERM_SET(UUID_LEN, UUID_128);
}
ohos_server_uuid_para[serverId]->ohos_att_db[index].max_size=128;
ohos_server_uuid_para[serverId]->next_att_handle++;
if(gatt_server_callbackfunc&&gatt_server_callbackfunc->serviceAddCb)
gatt_server_callbackfunc->characteristicAddCb(0, serverId, &characUuid,srvcHandle, index);
return OHOS_BT_STATUS_SUCCESS;
}
}
return OHOS_BT_STATUS_FAIL;
}
/* 添加描述符 */
int BleGattsAddDescriptor(int serverId, int srvcHandle, BtUuid descUuid, int permissions)
{
int index,max_index;
if(ohos_server_uuid_para[serverId])
{
index=ohos_server_uuid_para[serverId]->next_att_handle;
max_index=ohos_server_uuid_para[serverId]->max_att_handle;
if(index<max_index)
{
memcpy(ohos_server_uuid_para[serverId]->ohos_att_db[index].uuid,descUuid.uuid,descUuid.uuidLen);
//bk_printf("3att uuid:%x %x\r\n",ohos_server_uuid_para[serverId]->ohos_att_db[index].uuid[0],ohos_server_uuid_para[serverId]->ohos_att_db[index].uuid[1]);
if(permissions&OHOS_GATT_PERMISSION_READ)
{
ohos_server_uuid_para[serverId]->ohos_att_db[index].perm|=BK_PERM_SET(RD, ENABLE);
}
if(permissions&OHOS_GATT_PERMISSION_WRITE)
{
ohos_server_uuid_para[serverId]->ohos_att_db[index].perm|=BK_PERM_SET(WRITE_REQ, ENABLE);
}
ohos_server_uuid_para[serverId]->ohos_att_db[index].ext_perm=0;
ohos_server_uuid_para[serverId]->ohos_att_db[index].max_size=0;
ohos_server_uuid_para[serverId]->next_att_handle++;
if(gatt_server_callbackfunc&&gatt_server_callbackfunc->descriptorAddCb)
gatt_server_callbackfunc->descriptorAddCb(0, serverId, &descUuid,srvcHandle, index);
return OHOS_BT_STATUS_SUCCESS;
}
}
return OHOS_BT_STATUS_FAIL;
}
int BleGattsStartService(int serverId, int srvcHandle)
{
ble_err_t status = ERR_SUCCESS;
struct bk_ble_db_cfg ble_db_cfg;
ble_db_cfg.att_db = ohos_server_uuid_para[serverId]->ohos_att_db;
ble_db_cfg.att_db_nb = ohos_server_uuid_para[serverId]->max_att_handle;
ble_db_cfg.prf_task_id =serverId;
ble_db_cfg.start_hdl = 0;
if( ohos_server_uuid_para[serverId]->uuidLen==2)
{
ble_db_cfg.svc_perm = BK_PERM_SET(SVC_UUID_LEN, UUID_16);
}
else if( ohos_server_uuid_para[serverId]->uuidLen==16)
{
ble_db_cfg.svc_perm = BK_PERM_SET(SVC_UUID_LEN, UUID_128);
}
memcpy(&(ble_db_cfg.uuid[0]), &ohos_server_uuid_para[serverId]->uuid[0], 16);
status = bk_ble_create_db(&ble_db_cfg);
for(int i=0;i<ble_db_cfg.att_db_nb;i++)
{
bk_printf("index:%d,bd uuid:%x %x\r\n",i,ohos_server_uuid_para[serverId]->ohos_att_db[i].uuid[0],ohos_server_uuid_para[serverId]->ohos_att_db[i].uuid[1]);
bk_printf("index:%d,perm:%x ext_perm:%x max_size:%d\r\n",i,ohos_server_uuid_para[serverId]->ohos_att_db[i].perm,ohos_server_uuid_para[serverId]->ohos_att_db[i].ext_perm,ohos_server_uuid_para[serverId]->ohos_att_db[i].max_size);
}
bk_printf("ble_db_cfg.prf_task_id :%d,nb:%d,uuid:%x %x\r\n",ble_db_cfg.prf_task_id,ble_db_cfg.att_db_nb,ohos_server_uuid_para[serverId]->uuid[0],ohos_server_uuid_para[serverId]->uuid[1]);
status = bk_ble_create_db(&ble_db_cfg);
return (status==ERR_SUCCESS)?OHOS_BT_STATUS_SUCCESS:OHOS_BT_STATUS_FAIL;
}
/*No implementation required */
int BleGattsStopService(int serverId, int srvcHandle)
{
(void)serverId;
(void)srvcHandle;
return OHOS_BT_STATUS_SUCCESS;
}
/*No implementation required */
int BleGattsDeleteService(int serverId, int srvcHandle)
{
(void)serverId;
(void)srvcHandle;
return OHOS_BT_STATUS_SUCCESS;
}
/*No implementation required */
int BleGattsClearServices(int serverId)
{
(void)serverId;
return OHOS_BT_STATUS_SUCCESS;
}
/*No implementation required */
int BleGattsSendResponse(int serverId, GattsSendRspParam *param)
{
(void)serverId;
(void)param;
return OHOS_BT_STATUS_SUCCESS;
}
int BleGattsSendIndication(int serverId, GattsSendIndParam *param)
{
if(1==param->confirm) //IND
{
bk_ble_send_ind_value(param->valueLen,(uint8_t *)param->value,serverId,param->attrHandle);
}
else if(0==param->confirm) //NTF
{
bk_ble_send_ntf_value(param->valueLen,(uint8_t *)param->value,serverId,param->attrHandle);
}
return OHOS_BT_STATUS_SUCCESS;
}
int BleGattsSetEncryption(BdAddr bdAddr, BleSecAct secAct)
{
return OHOS_BT_STATUS_SUCCESS;
}
int BleGattsRegisterCallbacks(BtGattServerCallbacks *func)
{
gatt_server_callbackfunc=func;
return OHOS_BT_STATUS_SUCCESS;
}
int BleGattsStartServiceEx(int *srvcHandle, BleGattService *srvcInfo)
{
BleGattAttr *attr_list=srvcInfo->attrList;
uint8_t attr_num=srvcInfo->attrNum;
uint8_t attr_index=0;
uint8_t attr_uuidlen=0;
ohos_server_uuid_para[0]->ohos_att_db=os_malloc(sizeof(bk_attm_desc_t)*attr_num);
bk_printf("%s:%d,attr_num:%d\r\n",__FUNCTION__,__LINE__,attr_num);
while(attr_list && attr_num)
{
switch(attr_list->uuidType)
{
case OHOS_UUID_TYPE_16_BIT:
attr_uuidlen=2;
break;
case OHOS_UUID_TYPE_32_BIT:
attr_uuidlen=4;
break;
case OHOS_UUID_TYPE_128_BIT:
attr_uuidlen=16;
break;
default:
attr_uuidlen=0;
}
memcpy(ohos_server_uuid_para[0]->ohos_att_db[attr_index].uuid,attr_list->uuid,attr_uuidlen);
switch(attr_list->attrType)
{
case OHOS_BLE_ATTRIB_TYPE_SERVICE:
case OHOS_BLE_ATTRIB_TYPE_CHAR:
case OHOS_BLE_ATTRIB_TYPE_CHAR_CLIENT_CONFIG:
ohos_server_uuid_para[0]->ohos_att_db[attr_index].ext_perm=0;
ohos_server_uuid_para[0]->ohos_att_db[attr_index].max_size=0;
if(attr_list->permission&OHOS_GATT_PERMISSION_READ)
ohos_server_uuid_para[0]->ohos_att_db[attr_index].perm|=BK_PERM_SET(RD, ENABLE);
if(attr_list->permission&OHOS_GATT_PERMISSION_WRITE)
ohos_server_uuid_para[0]->ohos_att_db[attr_index].perm|=BK_PERM_SET(WRITE_REQ,ENABLE);
break;
case OHOS_BLE_ATTRIB_TYPE_CHAR_VALUE:
if(attr_list->properties&OHOS_GATT_CHARACTER_PROPERTY_BIT_READ)
{
ohos_server_uuid_para[0]->ohos_att_db[attr_index].perm|=BK_PERM_SET(RD, ENABLE);
}
if(attr_list->properties&OHOS_GATT_CHARACTER_PROPERTY_BIT_WRITE_NO_RSP)
{
ohos_server_uuid_para[0]->ohos_att_db[attr_index].perm|=BK_PERM_SET(WRITE_COMMAND,ENABLE);
}
if(attr_list->properties&OHOS_GATT_CHARACTER_PROPERTY_BIT_WRITE)
{
ohos_server_uuid_para[0]->ohos_att_db[attr_index].perm|=BK_PERM_SET(WRITE_REQ,ENABLE);
}
if(attr_list->properties&OHOS_GATT_CHARACTER_PROPERTY_BIT_NOTIFY)
{
ohos_server_uuid_para[0]->ohos_att_db[attr_index].perm|=BK_PERM_SET(NTF,ENABLE);
}
if(attr_list->properties&OHOS_GATT_CHARACTER_PROPERTY_BIT_INDICATE)
{
ohos_server_uuid_para[0]->ohos_att_db[attr_index].perm|=BK_PERM_SET(IND,ENABLE);
}
ohos_server_uuid_para[0]->ohos_att_db[attr_index].max_size=128;
if(attr_uuidlen==2)
{
ohos_server_uuid_para[0]->ohos_att_db[attr_index].ext_perm=BK_PERM_SET(RI, ENABLE)|BK_PERM_SET(UUID_LEN, UUID_16);
}
else if(attr_uuidlen==4)
{
ohos_server_uuid_para[0]->ohos_att_db[attr_index].ext_perm=BK_PERM_SET(RI, ENABLE)|BK_PERM_SET(UUID_LEN, UUID_32);
}
else if(attr_uuidlen==16)
{
ohos_server_uuid_para[0]->ohos_att_db[attr_index].ext_perm=BK_PERM_SET(RI, ENABLE)|BK_PERM_SET(UUID_LEN, UUID_128);
}
break;
default:
break;
}
attr_index++;
attr_list++;
attr_num--;
}
ble_err_t status = ERR_SUCCESS;
struct bk_ble_db_cfg ble_db_cfg;
ble_db_cfg.att_db = ohos_server_uuid_para[0]->ohos_att_db;
ble_db_cfg.att_db_nb = srvcInfo->attrNum;
ble_db_cfg.prf_task_id =0;
ble_db_cfg.start_hdl = 0;
if( ohos_server_uuid_para[0]->uuidLen==2)
{
ble_db_cfg.svc_perm = BK_PERM_SET(SVC_UUID_LEN, UUID_16);
}
else if( ohos_server_uuid_para[0]->uuidLen==16)
{
ble_db_cfg.svc_perm = BK_PERM_SET(SVC_UUID_LEN, UUID_128);
}
memcpy(&(ble_db_cfg.uuid[0]), &ohos_server_uuid_para[0]->uuid[0], 16);
#if 0
for(int i=0;i<ble_db_cfg.att_db_nb;i++)
{
bk_printf("index:%d,bd uuid:%x %x\r\n",i,ohos_server_uuid_para[0]->ohos_att_db[i].uuid[0],ohos_server_uuid_para[0]->ohos_att_db[i].uuid[1]);
bk_printf("index:%d,perm:%x ext_perm:%x max_size:%d\r\n",i,ohos_server_uuid_para[0]->ohos_att_db[i].perm,ohos_server_uuid_para[0]->ohos_att_db[i].ext_perm,ohos_server_uuid_para[0]->ohos_att_db[i].max_size);
}
bk_printf("ble_db_cfg.prf_task_id :%d,nb:%d,uuid:%x %x\r\n",ble_db_cfg.prf_task_id,ble_db_cfg.att_db_nb,ohos_server_uuid_para[0]->uuid[0],ohos_server_uuid_para[0]->uuid[1]);
#endif
status = bk_ble_create_db(&ble_db_cfg);
return (status==ERR_SUCCESS)?OHOS_BT_STATUS_SUCCESS:OHOS_BT_STATUS_FAIL;
}
int BleGattsStopServiceEx(int srvcHandle)
{
(void)srvcHandle;
return OHOS_BT_STATUS_SUCCESS;
}
@@ -3,15 +3,20 @@
#include <securec.h>
#include "rw_msg_pub.h"
#include "wlan_ui_pub.h"
#include "wifi_ui_extra.h"
#include "param_config.h"
#include "wifi_hotspot_config.h"
#include "utils_file.h"
static int g_wifiStaStatus = WIFI_STA_NOT_ACTIVE;
static ScanResult_adv scan_apList = {0,0};
static WifiDeviceConfig g_wifiConfigs[WIFI_MAX_CONFIG_SIZE] = {{{0}, {0}, {0}, 0, WIFI_CONFIG_INVALID, 0, 0}};
static WifiEvent * g_wifiEvents[WIFI_MAX_EVENT_SIZE] = {0};
#define MAX_STORE_FILE_LEN 8
static const char wifi_store_filename[MAX_STORE_FILE_LEN] = "ApInfo";
static void DispatchScanStateChangeEvent(const rw_evt_type *evt, const WifiEvent* hosEvent, WifiEventState state)
{
if(hosEvent->OnWifiScanStateChanged == NULL)
@@ -112,18 +117,16 @@ static void RegisterBkCallback(void )
static void los_scan_cb(void *ctxt, uint8_t param)
{
int i;
if(scan_apList.ApList != NULL)
{
free(scan_apList.ApList);
scan_apList.ApList = NULL;
scan_apList.ApNum = 0;
}
if (wlan_sta_scan_result(&scan_apList) == 0)
{
printf("Got ap count: %d\r\n", scan_apList.ApNum);
printf("=================Got ap count: %d================\r\n", scan_apList.ApNum);
for(int i=0; i<WIFI_MAX_EVENT_SIZE; i++)
{
if(g_wifiEvents[i] == NULL)
@@ -194,10 +197,7 @@ int IsWifiActive(void)
WifiErrorCode Scan(void)
{
//if(g_wifiStaStatus == WIFI_STA_NOT_ACTIVE)
//return ERROR_WIFI_UNKNOWN;
if (LockWifiEventLock() != WIFI_SUCCESS) {
if (LockWifiEventLock() != WIFI_SUCCESS) {
return ERROR_WIFI_UNKNOWN;
}
for (int i = 0; i < WIFI_MAX_EVENT_SIZE; i++) {
@@ -208,8 +208,7 @@ WifiErrorCode Scan(void)
}
if (UnlockWifiEventLock() != WIFI_SUCCESS) {
return ERROR_WIFI_UNKNOWN;
}
}
mhdr_scanu_reg_cb(los_scan_cb, 0);
bk_wlan_start_scan();
@@ -243,8 +242,14 @@ WifiErrorCode GetScanInfoList(WifiScanInfo* result, unsigned int* size)
}
return WIFI_SUCCESS;
}
WifiErrorCode AddDeviceConfig(const WifiDeviceConfig* config, int* result)
{
int fd;
unsigned int file_size,write_size;
char file_name[MAX_STORE_FILE_LEN + 2];
if (config == NULL || result == NULL)
{
@@ -273,40 +278,72 @@ WifiErrorCode AddDeviceConfig(const WifiDeviceConfig* config, int* result)
}
return ERROR_WIFI_BUSY;
}
memcpy(&g_wifiConfigs[netId],config,sizeof(WifiDeviceConfig));
g_wifiConfigs[netId].netId = netId;
/*save*/
snprintf(file_name, sizeof(file_name), "%s%02d",wifi_store_filename,netId);
fd = UtilsFileOpen(file_name, O_WRONLY_FS | O_CREAT_FS |O_TRUNC_FS, 0);
if(fd < 0)
return ERROR_WIFI_UNKNOWN;
file_size = sizeof(WifiDeviceConfig);
write_size = UtilsFileWrite(fd, &g_wifiConfigs[netId], file_size);
UtilsFileClose(fd);
if(write_size != file_size)
{
if (UnlockWifiGlobalLock() != WIFI_SUCCESS)
{
return ERROR_WIFI_UNKNOWN;
}
}
if (UnlockWifiGlobalLock() != WIFI_SUCCESS)
{
return ERROR_WIFI_UNKNOWN;
}
*result = netId;
return WIFI_SUCCESS;
}
WifiErrorCode GetDeviceConfigs(WifiDeviceConfig* result, unsigned int* size)
{
int fd;
unsigned int retIndex, i;
unsigned int file_size,read_size;
char file_name[MAX_STORE_FILE_LEN + 2];
if(result == NULL || size == NULL || *size == 0)
{
return ERROR_WIFI_INVALID_ARGS;
}
unsigned int retIndex = 0;
if (LockWifiGlobalLock() != WIFI_SUCCESS)
{
return ERROR_WIFI_UNKNOWN;
}
for(int i=0; i<WIFI_MAX_CONFIG_SIZE; i++)
retIndex = 0;
for(i=0; i<WIFI_MAX_CONFIG_SIZE; i++)
{
if(g_wifiConfigs[i].netId != i)
{
continue;
}
memcpy(&result[retIndex], &g_wifiConfigs[i], sizeof(WifiDeviceConfig));
snprintf(file_name, sizeof(file_name), "%s%02d",wifi_store_filename,i);
if(0 !=UtilsFileStat(file_name,&file_size))
break;
fd = UtilsFileOpen(file_name,O_RDONLY_FS, 0);
if(fd < 0)
goto error_ret;
read_size = UtilsFileRead(fd, &g_wifiConfigs[i], file_size);
if(read_size != file_size)
goto error_ret;
UtilsFileClose(fd);
}
if(i == 0)
goto error_ret;
while( retIndex < i )
{
memcpy(&result[retIndex], &g_wifiConfigs[retIndex], sizeof(WifiDeviceConfig));
retIndex++;
if(*size < retIndex)
@@ -318,10 +355,12 @@ WifiErrorCode GetDeviceConfigs(WifiDeviceConfig* result, unsigned int* size)
return ERROR_WIFI_INVALID_ARGS;
}
}
error_ret:
if (UnlockWifiGlobalLock() != WIFI_SUCCESS)
{
return ERROR_WIFI_UNKNOWN;
}
if(retIndex == 0)
return ERROR_WIFI_NOT_AVAILABLE;
@@ -331,12 +370,28 @@ WifiErrorCode GetDeviceConfigs(WifiDeviceConfig* result, unsigned int* size)
WifiErrorCode RemoveDevice(int networkId)
{
char file_name[MAX_STORE_FILE_LEN + 2];
int i,file_size;
int fd;
if (networkId >= WIFI_MAX_CONFIG_SIZE || networkId < 0)
{
return ERROR_WIFI_INVALID_ARGS;
}
if (LockWifiGlobalLock() != WIFI_SUCCESS)
{
return ERROR_WIFI_UNKNOWN;
}
memset(&g_wifiConfigs[networkId], 0, sizeof(WifiDeviceConfig)) ;
g_wifiConfigs[networkId].netId = WIFI_CONFIG_INVALID;
snprintf(file_name, sizeof(file_name), "%s%02d",wifi_store_filename,networkId);
i=UtilsFileDelete(file_name);
if (UnlockWifiGlobalLock() != WIFI_SUCCESS)
{
return ERROR_WIFI_UNKNOWN;
}
return WIFI_SUCCESS;
}
@@ -436,7 +491,8 @@ WifiErrorCode GetLinkedInfo(WifiLinkedInfo* result)
return ERROR_WIFI_INVALID_ARGS;
if(bk_wlan_get_link_status(&linkstat) != 0)
return ERROR_WIFI_UNKNOWN;
result->rssi = linkstat.wifi_strength;
memcpy(result->ssid, linkstat.ssid, sizeof(linkstat.ssid));
memcpy(result->bssid, linkstat.bssid, WIFI_MAC_LEN);
if(linkstat.conn_state == RW_EVT_STA_GOT_IP)
@@ -528,13 +584,6 @@ WifiErrorCode GetDeviceMacAddress(unsigned char* result)
}
static void AdvScan_Cb(void *ctxt, uint8_t param)
{
los_scan_cb(ctxt,param);
set_wifiscan_sema();
}
#define SSID_SCAN_TYPE 0
#define NORMAL_SCAN_TYPE 1
static WifiErrorCode ScanTypeJudge(WifiScanParams *params, uint8_t *BkScanType)
@@ -590,7 +639,6 @@ WifiErrorCode AdvanceScan(WifiScanParams *params)
if(ret != WIFI_SUCCESS)
return ret;
printf("==scan type:%d==\r\n",scan_type);
if(scan_type== NORMAL_SCAN_TYPE)
{
mhdr_scanu_reg_cb(los_scan_cb, 0);
@@ -599,14 +647,8 @@ WifiErrorCode AdvanceScan(WifiScanParams *params)
else
{
ssid_array = &params->ssid;
mhdr_scanu_reg_cb(AdvScan_Cb, 0);
mhdr_scanu_reg_cb(los_scan_cb, 0);
bk_wlan_start_assign_scan(ssid_array, 1);
if(get_wifiscan_sema() == WIFI_SUCCESS)
{
if( scan_apList.ApNum != 0)
return WIFI_SUCCESS;
}
return ERROR_WIFI_UNKNOWN;
}
return WIFI_SUCCESS;
}
@@ -14,7 +14,6 @@
static MutexId g_wifiGlobalLock = NULL;
static MutexId g_wifiEventLock = NULL;
static osSemaphoreId_t g_wifiScan = NULL;
WifiSecurityType BKSecToHoSec(bk_wlan_sec_type mode)
{
@@ -84,12 +83,6 @@ static void InitWifiGlobalLock(void)
};
g_wifiEventLock = osMutexNew(&eventMutexAttr);
}
if(g_wifiScan == NULL)
{
g_wifiScan = osSemaphoreNew(1,0,NULL);
}
}
WifiErrorCode LockWifiGlobalLock(void)
@@ -154,30 +147,6 @@ WifiErrorCode UnlockWifiEventLock(void)
}
return WIFI_SUCCESS;
}
WifiErrorCode get_wifiscan_sema(void)
{
if(g_wifiScan == NULL)
{
return ERROR_WIFI_UNKNOWN;
}
osStatus_t ret = osSemaphoreAcquire(g_wifiScan, 3000);
if(ret != osOK)
return ERROR_WIFI_UNKNOWN;
return WIFI_SUCCESS;
}
WifiErrorCode set_wifiscan_sema(void)
{
if(g_wifiScan == NULL)
{
return ERROR_WIFI_UNKNOWN;
}
osStatus_t ret = osSemaphoreRelease(g_wifiScan);
if(ret != osOK)
return ERROR_WIFI_UNKNOWN;
return WIFI_SUCCESS;
}
unsigned int ChannelToFrequency(unsigned int channel)
{
if (channel <= 0)
@@ -1,6 +1,6 @@
#include "wifi_hotspot.h"
#include "wifi_device_util.h"
#include "wlan_ui_pub.h"
#include "wifi_ui_extra.h"
#define WLAN_DEFAULT_IP "192.168.0.1"
#define WLAN_DEFAULT_GW "192.168.0.1"
@@ -6,20 +6,20 @@
unsigned int IoTFlashRead(unsigned int flashOffset, unsigned int size, unsigned char *ramData)
{
liteos_flash_read(flashOffset, ramData,size);
bk_flash_abs_addr_read(flashOffset, ramData,size);
return IOT_SUCCESS;
}
unsigned int IoTFlashWrite(unsigned int flashOffset, unsigned int size,
const unsigned char *ramData, unsigned char doErase)
{
liteos_flash_write(flashOffset,ramData,size,doErase);
bk_flash_abs_addr_write(flashOffset,ramData,size,doErase);
return IOT_SUCCESS;
}
unsigned int IoTFlashErase(unsigned int flashOffset, unsigned int size)
{
liteos_flash_erase(flashOffset, size);
bk_flash_abs_addr_erase(flashOffset, size);
return IOT_SUCCESS;
}
@@ -25,8 +25,12 @@ unsigned int IoTPwmStart(unsigned int port, unsigned short duty, unsigned int fr
if(port >= BK_PWM_MAX)
return IOT_FAILURE;
#if (CFG_SOC_NAME != SOC_BK7231N) && (CFG_SOC_NAME != SOC_BK7236)
ret = bk_pwm_initialize(port,duty,freq);
#else
ret = bk_pwm_initialize(port, freq, duty, 0, 0);
#endif
if (ret)
return IOT_FAILURE;
@@ -38,7 +38,10 @@ static struct file_info infos[MAX_FILE_CNT] = {
#define ESC_CHAR1 '\0'
//#define ESC_CHAR2 0xFE
#define ESC_CHAR2 0x41
#define ESC_CHAR2 0xDB
#define REP_CHAR1 0xDC
#define REP_CHAR2 0xDD
#define MAX_FILE_NAME_LEN 31
#define MAX_FILE_LENGTH 512
@@ -46,7 +49,7 @@ static struct file_info infos[MAX_FILE_CNT] = {
#define MAGIC_CHAR '&'
#define MAGIC_LEN 1
static unsigned int file_encode(const char *buf_in, unsigned int len, char *buf_out)
static unsigned int file_encode(const unsigned char *buf_in, unsigned int len, unsigned char *buf_out)
{
int i;
int j;
@@ -57,9 +60,10 @@ static unsigned int file_encode(const char *buf_in, unsigned int len, char *buf_
for (i = 0, j = 0; i < len; i++) {
if (buf_in[i] == ESC_CHAR1) {
buf_out[j++] = ESC_CHAR2;
buf_out[j++] = REP_CHAR1;
} else if (buf_in[i] == ESC_CHAR2) {
buf_out[j++] = ESC_CHAR2;
buf_out[j++] = ESC_CHAR2;
buf_out[j++] = REP_CHAR2;
} else {
buf_out[j++] = buf_in[i];
}
@@ -68,7 +72,7 @@ static unsigned int file_encode(const char *buf_in, unsigned int len, char *buf_
return j;
}
static unsigned int file_decode(char *buf_in, unsigned int len, char *buf_out)
static unsigned int file_decode(unsigned char *buf_in, unsigned int len, unsigned char *buf_out)
{
int i;
int j;
@@ -78,11 +82,17 @@ static unsigned int file_decode(char *buf_in, unsigned int len, char *buf_out)
for (i = 0, j = 0; i < len; i++) {
if (buf_in[i] == ESC_CHAR2) {
if ((i+1 < len) && (buf_in[i+1] == ESC_CHAR2)) {
buf_out[j++] = ESC_CHAR2;
if (i+1 < len) {
if (buf_in[i+1] == REP_CHAR1) {
buf_out[j++] = ESC_CHAR1;
} else if (buf_in[i+1] == REP_CHAR2) {
buf_out[j++] = ESC_CHAR2;
} else {
return 0; //err
}
i++; //skip it
} else {
buf_out[j++] = ESC_CHAR1;
return 0; //err
}
} else {
buf_out[j++] = buf_in[i];
@@ -204,7 +214,6 @@ int HalFileOpen(const char* path, int oflag, int mode)
return FILE_ERR_GENERAL;
exist = file_exist(path);
if (!(oflag & O_CREAT_FS) && !exist) {
return FILE_ERR_GENERAL;
}
@@ -239,7 +248,6 @@ int HalFileOpen(const char* path, int oflag, int mode)
}
info->fd = i + 1;
return info->fd;
}
@@ -374,3 +382,93 @@ int HalFileSeek(int fd, int offset, unsigned int whence)
return info->offset;
}
/*
* Read data from file or flash
*
* filename: The path name of the file
* offset: param reserved for future use
* buf: The buffer used to store the content readed from the file
* len: The size count in buffer trying to read from the file
* return < 0 read error, return > 0 real read length,
* return == 0 secret key information does not exist in storage media
*/
int FileRead(const char *filename, unsigned int offset, char *buf, unsigned int len)
{
//printf("FileRead:%s,buf:0x%x,len:%d,offset:%d\r\n",filename,buf,len,offset);
int fd;
int read_len = 0;
fd = HalFileOpen(filename, O_CREAT_FS, 0);
if (fd <= 0)
return FILE_ERR_GENERAL;
read_len = HalFileRead(fd,buf,len);
HalFileClose(fd);
return read_len;
}
//int32_t (*read)(const char *file_name, uint32_t offset,
// uint8_t *buf, uint32_t len);
/*
* Write data into file or flash
*
* filename: The path name of the file
* offset: param reserved for future use
* buf: The content which you want write into the file
* len: The size of the content
* return == 0 write ok, return < 0 other error
*/
int FileWrite(const char *filename, unsigned int offset, const char *buf, unsigned int len)
{
int fd;
fd = HalFileOpen(filename, O_CREAT_FS, 0);
HalFileWrite(fd,buf,len);
HalFileClose(fd);
}
//int32_t (*write)(const char *file_name, uint32_t offset,
// const uint8_t *buf, uint32_t len);
/*
* Get file size
*
* filename: The path name of the file
* return < 0 error, >= 0 The size of the file
* flash can return a fixed value of 4096
*/
int FileSize(const char *filename)
{
int fd;
struct file_info *info;
int32_t file_size;
fd = HalFileOpen(filename, O_RDONLY_FS, 0);
if (fd <= 0)
return FILE_ERR_GENERAL;
info = file_get_info(fd);
if (!info) {
HalFileClose(fd);
return FILE_ERR_GENERAL;
}
file_size = info->len;
HalFileClose(fd);
return file_size;
}
//int32_t (*file_size)(const char *file_name);
@@ -82,74 +82,43 @@ SECTIONS
.zInit :
{
__zinitcall_bsp_start = .;
KEEP (*(.zinitcall.bsp0.init))
KEEP (*(.zinitcall.bsp1.init))
KEEP (*(.zinitcall.bsp2.init))
KEEP (*(.zinitcall.bsp3.init))
KEEP (*(.zinitcall.bsp4.init))
KEEP(*(SORT(.zinitcall.bsp*)))
__zinitcall_bsp_end = .;
__zinitcall_device_start = .;
KEEP (*(.zinitcall.device0.init))
KEEP (*(.zinitcall.device1.init))
KEEP (*(.zinitcall.device2.init))
KEEP (*(.zinitcall.device3.init))
KEEP (*(.zinitcall.device4.init))
__zinitcall_device_start = .;
KEEP(*(SORT(.zinitcall.device*)))
__zinitcall_device_end = .;
__zinitcall_core_start = .;
KEEP (*(.zinitcall.core0.init))
KEEP (*(.zinitcall.core1.init))
KEEP (*(.zinitcall.core2.init))
KEEP (*(.zinitcall.core3.init))
KEEP (*(.zinitcall.core4.init))
KEEP(*(SORT(.zinitcall.core*)))
__zinitcall_core_end = .;
__zinitcall_sys_service_start = .;
KEEP (*(.zinitcall.sys.service0.init))
KEEP (*(.zinitcall.sys.service1.init))
KEEP (*(.zinitcall.sys.service2.init))
KEEP (*(.zinitcall.sys.service3.init))
KEEP (*(.zinitcall.sys.service4.init))
KEEP(*(SORT(.zinitcall.sys.service*)))
__zinitcall_sys_service_end = .;
__zinitcall_sys_feature_start = .;
KEEP (*(.zinitcall.sys.feature0.init))
KEEP (*(.zinitcall.sys.feature1.init))
KEEP (*(.zinitcall.sys.feature2.init))
KEEP (*(.zinitcall.sys.feature3.init))
KEEP (*(.zinitcall.sys.feature4.init))
KEEP(*(SORT(.zinitcall.sys.feature*)))
__zinitcall_sys_feature_end = .;
__zinitcall_run_start = .;
KEEP (*(.zinitcall.run0.init))
KEEP (*(.zinitcall.run1.init))
KEEP (*(.zinitcall.run2.init))
KEEP (*(.zinitcall.run3.init))
KEEP (*(.zinitcall.run4.init))
KEEP(*(SORT(.zinitcall.run*)))
__zinitcall_run_end = .;
__zinitcall_app_service_start = .;
KEEP (*(.zinitcall.app.service0.init))
KEEP (*(.zinitcall.app.service1.init))
KEEP (*(.zinitcall.app.service2.init))
KEEP (*(.zinitcall.app.service3.init))
KEEP (*(.zinitcall.app.service4.init))
KEEP(*(SORT(.zinitcall.app.service*)))
__zinitcall_app_service_end = .;
__zinitcall_app_feature_start = .;
KEEP (*(.zinitcall.app.feature0.init))
KEEP (*(.zinitcall.app.feature1.init))
KEEP (*(.zinitcall.app.feature2.init))
KEEP (*(.zinitcall.app.feature3.init))
KEEP (*(.zinitcall.app.feature4.init))
KEEP(*(SORT(.zinitcall.app.feature*)))
__zinitcall_app_feature_end = .;
__zinitcall_test_start = .;
KEEP (*(.zinitcall.test0.init))
KEEP (*(.zinitcall.test1.init))
KEEP (*(.zinitcall.test2.init))
KEEP (*(.zinitcall.test3.init))
KEEP (*(.zinitcall.test4.init))
KEEP(*(SORT(.zinitcall.test*)))
__zinitcall_test_end = .;
__zinitcall_exit_start = .;
KEEP (*(.zinitcall.exit0.init))
KEEP (*(.zinitcall.exit1.init))
KEEP (*(.zinitcall.exit2.init))
KEEP (*(.zinitcall.exit3.init))
KEEP (*(.zinitcall.exit4.init))
KEEP(*(SORT(.zinitcall.exit*)))
__zinitcall_exit_end = .;
} > flash
@@ -351,7 +320,7 @@ SECTIONS
*raw.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*netif.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
/* *memp.o(.bss .bss.* .scommon .sbss .dynbss COMMON) */
/* *mem.o(.bss .bss.* .scommon .sbss .dynbss COMMON) */
*mem.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*ip4.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*ip4_addr.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*igmp.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
@@ -369,6 +338,10 @@ SECTIONS
*heap_4.marm.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*timers.marm.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*los_sched.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*los_swtmr.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*los_memory.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*los_task.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
} >tcm AT>flash
_tcmbss_start = ADDR(.tcm);
_tcmbss_end = _tcmbss_start + SIZEOF(.tcm);
@@ -64,6 +64,22 @@ SECTIONS
*(.text.power_save_wakeup_isr)
*(.text.bmsg_rx_sender)
*(.text.bmsg_null_sender)
*(.text.fclk_get_tick)
*(.text.flash_read_sr)
*(.text.flash_write_sr)
*(.text.flash_clr_qwfr)
*(.text.set_flash_protect)
*(.text.flash_read)
*(.text.flash_read_data)
*(.text.flash_set_qe)
*(.text.flash_set_qwfr)
*(.text.flash_set_line_mode*)
*(.text.flash_get_line_mode)
*(.text.flash_write)
*(.text.flash_ctrl)
*(.text.power_save_dtim_wake)
*(.text.sctrl_fix_dpll_div)
} > itcm AT>flash
_itcmcode_flash_begin = LOADADDR(.itcm.code);
_itcmcode_ram_begin = ADDR(.itcm.code);
@@ -85,74 +101,43 @@ SECTIONS
.zInit :
{
__zinitcall_bsp_start = .;
KEEP (*(.zinitcall.bsp0.init))
KEEP (*(.zinitcall.bsp1.init))
KEEP (*(.zinitcall.bsp2.init))
KEEP (*(.zinitcall.bsp3.init))
KEEP (*(.zinitcall.bsp4.init))
KEEP(*(SORT(.zinitcall.bsp*)))
__zinitcall_bsp_end = .;
__zinitcall_device_start = .;
KEEP (*(.zinitcall.device0.init))
KEEP (*(.zinitcall.device1.init))
KEEP (*(.zinitcall.device2.init))
KEEP (*(.zinitcall.device3.init))
KEEP (*(.zinitcall.device4.init))
__zinitcall_device_start = .;
KEEP(*(SORT(.zinitcall.device*)))
__zinitcall_device_end = .;
__zinitcall_core_start = .;
KEEP (*(.zinitcall.core0.init))
KEEP (*(.zinitcall.core1.init))
KEEP (*(.zinitcall.core2.init))
KEEP (*(.zinitcall.core3.init))
KEEP (*(.zinitcall.core4.init))
KEEP(*(SORT(.zinitcall.core*)))
__zinitcall_core_end = .;
__zinitcall_sys_service_start = .;
KEEP (*(.zinitcall.sys.service0.init))
KEEP (*(.zinitcall.sys.service1.init))
KEEP (*(.zinitcall.sys.service2.init))
KEEP (*(.zinitcall.sys.service3.init))
KEEP (*(.zinitcall.sys.service4.init))
KEEP(*(SORT(.zinitcall.sys.service*)))
__zinitcall_sys_service_end = .;
__zinitcall_sys_feature_start = .;
KEEP (*(.zinitcall.sys.feature0.init))
KEEP (*(.zinitcall.sys.feature1.init))
KEEP (*(.zinitcall.sys.feature2.init))
KEEP (*(.zinitcall.sys.feature3.init))
KEEP (*(.zinitcall.sys.feature4.init))
KEEP(*(SORT(.zinitcall.sys.feature*)))
__zinitcall_sys_feature_end = .;
__zinitcall_run_start = .;
KEEP (*(.zinitcall.run0.init))
KEEP (*(.zinitcall.run1.init))
KEEP (*(.zinitcall.run2.init))
KEEP (*(.zinitcall.run3.init))
KEEP (*(.zinitcall.run4.init))
KEEP(*(SORT(.zinitcall.run*)))
__zinitcall_run_end = .;
__zinitcall_app_service_start = .;
KEEP (*(.zinitcall.app.service0.init))
KEEP (*(.zinitcall.app.service1.init))
KEEP (*(.zinitcall.app.service2.init))
KEEP (*(.zinitcall.app.service3.init))
KEEP (*(.zinitcall.app.service4.init))
KEEP(*(SORT(.zinitcall.app.service*)))
__zinitcall_app_service_end = .;
__zinitcall_app_feature_start = .;
KEEP (*(.zinitcall.app.feature0.init))
KEEP (*(.zinitcall.app.feature1.init))
KEEP (*(.zinitcall.app.feature2.init))
KEEP (*(.zinitcall.app.feature3.init))
KEEP (*(.zinitcall.app.feature4.init))
KEEP(*(SORT(.zinitcall.app.feature*)))
__zinitcall_app_feature_end = .;
__zinitcall_test_start = .;
KEEP (*(.zinitcall.test0.init))
KEEP (*(.zinitcall.test1.init))
KEEP (*(.zinitcall.test2.init))
KEEP (*(.zinitcall.test3.init))
KEEP (*(.zinitcall.test4.init))
KEEP(*(SORT(.zinitcall.test*)))
__zinitcall_test_end = .;
__zinitcall_exit_start = .;
KEEP (*(.zinitcall.exit0.init))
KEEP (*(.zinitcall.exit1.init))
KEEP (*(.zinitcall.exit2.init))
KEEP (*(.zinitcall.exit3.init))
KEEP (*(.zinitcall.exit4.init))
KEEP(*(SORT(.zinitcall.exit*)))
__zinitcall_exit_end = .;
} > flash
@@ -354,7 +339,7 @@ SECTIONS
*raw.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*netif.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
/* *memp.o(.bss .bss.* .scommon .sbss .dynbss COMMON) */
/* *mem.o(.bss .bss.* .scommon .sbss .dynbss COMMON) */
*mem.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*ip4.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*ip4_addr.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*igmp.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
@@ -371,7 +356,10 @@ SECTIONS
*tasks.marm.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*heap_4.marm.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*timers.marm.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*los_sched.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*los_swtmr.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*los_memory.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
*los_task.o(.bss .bss.* .scommon .sbss .dynbss COMMON)
} >tcm AT>flash
_tcmbss_start = ADDR(.tcm);
_tcmbss_end = _tcmbss_start + SIZEOF(.tcm);
@@ -2,7 +2,7 @@
kernel_type = "liteos_m"
# Kernel version.
kernel_version = ""
kernel_version = "0.2.x.n"
# Board CPU type, e.g. "cortex-a7", "riscv32".
board_cpu = ""
@@ -49,6 +49,7 @@ board_include_dirs = [
"${ohos_root_path}kernel/liteos_m/kal/cmsis",
"${ohos_root_path}kernel/liteos_m/utils",
"${ohos_root_path}kernel/liteos_m/components/cpup",
"${ohos_root_path}kernel/liteos_m/components/power",
"${ohos_root_path}kernel/liteos_m/kernel/include",
"${ohos_root_path}kernel/liteos_m/kernel/arch/include",
"${ohos_root_path}kernel/liteos_m/kernel/arch/arm/arm9/gcc",
Binary file not shown.
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
import("//build/lite/config/component/lite_component.gni")
lite_component("ohos") {
features = [ ":ohos_entry" ]
}
static_library("ohos_entry") {
sources = [
"ohos_entry.c",
]
deps = [
"${beken_sdk_dir}/os/liteos_m/kal:kal",
]
include_dirs = [
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
"//foundation/distributedschedule/samgr_lite/interfaces/kits/communication/broadcast",
"//foundation/distributedschedule/samgr_lite/samgr/adapter",
"//foundation/distributedschedule/samgr_lite/samgr/source",
"//foundation/communication/wifi_lite/interfaces/wifiservice",
]
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+27
View File
@@ -0,0 +1,27 @@
import("//build/lite/config/component/lite_component.gni")
import("//build/lite/config/subsystem/lite_subsystem.gni")
declare_args() {
}
lite_subsystem("bk_sdk") {
subsystem_components = [ ":cjson" ]
}
lite_component("cjson") {
features = []
deps = [
"//build/lite/config/component/cJSON:cjson_static",
]
}
build_ext_component("build_bk7231u_sdk") {
exec_path = rebase_path(".", root_build_dir)
outdir = rebase_path(root_out_dir)
command = "sh build_sdk.sh $outdir"
deps = [
"//build/lite:ohos",
"ohos"
]
}
+136
View File
@@ -0,0 +1,136 @@
LITEOSTOPDIR := ../../../../kernel/liteos_m/
LITEOSTOPDIR := $(realpath $(LITEOSTOPDIR))
C_INCLUDES = -I$(LITEOSTOPDIR)/utils \
-I$(LITEOSTOPDIR)/kal/cmsis \
-I$(LITEOSTOPDIR)/kernel/include \
-I$(LITEOSTOPDIR)/components/cpup \
-I$(LITEOSTOPDIR)/../../third_party/bounds_checking_function/include
C_INCLUDES += -I$(LITEOSTOPDIR)/kernel/arch/include \
-I$(LITEOSTOPDIR)/kernel/arch/arm/arm9/gcc
C_INCLUDES += -I$(LITEOSTOPDIR)/targets/bk7231
BUILD_DIR = build
OUTPUT_DST_DIR ?= ../../../../out/bk7231/wifi_iot
C_SOURCES =
#C_SOURCES += ohos/ohos_entry.c ohos/printf.c
#C_SOURCES += ohos/printf.c
EXTRA_LIBS_DIR = extra_libs
EXTRA_LIBS = $(shell ./get_libs.sh $(EXTRA_LIBS_DIR))
EXTRA_DEP1 = $(shell ls $(EXTRA_LIBS_DIR))
EXTRA_DEP = $(addprefix $(EXTRA_LIBS_DIR)/, $(EXTRA_DEP1))
SDK_LIBS_DIR = sdk_libs
SDK_LIBS = $(shell ./get_libs.sh $(SDK_LIBS_DIR))
SDK_DEP1 = $(shell ls $(SDK_LIBS_DIR))
SDK_DEP = $(addprefix $(SDK_LIBS_DIR)/, $(SDK_DEP1))
OHOS_LIBS = $(shell ./get_libs.sh $(OUTPUT_DST_DIR)/libs)
OHOS_DEP1 = $(shell ls $(OUTPUT_DST_DIR)/libs)
OHOS_DEP = $(addprefix $(OUTPUT_DST_DIR)/libs/, $(OHOS_DEP1))
SDK_OBJS_DIR = sdk_objs
SDK_OBJS1 = $(shell ls $(SDK_OBJS_DIR))
#SDK_OBJS =
SDK_OBJS = $(addprefix $(SDK_OBJS_DIR)/, $(SDK_OBJS1))
LIBS =
#LIBS += -L$(SDK_LIBS_DIR) -lbk7231_sdk $(SDK_LIBS) -lbk7231_sdk
LIBS += -L$(OUTPUT_DST_DIR)/libs
LIBS += -Wl,--whole-archive $(OHOS_LIBS) -Wl,--no-whole-archive
LIBS += -L$(SDK_LIBS_DIR) -L$(EXTRA_LIBS_DIR) $(SDK_LIBS) $(EXTRA_LIBS) $(SDK_LIBS) $(EXTRA_LIBS)
#LIBS += -lgcc
PREFIX = arm-none-eabi-
CFLAGS = $(C_INCLUDES)
CFLAGS += -g -mcpu=arm968e-s -march=armv5te -marm -mthumb-interwork -mlittle-endian -Os -std=c99 -ffunction-sections -Wall -Wno-format -Wno-unknown-pragmas -fsigned-char -fdata-sections -fno-strict-aliasing
LINK_FLAGS =
LINK_FLAGS += -g -Wl,--gc-sections -marm -mthumb-interwork -mcpu=arm968e-s
EXTRA_FLAGS =
EXTRA_FLAGS += -Wl,-wrap,printf -Wl,-wrap,vsnprintf -Wl,-wrap,snprintf -Wl,-wrap,sprintf -Wl,-wrap,puts
#EXTRA_FLAGS += -Wl,-wrap,malloc -Wl,-wrap,_malloc_r -Wl,-wrap,free -Wl,-wrap,_free_r -Wl,-wrap,zalloc -Wl,-wrap,calloc -Wl,-wrap,realloc -Wl,-wrap,_realloc_r
EXTRA_FLAGS += -Wl,-wrap,malloc -Wl,-wrap,free -Wl,-wrap,zalloc -Wl,-wrap,calloc -Wl,-wrap,realloc
CC = $(PREFIX)gcc
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
SZ = $(PREFIX)size
AR = $(PREFIX)ar
OBJDUMP = $(PREFIX)objdump
BIN = $(CP) -O binary -S
ENCRYPT = ./encrypt
ENCRYPT_FLAG = 0 0 0 0
LDSCRIPT = bk7231.ld
#keep sync with build_sdk.sh
TARGET = bk7231_sdk
MAP_FILE = $(TARGET).map
LDSCRIPT_OTA = bk7231_ota.ld
#keep sync with pack.json
TARGET_OTA = bk7231_ota
MAP_FILE_OTA = $(TARGET_OTA).map
OBJECTS =
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
.PHONY: all
#all: $(BUILD_DIR)/$(TARGET).bin
all: $(BUILD_DIR)/$(TARGET).bin $(BUILD_DIR)/$(TARGET_OTA).bin
$(BUILD_DIR)/$(TARGET).bin : $(BUILD_DIR)/$(TARGET).elf
$(BIN) $< $@
$(OBJDUMP) -d $< > $(BUILD_DIR)/$(TARGET).asm
$(ENCRYPT) $@ $(ENCRYPT_FLAG)
@echo please burn the file : $(BUILD_DIR)/$(TARGET)_crc.bin
$(BUILD_DIR)/$(TARGET).elf : $(OBJECTS) $(SDK_OBJS_DIR)/arch_main.o $(OHOS_DEP) $(SDK_DEP) $(EXTRA_DEP)
@echo "building bk7231 sdk..."
$(CC) $(OBJECTS) $(SDK_OBJS) $(EXTRA_FLAGS) -specs=nano.specs -T$(LDSCRIPT) $(LIBS) $(LINK_FLAGS) -Xlinker -Map=$(BUILD_DIR)/$(MAP_FILE) -o $@
$(BUILD_DIR)/$(TARGET_OTA).bin : $(BUILD_DIR)/$(TARGET_OTA).elf
$(BIN) $< $@
$(OBJDUMP) -d $< > $(BUILD_DIR)/$(TARGET_OTA).asm
(cd $(BUILD_DIR) && ../beken_packager ../pack.json )
$(BUILD_DIR)/$(TARGET_OTA).elf : $(OBJECTS) $(SDK_OBJS_DIR)/arch_main.o $(OHOS_DEP) $(SDK_DEP) $(EXTRA_DEP)
$(CC) $(OBJECTS) $(SDK_OBJS) $(EXTRA_FLAGS) -specs=nano.specs -T$(LDSCRIPT_OTA) $(LIBS) $(LINK_FLAGS) -Xlinker -Map=$(BUILD_DIR)/$(MAP_FILE_OTA) -o $@
$(SDK_OBJS_DIR)/arch_main.o : $(SDK_LIBS_DIR)/libbk7231_sdk.a
@echo "uppack libbk7231_sdk.a..."
rm -rf $(SDK_OBJS_DIR)
mkdir $(SDK_OBJS_DIR)
cd $(SDK_OBJS_DIR) && $(AR) -x ../$(SDK_LIBS_DIR)/libbk7231_sdk.a
$(SDK_LIBS_DIR)/libbk7231_sdk.a : ../../bk72xx_liteosm_sdk/sdk_libs/libbk7231_sdk.a
@echo "update libbk7231_sdk.a..."
rm -rf $(SDK_LIBS_DIR)
cp -r ../../bk72xx_liteosm_sdk/sdk_libs ./
../../bk72xx_liteosm_sdk/sdk_libs/libbk7231_sdk.a :
@echo "compile libbk7231_sdk.a..."
cd ../../bk72xx_liteosm_sdk && make bk7231u OHOS=1
$(BUILD_DIR)/%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
$(BUILD_DIR):
mkdir $@
clean:
-rm -fR $(BUILD_DIR)
mkdir $(BUILD_DIR)
+168
View File
@@ -0,0 +1,168 @@
/*
* Script for GNU linker.
* Describes layout of sections, location of stack.
*
* In this case vectors are at location 0 (reset @ 0x08)
*
* +------------+ 0x00400020
* data |
* end
* |(heap) |
* . .
* . .
* |(heap limit)|
*
* |- - - - - - |
* stack bottom 256k
* +------------+
*
* +------------+ 0x0000000
* |vectors |
* | |
* |------------+
* |text |
* |data |
* | | 1024k
* +------------+
*/
/* Split memory into area for vectors and ram */
MEMORY
{
flash (rx) : ORIGIN = 0x00000000, LENGTH = 2M
ram (rw!x): ORIGIN = 0x00400100, LENGTH = 256k - 0x100
}
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_vector_start);
_vector_start = ORIGIN(flash);
SECTIONS
{
/* vectors go to vectors region */
. = ORIGIN(flash);
.vectors :
{
KEEP(*(*.vectors))
KEEP( *(*.boot))
} > flash
/* instructions go to the text region*/
. = ALIGN(0x8);
/* code, instructions.for example: i=i+1; */
.text :
{
*(.text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7t) *(.glue_7)
} > flash
.zInit :
{
__zinitcall_bsp_start = .;
KEEP(*(SORT(.zinitcall.bsp*)))
__zinitcall_bsp_end = .;
__zinitcall_device_start = .;
KEEP(*(SORT(.zinitcall.device*)))
__zinitcall_device_end = .;
__zinitcall_core_start = .;
KEEP(*(SORT(.zinitcall.core*)))
__zinitcall_core_end = .;
__zinitcall_sys_service_start = .;
KEEP(*(SORT(.zinitcall.sys.service*)))
__zinitcall_sys_service_end = .;
__zinitcall_sys_feature_start = .;
KEEP(*(SORT(.zinitcall.sys.feature*)))
__zinitcall_sys_feature_end = .;
__zinitcall_run_start = .;
KEEP(*(SORT(.zinitcall.run*)))
__zinitcall_run_end = .;
__zinitcall_app_service_start = .;
KEEP(*(SORT(.zinitcall.app.service*)))
__zinitcall_app_service_end = .;
__zinitcall_app_feature_start = .;
KEEP(*(SORT(.zinitcall.app.feature*)))
__zinitcall_app_feature_end = .;
__zinitcall_test_start = .;
KEEP(*(SORT(.zinitcall.test*)))
__zinitcall_test_end = .;
__zinitcall_exit_start = .;
KEEP(*(SORT(.zinitcall.exit*)))
__zinitcall_exit_end = .;
} > flash
/* read only data.for example: const int rom_data[3]={1,2,3}; */
.rodata ALIGN(8) :
{
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r*)
} > flash
.ARM.exidx :
{
*(.ARM.exidx*)
*(.gnu.linkonce.armexidx.*)
} > flash
/* globals.for example: int ram_data[3]={4,5,6}; */ /* VMA in RAM, but keep LMA in flash */
_begin_data = .;
.data : AT ( _begin_data )
{
*(.data .data.*)
*(.sdata)
*(.gnu.linkonce.d*)
SORT(CONSTRUCTORS)
} >ram
/* Loader will copy data from _flash_begin to _ram_begin..ram_end */
_data_flash_begin = LOADADDR(.data);
_data_ram_begin = ADDR(.data);
_data_ram_end = .;
/* uninitialized data section - global int i; */
.bss ALIGN(8):
{
_bss_start = .;
*boot_handlers.O(.bss .bss.* .scommon .sbss .dynbss COMMON)
*(.bss .bss.*)
*(.scommon)
*(.sbss)
*(.dynbss)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(32 / 8);
_bss_end = .;
} > ram /* in RAM */
. = ALIGN (8);
_empty_ram = .;
/* This symbol defines end of code/data sections. Heap starts here. */
PROVIDE(end = .);
}
GROUP(
libgcc.a
libg.a
libc.a
libm.a
libnosys.a
)
+168
View File
@@ -0,0 +1,168 @@
/*
* Script for GNU linker.
* Describes layout of sections, location of stack.
*
* In this case vectors are at location 0 (reset @ 0x08)
*
* +------------+ 0x00400020
* data |
* end
* |(heap) |
* . .
* . .
* |(heap limit)|
*
* |- - - - - - |
* stack bottom 256k
* +------------+
*
* +------------+ 0x0000000
* |vectors |
* | |
* |------------+
* |text |
* |data |
* | | 1024k
* +------------+
*/
/* Split memory into area for vectors and ram */
MEMORY
{
flash (rx) : ORIGIN = 0x00010000, LENGTH = 1912K
ram (rw!x): ORIGIN = 0x00400100, LENGTH = 256k - 0x100
}
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_vector_start);
_vector_start = ORIGIN(flash);
SECTIONS
{
/* vectors go to vectors region */
. = ORIGIN(flash);
.vectors :
{
KEEP(*(*.vectors))
KEEP( *(*.boot))
} > flash
/* instructions go to the text region*/
. = ALIGN(0x8);
/* code, instructions.for example: i=i+1; */
.text :
{
*(.text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7t) *(.glue_7)
} > flash
.zInit :
{
__zinitcall_bsp_start = .;
KEEP(*(SORT(.zinitcall.bsp*)))
__zinitcall_bsp_end = .;
__zinitcall_device_start = .;
KEEP(*(SORT(.zinitcall.device*)))
__zinitcall_device_end = .;
__zinitcall_core_start = .;
KEEP(*(SORT(.zinitcall.core*)))
__zinitcall_core_end = .;
__zinitcall_sys_service_start = .;
KEEP(*(SORT(.zinitcall.sys.service*)))
__zinitcall_sys_service_end = .;
__zinitcall_sys_feature_start = .;
KEEP(*(SORT(.zinitcall.sys.feature*)))
__zinitcall_sys_feature_end = .;
__zinitcall_run_start = .;
KEEP(*(SORT(.zinitcall.run*)))
__zinitcall_run_end = .;
__zinitcall_app_service_start = .;
KEEP(*(SORT(.zinitcall.app.service*)))
__zinitcall_app_service_end = .;
__zinitcall_app_feature_start = .;
KEEP(*(SORT(.zinitcall.app.feature*)))
__zinitcall_app_feature_end = .;
__zinitcall_test_start = .;
KEEP(*(SORT(.zinitcall.test*)))
__zinitcall_test_end = .;
__zinitcall_exit_start = .;
KEEP(*(SORT(.zinitcall.exit*)))
__zinitcall_exit_end = .;
} > flash
/* read only data.for example: const int rom_data[3]={1,2,3}; */
.rodata ALIGN(8) :
{
*(.rodata)
*(.rodata.*)
*(.gnu.linkonce.r*)
} > flash
.ARM.exidx :
{
*(.ARM.exidx*)
*(.gnu.linkonce.armexidx.*)
} > flash
/* globals.for example: int ram_data[3]={4,5,6}; */ /* VMA in RAM, but keep LMA in flash */
_begin_data = .;
.data : AT ( _begin_data )
{
*(.data .data.*)
*(.sdata)
*(.gnu.linkonce.d*)
SORT(CONSTRUCTORS)
} >ram
/* Loader will copy data from _flash_begin to _ram_begin..ram_end */
_data_flash_begin = LOADADDR(.data);
_data_ram_begin = ADDR(.data);
_data_ram_end = .;
/* uninitialized data section - global int i; */
.bss ALIGN(8):
{
_bss_start = .;
*boot_handlers.O(.bss .bss.* .scommon .sbss .dynbss COMMON)
*(.bss .bss.*)
*(.scommon)
*(.sbss)
*(.dynbss)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(32 / 8);
_bss_end = .;
} > ram /* in RAM */
. = ALIGN (8);
_empty_ram = .;
/* This symbol defines end of code/data sections. Heap starts here. */
PROVIDE(end = .);
}
GROUP(
libgcc.a
libg.a
libc.a
libm.a
libnosys.a
)
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
set -e
OUTPUT_DST_DIR=$1
export OUTPUT_DST_DIR
echo "begin sdk build..."
#cp empty_bk7231_sdk.bin $OUTPUT_DST_DIR/bk7231_sdk.bin
if [ ! -d build ]; then
mkdir build
fi
make -f Makefile all
cp build/bk7231_ota_uart_2M.1220.bin $OUTPUT_DST_DIR/bk7231u_sdk_uart.bin
if [ -f build/all_2M.1220.bin ]; then
cp build/all_2M.1220.bin $OUTPUT_DST_DIR/bk7231u_sdk_ota.bin
fi
echo "finsh sdk build."
+80
View File
@@ -0,0 +1,80 @@
# Kernel type, e.g. "linux", "liteos_a", "liteos_m".
kernel_type = "liteos_m"
# Kernel version.
kernel_version = "0.2.x"
# Board CPU type, e.g. "cortex-a7", "riscv32".
board_cpu = ""
# Board arch, e.g. "armv7-a", "rv32imac".
board_arch = "armv5te"
# Toolchain name used for system compiling.
# E.g. gcc-arm-none-eabi, arm-linux-harmonyeabi-gcc, ohos-clang, riscv32-unknown-elf.
# Note: The default toolchain is "ohos-clang". It's not mandatory if you use the default toochain.
board_toolchain = "arm-none-eabi"
# The toolchain path instatlled, it's not mandatory if you have added toolchian path to your ~/.bashrc.
board_toolchain_path = ""
# Compiler prefix.
board_toolchain_prefix = "arm-none-eabi-"
# Compiler type, "gcc" or "clang".
board_toolchain_type = "gcc"
# Board related common compile flags.
board_cflags = [
"-marm",
"-mcpu=arm968e-s",
"-mthumb-interwork",
"-mlittle-endian",
"-ffunction-sections",
"-fdata-sections",
"-D__LITEOS__",
"-DCFG_SUPPORT_LITEOS",
]
board_cxx_flags = board_cflags
board_ld_flags = []
beken_sdk_dir = "${ohos_root_path}/device/bk_corp/bk72xx_liteosm_sdk"
# Board related headfiles search path.
board_include_dirs = [
"${ohos_root_path}utils/native/lite/include",
"${ohos_root_path}third_party/bounds_checking_function/include",
"${beken_sdk_dir}/config",
"${ohos_root_path}kernel/liteos_m/config",
"${ohos_root_path}kernel/liteos_m/kal/cmsis",
"${ohos_root_path}kernel/liteos_m/utils",
"${ohos_root_path}kernel/liteos_m/components/cpup",
"${ohos_root_path}kernel/liteos_m/components/power",
"${ohos_root_path}kernel/liteos_m/kernel/include",
"${ohos_root_path}kernel/liteos_m/kernel/arch/include",
"${ohos_root_path}kernel/liteos_m/kernel/arch/arm/arm9/gcc",
"${ohos_root_path}kernel/liteos_m/targets/bk7231",
"${beken_sdk_dir}/beken378/func/lwip_intf/lwip-2.0.2/src/include",
"${beken_sdk_dir}/beken378/func/lwip_intf/lwip-2.0.2/port",
"${beken_sdk_dir}/beken378/os/include",
"${beken_sdk_dir}/beken378/driver/include",
"${beken_sdk_dir}/beken378/func/user_driver",
"${beken_sdk_dir}/os/liteos_m/port",
"${beken_sdk_dir}/beken378/ip/common",
"${beken_sdk_dir}/beken378/driver/entry",
"${beken_sdk_dir}/beken378/release",
"${beken_sdk_dir}/beken378/driver/common",
"${beken_sdk_dir}/beken378/common",
"${beken_sdk_dir}/os/liteos_m/kal/posix/include",
"${beken_sdk_dir}/beken378/func/include",
]
# Board adapter dir for OHOS components.
board_adapter_dir = "${ohos_root_path}device/bk_corp/bk7231/bk7231u_sdk"
# Sysroot path.
board_configed_sysroot = ""
# Board storage type, it used for file system generation.
storage_type = ""
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/sh
if [ $# != 1 ]; then
echo "no dir param"
exit 1
fi
SDK_LIBS_DIR=$1
SDK_LIBS=$(ls $SDK_LIBS_DIR)
#SDK_LIBS=$(basename $SDK_LIBS)
RESULT=$(echo $SDK_LIBS | sed 's/libbk7231_sdk.a//' | sed 's/\.a//g' | sed 's/lib/-l/g')
echo $RESULT
+22
View File
@@ -0,0 +1,22 @@
import("//build/lite/config/component/lite_component.gni")
lite_component("ohos") {
features = [ ":ohos_entry" ]
}
static_library("ohos_entry") {
sources = [
"ohos_entry.c",
]
deps = [
"${beken_sdk_dir}/os/liteos_m/kal:kal",
]
include_dirs = [
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
"//foundation/distributedschedule/samgr_lite/interfaces/kits/communication/broadcast",
"//foundation/distributedschedule/samgr_lite/samgr/adapter",
"//foundation/distributedschedule/samgr_lite/samgr/source",
"//foundation/communication/wifi_lite/interfaces/wifiservice",
]
}
+144
View File
@@ -0,0 +1,144 @@
/*
* Copyright (c) 2020 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef LITE_CORE_MAIN_H
#define LITE_CORE_MAIN_H
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
#define SYS_NAME(name, step) ".zinitcall.sys." #name #step ".init"
#define MODULE_NAME(name, step) ".zinitcall." #name #step ".init"
#define SYS_CALL(name, step) \
do { \
InitCall *initcall = (InitCall *)(SYS_BEGIN(name, step)); \
InitCall *initend = (InitCall *)(SYS_END(name, step)); \
for (; initcall < initend; initcall++) { \
(*initcall)(); \
} \
} while (0)
#define MODULE_CALL(name, step) \
do { \
InitCall *initcall = (InitCall *)(MODULE_BEGIN(name, step)); \
InitCall *initend = (InitCall *)(MODULE_END(name, step)); \
for (; initcall < initend; initcall++) { \
(*initcall)(); \
} \
} while (0)
#if (defined(__GNUC__) || defined(__clang__))
#define SYS_BEGIN(name, step) \
({ extern InitCall __zinitcall_sys_##name##_start; \
InitCall *initCall = &__zinitcall_sys_##name##_start; \
(initCall); \
})
#define SYS_END(name, step) \
({ extern InitCall __zinitcall_sys_##name##_end; \
InitCall *initCall = &__zinitcall_sys_##name##_end; \
(initCall); \
})
#define MODULE_BEGIN(name, step) \
({ extern InitCall __zinitcall_##name##_start; \
InitCall *initCall = &__zinitcall_##name##_start; \
(initCall); \
})
#define MODULE_END(name, step) \
({ extern InitCall __zinitcall_##name##_end; \
InitCall *initCall = &__zinitcall_##name##_end; \
(initCall); \
})
#define SYS_INIT(name) \
do { \
SYS_CALL(name, 0); \
} while (0)
#define MODULE_INIT(name) \
do { \
MODULE_CALL(name, 0); \
} while (0)
#elif (defined(__ICCARM__))
#define SYS_BEGIN(name, step) __section_begin(SYS_NAME(name, step))
#define SYS_END(name, step) __section_end(SYS_NAME(name, step))
#define MODULE_BEGIN(name, step) __section_begin(MODULE_NAME(name, step))
#define MODULE_END(name, step) __section_end(MODULE_NAME(name, step))
#pragma section = SYS_NAME(service, 0)
#pragma section = SYS_NAME(service, 1)
#pragma section = SYS_NAME(service, 2)
#pragma section = SYS_NAME(service, 3)
#pragma section = SYS_NAME(service, 4)
#pragma section = SYS_NAME(feature, 0)
#pragma section = SYS_NAME(feature, 1)
#pragma section = SYS_NAME(feature, 2)
#pragma section = SYS_NAME(feature, 3)
#pragma section = SYS_NAME(feature, 4)
#pragma section = MODULE_NAME(bsp, 0)
#pragma section = MODULE_NAME(bsp, 1)
#pragma section = MODULE_NAME(bsp, 2)
#pragma section = MODULE_NAME(bsp, 3)
#pragma section = MODULE_NAME(bsp, 4)
#pragma section = MODULE_NAME(device, 0)
#pragma section = MODULE_NAME(device, 1)
#pragma section = MODULE_NAME(device, 2)
#pragma section = MODULE_NAME(device, 3)
#pragma section = MODULE_NAME(device, 4)
#pragma section = MODULE_NAME(core, 0)
#pragma section = MODULE_NAME(core, 1)
#pragma section = MODULE_NAME(core, 2)
#pragma section = MODULE_NAME(core, 3)
#pragma section = MODULE_NAME(core, 4)
#pragma section = MODULE_NAME(run, 0)
#pragma section = MODULE_NAME(run, 1)
#pragma section = MODULE_NAME(run, 2)
#pragma section = MODULE_NAME(run, 3)
#pragma section = MODULE_NAME(run, 4)
#define SYS_INIT(name) \
do { \
SYS_CALL(name, 0); \
SYS_CALL(name, 1); \
SYS_CALL(name, 2); \
SYS_CALL(name, 3); \
SYS_CALL(name, 4); \
} while (0)
#define MODULE_INIT(name) \
do { \
MODULE_CALL(name, 0); \
MODULE_CALL(name, 1); \
MODULE_CALL(name, 2); \
MODULE_CALL(name, 3); \
MODULE_CALL(name, 4); \
} while (0)
#else
#error Not support current compiler!
#endif
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif // LITE_CORE_MAIN_H
+50
View File
@@ -0,0 +1,50 @@
#include <stdio.h>
//#include "los_context.h"
//#include "los_task.h"
#include "core_main.h"
#include <ohos_init.h>
#include <samgr_lite.h>
#include "cmsis_os2.h"
#include "libc.h"
extern int wif_test_task(void);
#if 1
unsigned int __stack_chk_guard = 0xd00a0dff;
void __stack_chk_fail(VOID)
{
printf("here you go!!!\n");
LOS_Panic("stack-protector: Kernel stack is corrupted in: %p\n",
__builtin_return_address(0));
}
#endif
const char * const FUN_ARG_S = "0123456I";
void HiLogPrintf(uint8 module, uint8 level, const char *nums, const char *fmt, ...)
{
}
void OHOS_SystemInit(void)
{
printf("@-OHOS-@ for bk7231u\n");
printf("libc : %s\n", libc_get_version_string());
MODULE_INIT(bsp);
MODULE_INIT(device);
MODULE_INIT(core);
SYS_INIT(service);
SYS_INIT(feature);
MODULE_INIT(app_service);
MODULE_INIT(app_feature);
MODULE_INIT(run);
SAMGR_Bootstrap();
printf("OHOS_SystemInit ok\n");
return;
}
+21
View File
@@ -0,0 +1,21 @@
{
"count": 2,
"magic": "RT-Thread",
"section": [
{
"firmware": "../bootloader_bk7231u_uart2_v1.0.8.bin",
"partition": "bootloader",
"size": "65280",
"start_addr": "0x00000000",
"version": "2M.1220"
},
{
"firmware": "bk7231_ota.bin",
"partition": "app",
"size": "1156K",
"start_addr": "0x00011000",
"version": "2M.1220"
}
],
"version": "0.1"
}
+1
View File
@@ -0,0 +1 @@
../../../../third_party
+22
View File
@@ -0,0 +1,22 @@
.gdbinit
.settings/language.settings.xml
.settings/org.eclipse.cdt.managedbuilder.core.prefs
[dD]ebug
si
*.si4project
*.bak
# source sight project files
*.IAB
*.IAD
*.IMB
*.IMD
*.PFI
*.PO
*.PR
*.PRI
*.PS
*.SearchResults
*.WK3
.config
+55
View File
@@ -0,0 +1,55 @@
stages:
- build
- test
build1:
stage: build
script:
- echo "***********************start building***********************"
- echo $CI_COMMIT_BRANCH
- cd /home/gitlab-runner/build
- ./make_utd_builds.sh $CI_COMMIT_BRANCH $CI_PROJECT_NAME
- echo "***********************start burning***********************"
- cp -rf /home/gitlab-runner/build/up_to_date_builds/out_builds/ /home/gitlab-runner/version/$CI_COMMIT_SHA/
- python3 ./flash.py
- echo "***********************test prepare***********************"
- cd /home/gitlab-runner/Documents/AutoTest/config
- python3 ./config.py -b $CI_COMMIT_BRANCH -o $CI_PROJECT_NAME
rules:
- if: '$CI_COMMIT_BRANCH =~ /^.*3\.0\..*/ || $CI_COMMIT_BRANCH =~ /^.*3\.1\..*/ || $CI_COMMIT_BRANCH == "master"'
when: always
- when: never
test_sta:
stage: test
script:
- echo "***********************STA TEST START***********************"
- cd /home/gitlab-runner/Documents/AutoTest/Testcases
- python3 ./CI_TEST_STA.py
rules:
- if: '$CI_COMMIT_BRANCH =~ /^.*3\.0\..*/ || $CI_COMMIT_BRANCH =~ /^.*3\.1\..*/ || $CI_COMMIT_BRANCH == "master"'
when: always
- when: never
test_ap:
stage: test
script:
- echo "***********************AP TEST START***********************"
- cd /home/gitlab-runner/Documents/AutoTest/Testcases
- python3 ./CI_TEST_AP.py
rules:
- if: '$CI_COMMIT_BRANCH =~ /^.*3\.0\..*/ || $CI_COMMIT_BRANCH =~ /^.*3\.1\..*/ || $CI_COMMIT_BRANCH == "master"'
when: always
- when: never
test_BLE:
stage: test
script:
- echo "***********************BLE TEST START***********************"
- cd /home/gitlab-runner/Documents/AutoTest/Testcases
- python3 ./CI_TEST_BLE.py
rules:
- if: '$CI_COMMIT_BRANCH =~ /^.*3\.0\..*/ || $CI_COMMIT_BRANCH =~ /^.*3\.1\..*/ || $CI_COMMIT_BRANCH == "master"'
when: always
- when: never
+3
View File
@@ -0,0 +1,3 @@
[submodule "beken378"]
path = beken378
url = ../beken_wifi_sdk.git
+1 -1
View File
@@ -127,4 +127,4 @@ ramdebug: toolchain
%:
@$(ECHO) "Build for $(GREEN)$@$(NC)..."
@$(call update_sys_config_if_needed, $@)
@$(MAKE) -f application.mk application
@$(MAKE) -f application.mk application OHOS=$(OHOS)
+274
View File
@@ -0,0 +1,274 @@
# bk7231_freertos_full_code
## 当前repository中submodule所在分支
| submodule | branch |
| --------- | ------ |
| beken378 | master |
> clone代码后,需执行如下命令:
```shell
cd beken378
git checkout master
```
> 如果不确定submodule所在分支,可用如下命令查找并手动确认
```shell
cd beken378
git branch -r --contains CommitID
```
## 代码管理策略
随着项目的日益增多,决定使用`submodule+branch`的方式来管理
1. 每类项目单独创建一个`repository`
2. 同类项目用分支区分不同产品、不同代理商、不同客户
3. `beken378`使用`submodule`关联,`beken378`包含协议栈源码,相当于`fullcode`,发布时可使用脚本自动剔除协议栈等源码
4. 在项目稳定前,可直接使用`submodule`主分支,如果`submodule`有重大功能合入,可提前创建项目分支
5. 在提交代码时,不同目的的修改分开提交,便于向其它分支合入
6. 在提交代码后,如果需要将修改合入其它分支,使用`git cherry-pick commitid`
7. 在版本发布后,使用`git tag -a -m "notes" tag_name`创建标签,并用`git push --tags`提交
## submodule使用说明
### 创建submodule
1. `git submodule add http://192.168.0.6/wifi/beken_wifi_sdk.git beken378`
2. 修改`.gitmodules`中的`url`为相对路径,便于`ssh``http`同时使用
3. `git add .gitmodules beken378`
4. `git commit -m "xxx"`
注:
1. 所有`submodules`可能使用不同的分支,建议使用如下命令,指定所有`submodules`(包括主`repository`)的分支
`git branch --set-upstream-to=origin/xxx master`
### 获取submodule
> 如果使用`http`而不是`ssh`获取代码,请先运行如下命令(将用户名密码保存到本地文件中,解决`submodule`获取时无法访问的问题)
>
> `git config --global credential.helper store`
1. `git clone --recurse-submodules http://xxx.git`
或者
2. `git clone http://xxx.git`
3. `cd xxx`
4. `git submodule update --init --recursive`
### 更新submodule
可以在`repository`根目录使用`git pull --recurse-submodules`命令更新整个工程
当然也可以进入特定submodule通过`git pull`单独更新
推荐使用前者更新,因为更新后`submodules`仍然停留在主`repository`关联的`commit`,不会主动切换到最新`commit`
### 提交submodule
需要先在`submodule`中提交修改,然后在主`repository`中更新`submodule`
1. `cd beken378` (the submodle name)
2. `git add xxx`
3. `git commit -m ""`
4. `git push origin xxx:yyy`
5. cd .. (the root of repo)
6. `git add beken378`
7. `git commit -m ""`
8. `git push origin`
## Build with dynamic configure
针对目前多系统、多平台、多项目同时运行的情况,为了使用统一基线代码,制定了一种针对多种编译方式可内嵌的动态编译机制,基本原理为:编译时指定目标参数,触发配置文件生成脚本来选择相应的配置文件,随后根据所选择的配置文件编译。
编译动态配置文件如下
```
├───generate_sys_config.bat
├───generate_sys_config.sh
├───Makefile
└───config
├───sys_config_bk7231.h
├───sys_config_bk7231u.h
├───sys_config_bk7231n.h
├───sys_config_bk7251.h
└───sys_config.h
```
| 文件 | 说明 |
| --------------------- | ------------------------------------------------------------ |
| Makefile | 主编译文件 |
| generate_sys_config.* | 生成编译配置脚本,根据传入配置名称更新编译配置文件(sys_config.h) |
| config | 编译配置目录,包含当前所有项目的编译配置文件 |
#### Build with Makefile
针对使用Makefile的编译系统,如FreeRTOS,修改主Makefile如下:
```makefile
OS := $(shell uname)
ifeq ($(findstring MINGW32_NT, $(OS)), MINGW32_NT)
define update_sys_config_if_needed
generate_sys_config.bat $(1)
endef
else ifeq ($(findstring CYGWIN, $(OS)), CYGWIN)
define update_sys_config_if_needed
generate_sys_config.bat $(1)
endef
else
define update_sys_config_if_needed
./generate_sys_config.sh $(1)
endef
endif
%:
$(call update_sys_config_if_needed, $@)
```
用法如下:
- Install arm-gcc tool-chain and add path to system environment
- update `make.exe` in rt-thread env with `tool\make\make.exe` of project directory if you want to use parallel compiling with it
- make target [-j6]
```shell
>make help
Usage of build with Beken SDK with Makefile
ip build wifi library
ble build ble library
clean clean project
bk7231 build bk7231 default project
bk7231u build bk7231u default project
bk7231n build bk7231n default project
bk7251 build bk7251 default project
```
```shell
make bk7231u -j8
make bk7251
make bk7231 -j6
make ip
make ble
make clean
```
#### Build with Scons
针对`rt-thread`平台,更新`rt-thread/tools/building.py`支持`--beken=BEKEN_TARGET`参数, 并调用`generate_sys_config`脚本更新`sys_config.h`文件,修改如下:
```diff
diff --git a/rt-thread/tools/building.py b/rt-thread/tools/building.py
index d58160f..479b9b7 100644
--- a/rt-thread/tools/building.py
+++ b/rt-thread/tools/building.py
@@ -204,6 +204,16 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
default = False,
help = 'print verbose information during build')
+ AddOption('--beken',
+ dest = 'beken',
+ type = 'string',
+ help = 'set beken project: tuya/xindalu/etc...')
+ beken_target = GetOption('beken')
+ if sys.platform == 'win32':
+ os.system("generate_sys_config.bat " + beken_target)
+ else:
+ os.system("generate_sys_config.sh " + beken_target)
+
Env = env
Rtt_Root = os.path.abspath(root_directory)
# set RTT_ROOT in ENV
```
用法如下:
```shell
scons --beken=bk7231u -j6
```
#### Build with aos
#### Add target
当前config目录预置了4个平台的缺省配置文件,如果需要新增配置文件,修改步骤如下:
1. 在config目录中增加配置文件,名称自定义,建议为sys_config_xxx.h
2. 修改generate_sys_config.bat,定义目标名称,如:
```shell
...
if "%1" equ "xiaoya" (
set new_sys_config=config\sys_config_bk7251_xiaoya.h
goto update_sys_config
)
set new_sys_config=config\%1.h
```
3. 修改generate_sys_config.sh,同上
```shell
case $1 in
...
xiaoya)
new_sys_config=config/sys_config_bk7251_xiaoya.h
;;
*)
new_sys_config=config/$1.h
esac
```
保存上述修改,可以使用如下命令使用新增加的配置
```shell
make xiaoya -j6
```
## 版本发布
在发布版本时,`wifi/ble stack`中的代码编译以库的形式打包,然后对代码打标签并发布,方法如下
- 根据项目实际情况修改`sys_config.h`中的`CFG_SOC_NAME`,并返回项目根目录
编译库文件
- `scons --buildlib=beken_ip` 编译结束后会根据`CFG_SOC_NAME`重命名为`beken378/ip/libip72xx.a`
- `scons --buildlib=beken_ble` 编译结束后会重命名为`beken378/driver/ble/libble.a`
编译好库并提交代码以后,需要打标签,由于`submodule`本身就是以`commit id`的形式存在,无需单独打标签。
(当然,如果为了方便查找,可以用相同名称在相应代码库中打标签。)
- `git tag -a -m "" tag_name`
- `git push --tags`
运行脚本打包文件并发布
- run `release_tool.bat`
@@ -62,7 +62,10 @@ INCLUDES += -I./release
ifeq ("${CFG_SUPPORT_RTOS}", "4")
INCLUDES += -I./os/liteos_m/config/
INCLUDES += -I./os/liteos_m/components/exchook
INCLUDES += -I./os/liteos_m/components/cpup
INCLUDES += -I./os/liteos_m/components/power
INCLUDES += -I./os/liteos_m/components/port
INCLUDES += -I./os/liteos_m/components/bounds_checking_function/include/
INCLUDES += -I./os/liteos_m/kernel/include/
INCLUDES += -I./os/liteos_m/kernel/arch/include/
@@ -200,6 +203,7 @@ SRC_C += ./os/liteos_m/kernel/src/los_sortlink.c
SRC_C += ./os/liteos_m/port/rtos_pub.c
SRC_C += ./os/liteos_m/port/mem_arch.c
SRC_C += ./os/liteos_m/port/platform_stub.c
SRC_C += ./os/liteos_m/port/wifi_ui_extra.c
SRC_C += ./os/liteos_m/port/str_arch.c
SRC_OS += ./os/liteos_m/port/port.c
SRC_C += ./os/liteos_m/components/bounds_checking_function/src/fscanf_s.c
@@ -240,12 +244,14 @@ SRC_C += ./os/liteos_m/components/bounds_checking_function/src/wcsncpy_s.c
SRC_C += ./os/liteos_m/components/bounds_checking_function/src/wcstok_s.c
SRC_C += ./os/liteos_m/components/bounds_checking_function/src/wmemcpy_s.c
SRC_C += ./os/liteos_m/components/bounds_checking_function/src/wmemmove_s.c
SRC_C += ./os/liteos_m/components/bounds_checking_function/src/wscanf_s.c
SRC_C += ./os/liteos_m/components/bounds_checking_function/src/wscanf_s.c
SRC_C += ./os/liteos_m/components/power/los_pm.c
SRC_C += ./os/liteos_m/components/exchook/los_exc_info.c
SRC_C += ./os/liteos_m/utils/los_error.c
SRC_C += ./os/liteos_m/utils/los_debug.c
SRC_OS += ./os/liteos_m/kernel/arch/arm/arm9/gcc/los_context.c
SRC_C += ./os/liteos_m/kernel/arch/arm/arm9/gcc/los_interrupt.c
SRC_OS += ./os/liteos_m/kernel/arch/arm/arm9/gcc/los_interrupt.c
SRC_C += ./os/liteos_m/kernel/arch/arm/arm9/gcc/los_timer.c
SRC_C += ./os/liteos_m/targets/bk72xx/bk_los_timer.c
@@ -321,30 +327,54 @@ else ifeq ($(CFG_SOC_NAME), 5)
SOC_NAME_ELF = beken7231n.elf
SOC_NAME_BIN = beken7231n.bin
SOC_NAME_MAP = beken7231n.map
ifeq ("${CFG_SUPPORT_RTOS}", "4")
SOC_NAME_LDS = bk7231n_ohos.lds
SOC_NAME_BSP_LDS = bk7231n_bsp_ohos.lds
$(warning using-bk7231n_bsp_ohos.lds)
else
$(warning using-bk7231n_bsp.lds)
SOC_NAME_LDS = bk7231n.lds
SOC_NAME_BSP_LDS = bk7231n_bsp.lds
endif
endif
SOC_NAME_BSP_ELF = beken7231_bsp.elf
SOC_NAME_BSP_BIN = beken7231_bsp.bin
SOC_NAME_BSP_MAP = beken7231_bsp.map
# Compile options
# -------------------------------------------------------------------
# release : -Os
# debug : -O0 -gdwarf-2
# -------------------------------------------------------------------
ifeq ("${CFG_SUPPORT_RTOS}", "3")
CFLAGS = -DCFG_OS_FREERTOS=1
else ifeq ("${CFG_SUPPORT_RTOS}", "4")
CFLAGS = -DCFG_SUPPORT_LITEOS=1
CFLAGS += -g -mthumb -mcpu=arm968e-s -march=armv5te -mthumb-interwork -mlittle-endian -Os -std=c99 -ffunction-sections -Wall -Wno-format -Wno-unknown-pragmas -fsigned-char -fdata-sections -nostdlib -fno-strict-aliasing
#CFLAGS += -g -mthumb -mcpu=arm968e-s -march=armv5te -mthumb-interwork -mlittle-endian -O0 -gdwarf-2 -std=c99 -ffunction-sections -Wall -Wno-unused-function -fsigned-char -fdata-sections -Wunknown-pragmas -nostdlib -Wl,--gc-sections
endif
CFLAGS += -g -mthumb -mcpu=arm968e-s -march=armv5te -mthumb-interwork -mlittle-endian -Os -std=c99 -ffunction-sections -Wall -Werror -Wno-format -Wno-unknown-pragmas -fsigned-char -fdata-sections -nostdlib -fno-strict-aliasing
CFLAGS += -DWIFI_BLE_COEXIST
ifeq ("${CFG_MBEDTLS}", "1")
CFLAGS += -DMBEDTLS_CONFIG_FILE=\"tls_config.h\"
endif
ifeq ("${CFG_SUPPORT_RTOS}", "3")
OSFLAGS = -DCFG_OS_FREERTOS=1
else ifeq ("${CFG_SUPPORT_RTOS}", "4")
OSFLAGS = -DCFG_SUPPORT_LITEOS=1
OSFLAGS += -g -marm -mcpu=arm968e-s -march=armv5te -mthumb-interwork -mlittle-endian -O0 -std=c99 -ffunction-sections -Wall -fsigned-char -fdata-sections -Wunknown-pragmas
endif
OSFLAGS += -g -marm -mcpu=arm968e-s -march=armv5te -mthumb-interwork -mlittle-endian -Os -std=c99 -ffunction-sections -Wall -fsigned-char -fdata-sections -Wunknown-pragmas
ifeq ($(OHOS), 1)
CFLAGS += -DCFG_SUPPORT_OHOS=1
OSFLAGS += -DCFG_SUPPORT_OHOS=1
endif
ASMFLAGS =
ASMFLAGS += -g -marm -mthumb-interwork -mcpu=arm968e-s -march=armv5te -x assembler-with-cpp
#ASMFLAGS += -g -marm -mthumb-interwork -mcpu=arm968e-s -march=armv5te -x assembler-with-cpp -O0 -gdwarf-2
LFLAGS =
LFLAGS += -g -Wl,--gc-sections -marm -mcpu=arm968e-s -mthumb-interwork -nostdlib -Xlinker -Map=beken.map
@@ -370,11 +400,7 @@ RF_USE_LIB = ./beken378/lib/librf_use.a
LIBFLAGS =
LIBFLAGS += -L./beken378/lib -lrwnx -lwpa
ifeq ($(CFG_WZL_AIRKISS),1)
LIBFLAGS += -L./beken378/func/airkiss -lairkiss
endif
LIBFLAGS += -L./beken378/lib -lusb
LIBFLAGS += -L./beken378/lib -lsensor
LIBFLAGS += -L./beken378/lib -lble
@@ -386,8 +412,11 @@ LIBFLAGS += -L./beken378/lib -lrf_use
CUR_PATH = $(shell pwd)
.PHONY: application
ifeq ("${CFG_SUPPORT_RTOS}", "4")
application: $(OBJ_LIST) $(OBJ_S_LIST) $(OBJ_OS_LIST) $(WPA_LIB) $(RWNX_LIB) $(USB_LIB) $(SENSOR_LIB) $(BLE_LIB) $(CAL_LIB) $(SUPPLICANT_LIB) $(UART_DEBUG_LIB) $(RF_TEST_LIB) $(RF_USE_LIB) bksdk
else
application: $(OBJ_LIST) $(OBJ_S_LIST) $(OBJ_OS_LIST) $(WPA_LIB) $(RWNX_LIB) $(USB_LIB) $(SENSOR_LIB) $(BLE_LIB) $(CAL_LIB) $(SUPPLICANT_LIB) $(UART_DEBUG_LIB) $(RF_TEST_LIB) $(RF_USE_LIB)
endif
@$(ECHO) " $(GREEN)LD $(BIN_DIR)/$(SOC_NAME_ELF)$(NC)"
$(Q)$(LD) $(LFLAGS) -o $(BIN_DIR)/$(SOC_NAME_ELF) $(OBJ_LIST) $(OBJ_S_LIST) $(OBJ_OS_LIST) $(LIBFLAGS) -T./build/$(SOC_NAME_LDS) -Xlinker -Map=$(BIN_DIR)/$(SOC_NAME_MAP)
$(Q)$(OBJCOPY) -O binary $(BIN_DIR)/$(SOC_NAME_ELF) $(BIN_DIR)/$(SOC_NAME_BIN)
@@ -399,6 +428,7 @@ application: $(OBJ_LIST) $(OBJ_S_LIST) $(OBJ_OS_LIST) $(WPA_LIB) $(RWNX_LIB) $(U
$(Q)$(OBJCOPY) -O binary $(BIN_DIR)/$(SOC_NAME_BSP_ELF) $(BIN_DIR)/$(SOC_NAME_BSP_BIN)
$(Q)(cd ./tools/beken_packager; $(ECHO) " $(GREEN)PACK $(SOC_NAME_BSP_BIN)$(NC)"; if [ "$(Q)" = "@" ]; then python ./beken_packager_wrapper -i $(CFG_SOC_NAME) > /dev/null; else python ./beken_packager_wrapper -i $(CFG_SOC_NAME); fi)
ifeq ("${CFG_SUPPORT_RTOS}", "4")
# -------------------------------------------------------------------
BKSDK_LIB = ./build/libbk7231_sdk.a
BKSDK_OUT_DIR = sdk_libs
@@ -415,9 +445,7 @@ cp_libs : $(BKSDK_LIB) $(WPA_LIB) $(RWNX_LIB) $(USB_LIB) $(SENSOR_LIB) $(BLE_LI
$(Q)rm -rf $(BKSDK_OUT_DIR)
$(Q)mkdir $(BKSDK_OUT_DIR)
$(Q)cp $^ $(BKSDK_OUT_DIR)/
endif
# Generate build info
# -------------------------------------------------------------------
ble: $(BLE_LIB)
@@ -504,8 +532,10 @@ $(OBJ_DIR)/%.marm.o: %.c
clean:
$(Q)-rm -rf $(TARGET)
$(Q)-rm -f .config
ifeq ("${CFG_SUPPORT_RTOS}", "4")
$(Q)-rm -rf build/libbk7231_sdk.a
$(Q)-rm -rf sdk_libs
endif
@$(ECHO) "$(GREEN)Done$(NC)"
.PHONY: cleanlib
@@ -0,0 +1,55 @@
stages:
- build
- test
build1:
stage: build
script:
- echo "***********************start building***********************"
- echo $CI_COMMIT_BRANCH
- cd /home/gitlab-runner/build
- ./make_utd_builds.sh $CI_COMMIT_BRANCH $CI_PROJECT_NAME
- echo "***********************start burning***********************"
- cp -rf /home/gitlab-runner/build/up_to_date_builds/out_builds/ /home/gitlab-runner/version/$CI_COMMIT_SHA/
- python3 ./flash.py
- echo "***********************test prepare***********************"
- cd /home/gitlab-runner/Documents/AutoTest/config
- python3 ./config.py -b $CI_COMMIT_BRANCH -o $CI_PROJECT_NAME
rules:
- if: '$CI_COMMIT_BRANCH =~ /^.*3\.0\..*/ || $CI_COMMIT_BRANCH =~ /^.*3\.1\..*/ || $CI_COMMIT_BRANCH == "master"'
when: always
- when: never
test_sta:
stage: test
script:
- echo "***********************STA TEST START***********************"
- cd /home/gitlab-runner/Documents/AutoTest/Testcases
- python3 ./CI_TEST_STA.py
rules:
- if: '$CI_COMMIT_BRANCH =~ /^.*3\.0\..*/ || $CI_COMMIT_BRANCH =~ /^.*3\.1\..*/ || $CI_COMMIT_BRANCH == "master"'
when: always
- when: never
test_ap:
stage: test
script:
- echo "***********************AP TEST START***********************"
- cd /home/gitlab-runner/Documents/AutoTest/Testcases
- python3 ./CI_TEST_AP.py
rules:
- if: '$CI_COMMIT_BRANCH =~ /^.*3\.0\..*/ || $CI_COMMIT_BRANCH =~ /^.*3\.1\..*/ || $CI_COMMIT_BRANCH == "master"'
when: always
- when: never
test_BLE:
stage: test
script:
- echo "***********************BLE TEST START***********************"
- cd /home/gitlab-runner/Documents/AutoTest/Testcases
- python3 ./CI_TEST_BLE.py
rules:
- if: '$CI_COMMIT_BRANCH =~ /^.*3\.0\..*/ || $CI_COMMIT_BRANCH =~ /^.*3\.1\..*/ || $CI_COMMIT_BRANCH == "master"'
when: always
- when: never
+127
View File
@@ -0,0 +1,127 @@
# submodule 代码管理说明
## 当前repository中submodule所在分支
| submodule | branch |
| --------- | ------ |
| beken378 | master |
> clone代码后,需执行如下命令:
```shell
cd beken378
git checkout master
```
> 如果不确定submodule所在分支,可用如下命令查找并手动确认
```shell
cd beken378
git branch -r --contains CommitID
```
## 代码管理策略
随着项目的日益增多,决定使用`submodule+branch`的方式来管理
1. 每类项目单独创建一个`repository`
2. 同类项目用分支区分不同产品、不同代理商、不同客户
3. `beken378`使用`submodule`关联,`beken378`包含协议栈源码,相当于`fullcode`,发布时可使用脚本自动剔除协议栈等源码
4. 在项目稳定前,可直接使用`submodule`主分支,如果`submodule`有重大功能合入,可提前创建项目分支
5. 在提交代码时,不同目的的修改分开提交,便于向其它分支合入
6. 在提交代码后,如果需要将修改合入其它分支,使用`git cherry-pick commitid`
7. 在版本发布后,使用`git tag -a -m "notes" tag_name`创建标签,并用`git push --tags`提交
## submodule使用说明
### 创建submodule
1. `git submodule add http://192.168.0.6/wifi/beken_wifi_sdk.git beken378`
2. 修改`.gitmodules`中的`url`为相对路径,便于`ssh``http`同时使用
3. `git add .gitmodules beken378`
4. `git commit -m "xxx"`
注:
1. 所有`submodules`可能使用不同的分支,建议使用如下命令,指定所有`submodules`(包括主`repository`)的分支
`git branch --set-upstream-to=origin/xxx master`
### 获取submodule
> 如果使用`http`而不是`ssh`获取代码,请先运行如下命令(将用户名密码保存到本地文件中,解决`submodule`获取时无法访问的问题)
>
> `git config --global credential.helper store`
1. `git clone --recurse-submodules http://xxx.git`
或者
2. `git clone http://xxx.git`
3. `cd xxx`
4. `git submodule update --init --recursive`
### 更新submodule
可以在`repository`根目录使用`git pull --recurse-submodules`命令更新整个工程
当然也可以进入特定submodule通过`git pull`单独更新
推荐使用前者更新,因为更新后`submodules`仍然停留在主`repository`关联的`commit`,不会主动切换到最新`commit`
### 提交submodule
需要先在`submodule`中提交修改,然后在主`repository`中更新`submodule`
1. `cd beken378` (the submodle name)
2. `git add xxx`
3. `git commit -m ""`
4. `git push origin xxx:yyy`
5. cd .. (the root of repo)
6. `git add beken378`
7. `git commit -m ""`
8. `git push origin`
## Build with Makefile
- Install arm-gcc tool-chain and add path to system environment
- update `make.exe` in rt-thread env with `tool\make\make.exe` of project directory if you want to use parallel compiling with it
- update `beken378\app\config\sys_config.h` if needed
- make target [-j6]
```shell
make bk7231u -j8
make bk7251
make bk7231 -j6
make ip
make ble
make clean
```
## 版本发布
在发布版本时,`wifi/ble stack`中的代码编译以库的形式打包,然后对代码打标签并发布,方法如下
- 根据项目实际情况修改`sys_config.h`中的`CFG_SOC_NAME`,并返回项目根目录
编译库文件
- `scons --buildlib=beken_ip` 编译结束后会根据`CFG_SOC_NAME`重命名为`beken378/ip/libip72xx.a`
- `scons --buildlib=beken_ble` 编译结束后会重命名为`beken378/driver/ble/libble.a`
编译好库并提交代码以后,需要打标签,由于`submodule`本身就是以`commit id`的形式存在,无需单独打标签。
(当然,如果为了方便查找,可以用相同名称在相应代码库中打标签。)
- `git tag -a -m "" tag_name`
- `git push --tags`
运行脚本打包文件并发布
- run `release_tool.bat`
@@ -241,21 +241,13 @@ path += [cwd + '/func/ethernet_intf']
path += [cwd + '/func/uart_debug']
path += [cwd + '/func/ip/umac/src/apm']
path += [cwd + '/func/rwnx_intf']
if 1 or (GetLocalDepend(options, 'CFG_USE_WPA_29') == 1):
path += [cwd + '/func/wpa_supplicant_2_9/src']
path += [cwd + '/func/wpa_supplicant_2_9/bk_patch']
path += [cwd + '/func/wpa_supplicant_2_9/hostapd']
path += [cwd + '/func/wpa_supplicant_2_9/src/utils']
path += [cwd + '/func/wpa_supplicant_2_9/src/drivers']
path += [cwd + '/func/wpa_supplicant_2_9/src/common']
path += [cwd + '/func/wpa_supplicant_2_9/wpa_supplicant']
else:
path += [cwd + '/func/hostapd-2.5/src']
path += [cwd + '/func/hostapd-2.5/bk_patch']
path += [cwd + '/func/hostapd-2.5/hostapd']
path += [cwd + '/func/hostapd-2.5/src/utils']
path += [cwd + '/func/hostapd-2.5/src/drivers']
path += [cwd + '/func/hostapd-2.5/src/common']
path += [cwd + '/func/wpa_supplicant_2_9/src']
path += [cwd + '/func/wpa_supplicant_2_9/bk_patch']
path += [cwd + '/func/wpa_supplicant_2_9/hostapd']
path += [cwd + '/func/wpa_supplicant_2_9/src/utils']
path += [cwd + '/func/wpa_supplicant_2_9/src/drivers']
path += [cwd + '/func/wpa_supplicant_2_9/src/common']
path += [cwd + '/func/wpa_supplicant_2_9/wpa_supplicant']
path += [cwd + '/func/wpa_supplicant_2_9/src/common/']
path += [cwd + '/func/vad']
path += [cwd + '/func/spidma_intf']
@@ -1,5 +1,5 @@
#ifndef _IPERF_H_
#define _IPERF_H_
void iperf(int argc, char **argv);
#endif
#endif
@@ -1,5 +1,5 @@
#ifndef _PING_H_
#define _PING_H_
int ping(char* target_name, uint32_t times, uint32_t size);
#ifndef _PING_H_
#define _PING_H_
int ping(char* target_name, uint32_t times, uint32_t size);
#endif
@@ -12,6 +12,7 @@ typedef enum _wifi_interface_type
#define ADDR_TYPE_STATIC 1
#define ADDR_TYPE_DHCP 0
#define MAX_IPV6_ADDRESSES 3
/** This data structure represents an IPv4 address */
struct ipv4_config {
@@ -29,13 +30,20 @@ struct ipv4_config {
unsigned dns2;
};
#if LWIP_IPV6
struct ipv6_config {
ip6_addr_t address;
u8 addr_state;
};
#endif
/** Network IP configuration.
*
* This data structure represents the network IP configuration
* for IPv4 as well as IPv6 addresses
*/
struct wlan_ip_config {
#ifdef CONFIG_IPV6
#if LWIP_IPV6
/** The network IPv6 address configuration that should be
* associated with this interface. */
struct ipv6_config ipv6[MAX_IPV6_ADDRESSES];

Some files were not shown because too many files have changed in this diff Show More