This commit is contained in:
pvvx 2017-02-20 11:19:32 +03:00
parent bd42ffa334
commit 3904cfcf03
34 changed files with 3570 additions and 133 deletions

View file

@ -618,7 +618,7 @@ void fATSx(void *arg)
#define ATCMD_VERSION "v2" //ATCMD MAJOR VERSION, AT FORMAT CHANGED #define ATCMD_VERSION "v2" //ATCMD MAJOR VERSION, AT FORMAT CHANGED
#define ATCMD_SUBVERSION "2" //ATCMD MINOR VERSION, NEW COMMAND ADDED #define ATCMD_SUBVERSION "2" //ATCMD MINOR VERSION, NEW COMMAND ADDED
#define ATCMD_REVISION "1" //ATCMD FIX BUG REVISION #define ATCMD_REVISION "2" //ATCMD FIX BUG REVISION
#define SDK_VERSION "v3.5" //SDK VERSION #define SDK_VERSION "v3.5" //SDK VERSION
extern void sys_reset(void); extern void sys_reset(void);
void print_system_at(void *arg); void print_system_at(void *arg);

View file

@ -0,0 +1,139 @@
#ifndef _INCLUDE_ESP_COMP_H_
#define _INCLUDE_ESP_COMP_H_
#include "platform_autoconf.h"
#include "flash_api.h"
#define ICACHE_FLASH_ATTR
#define ICACHE_RODATA_ATTR
#define DATA_IRAM_ATTR
#define os_printf(...) rtl_printf(__VA_ARGS__)
#define os_printf_plus(...) rtl_printf(__VA_ARGS__)
#define os_sprintf_fd(...) rtl_sprintf(__VA_ARGS__)
#define ets_sprintf(...) rtl_sprintf(__VA_ARGS__)
/*
#define os_malloc pvPortMalloc
#define os_zalloc pvPortZalloc
#define os_calloc pvPortCalloc
#define os_realloc pvPortRealloc
*/
#undef os_free
#define os_free vPortFree
#define system_get_free_heap_size xPortGetFreeHeapSize
#undef os_realloc
#define os_realloc pvPortReAlloc
#define os_bzero rtl_bzero
#define os_delay_us wait_us // HalDelayUs
//#define os_install_putc1 rtl_install_putc1
//#define os_install_putc2 rtl_install_putc2
//#define os_intr_lock rtl_intr_lock
//#define os_intr_unlock rtl_intr_unlock
//#define os_isr_attach rtl_isr_attach
//#define os_isr_mask rtl_isr_mask
//#define os_isr_unmask rtl_isr_unmask
#define os_memcmp rtl_memcmp
#define os_memcpy rtl_memcpy
#define ets_memcpy rtl_memcpy
#define os_memmove rtl_memmove
#define os_memset rtl_memset
#define os_putc rtl_putc
//#define os_str2macaddr rtl_str2macaddr
//#define os_strcat strcat
#define os_strchr rtl_strchr
#define os_strrchr rtl_strrchr
#define os_strcmp rtl_strcmp
#define os_strcpy rtl_strcpy
#define os_strlen rtl_strlen
#define os_strncmp rtl_strncmp
#define os_strncpy rtl_strncpy
#define os_strstr rtl_strstr
#define os_random Rand
//extern uint32 phy_get_rand(void);
#define system_get_os_print() 1
#ifdef USE_US_TIMER
#define os_timer_arm_us(a, b, c) rtl_timer_arm_new(a, b, c, 0)
#endif
//#define os_timer_arm(a, b, c) rtl_timer_arm_new(a, b, c, 1)
//#define os_timer_disarm rtl_timer_disarm
//#define os_timer_init rtl_timer_init
//#define os_timer_setfn rtl_timer_setfn
//#define os_timer_done rtl_timer_done
//#define os_timer_handler_isr rtl_timer_handler_isr
//#define os_update_cpu_frequency rtl_update_cpu_frequency
//#define os_sprintf ets_sprintf
/*
typedef struct{
uint32_t deviceId; //+00
uint32_t chip_size; //+04 chip size in byte
uint32_t block_size; //+08
uint32_t sector_size; //+0c
uint32_t page_size; //+10
uint32_t status_mask; //+14
} SpiFlashChip;
typedef enum {
SPI_FLASH_RESULT_OK,
SPI_FLASH_RESULT_ERR,
SPI_FLASH_RESULT_TIMEOUT
} SpiFlashOpResult;
extern SpiFlashChip * flashchip; // in RAM-BIOS: 0x3fffc714
*/
// include "flash_api.h"
#define spi_flash_real_size() flash_get_size(&flashobj)
#define Cache_Read_Disable() SpicDisableRtl8195A()
#define Cache_Read_Enable(a, b, c) flash_turnon()
#define spi_flash_get_id() ((flashobj.SpicInitPara.id[0] << 16) | (flashobj.SpicInitPara.id[1]<<8) | flashobj.SpicInitPara.id[2])
//SpiFlashOpResult spi_flash_read_status(uint32_t * sta);
//SpiFlashOpResult spi_flash_write_status(uint32_t sta);
#define spi_flash_erase_sector(sec) flash_erase_sector(&flashobj, (sec)<<12)
#define spi_flash_write(faddr, pbuf, size) flash_stream_write(&flashobj, faddr, size, (uint8_t *)pbuf)
#define spi_flash_read(faddr, pbuf, size) flash_stream_read(&flashobj, faddr, size, (uint8_t *)pbuf)
#define spi_flash_erase_block(blk) flash_erase_block(&flashobj, (blk)<<16);
#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0])
#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1])
#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2])
#define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3])
/* These are cast to u16_t, with the intent that they are often arguments
* to printf using the U16_F format from cc.h. */
#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr))
#define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr))
#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr))
#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr))
#define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \
ip4_addr2_16(ipaddr), \
ip4_addr3_16(ipaddr), \
ip4_addr4_16(ipaddr)
#define IPSTR "%d.%d.%d.%d"
/* CONFIG_DEBUG_LOG:
=0 Off all diag/debug msg,
=1 Only errors,
=2 errors + warning, (default)
=3 errors + warning + info,
=4 errors + warning + info + debug,
=5 full */
#if CONFIG_DEBUG_LOG > 3
#define DEBUGSOO (CONFIG_DEBUG_LOG - 1)
#elif CONFIG_DEBUG_LOG > 1
#define DEBUGSOO 2
#else
#define DEBUGSOO CONFIG_DEBUG_LOG
#endif
#endif // _INCLUDE_ESP_COMP_H_

View file

@ -47,7 +47,7 @@
#include "lwip/udp.h" #include "lwip/udp.h"
#include "lwip/netif.h" #include "lwip/netif.h"
#include "lwip_netconf.h" #include "lwip_netconf.h"
#include "rtl8195a/esp_comp.h" #include "platform/esp_comp.h"
#define NETBIOS_CODE_ATTR #define NETBIOS_CODE_ATTR
#define NETBIOS_DATA_ATTR #define NETBIOS_DATA_ATTR

View file

@ -85,10 +85,8 @@
#include "webserver.h" #include "webserver.h"
#include "wlan_intf.h" #include "wlan_intf.h"
#define CONFIG_READ_FLASH 1 #define CONFIG_READ_FLASH 1
#ifdef CONFIG_READ_FLASH #ifdef CONFIG_READ_FLASH
#ifndef CONFIG_PLATFORM_8195A #ifndef CONFIG_PLATFORM_8195A
@ -104,7 +102,14 @@
#else #else
#include "flash_api.h" #include "flash_api.h"
#include "flash_eep.h"
#include "feep_config.h"
#include "device_lock.h" #include "device_lock.h"
#ifndef FEEP_ID_WIFI_AP_CFG
#define FEEP_ID_WIFI_AP_CFG 0x5731
#endif
#define DATA_SECTOR AP_SETTING_SECTOR #define DATA_SECTOR AP_SETTING_SECTOR
#define BACKUP_SECTOR (0x00008000) #define BACKUP_SECTOR (0x00008000)
@ -542,13 +547,40 @@ int StoreApInfo()
void LoadWifiConfig() void LoadWifiConfig()
{ {
flash_t flash;
rtw_wifi_config_t local_config; rtw_wifi_config_t local_config;
uint32_t address; local_config.boot_mode = 0;
#ifdef USE_FLASH_EEP
if(flash_read_cfg((uint8_t *)(&local_config), FEEP_ID_WIFI_AP_CFG, sizeof(rtw_wifi_config_t)) >= sizeof(rtw_wifi_config_t)) {
printf("%s: Read from FLASH!\n", __FUNCTION__);
printf("%s: local_config.boot_mode=0x%x\n", __FUNCTION__, local_config.boot_mode);
printf("%s: local_config.ssid=%s\n", __FUNCTION__, local_config.ssid);
printf("%s: local_config.channel=%d\n", __FUNCTION__, local_config.channel);
printf("%s: local_config.security_type=%d\n", __FUNCTION__, local_config.security_type);
printf("%s: local_config.password=%s\n", __FUNCTION__, local_config.password);
}
if(local_config.boot_mode == 0x77665502) {
wifi_setting.mode = RTW_MODE_AP;
if(local_config.ssid_len > 32)
local_config.ssid_len = 32;
memcpy(wifi_setting.ssid, local_config.ssid, local_config.ssid_len);
wifi_setting.ssid[local_config.ssid_len] = '\0';
wifi_setting.channel = local_config.channel;
if(local_config.security_type == 1)
wifi_setting.security_type = RTW_SECURITY_WPA2_AES_PSK;
else
wifi_setting.security_type = RTW_SECURITY_OPEN;
if(local_config.password_len > 32)
local_config.password_len = 32;
memcpy(wifi_setting.password, local_config.password, local_config.password_len);
wifi_setting.password[local_config.password_len] = '\0';
}
else {
LoadWifiSetting();
}
#else
flash_t flash;
uint32_t address;
address = DATA_SECTOR; address = DATA_SECTOR;
@ -560,6 +592,7 @@ void LoadWifiConfig()
flash_stream_read(&flash, address, sizeof(rtw_wifi_config_t),(uint8_t *)(&local_config)); flash_stream_read(&flash, address, sizeof(rtw_wifi_config_t),(uint8_t *)(&local_config));
device_mutex_unlock(RT_DEV_LOCK_FLASH); device_mutex_unlock(RT_DEV_LOCK_FLASH);
printf("\r\nLoadWifiConfig(): local_config.boot_mode=0x%x\n", local_config.boot_mode); printf("\r\nLoadWifiConfig(): local_config.boot_mode=0x%x\n", local_config.boot_mode);
printf("\r\nLoadWifiConfig(): local_config.ssid=%s\n", local_config.ssid); printf("\r\nLoadWifiConfig(): local_config.ssid=%s\n", local_config.ssid);
printf("\r\nLoadWifiConfig(): local_config.channel=%d\n", local_config.channel); printf("\r\nLoadWifiConfig(): local_config.channel=%d\n", local_config.channel);
@ -587,12 +620,29 @@ void LoadWifiConfig()
{ {
LoadWifiSetting(); LoadWifiSetting();
} }
#endif
} }
int StoreApInfo() int StoreApInfo()
{ {
#ifdef USE_FLASH_EEP
rtw_wifi_config_t wifi_config;
// clean wifi_config first
memset(&wifi_config, 0x00, sizeof(rtw_wifi_config_t));
wifi_config.boot_mode = 0x77665502;
memcpy(wifi_config.ssid, wifi_setting.ssid, strlen((char*)wifi_setting.ssid));
wifi_config.ssid_len = strlen((char*)wifi_setting.ssid);
wifi_config.security_type = wifi_setting.security_type;
if(wifi_setting.security_type !=0)
wifi_config.security_type = 1;
else
wifi_config.security_type = 0;
memcpy(wifi_config.password, wifi_setting.password, strlen((char*)wifi_setting.password));
wifi_config.password_len= strlen((char*)wifi_setting.password);
wifi_config.channel = wifi_setting.channel;
printf("\n\rWritting boot mode 0x77665502 and Wi-Fi setting to flash ...");
flash_write_cfg((uint8_t *)(&wifi_config), FEEP_ID_WIFI_AP_CFG, sizeof(wifi_config));
#else
flash_t flash; flash_t flash;
rtw_wifi_config_t wifi_config; rtw_wifi_config_t wifi_config;
@ -659,11 +709,14 @@ int StoreApInfo()
//flash_stream_read(&flash, address, sizeof(rtw_wifi_config_t),data); //flash_stream_read(&flash, address, sizeof(rtw_wifi_config_t),data);
//printf("\n\r Base + 0x000FF000 +4 wifi config = %s",data[4]); //printf("\n\r Base + 0x000FF000 +4 wifi config = %s",data[4]);
//printf("\n\r Base + 0x000FF000 +71 wifi channel = %d",data[71]); //printf("\n\r Base + 0x000FF000 +71 wifi channel = %d",data[71]);
#endif
return 0; return 0;
} }
int EraseApinfo() { int EraseApinfo() {
#ifdef USE_FLASH_EEP
flash_write_cfg(NULL, FEEP_ID_WIFI_AP_CFG, 0);
#else
flash_t flash; flash_t flash;
uint32_t address; uint32_t address;
@ -671,6 +724,7 @@ int EraseApinfo(){
device_mutex_lock(RT_DEV_LOCK_FLASH); device_mutex_lock(RT_DEV_LOCK_FLASH);
flash_erase_sector(&flash, address); flash_erase_sector(&flash, address);
device_mutex_unlock(RT_DEV_LOCK_FLASH); device_mutex_unlock(RT_DEV_LOCK_FLASH);
#endif
return 0; return 0;
} }
#endif #endif

View file

@ -227,10 +227,8 @@ BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
void *pvReturn = NULL; void *pvReturn = NULL;
/* Realtek test code start */ /* Realtek test code start */
if(pxEnd == NULL) if(pxEnd == NULL) vPortDefineHeapRegions( xHeapRegions );
{
vPortDefineHeapRegions( xHeapRegions );
}
/* Realtek test code end */ /* Realtek test code end */
/* The heap must be initialised before the first call to /* The heap must be initialised before the first call to
@ -531,19 +529,25 @@ const HeapRegion_t *pxHeapRegion;
xHeapRegions[2].pucStartAddress = (uint8_t*)&__sdram_data_start__; xHeapRegions[2].pucStartAddress = (uint8_t*)&__sdram_data_start__;
xHeapRegions[2].xSizeInBytes = (u32)0x30200000 - (u32)xHeapRegions[2].pucStartAddress; xHeapRegions[2].xSizeInBytes = (u32)0x30200000 - (u32)xHeapRegions[2].pucStartAddress;
*/ */
int chip_id = HalGetChipId();
if (chip_id >= CHIP_ID_8711AN && chip_id <= CHIP_ID_8711AF) xHeapRegions[2].xSizeInBytes = 0;
#endif #endif
/* Can only call once! */ /* Can only call once! */
configASSERT( pxEnd == NULL ); configASSERT( pxEnd == NULL );
pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] ); pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] );
int chip_id = HalGetChipId();
while( pxHeapRegion->xSizeInBytes > 0 ) while( pxHeapRegion->xSizeInBytes > 0 )
{ {
if(pxHeapRegion->pucStartAddress > 0x20000000
&& chip_id >= CHIP_ID_8711AN && chip_id <= CHIP_ID_8711AF) {
// pxHeapRegion->pucStartAddress = 0;
// pxHeapRegion->xSizeInBytes = 0;
// DBG_8195A("ChipID: %p !\n", chip_id);
}
else {
DBG_8195A("Init Heap Region: %p[%d]\n", pxHeapRegion->pucStartAddress, pxHeapRegion->xSizeInBytes); DBG_8195A("Init Heap Region: %p[%d]\n", pxHeapRegion->pucStartAddress, pxHeapRegion->xSizeInBytes);
#if CONFIG_DEBUG_LOG > 4 #if CONFIG_DEBUG_LOG > 4
// rtl_memset(pxHeapRegion->pucStartAddress, 0, pxHeapRegion->xSizeInBytes); rtl_memset(pxHeapRegion->pucStartAddress, 0, pxHeapRegion->xSizeInBytes);
#endif #endif
xTotalRegionSize = pxHeapRegion->xSizeInBytes; xTotalRegionSize = pxHeapRegion->xSizeInBytes;
/* Ensure the heap region starts on a correctly aligned boundary. */ /* Ensure the heap region starts on a correctly aligned boundary. */
@ -605,7 +609,7 @@ const HeapRegion_t *pxHeapRegion;
} }
xTotalHeapSize += pxFirstFreeBlockInRegion->xBlockSize; xTotalHeapSize += pxFirstFreeBlockInRegion->xBlockSize;
}
/* Move onto the next HeapRegion_t structure. */ /* Move onto the next HeapRegion_t structure. */
xDefinedRegions++; xDefinedRegions++;
pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] ); pxHeapRegion = &( pxHeapRegions[ xDefinedRegions ] );

