Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
- Rename bootloader/prebootloader/tron -> bootloader/prebootloader/rtl872x
- Refactor platform defines
- Move HAL_USART_SERIAL2 to respective platform header files
- More
  • Loading branch information
keeramis committed Aug 4, 2022
1 parent 700cf1f commit 7706293
Show file tree
Hide file tree
Showing 74 changed files with 59 additions and 117 deletions.
2 changes: 1 addition & 1 deletion bootloader/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ BOOTLOADER_MODULE_PATH=.
PLATFORM_DFU=0x8000000
BUILD_PATH_EXT = $(BOOTLOADER_BUILD_PATH_EXT)

ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","p2" "trackerm"))
ifeq ($(PLATFORM_MCU),rtl872x)
RTL_BINARY_FLASH_START = 0x4000
endif

Expand Down
7 changes: 1 addition & 6 deletions bootloader/prebootloader/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ include $(PROJECT_ROOT)/build/macros.mk
include $(PROJECT_ROOT)/build/module-defaults.mk
include $(PROJECT_ROOT)/build/arm-tools.mk

# overwrite if PLATFORM_DYNALIB_MODULES is trackerm to use the same prebl as tron
ifeq ("$(PLATFORM_DYNALIB_MODULES)", "trackerm")
PLATFORM_DYNALIB_MODULES=tron
endif

projects = $(sort $(wildcard $(current_dir)/src/$(PLATFORM_DYNALIB_MODULES)/*))
projects = $(sort $(wildcard $(current_dir)/src/$(PLATFORM_MCU)/*))
makefiles = $(foreach module,$(projects),$(and $(strip $(subst $(MODULE_EXCLUDE),,$(notdir $(module)))),$(wildcard $(module)/makefile)))

SUBDIR_GOALS := $(MAKECMDGOALS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ CPPSRC += $(PROJECT_ROOT)/hal/src/rtl872x/flash_common.cpp
CPPSRC += $(PROJECT_ROOT)/hal/src/rtl872x/km0_km4_ipc.cpp
CPPSRC += $(PROJECT_ROOT)/hal/src/rtl872x/pinmap_hal.cpp

ifeq ("$(PLATFORM_NAME)",$(filter "$(PLATFORM_NAME)","p2" "trackerm"))
CPPSRC += $(PROJECT_ROOT)/hal/src/$(PLATFORM_NAME)/pinmap_defines.cpp
endif

LDFLAGS += -T$(PREBOOTLOADER_PART1_SRC_PATH)/linker.ld
LINKER_DEPS += $(PREBOOTLOADER_PART1_SRC_PATH)/linker.ld
4 changes: 2 additions & 2 deletions bootloader/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "button_hal.h"
#include "dct.h"
#include "feature_flags.h"
#if (PLATFORM_ID == PLATFORM_P2 || PLATFORM_ID == PLATFORM_TRACKERM)
#if HAL_PLATFORM_RTL872X
#include "rtl8721d.h"
#include "nonsecure.h"
#endif
Expand All @@ -48,7 +48,7 @@ extern void HAL_DFU_Process();

void platform_startup();

#if (PLATFORM_ID == PLATFORM_P2 || PLATFORM_ID == PLATFORM_TRACKERM)
#if HAL_PLATFORM_RTL872X
static void jump_to_system(uint32_t addr, uint32_t sp) {
nonsecure_jump_to_system(addr);
(void) sp;
Expand Down
2 changes: 1 addition & 1 deletion build/module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ exe: $(TARGET_BASE)$(EXECUTABLE_EXTENSION)
none:
;

ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","p2" "trackerm"))
ifeq ($(PLATFORM_MCU),rtl872x)
.PHONY: rtl-flash
rtl_module_start_address = $(subst 0x08,0x00,$(call get_module_start_address))
rtl-flash:
Expand Down
2 changes: 1 addition & 1 deletion dynalib/inc/dynalib.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ constexpr T2* dynalib_checked_cast(T2 *p) {
#define __S(x) #x
#define __SX(x) __S(x)

#if (PLATFORM_ID == 32 || PLATFORM_ID == 28)
#if HAL_PLATFORM_DYNALIB_DYNAMIC_LOCATION
#define DYNALIB_FN_IMPORT(index, tablename, name, counter) \
DYNALIB_STATIC_ASSERT(index == counter, "Index of the dynamically exported function has changed"); \
const char check_name_##tablename_##name[0]={}; /* this will fail if the name is already defined */ \
Expand Down
2 changes: 1 addition & 1 deletion dynalib/inc/module_info.inc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ extern "C" {

extern char link_module_start;
extern char link_module_end;
#if PLATFORM_ID == 32 || PLATFORM_ID == 28
#if HAL_PLATFORM_RTL872X
extern uintptr_t link_dynalib_start;
extern uintptr_t link_dynalib_flash_start;
#endif
Expand Down
4 changes: 4 additions & 0 deletions hal/inc/hal_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,4 +513,8 @@
#define HAL_PLATFORM_CELLULAR_MODEM_VOLTAGE_TRANSLATOR (1)
#endif // HAL_PLATFORM_CELLULAR_MODEM_VOLTAGE_TRANSLATOR

#ifndef HAL_PLATFORM_DYNALIB_DYNAMIC_LOCATION
#define HAL_PLATFORM_DYNALIB_DYNAMIC_LOCATION (0)
#endif

#endif /* HAL_PLATFORM_H */
6 changes: 2 additions & 4 deletions hal/src/rtl872x/hal_platform_rtl8721x_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@

#define HAL_PLATFORM_BLE_SETUP (1)

#define HAL_PLATFORM_WIFI (1)

#define HAL_PLATFORM_RTL872X (1)

/* 25 seconds */
Expand All @@ -55,8 +53,6 @@

#define HAL_PLATFORM_I2C2 (1)

#define HAL_PLATFORM_USART2 (0)

#define HAL_PLATFORM_USART3 (1)

#define HAL_PLATFORM_USB_VENDOR_REQUEST (1)
Expand Down Expand Up @@ -130,3 +126,5 @@
#define HAL_PLATFORM_SYSTEM_POOL_SIZE 1024

#define HAL_PLATFORM_MODULE_SUFFIX_EXTENSIONS (1)

#define HAL_PLATFORM_DYNALIB_DYNAMIC_LOCATION (1)
2 changes: 1 addition & 1 deletion hal/src/rtl872x/pinmap_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ typedef struct hal_pin_info_t {
uint8_t adc_channel;
uint8_t pwm_instance;
uint8_t pwm_channel;
#if HAL_PLATFORM_IO_EXTENSION || HAL_PLATFORM_DEMUX
#if HAL_PLATFORM_IO_EXTENSION
hal_pin_type_t type;
#endif // HAL_PLATFORM_IO_EXTENSION
uint32_t user_data;
Expand Down
5 changes: 2 additions & 3 deletions hal/src/trackerm/hal_platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
// #define HAL_PLATFORM_MUXER_MAY_NEED_DELAY_IN_TX (1)
#define HAL_PLATFORM_SPI_NUM (2)
#define HAL_PLATFORM_I2C_NUM (2)
#define HAL_PLATFORM_USART_NUM (2)
#define HAL_PLATFORM_USART_NUM (3)
#define HAL_PLATFORM_NCP_COUNT (1)
#define HAL_PLATFORM_BROKEN_MTU (1)
#undef HAL_PLATFORM_WIFI
#define HAL_PLATFORM_WIFI (0)
// #define HAL_PLATFORM_WIFI_COMPAT (1)
Expand Down Expand Up @@ -44,4 +43,4 @@
#define HAL_PLATFORM_USB_PRODUCT_STRING "TrackerM DFU Mode"
#endif // defined(MODULE_FUNCTION) && MODULE_FUNCTION != 2 // MOD_FUNC_BOOTLOADER

#define PRODUCT_SERIES "TrackerM"
#define PRODUCT_SERIES "Tracker"
4 changes: 1 addition & 3 deletions hal/src/trackerm/include.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
# based on the root of the project

INCLUDE_DIRS += $(TARGET_HAL_PATH)/src/$(PLATFORM_NAME)
# FIXME: Double check if this line is required.
# INCLUDE_DIRS += $(HAL_MODULE_PATH)/network/ncp/wifi

ifneq (,$(findstring platform,$(DEPENDENCIES)))
INCLUDE_DIRS += $(HAL_MODULE_PATH)/network/lwip/cellular
endif

ifneq (,$(findstring platform,$(DEPENDENCIES)))
INCLUDE_DIRS += $(HAL_MODULE_PATH)/network/lwip/esp32
INCLUDE_DIRS += $(HAL_MODULE_PATH)/network/lwip/realtek
INCLUDE_DIRS += $(HAL_MODULE_PATH)/network/ncp/wifi
endif

Expand Down
6 changes: 2 additions & 4 deletions hal/src/trackerm/network/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ int if_init_platform(void*) {
}

if (HAL_Feature_Get(FEATURE_ETHERNET_DETECTION)) {
#if PLATFORM_ID == PLATFORM_ARGON || PLATFORM_ID == PLATFORM_P2 || PLATFORM_ID == PLATFORM_TRACKERM
en2 = new WizNetif(HAL_SPI_INTERFACE1, D5, D3, D4, mac);
#else // A SoM
en2 = new WizNetif(HAL_SPI_INTERFACE1, D8, A7, D22, mac);
#endif
}

uint8_t dummy;
Expand All @@ -197,6 +193,8 @@ int if_init_platform(void*) {
}

/* TODO: wl4 - ESP32 NCP Access Point */
reserve_netif_index();
reserve_netif_index();
(void)wl4;

auto m = mallinfo();
Expand Down
2 changes: 1 addition & 1 deletion hal/src/trackerm/ota_flash_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @file ota_flash_hal.cpp
* @author Matthew McGowan, Satish Nair
* @version V1.0.0
* @date 25-Sept-2014
* @date 27-Jul-2022
* @brief
******************************************************************************
Copyright (c) 2013-2015 Particle Industries, Inc. All rights reserved.
Expand Down
4 changes: 0 additions & 4 deletions hal/src/trackerm/platform_ncp_quectel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ bool isValidNcpId(uint8_t id) {
}

const auto NCP_IDX_PRIMARY_QUECTEL = 0;
const auto NCP_IDX_SECONDARY_ESP32 = 1;

} // unnamed

Expand All @@ -64,9 +63,6 @@ int platform_ncp_get_info(int idx, PlatformNCPInfo* info) {
if (idx == NCP_IDX_PRIMARY_QUECTEL) {
info->identifier = platform_primary_ncp_identifier();
info->updatable = false;
} else if (idx == NCP_IDX_SECONDARY_ESP32) {
info->identifier = PLATFORM_NCP_ESP32;
info->updatable = true;
}
return 0;
}
3 changes: 2 additions & 1 deletion hal/src/tron/hal_platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
#include "platforms.h"

#define HAL_PLATFORM_NCP (1)
#define HAL_PLATFORM_USART2 (1)
#define HAL_PLATFORM_NCP_AT (0)
#define HAL_PLATFORM_CELLULAR (0)
// #define HAL_PLATFORM_CELLULAR_SERIAL (HAL_USART_SERIAL2)
#define HAL_PLATFORM_SETUP_BUTTON_UX (1)
// #define HAL_PLATFORM_MUXER_MAY_NEED_DELAY_IN_TX (1)
#define HAL_PLATFORM_SPI_NUM (2)
#define HAL_PLATFORM_I2C_NUM (2)
#define HAL_PLATFORM_USART_NUM (2)
#define HAL_PLATFORM_USART_NUM (3)
#define HAL_PLATFORM_NCP_COUNT (1)
#define HAL_PLATFORM_BROKEN_MTU (1)
#define HAL_PLATFORM_WIFI_COMPAT (1)
Expand Down
4 changes: 0 additions & 4 deletions hal/src/tron/network/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,7 @@ int if_init_platform(void*) {
}

if (HAL_Feature_Get(FEATURE_ETHERNET_DETECTION)) {
#if PLATFORM_ID == PLATFORM_ARGON || PLATFORM_ID == PLATFORM_P2
en2 = new WizNetif(HAL_SPI_INTERFACE1, D5, D3, D4, mac);
#else // A SoM
en2 = new WizNetif(HAL_SPI_INTERFACE1, D8, A7, D22, mac);
#endif
}

uint8_t dummy;
Expand Down
19 changes: 0 additions & 19 deletions hal/src/uhura/include.mk

This file was deleted.

2 changes: 1 addition & 1 deletion main/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ BUILD_PATH_EXT = $(BUILD_TARGET_PLATFORM)$(USER_FLAVOR)

USE_PRINTF_FLOAT ?= y

ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","p2" "trackerm"))
ifeq ($(PLATFORM_MCU),rtl872x)
RTL_BINARY_FLASH_START = 0x60000
endif

Expand Down
28 changes: 4 additions & 24 deletions modules/shared/system_module_version.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,23 @@ USER_PART_MODULE_VERSION ?= 6
# Bump by 1 for every updated bootloader image for a release with the same v0.x.* base.
BOOTLOADER_VERSION ?= 2000

ifeq ($(PLATFORM_ID),32)
PREBOOTLOADER_MBR_VERSION ?= 2
PREBOOTLOADER_PART1_VERSION ?= 3
endif

ifeq ($(PLATFORM_ID),28)
ifeq ($(PLATFORM_MCU),rtl872x)
PREBOOTLOADER_MBR_VERSION ?= 2
PREBOOTLOADER_PART1_VERSION ?= 3
endif

# The version of the bootloader that the system firmware requires
# NOTE: this will force the device into safe mode until this dependency is met, which is why
# this version usually lags behind the current bootloader version, to avoid non-mandatory updates.
ifeq ($(PLATFORM_ID),32)
BOOTLOADER_DEPENDENCY = 2000
else ifeq ($(PLATFORM_GEN),3)
BOOTLOADER_DEPENDENCY = 1101
else
# Some sensible default
BOOTLOADER_DEPENDENCY = 0
endif
ifeq ($(PLATFORM_ID),32)
PREBOOTLOADER_PART1_DEPENDENCY = 3
endif

# The version of the bootloader that the system firmware requires for 28
# NOTE: this will force the device into safe mode until this dependency is met, which is why
# this version usually lags behind the current bootloader version, to avoid non-mandatory updates.
ifeq ($(PLATFORM_ID),28)
ifeq ($(PLATFORM_MCU),rtl872x)
BOOTLOADER_DEPENDENCY = 2000
else ifeq ($(PLATFORM_GEN),3)
BOOTLOADER_DEPENDENCY = 1101
else
# Some sensible default
BOOTLOADER_DEPENDENCY = 0
endif
ifeq ($(PLATFORM_ID),28)
ifeq ($(PLATFORM_MCU),rtl872x)
PREBOOTLOADER_PART1_DEPENDENCY = 3
endif

Expand Down Expand Up @@ -90,7 +70,7 @@ endif
endif
endif # ($(PLATFORM_MCU),nRF52840)

ifeq ($(PLATFORM_ID),$(filter $(PLATFORM_ID),28 32))
ifeq ($(PLATFORM_MCU),rtl872x)
SYSTEM_PART1_MODULE_DEPENDENCY ?= ${MODULE_FUNCTION_BOOTLOADER},0,${BOOTLOADER_DEPENDENCY}
BOOTLOADER_MODULE_DEPENDENCY ?= ${MODULE_FUNCTION_BOOTLOADER},2,${PREBOOTLOADER_PART1_DEPENDENCY}
endif
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ PROVIDE (link_dynalib_location_offset_hal_wlan = 92);
PROVIDE (link_dynalib_location_offset_hal_ble = 96);
PROVIDE (link_dynalib_location_offset_hal_posix_syscall = 100);
PROVIDE (link_dynalib_location_offset_hal_storage = 104);
PROVIDE (link_dynalib_location_offset_hal_cellular = 108);
2 changes: 1 addition & 1 deletion platform/MCU/rtl872x/inc/platform_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

#define SYSTICK_IRQ_PRIORITY 7 //CORTEX_M33 Systick Interrupt

#if (PLATFORM_ID == PLATFORM_P2 || PLATFORM_ID == PLATFORM_TRACKERM)
#if HAL_PLATFORM_RTL872X
#define INTERNAL_FLASH_SIZE (0x800000)
#else
#pragma message "PLATFORM_ID is " PREPSTRING(PLATFORM_ID)
Expand Down
2 changes: 1 addition & 1 deletion system/src/control/wifi_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int joinNewNetwork(ctrl_request* req) {
CHECK_TRUE(ncpClient, SYSTEM_ERROR_UNKNOWN);
const NcpClientLock lock(ncpClient);
// FIXME; the security sent from the mobile app is always zero.
#if (PLATFORM_ID == 32 || PLATFORM_ID == 28)
#if HAL_PLATFORM_RTL872X
// Scan for networks
Vector<WifiScanResult> networks;
CHECK(ncpClient->scan([](WifiScanResult network, void* data) -> int {
Expand Down
2 changes: 1 addition & 1 deletion system/src/system_sleep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ network_status_t system_sleep_network_suspend(network_interface_index index) {
}
}
#endif
#if (PLATFORM_ID == PLATFORM_P2 || PLATFORM_ID == PLATFORM_TRACKERM)
#if HAL_PLATFORM_RTL872X
// P2 doesn't need to turn off the modem manually
system_notify_event(network_status, network_status_off);
#else
Expand Down
2 changes: 1 addition & 1 deletion user/inc/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ inline void yield() {
#endif

#ifndef analogInputToDigitalPin
#if (PLATFORM_ID == PLATFORM_P2 || PLATFORM_ID == PLATFORM_TRACKERM)
#if HAL_PLATFORM_RTL872X
#define analogInputToDigitalPin(p) ((p) == 3 ? 0 : \
((p) == 4 ? 1 : \
((p) == 5 ? 14 : \
Expand Down
5 changes: 1 addition & 4 deletions user/tests/wiring/no_fixture/i2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,8 @@ test(I2C_04_Serial1_Cannot_Be_Enabled_While_Wire3_Is_Enabled) {

#endif // PLATFORM_ID == PLATFORM_TRACKER

#if !HAL_PLATFORM_RTL872X

test(I2C_05_Hal_Sleep_API_Test) { Hal_Sleep_API_Test
test(I2C_05_Hal_Sleep_API_Test) {
Wire.lock();
bool enabled = Wire.isEnabled();
SCOPE_GUARD({
Expand Down Expand Up @@ -377,6 +376,4 @@ test(I2C_07_bus_reset_is_not_destructive) {
}
}

#endif // !HAL_PLATFORM_RTL872X

#endif // HAL_PLATFORM_FUELGAUGE_MAX17043
Loading

0 comments on commit 7706293

Please sign in to comment.