Skip to content

Commit

Permalink
Enable HAL_PLATFORM_WIFI for trackerm and other minor
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed Aug 11, 2022
1 parent a61583f commit 9e01d92
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 8 deletions.
6 changes: 6 additions & 0 deletions hal/inc/hal_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@
#define HAL_PLATFORM_WIFI_NCP_SDIO (0)
#endif // HAL_PLATFORM_WIFI_NCP_SDIO

#ifndef HAL_PLATFORM_ESP32_NCP
#define HAL_PLATFORM_ESP32_NCP (0)
#endif // HAL_PLATFORM_ESP32_NCP

#if HAL_PLATFORM_ESP32_NCP
#if HAL_PLATFORM_WIFI && HAL_PLATFORM_NCP_AT && !HAL_PLATFORM_WIFI_NCP_SDIO
# ifndef HAL_PLATFORM_WIFI_SERIAL
# error "HAL_PLATFORM_WIFI_SERIAL is not defined"
# endif /* HAL_PLATFORM_WIFI_SERIAL */
#endif /* HAL_PLATFORM_WIFI */
#endif /* HAL_PLATFORM_ESP32_NCP */

#ifndef HAL_PLATFORM_CELLULAR
#define HAL_PLATFORM_CELLULAR 0
Expand Down
1 change: 1 addition & 0 deletions hal/src/argon/hal_platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define HAL_PLATFORM_WIFI_COMPAT (1)
#define HAL_PLATFORM_NCP_COUNT (1)
#define HAL_PLATFORM_MAX_CLOUD_CONNECT_TIME (1*60*1000)
#define HAL_PLATFORM_ESP32_NCP (1)

#define PRODUCT_SERIES "argon"

Expand Down
4 changes: 2 additions & 2 deletions hal/src/rtl872x/deviceid_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ int hal_get_device_serial_number(char* str, size_t size, void* reserved)

int hal_get_device_hw_version(uint32_t* revision, void* reserved)
{
// HW Data format: | NCP_ID | HW_VERSION | HW Feature Flags |
// | byte 0 | byte 1 | byte 2/3 |
// HW Data format: | NCP_ID (LSB) | HW_VERSION | HW Feature Flags |
// | byte 0 | byte 1 | byte 2/3 |
uint8_t hw_data[4] = {};
CHECK(readLogicalEfuse(HARDWARE_DATA_OFFSET, (uint8_t*)hw_data, HARDWARE_DATA_SIZE));
if (hw_data[1] == 0xFF) {
Expand Down
1 change: 1 addition & 0 deletions hal/src/tracker/hal_platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define HAL_PLATFORM_I2C_NUM (3)
#define HAL_PLATFORM_USART_NUM (2)
#define HAL_PLATFORM_NCP_UPDATABLE (1)
#define HAL_PLATFORM_ESP32_NCP (1)

#define HAL_PLATFORM_PMIC_BQ24195 (1)
#define HAL_PLATFORM_PMIC_BQ24195_I2C (HAL_I2C_INTERFACE2)
Expand Down
4 changes: 2 additions & 2 deletions hal/src/trackerm/hal_platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#define HAL_PLATFORM_I2C_NUM (2)
#define HAL_PLATFORM_USART_NUM (3)
#define HAL_PLATFORM_NCP_COUNT (1)
#define HAL_PLATFORM_WIFI (0)
// #define HAL_PLATFORM_WIFI_COMPAT (1)
#define HAL_PLATFORM_WIFI (1)
#define HAL_PLATFORM_WIFI_COMPAT (0)
// #define HAL_PLATFORM_WIFI_NCP_SDIO (1)
#define HAL_PLATFORM_WIFI_SCAN_ONLY (1)

Expand Down
2 changes: 1 addition & 1 deletion hal/src/trackerm/network/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ int if_init_platform(void*) {
reserve_netif_index();
}

// Order of initialization is important!
/* pp3 - Cellular */
pp3 = new PppNcpNetif();
if (pp3) {
Expand All @@ -196,7 +197,6 @@ int if_init_platform(void*) {
return 0;
}


extern "C" {

struct netif* lwip_hook_ip4_route_src(const ip4_addr_t* src, const ip4_addr_t* dst) {
Expand Down
11 changes: 8 additions & 3 deletions hal/src/trackerm/platform_ncp_quectel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
#include "dct.h"
#include "check.h"
#include "system_error.h"
#include "deviceid_hal.h"

namespace {

const uintptr_t NCP_ID_OTP_ADDRESS = 0x00000020;
// Undefine hardware version
const auto HW_VERSION_UNDEFINED = 0xFF;

bool isValidNcpId(uint8_t id) {
switch (id) {
Expand All @@ -47,8 +49,11 @@ PlatformNCPIdentifier platform_primary_ncp_identifier() {
uint8_t ncpId = 0;
int r = dct_read_app_data_copy(DCT_NCP_ID_OFFSET, &ncpId, 1);
if (r < 0 || !isValidNcpId(ncpId)) {
// Check the OTP flash
r = hal_exflash_read_special(HAL_EXFLASH_SPECIAL_SECTOR_OTP, NCP_ID_OTP_ADDRESS, &ncpId, 1);
// Check the logical eFuse
uint32_t hwVersion = HW_VERSION_UNDEFINED;
r = hal_get_device_hw_version(&hwVersion, nullptr);
// get the first byte for NCP ID
ncpId = (hwVersion & 0xFF);
if (r < 0 || !isValidNcpId(ncpId)) {
ncpId = PlatformNCPIdentifier::PLATFORM_NCP_UNKNOWN;
}
Expand Down
2 changes: 2 additions & 0 deletions hal/src/tron/network/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include "realtek/rtlncpnetif.h"
#include "lwip_util.h"
#include "core_hal.h"
#include "deviceid_hal.h"


using namespace particle;
using namespace particle::net;
Expand Down

0 comments on commit 9e01d92

Please sign in to comment.