Skip to content

Commit

Permalink
fbt: fixed include paths; added PVS-Studio configuration (flipperdevi…
Browse files Browse the repository at this point in the history
…ces#1615)

* fbt: fixed include paths for generated version header
* lib: STM32CubeWB: refactored & cleaned up WPAN include paths
* hal: linter fixes for new headers
* fbt: added version_json target
* Added .pvsconfig; split common_defines.h into 2 files
* Added PVS-Studio basic configuration files; updated .gitignore

Co-authored-by: あく <[email protected]>
  • Loading branch information
hedger and skotopes authored Aug 22, 2022
1 parent 5b4e732 commit 9829145
Show file tree
Hide file tree
Showing 30 changed files with 507 additions and 157 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ build/

# openocd output file
openocd.log

# PVS Studio temporary files
.PVS-Studio/
PVS-Studio.log
22 changes: 22 additions & 0 deletions .pvsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# MLib macros we can't do much about.
//-V:M_EACH:1048,1044
//-V:ARRAY_DEF:760,747,568,776,729,712,654
//-V:LIST_DEF:760,747,568,712,729,654,776
//-V:BPTREE_DEF2:779,1086,557,773,512
//-V:DICT_DEF2:779,524,776,760,1044,1001,729,590,568,747,685
//-V:ALGO_DEF:1048,747,1044

# Non-severe malloc/null pointer deref warnings
//-V::522:2,3

# Warning about headers with copyleft license
//-V::1042

# Potentially null argument warnings
//-V:memset:575
//-V:memcpy:575
//-V:strcpy:575
//-V:strchr:575

# For loop warning on M_FOREACH
//-V:for:1044
1 change: 1 addition & 0 deletions .pvsoptions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--rules-config .pvsconfig -e lib/fatfs -e lib/fnv1a-hash -e lib/FreeRTOS-Kernel -e lib/heatshrink -e lib/libusb_stm32 -e lib/littlefs -e lib/mbedtls -e lib/micro-ecc -e lib/microtar -e lib/mlib -e lib/qrcode -e lib/ST25RFAL002 -e lib/STM32CubeWB -e lib/u8g2 -e toolchain/
2 changes: 1 addition & 1 deletion applications/bt/bt_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <applications/cli/cli.h>
#include <lib/toolbox/args.h>

#include "ble.h"
#include <ble/ble.h>
#include "bt_settings.h"
#include "bt_service/bt.h"

Expand Down
2 changes: 2 additions & 0 deletions firmware.scons
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ if should_gen_cdb_and_link_dir(fwenv, BUILD_TARGETS):
# without filtering, both updater & firmware commands would be generated
fwenv.Replace(COMPILATIONDB_PATH_FILTER=fwenv.subst("*${FW_FLAVOR}*"))
AlwaysBuild(fwcdb)
Precious(fwcdb)
NoClean(fwcdb)
Alias(fwenv["FIRMWARE_BUILD_CFG"] + "_cdb", fwcdb)
fw_artifacts.append(fwcdb)

Expand Down
5 changes: 5 additions & 0 deletions firmware/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Import("env")
env.Append(LINT_SOURCES=["firmware"])

libenv = env.Clone(FW_LIB_NAME="flipper${TARGET_HW}")
libenv.Append(
CPPPATH=[
"#/lib/STM32CubeWB/Middlewares/ST/STM32_WPAN/interface/patterns/ble_thread/tl",
]
)
libenv.ApplyLibFlags()


Expand Down
32 changes: 1 addition & 31 deletions firmware/targets/f7/Inc/stm32.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,6 @@
/* bit value */
#define _BV(bit) (0x01 << (bit))

#if defined(STM32F0)
#include "STM32F0xx/Include/stm32f0xx.h"
#elif defined(STM32F1)
#include "STM32F1xx/Include/stm32f1xx.h"
#elif defined(STM32F2)
#include "STM32F2xx/Include/stm32f2xx.h"
#elif defined(STM32F3)
#include "STM32F3xx/Include/stm32f3xx.h"
#elif defined(STM32F4)
#include "STM32F4xx/Include/stm32f4xx.h"
#elif defined(STM32F7)
#include "STM32F7xx/Include/stm32f7xx.h"
#elif defined(STM32H7)
#include "STM32H7xx/Include/stm32h7xx.h"
#elif defined(STM32L0)
#include "STM32L0xx/Include/stm32l0xx.h"
#elif defined(STM32L1)
#include "STM32L1xx/Include/stm32l1xx.h"
#elif defined(STM32L4)
#include "STM32L4xx/Include/stm32l4xx.h"
#elif defined(STM32L5)
#include "STM32L5xx/Include/stm32l5xx.h"
#elif defined(STM32G0)
#include "STM32G0xx/Include/stm32g0xx.h"
#elif defined(STM32G4)
#include "STM32G4xx/Include/stm32g4xx.h"
#elif defined(STM32WB)
#include "STM32WBxx/Include/stm32wbxx.h"
#else
#error "STM32 family not defined"
#endif
#include "stm32wbxx.h"

#endif // _STM32_H_
5 changes: 3 additions & 2 deletions firmware/targets/f7/ble_glue/app_conf.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#pragma once

#include "hw.h"
#include "hw_conf.h"
#include "hw_if.h"
#include "ble_bufsize.h"

#include <interface/patterns/ble_thread/hw.h>
#include <ble/core/ble_bufsize.h>

#define CFG_TX_POWER (0x19) /* +0dBm */

Expand Down
11 changes: 6 additions & 5 deletions firmware/targets/f7/ble_glue/app_debug.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "utilities_common.h"

#include "app_common.h"
#include "app_debug.h"
#include "shci.h"
#include "tl.h"
#include "dbg_trace.h"
#include <interface/patterns/ble_thread/tl/tl.h>
#include <interface/patterns/ble_thread/tl/mbox_def.h>
#include <interface/patterns/ble_thread/shci/shci.h>
#include <utilities/dbg_trace.h>
#include <utilities/utilities_common.h>

#include <furi_hal.h>

typedef PACKED_STRUCT {
Expand Down
2 changes: 1 addition & 1 deletion firmware/targets/f7/ble_glue/battery_service.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "battery_service.h"
#include "app_common.h"
#include "ble.h"
#include <ble/ble.h>

#include <furi.h>
#include <furi_hal_power.h>
Expand Down
6 changes: 3 additions & 3 deletions firmware/targets/f7/ble_glue/ble_app.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "ble_app.h"

#include "hci_tl.h"
#include "ble.h"
#include "shci.h"
#include <ble/ble.h>
#include <interface/patterns/ble_thread/tl/hci_tl.h>
#include <interface/patterns/ble_thread/shci/shci.h>
#include "gap.h"

#include <furi_hal.h>
Expand Down
115 changes: 115 additions & 0 deletions firmware/targets/f7/ble_glue/ble_const.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*****************************************************************************
* @file ble_const.h
* @author MDG
* @brief This file contains the definitions which are compiler dependent.
*****************************************************************************
* @attention
*
* Copyright (c) 2018-2022 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
*****************************************************************************
*/

#ifndef BLE_CONST_H__
#define BLE_CONST_H__

#include <stdint.h>
#include <string.h>
#include <ble/core/ble_std.h>
#include <ble/core/ble_defs.h>
#include "osal.h"

/* Default BLE variant */
#ifndef BASIC_FEATURES
#define BASIC_FEATURES 0
#endif
#ifndef SLAVE_ONLY
#define SLAVE_ONLY 0
#endif
#ifndef LL_ONLY
#define LL_ONLY 0
#endif
#ifndef BEACON_ONLY
#define BEACON_ONLY 0
#endif

/* Size of command/events buffers:
*
* To change the size of commands and events parameters used in the
* auto-generated files, you need to update 2 defines:
*
* - BLE_CMD_MAX_PARAM_LEN
* - BLE_EVT_MAX_PARAM_LEN
*
* These 2 defines are set below with default values and can be changed.
*
* To compute the value to support a characteristic of 512 bytes for a specific
* command or an event, you need to look in "ble_types.h".
*
* Here are 2 examples, one with a command and one with an event:
*
* - aci_gatt_update_char_value_ext_cp0
* ----------------------------------
*
* we have in the structure:
*
* uint8_t Value[(BLE_CMD_MAX_PARAM_LEN- 12)/sizeof(uint8_t)];
*
* so to support a 512 byte value, we need to have
*
* BLE_CMD_MAX_PARAM_LEN at least equal to: 512 + 12 = 524
*
* - aci_gatt_read_handle_value_rp0
* ------------------------------
*
* we have in the structure:
*
* uint8_t Value[((BLE_EVT_MAX_PARAM_LEN - 3) - 5)/sizeof(uint8_t)];
*
* so to support a 512 byte value, we need to have
*
* BLE_EVT_MAX_PARAM_LEN at least equal to: 512 + 3 + 5 = 520
*
* If you need several events or commands with 512-size values, you need to
* take the maximum values for BLE_EVT_MAX_PARAM_LEN and BLE_CMD_MAX_PARAM_LEN.
*
*/

/* Maximum parameter size of BLE commands.
* Change this value if needed. */
#define BLE_CMD_MAX_PARAM_LEN HCI_COMMAND_MAX_PARAM_LEN

/* Maximum parameter size of BLE responses/events.
* Change this value if needed. */
#define BLE_EVT_MAX_PARAM_LEN HCI_EVENT_MAX_PARAM_LEN

/* Callback function to send command and receive response */
struct hci_request {
uint16_t ogf;
uint16_t ocf;
int event;
void* cparam;
int clen;
void* rparam;
int rlen;
};
extern int hci_send_req(struct hci_request* req, uint8_t async);

#ifndef FALSE
#define FALSE 0
#endif

#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif

#ifndef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif

#endif /* BLE_CONST_H__ */
10 changes: 5 additions & 5 deletions firmware/targets/f7/ble_glue/ble_glue.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "ble_glue.h"
#include "app_common.h"
#include "ble_app.h"
#include "ble.h"
#include "tl.h"
#include "shci.h"
#include "shci_tl.h"
#include <ble/ble.h>

#include <interface/patterns/ble_thread/tl/tl.h>
#include <interface/patterns/ble_thread/shci/shci.h>
#include <interface/patterns/ble_thread/tl/shci_tl.h>
#include "app_debug.h"

#include <furi_hal.h>
#include <shci/shci.h>

#define TAG "Core2"

Expand Down
Loading

0 comments on commit 9829145

Please sign in to comment.