From 1602f0189778a09686b63bb5d6daef841a678076 Mon Sep 17 00:00:00 2001 From: Th3maz1ng Date: Sun, 19 Feb 2023 20:30:04 +0100 Subject: [PATCH] Increased application max size in the gcc_csky_bt.ld script as well, added WiFi hotspot scan routine to test antenna --- src/W800_SDK_v1.00.10/app/gfx/gfx_task.c | 42 ++++ src/W800_SDK_v1.00.10/ld/w800/gcc_csky_bt.ld | 9 +- .../ld/w800/gcc_csky_bt_backup.ld | 213 ++++++++++++++++++ 3 files changed, 263 insertions(+), 1 deletion(-) create mode 100644 src/W800_SDK_v1.00.10/ld/w800/gcc_csky_bt_backup.ld diff --git a/src/W800_SDK_v1.00.10/app/gfx/gfx_task.c b/src/W800_SDK_v1.00.10/app/gfx/gfx_task.c index 9cac928..50c5201 100644 --- a/src/W800_SDK_v1.00.10/app/gfx/gfx_task.c +++ b/src/W800_SDK_v1.00.10/app/gfx/gfx_task.c @@ -133,6 +133,43 @@ static void delay_us(uint32_t period, void *intf_ptr) tls_os_time_delay(pdMS_TO_TICKS(period / 1000)); } +static void scan_result_cb(void) +{ + size_t buffer_size = sizeof(struct tls_scan_bss_format2_t) + sizeof(struct tls_bss_info_format2_t) * 10; + uint8_t *buffer = tls_mem_alloc(buffer_size); + if(!buffer) + { + APP_LOG_ERROR("Failed to allocate buffer"); + return; + } + + struct tls_scan_bss_format2_t *scan_result = (struct tls_scan_bss_format2_t *)buffer; + struct tls_bss_info_format2_t *station_list = scan_result->bss; + + if(WM_SUCCESS != tls_wifi_get_scan_rslt_format2((u8 *)buffer, buffer_size)) + { + APP_LOG_ERROR("Failed to retrieve scan results"); + tls_mem_free(buffer); + return; + } + + APP_LOG_DEBUG("Found %d nearby stations(s) - size(%d/%d)", scan_result->count, scan_result->length, buffer_size); + + for(uint8_t i = 0; i < scan_result->count; i++) + { + station_list[i].ssid[station_list[i].ssid_len] = '\0'; + APP_LOG_DEBUG("WiFi(%u) : %s -> %d dB on channel : %u bgn(%u)", + i, + (char *)station_list[i].ssid, + (int8_t)station_list[i].rssi, + station_list[i].channel, + station_list[i].bgn + ); + } + + tls_mem_free(buffer); +} + void gfx_task(void *param) { APP_LOG_TRACE("starting"); @@ -270,6 +307,9 @@ void gfx_task(void *param) don't forget to turn the backlight on ! */ setBrightness(persistency_get_settings()->display.brightness); + /* Enable WiFi hotspot scanning for antenna performance test purposes */ + tls_wifi_scan_result_cb_register(&(scan_result_cb)); + extern LCDConfig_t LCDConfig; float temperature = 0; float pressure = 0; @@ -316,6 +356,8 @@ void gfx_task(void *param) pressure/100, battery_voltage, battery_percentage); + + //APP_LOG_DEBUG("Scanning WiFi : %d", tls_wifi_scan()); aliveCounter = 0; } diff --git a/src/W800_SDK_v1.00.10/ld/w800/gcc_csky_bt.ld b/src/W800_SDK_v1.00.10/ld/w800/gcc_csky_bt.ld index 90732bf..923c9fd 100644 --- a/src/W800_SDK_v1.00.10/ld/w800/gcc_csky_bt.ld +++ b/src/W800_SDK_v1.00.10/ld/w800/gcc_csky_bt.ld @@ -20,9 +20,16 @@ * @version V1.0 * @date 02. June 2017 ******************************************************************************/ + +/****************************************************************************** + * Linker script addresses modified, now the memory map is the following : + * Run Image Header (1KB) starts at 0x0801 0000 + * Application Run Image starts at 0x0801 0400 and is 1,952 MB + * User Area is 112KB and starts at 0x081E 0000 + ******************************************************************************/ MEMORY { - I-SRAM : ORIGIN = 0x080d0400 , LENGTH = 0x128000 /* I-SRAM 1M+160KB */ + I-SRAM : ORIGIN = 0x08010400 , LENGTH = 0x1E8000 /* I-SRAM 1 952KB */ D-SRAM : ORIGIN = 0x20000100 , LENGTH = 0x47EFC /* D-SRAM 288KB */ V-SRAM : ORIGIN = 0x20000000 , LENGTH = 0x100 /* off-chip SRAM 8MB */ } diff --git a/src/W800_SDK_v1.00.10/ld/w800/gcc_csky_bt_backup.ld b/src/W800_SDK_v1.00.10/ld/w800/gcc_csky_bt_backup.ld new file mode 100644 index 0000000..90732bf --- /dev/null +++ b/src/W800_SDK_v1.00.10/ld/w800/gcc_csky_bt_backup.ld @@ -0,0 +1,213 @@ +/* + * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved. + * + * 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. + */ + +/****************************************************************************** + * @file gcc_csky.ld + * @brief csky linker file + * @version V1.0 + * @date 02. June 2017 + ******************************************************************************/ +MEMORY +{ + I-SRAM : ORIGIN = 0x080d0400 , LENGTH = 0x128000 /* I-SRAM 1M+160KB */ + D-SRAM : ORIGIN = 0x20000100 , LENGTH = 0x47EFC /* D-SRAM 288KB */ + V-SRAM : ORIGIN = 0x20000000 , LENGTH = 0x100 /* off-chip SRAM 8MB */ +} + +__min_heap_size = 0x18000; +PROVIDE (__ram_end = 0x2003A000); +PROVIDE (__heap_end = __ram_end); + +REGION_ALIAS("REGION_TEXT", I-SRAM); +REGION_ALIAS("REGION_RODATA", I-SRAM); +REGION_ALIAS("REGION_VDATA", V-SRAM); +REGION_ALIAS("REGION_DATA", D-SRAM); +REGION_ALIAS("REGION_BSS", D-SRAM); + +ENTRY(Reset_Handler) +SECTIONS +{ + .text : { + . = ALIGN(0x4) ; + KEEP(*startup.o(.vectors)) + __stext = . ; + *(.text) + *(.text*) + *(.text.*) + *(.gnu.warning) + *(.stub) + *(.gnu.linkonce.t*) + *(.glue_7t) + *(.glue_7) + *(.jcr) + KEEP (*(.init)) + KEEP (*(.fini)) + . = ALIGN (4) ; + PROVIDE(__ctbp = .); + *(.call_table_data) + *(.call_table_text) + . = ALIGN(0x10) ; + __etext = . ; + } > REGION_TEXT + .rodata : { + . = ALIGN(0x4) ; + __srodata = .; + *(.rdata) + *(.rdata*) + *(.rdata1) + *(.rdata.*) + *(.rodata) + *(.rodata1) + *(.rodata*) + *(.rodata.*) + *(.rodata.str1.4) + . = ALIGN(0x4) ; + __ctor_start__ = .; + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __ctor_end__ = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __dtor_end__ = .; + . = ALIGN(0x4) ; + __erodata = .; + } > REGION_RODATA + .vdata : { + . = ALIGN(0x4) ; + __vdata_start__ = . ; + KEEP(*startup.o(.vdata)) + . = ALIGN(0x4) ; + __vdata_end__ = .; + } > REGION_VDATA + .data : { + . = ALIGN(0x4) ; + __sdata = . ; + __data_start__ = . ; + data_start = . ; + *(.got.plt) + *(.got) + *(.gnu.linkonce.r*) + *(.data) + *(.data*) + *(.data1) + *(.data.*) + *(.gnu.linkonce.d*) + *(.data1) + *(.gcc_except_table) + *(.gcc_except_table*) + __start_init_call = .; + *(.initcall.init) + __stop_init_call = .; + __start_cmd = .; + *(.bootloaddata.cmd) + . = ALIGN(4) ; + __stop_cmd = .; + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + *(__libc_atexit) + *(__libc_subinit) + *(__libc_subfreeres) + *(.note.ABI-tag) + . = ALIGN(0x4) ; + __edata = .; + __data_end__ = .; + } > REGION_DATA AT > REGION_RODATA + .bss : { + . = ALIGN(0x4) ; + __sbss = ALIGN(0x4) ; + __bss_start__ = . ; + *(.dynsbss) + *(.sbss) + *(.sbss.*) + *(.scommon) + *(.dynbss) + *(.bss) + *(.bss.*) + *(COMMON) + . = ALIGN(0x4) ; + __ebss = . ; + __end = . ; + end = . ; + __bss_end__ = .; + } > REGION_BSS + ._user_heap : { + . = ALIGN(0x4) ; + __heap_start = .; + . += __min_heap_size; + . = ALIGN(0x4) ; + } > REGION_BSS + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } > REGION_BSS + .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } > REGION_BSS + .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + .eh_frame_hdr : { *(.eh_frame_hdr) } + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array)) + KEEP (*(SORT(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } + .junk 0 : { *(.rel*) *(.rela*) } + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } +}