initial commit

This commit is contained in:
2024-12-15 00:34:01 +06:00
commit 31efbc726f
1576 changed files with 657692 additions and 0 deletions

232
mk/application.bak.mk Normal file
View File

@@ -0,0 +1,232 @@
# Toolchain configuration
CROSS_COMPILE = arm-none-eabi-
TARGET := application
BUILD_DIR := build
BIN_DIR := $(BUILD_DIR)/bin
DEP_DIR := $(BUILD_DIR)/dep
# SDK Paths
# -------------------------------------------------------------------
SDK_ROOT := lib/amb1_sdk
SOC_PATH := $(SDK_ROOT)/soc/realtek/8711b
# Define tool directories
AMEBA_TOOLS := $(SOC_PATH)/misc/iar_utility/common/tools
FLASH_TOOLS := $(SDK_ROOT)/soc/realtek/8195a/misc/gcc_utility
FLASH_DOWNLOAD := $(SOC_PATH)/misc/gnu_utility/flash_download/image
DEBUG_TOOLS := $(SOC_PATH)/misc/gcc_utility
# Build Tools
# -------------------------------------------------------------------
CC := $(CROSS_COMPILE)gcc
AR := $(CROSS_COMPILE)ar
AS := $(CROSS_COMPILE)as
NM := $(CROSS_COMPILE)nm
LD := $(CROSS_COMPILE)gcc
GDB := $(CROSS_COMPILE)gdb
OBJCOPY := $(CROSS_COMPILE)objcopy
OBJDUMP := $(CROSS_COMPILE)objdump
PYTHON ?= python tools/
# OS-Specific Tool Selection
# -------------------------------------------------------------------
OS := $(shell uname)
ifeq ($(findstring CYGWIN, $(OS)), CYGWIN)
EXT := .exe
else
EXT :=
endif
PICK := $(AMEBA_TOOLS)/pick$(EXT)
PAD := $(AMEBA_TOOLS)/padding$(EXT)
CHKSUM := $(AMEBA_TOOLS)/checksum$(EXT)
OTA := $(AMEBA_TOOLS)/ota$(EXT)
# OTA Configuration and Image Names
# -------------------------------------------------------------------
OTA_IDX ?= 1
ifeq ($(OTA_IDX),1)
LINKER_SCRIPT := rlx8711B-symbol-v02-img2_xip1.ld
IMAGE2_OTA := image2_all_ota1.bin
else ifeq ($(OTA_IDX),2)
LINKER_SCRIPT := rlx8711B-symbol-v02-img2_xip2.ld
IMAGE2_OTA := image2_all_ota2.bin
else
$(error OTA_IDX must be 1 or 2)
endif
# Image configuration based on build type
# -------------------------------------------------------------------
ifeq ($(MAKECMDGOALS),mp)
RAMALL_BIN := ram_all_mp.bin
OTA_BIN := ota_mp.bin
IMAGE2_OTA1 := image2_all_ota1_mp.bin
IMAGE2_OTA2 := image2_all_ota2_mp.bin
OTA_ALL := ota_all_mp.bin
else
RAMALL_BIN := ram_all.bin
OTA_BIN := ota.bin
IMAGE2_OTA1 := image2_all_ota1.bin
IMAGE2_OTA2 := image2_all_ota2.bin
OTA_ALL := ota_all.bin
endif
# Include other makefiles
# -------------------------------------------------------------------
include $(MKFILES)/includes.mk
include $(MKFILES)/sources.mk
# Build Configuration
# -------------------------------------------------------------------
CFLAGS := \
-DM3 -DCONFIG_PLATFORM_8711B \
-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 \
-g2 -w -O2 -fno-common -fmessage-length=0 \
-ffunction-sections -fdata-sections -fomit-frame-pointer \
-fno-short-enums -DF_CPU=166000000L -std=gnu99 -fsigned-char \
-Wno-pointer-sign -Wno-implicit-function-declaration \
-Wno-incompatible-pointer-types -Wno-int-conversion
LFLAGS := \
-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 \
-g --specs=nano.specs -nostartfiles \
-Wl,-Map=$(BIN_DIR)/application.map -Os -Wl,--gc-sections \
-Wl,--cref -Wl,--entry=Reset_Handler \
-Wl,--no-enum-size-warning -Wl,--no-wchar-size-warning \
-Wl,--wrap=malloc -Wl,--wrap=free -Wl,--wrap=realloc -Wl,--wrap=rom_psk_CalcGTK \
-Wl,--wrap=rom_psk_CalcPTK -Wl,--wrap=CalcMIC -Wl,--wrap=CheckMIC \
-Wl,--wrap=aes_80211_encrypt -Wl,--wrap=aes_80211_decrypt -Wl,--wrap=DecGTK
# Library configuration
# -------------------------------------------------------------------
LIB_DIR := $(SOC_PATH)/misc/bsp/lib/common/GCC
# Platform-specific libraries (with underscore)
PLATFORM_LIBS := platform wlan eap http wps p2p rtlstd
MP_PLATFORM_LIBS := platform wlan_mp eap wps p2p rtlstd
# System libraries (without underscore)
SYS_LIBS := m c nosys gcc
# Combined library flags
LIBFLAGS := -L$(LIB_DIR) $(addprefix -l_,$(PLATFORM_LIBS)) $(addprefix -l,$(SYS_LIBS))
MP_LIBFLAGS := -L$(LIB_DIR) $(addprefix -l_,$(MP_PLATFORM_LIBS)) $(addprefix -l,$(SYS_LIBS))
# Object files
# -------------------------------------------------------------------
SRC_O := $(patsubst %.c,$(BUILD_DIR)/%.o,$(SRC_C))
DRAM_O := $(patsubst %.c,$(BUILD_DIR)/%.o,$(DRAM_C))
DEPENDENCY_LIST := $(patsubst %.c,$(BUILD_DIR)/%.d,$(SRC_C) $(DRAM_C))
VPATH := $(sort $(dir $(SRC_C)) $(dir $(DRAM_C)))
# Main targets
# -------------------------------------------------------------------
.PHONY: all mp clean directories application manipulate_images build_info prerequirement
all mp: directories application manipulate_images
directories:
@mkdir -p $(BIN_DIR) $(DEP_DIR) $(dir $(SRC_O) $(DRAM_O))
# Compilation rules
# -------------------------------------------------------------------
$(filter $(BUILD_DIR)/%,$(SRC_O)): $(BUILD_DIR)/%.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(CC) $(CFLAGS) $(INCLUDES) -c $< -MM -MT $@ -MF $(patsubst %.o,%.d,$@)
$(filter $(BUILD_DIR)/%,$(DRAM_O)): $(BUILD_DIR)/%.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(OBJCOPY) --prefix-alloc-sections .sdram $@
$(CC) $(CFLAGS) $(INCLUDES) -c $< -MM -MT $@ -MF $(patsubst %.o,%.d,$@)
# Build Info Generation
# -------------------------------------------------------------------
.PHONY: build_info
build_info:
@echo "Generating build information..."
@( \
echo '#define RTL_FW_COMPILE_TIME "'`date +%Y/%m/%d-%T`'"'; \
echo '#define RTL_FW_COMPILE_DATE "'`date +%Y%m%d`'"'; \
echo '#define UTS_VERSION "'`date +%Y/%m/%d-%T`'"'; \
echo '#define RTL8195AFW_COMPILE_TIME "'`date +%Y/%m/%d-%T`'"'; \
echo '#define RTL8195AFW_COMPILE_DATE "'`date +%Y%m%d`'"'; \
echo '#define RTL8195AFW_COMPILE_BY "'`id -u -n`'"'; \
echo '#define RTL8195AFW_COMPILE_HOST "'`$(HOSTNAME_APP)`'"'; \
if [ -x /bin/dnsdomainname ]; then \
echo '#define RTL8195AFW_COMPILE_DOMAIN "'`dnsdomainname`'"'; \
elif [ -x /bin/domainname ]; then \
echo '#define RTL8195AFW_COMPILE_DOMAIN "'`domainname`'"'; \
else \
echo '#define RTL8195AFW_COMPILE_DOMAIN ""'; \
fi; \
echo '#define RTL195AFW_COMPILER "gcc '`$(CC) $(CFLAGS) -dumpversion | tr --delete '\r'`'"'; \
) > include/build_info.h
# Image Manipulation
# -------------------------------------------------------------------
.PHONY: manipulate_images
manipulate_images:
@echo "=== Image Manipulation ==="
# Generate symbol maps
$(NM) $(BIN_DIR)/$(TARGET).axf | sort > $(BIN_DIR)/$(TARGET).nmap
# Extract sections
$(OBJCOPY) -j .ram_image2.entry -j .ram_image2.data -j .ram_image2.text -j .ram_image2.bss -j .ram_image2.skb.bss -j .ram_heap.data -Obinary $(BIN_DIR)/$(TARGET).axf $(BIN_DIR)/ram_2.r.bin
$(OBJCOPY) -j .xip_image2.text -Obinary $(BIN_DIR)/$(TARGET).axf $(BIN_DIR)/xip_image2.bin
$(OBJCOPY) -j .ram_rdp.text -Obinary $(BIN_DIR)/$(TARGET).axf $(BIN_DIR)/rdp.bin
# Prepare boot image
cp $(SOC_PATH)/misc/bsp/image/boot_all.bin $(BIN_DIR)/boot_all.bin
chmod 777 $(BIN_DIR)/boot_all.bin
chmod +rx $(PICK) $(CHKSUM) $(PAD) $(OTA)
# Process memory images
$(PICK) 0x`grep __ram_image2_text_start__ $(BIN_DIR)/$(TARGET).nmap | gawk '{print $$1}'` 0x`grep __ram_image2_text_end__ $(BIN_DIR)/$(TARGET).nmap | gawk '{print $$1}'` $(BIN_DIR)/ram_2.r.bin $(BIN_DIR)/ram_2.bin raw
$(PICK) 0x`grep __ram_image2_text_start__ $(BIN_DIR)/$(TARGET).nmap | gawk '{print $$1}'` 0x`grep __ram_image2_text_end__ $(BIN_DIR)/$(TARGET).nmap | gawk '{print $$1}'` $(BIN_DIR)/ram_2.bin $(BIN_DIR)/ram_2.p.bin
$(PICK) 0x`grep __xip_image2_start__ $(BIN_DIR)/$(TARGET).nmap | gawk '{print $$1}'` 0x`grep __xip_image2_start__ $(BIN_DIR)/$(TARGET).nmap | gawk '{print $$1}'` $(BIN_DIR)/xip_image2.bin $(BIN_DIR)/xip_image2.p.bin
# Generate OTA images
ifeq ("${OTA_IDX}", "1")
cat $(BIN_DIR)/xip_image2.p.bin > $(BIN_DIR)/$(IMAGE2_OTA1)
chmod 777 $(BIN_DIR)/$(IMAGE2_OTA1)
cat $(BIN_DIR)/ram_2.p.bin >> $(BIN_DIR)/$(IMAGE2_OTA1)
$(CHKSUM) $(BIN_DIR)/$(IMAGE2_OTA1) || true
#rm $(BIN_DIR)/xip_image2.p.bin $(BIN_DIR)/ram_2.p.bin
else ifeq ("${OTA_IDX}", "2")
cat $(BIN_DIR)/xip_image2.p.bin > $(BIN_DIR)/$(IMAGE2_OTA2)
chmod 777 $(BIN_DIR)/$(IMAGE2_OTA2)
cat $(BIN_DIR)/ram_2.p.bin >> $(BIN_DIR)/$(IMAGE2_OTA2)
$(CHKSUM) $(BIN_DIR)/$(IMAGE2_OTA2) || true
$(OTA) $(BIN_DIR)/$(IMAGE2_OTA1) 0x800B000 $(BIN_DIR)/$(IMAGE2_OTA2) 0x08080000 0x20170111 $(BIN_DIR)/$(OTA_ALL)
endif
# Prerequisite setup
# -------------------------------------------------------------------
.PHONY: prerequirement
prerequirement:
@echo "=== Setting up prerequisites for $(TARGET) ==="
@mkdir -p $(BUILD_DIR)/boot $(BIN_DIR)
cp $(SOC_PATH)/misc/bsp/image/boot_all.bin $(BUILD_DIR)/boot/boot_all.bin
chmod 777 $(BUILD_DIR)/boot/boot_all.bin
$(OBJCOPY) -I binary -O elf32-littlearm -B arm \
$(BUILD_DIR)/boot/boot_all.bin $(BUILD_DIR)/boot/boot_all.o
# Main build target
# -------------------------------------------------------------------
application: prerequirement build_info $(SRC_O) $(DRAM_O)
$(LD) $(LFLAGS) -o $(BIN_DIR)/$(TARGET).axf $(SRC_O) $(DRAM_O) \
$(BUILD_DIR)/boot/boot_all.o $(LIBFLAGS) -T./$(LINKER_SCRIPT)
$(OBJDUMP) -d $(BIN_DIR)/$(TARGET).axf > $(BIN_DIR)/$(TARGET).asm
# Include generated dependencies
-include $(DEPENDENCY_LIST)
# Clean target
# -------------------------------------------------------------------
clean:
rm -rf $(BUILD_DIR)