View file

@ -1,18 +0,0 @@
set libname=lib_platform
del %libname%_tst.a
md %libname%.lib
cd %libname%.lib
PATH=D:\MCU\GNU_Tools_ARM_Embedded\5.2_2015q4\bin;%PATH%
arm-none-eabi-ar.exe x ..\%libname%.a
del hal_efuse.o
del hal_common.o
del freertos_pmu_8195a.o
del hal_soc_ps_monitor.o
del app_start.o
del hal_log_uart.o
del hal_pinmux.o
del hal_misc.o
del startup.o
arm-none-eabi-ar.exe ru ..\%libname%_tst.a *.o
cd ..
rd /q /s %libname%.lib

View file

@ -1,4 +0,0 @@
ram_libc.o
ram_libgloss_retarget.o
rtl_eabi_cast_ram.o
rtl_math_ram.o

View file

@ -1,13 +0,0 @@
set libname=lib_rtlstd
del %libname%_new.a
md %libname%.lib
cd %libname%.lib
PATH=D:\MCU\GNU_Tools_ARM_Embedded\5.2_2015q4\bin;%PATH%
arm-none-eabi-ar.exe x ..\%libname%.a
del ram_libc.o
rem del ram_libgloss_retarget.o
rem del rtl_eabi_cast_ram.o
rem del rtl_math_ram.o
arm-none-eabi-ar.exe ru ..\%libname%_new.a *.o
cd ..
rem rd /q /s %libname%.lib

