<commit_before>// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
//
// 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.

#include <stdint.h>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>

#include "sdkconfig.h"

#include "nvs_flash.h"
#include "tcpip_adapter.h"

#include "esp_log.h"
#include "esp_image_format.h"
#include "esp_phy_init.h"
#include "esp_wifi_osi.h"
#include "internal/esp_wifi_internal.h"

#define FLASH_MAP_ADDR 0x40200000

extern void chip_boot(size_t start_addr);
extern int rtc_init(void);
extern int mac_init(void);
extern int base_gpio_init(void);
extern int watchdog_init(void);
extern int wifi_timer_init(void);
extern int wifi_nvs_init(void);

static void user_init_entry(void *param)
{
    void (**func)(void);

    extern void (*__init_array_start)(void);
    extern void (*__init_array_end)(void);

    extern void app_main(void);

    /* initialize C++ construture function */
    for (func = &__init_array_start; func < &__init_array_end; func++)
        func[0]();

    assert(nvs_flash_init() == 0);
    assert(wifi_nvs_init() == 0);
    assert(rtc_init() == 0);
    assert(mac_init() == 0);
    assert(base_gpio_init() == 0);
    esp_phy_load_cal_and_init(0);
    assert(watchdog_init() == 0);
    assert(wifi_timer_init() == 0);

    tcpip_adapter_init();
    esp_wifi_set_rx_pbuf_mem_type(WIFI_RX_PBUF_DRAM);

    app_main();

    wifi_task_delete(NULL);
}

void call_user_start(size_t start_addr)
{
    int i;
    int *p;

    extern int _bss_start, _bss_end;

    esp_image_header_t *head = (esp_image_header_t *)(FLASH_MAP_ADDR + CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET);
    esp_image_segment_header_t *segment = (esp_image_segment_header_t *)((uintptr_t)head + sizeof(esp_image_header_t));

    for (i = 0; i < 3; i++) {
        segment = (esp_image_segment_header_t *)((uintptr_t)segment + sizeof(esp_image_segment_header_t) + segment->data_len);

        uint32_t *dest = (uint32_t *)segment->load_addr;
        uint32_t *src = (uint32_t *)((uintptr_t)segment + sizeof(esp_image_segment_header_t));
        uint32_t size = segment->data_len / sizeof(uint32_t);

        while (size--)<commit_msg>feat(esp8266): Remove TCPIP adapter initilization from startup.<commit_after>// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
//
// 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.

#include <stdint.h>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>

#include "sdkconfig.h"

#include "nvs_flash.h"
#include "tcpip_adapter.h"

#include "esp_log.h"
#include "esp_image_format.h"
#include "esp_phy_init.h"
#include "esp_wifi_osi.h"
#include "internal/esp_wifi_internal.h"

#define FLASH_MAP_ADDR 0x40200000

extern void chip_boot(size_t start_addr);
extern int rtc_init(void);
extern int mac_init(void);
extern int base_gpio_init(void);
extern int watchdog_init(void);
extern int wifi_timer_init(void);
extern int wifi_nvs_init(void);

static void user_init_entry(void *param)
{
    void (**func)(void);

    extern void (*__init_array_start)(void);
    extern void (*__init_array_end)(void);

    extern void app_main(void);

    /* initialize C++ construture function */
    for (func = &__init_array_start; func < &__init_array_end; func++)
        func[0]();

    assert(nvs_flash_init() == 0);
    assert(wifi_nvs_init() == 0);
    assert(rtc_init() == 0);
    assert(mac_init() == 0);
    assert(base_gpio_init() == 0);
    esp_phy_load_cal_and_init(0);
    assert(watchdog_init() == 0);
    assert(wifi_timer_init() == 0);

    esp_wifi_set_rx_pbuf_mem_type(WIFI_RX_PBUF_DRAM);

    app_main();

    wifi_task_delete(NULL);
}

void call_user_start(size_t start_addr)
{
    int i;
    int *p;

    extern int _bss_start, _bss_end;

    esp_image_header_t *head = (esp_image_header_t *)(FLASH_MAP_ADDR + CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET);
    esp_image_segment_header_t *segment = (esp_image_segment_header_t *)((uintptr_t)head + sizeof(esp_image_header_t));

    for (i = 0; i < 3; i++) {
        segment = (esp_image_segment_header_t *)((uintptr_t)segment + sizeof(esp_image_segment_header_t) + segment->data_len);

        uint32_t *dest = (uint32_t *)segment->load_addr;
        uint32_t *src = (uint32_t *)((uintptr_t)segment + sizeof(esp_image_segment_header_t));
        uint32_t size = segment->data_len / sizeof(uint32_t);

        while (size--)
{'fraction_non_alphanumeric': 0.12131941856131197, 'fraction_numerical': 0.01714498695490123, 'mean_word_length': 4.404833836858006, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2629785', 'n_tokens_mistral': 1952, 'n_tokens_neox': 1863, 'n_words': 458}