View file

@ -100,16 +100,36 @@ SECTIONS
.ram_image2.text : .ram_image2.text :
{ {
*(.infra.ram.start*) *(.infra.ram.start*)
. = ALIGN(4);
KEEP(*(.init))
/* init data */
. = ALIGN(4);
PROVIDE (__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE (__init_array_end = .);
. = ALIGN(4);
KEEP(*(.fini))
. = ALIGN(4);
PROVIDE (__fini_array_start = .);
KEEP(*(SORT(.fini_array.*)))
KEEP(*(.fini_array))
PROVIDE (__fini_array_end = .);
*(.mon.ram.text*) *(.mon.ram.text*)
*(.hal.flash.text*) *(.hal.flash.text*)
*(.hal.sdrc.text*) *(.hal.sdrc.text*)
*(.hal.gpio.text*) *(.hal.gpio.text*)
*(.fwu.text*) *(.fwu.text*)
*(.text*) *(.otg.rom.text*)
*(.sdram.text*) *(.sdram.text*)
*(.p2p.text*) *(.p2p.text*)
*(.wps.text*) *(.wps.text*)
*(.websocket.text*) *(.websocket.text*)
*(.text*)
} > BD_RAM } > BD_RAM
.ram_image2.rodata : .ram_image2.rodata :
@ -136,10 +156,6 @@ SECTIONS
{ {
__data_start__ = .; __data_start__ = .;
*(.data*) *(.data*)
*(.sdram.data*)
*(.p2p.data*)
*(.wps.data*)
*(.websocket.data*)
__data_end__ = .; __data_end__ = .;
__ram_image2_text_end__ = .; __ram_image2_text_end__ = .;
} > BD_RAM } > BD_RAM
@ -152,6 +168,12 @@ SECTIONS
*(.hal.sdrc.data*) *(.hal.sdrc.data*)
*(.hal.gpio.data*) *(.hal.gpio.data*)
*(.fwu.data*) *(.fwu.data*)
*(.bdsram.data*)
*(.bfsram.data*)
*(.sdram.data*)
*(.p2p.data*)
*(.wps.data*)
*(.websocket.data*)
*(.bss*) *(.bss*)
*(COMMON) *(COMMON)
*(.sdram.bss*) *(.sdram.bss*)
@ -159,8 +181,6 @@ SECTIONS
*(.wps.bss*) *(.wps.bss*)
*(.websocket.bss*) *(.websocket.bss*)
*(.ssl_ram_map*) *(.ssl_ram_map*)
*(.bdsram.data*)
*(.bfsram.data*)
__bss_end__ = .; __bss_end__ = .;
.ram.bss$$Limit = .; .ram.bss$$Limit = .;

View file

@ -24,8 +24,7 @@ extern char end;
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// Data declarations // Data declarations
static char *rheap_end;
char *heap_end;
// extern __rtl_errno; // extern __rtl_errno;
// extern end; // extern end;
// extern rom_libgloss_ram_map; // extern rom_libgloss_ram_map;
@ -77,12 +76,12 @@ int ram_libgloss_read(int file, char *ptr, int len) {
char *ram_libgloss_sbrk(int incr) { char *ram_libgloss_sbrk(int incr) {
char *prev_heap_end; char *prev_heap_end;
if (!heap_end) if (!rheap_end)
heap_end = (char *) &end; rheap_end = (char *) &end;
prev_heap_end = heap_end; prev_heap_end = rheap_end;
heap_end += incr; rheap_end += incr;
#if CONFIG_DEBUG_LOG > 4 #if CONFIG_DEBUG_LOG > 4
DBG_8195A("ROM_heap = %p[%d], end = %p\n", prev_heap_end, incr, heap_end); DBG_8195A("ROM_heap = %p[%d], end = %p\n", prev_heap_end, incr, rheap_end);
#endif #endif
return prev_heap_end; return prev_heap_end;
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3255
build/obj/build.nmap Normal file

File diff suppressed because it is too large Load diff

View file

@ -9,6 +9,7 @@
#define _INC_FEEP_CONFIG_H_ #define _INC_FEEP_CONFIG_H_
#define FEEP_ID_WIFI_CFG 0x5730 // id:'0W', type: struct wlan_fast_reconnect #define FEEP_ID_WIFI_CFG 0x5730 // id:'0W', type: struct wlan_fast_reconnect
#define FEEP_ID_WIFI_AP_CFG 0x5731 // id:'1W', type: struct rtw_wifi_config_t
#define FEEP_ID_UART_CFG 0x5530 // id:'0U', type: UART_LOG_CONF #define FEEP_ID_UART_CFG 0x5530 // id:'0U', type: UART_LOG_CONF
#define FEEP_ID_LWIP_CFG 0x4C30 // id:'0L', type: struct atcmd_lwip_conf #define FEEP_ID_LWIP_CFG 0x4C30 // id:'0L', type: struct atcmd_lwip_conf
#define FEEP_ID_DHCP_CFG 0x4430 // id:'0D', type: struct #define FEEP_ID_DHCP_CFG 0x4430 // id:'0D', type: struct