Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: Solve some compile and ci problem
  • Loading branch information
xcguang committed Feb 21, 2020
1 parent 48e930a commit 1329b6e
Show file tree
Hide file tree
Showing 103 changed files with 222 additions and 199 deletions.
23 changes: 18 additions & 5 deletions .gitlab-ci.yml
Expand Up @@ -61,6 +61,8 @@ esp32_wroom_at:
- time ./tools/ci/get-full-sources.sh
- git submodule update --init
- cd -
- export ESP_AT_PROJECT_PLATFORM=PLATFORM_ESP32
- export ESP_AT_MODULE_NAME=WROOM-32
- export ESP_AT_PROJECT_PATH=$(pwd)
- ./esp-idf/tools/idf.py build
- cp build/flash_project_args build/download.config
Expand Down Expand Up @@ -127,6 +129,7 @@ esp32_wrover_at:
- git submodule update --init
- cd -

- export ESP_AT_PROJECT_PLATFORM=PLATFORM_ESP32
- export ESP_AT_MODULE_NAME=WROVER-32
- export ESP_AT_PROJECT_PATH=$(pwd)
- ./esp-idf/tools/idf.py build -DSILENCE=1
Expand Down Expand Up @@ -194,9 +197,10 @@ pico_d4_at:
- git submodule update --init
- cd -

- export ESP_AT_PROJECT_PLATFORM=PLATFORM_ESP32
- export ESP_AT_MODULE_NAME=PICO-D4
- export ESP_AT_PROJECT_PATH=$(pwd)
- ./esp-idf/tools/idf.py build -DSILENCE=1
- ./esp-idf/tools/idf.py build
- cp build/flash_project_args build/download.config
# - make print_flash_cmd | tail -n 1 > build/download.config
# - make factory_bin
Expand Down Expand Up @@ -262,9 +266,10 @@ solo_1_at:
- git submodule update --init
- cd -

- export ESP_AT_PROJECT_PLATFORM=PLATFORM_ESP32
- export ESP_AT_MODULE_NAME=SOLO-1
- export ESP_AT_PROJECT_PATH=$(pwd)
- ./esp-idf/tools/idf.py build -DSILENCE=1
- ./esp-idf/tools/idf.py build
- cp build/flash_project_args build/download.config
# - make print_flash_cmd | tail -n 1 > build/download.config
# - make factory_bin
Expand Down Expand Up @@ -329,11 +334,12 @@ esp8266_wroom_02_at:
- export ESP_AT_PROJECT_PLATFORM=PLATFORM_ESP8266
- export ESP_AT_MODULE_NAME=WROOM-02
- export ESP_AT_PROJECT_PATH=$(pwd)
- ./esp-idf/tools/idf.py build -DSILENCE=1
- ./esp-idf/tools/idf.py build
- cp build/flash_project_args build/download.config
# - make print_flash_cmd | tail -n 1 > build/download.config
# - make factory_bin


esp8266_wroom_5V2L_at:
stage: build
image: $CI_DOCKER_REGISTRY/esp8266-ci-env-new
Expand Down Expand Up @@ -393,7 +399,7 @@ esp8266_wroom_5V2L_at:
- export ESP_AT_PROJECT_PLATFORM=PLATFORM_ESP8266
- export ESP_AT_MODULE_NAME=WROOM-5V2L
- export ESP_AT_PROJECT_PATH=$(pwd)
- ./esp-idf/tools/idf.py build -DSILENCE=1
- ./esp-idf/tools/idf.py build
- cp build/flash_project_args build/download.config
# - make print_flash_cmd | tail -n 1 > build/download.config
# - make factory_bin
Expand Down Expand Up @@ -456,8 +462,14 @@ esp32_demo:
- cd -

- cd examples/at_http_webserver
- export ESP_AT_PROJECT_PLATFORM=PLATFORM_ESP32
- export ESP_AT_MODULE_NAME=WROOM-32
- export ESP_AT_PROJECT_PATH=$(pwd)/../..
- make defconfig
- make -j8
- unset ESP_AT_PROJECT_PLATFORM
- unset ESP_AT_MODULE_NAME
- unset ESP_AT_PROJECT_PATH
- cd -

- cd examples/at_sdio_host
Expand Down Expand Up @@ -545,9 +557,10 @@ wrover32_all_function_at:
- git submodule update --init
- cd -

- export ESP_AT_PROJECT_PLATFORM=PLATFORM_ESP32
- export ESP_AT_MODULE_NAME=WROVER-32
- export ESP_AT_PROJECT_PATH=$(pwd)
- ./esp-idf/tools/idf.py build -DSILENCE=1
- ./esp-idf/tools/idf.py build
- cp build/flash_project_args build/download.config
# - make print_flash_cmd | tail -n 1 > build/download.config
# - make factory_bin
8 changes: 7 additions & 1 deletion CMakeLists.txt
Expand Up @@ -14,10 +14,16 @@ endif()

set(IDF_PATH ${CMAKE_SOURCE_DIR}/esp-idf)

string(TOLOWER $ENV{ESP_AT_MODULE_NAME} LOWER_NAME)

set(ESP_AT_MODULE_CONFIG_DIR ${CMAKE_SOURCE_DIR}/module_config/module_${LOWER_NAME})
if (NOT EXISTS "${ESP_AT_MODULE_CONFIG_DIR}")
string(SUBSTRING "$ENV{ESP_AT_PROJECT_PLATFORM}" 9 31 PLATFORM_NAME) # remove PLATFORM_
string(TOLOWER ${PLATFORM_NAME} LOWER_NAME)

set(ESP_AT_MODULE_CONFIG_DIR ${CMAKE_SOURCE_DIR}/module_config/module_${LOWER_NAME}_default )
endif()

SET(ENV{ESP_AT_PROJECT_PATH} ${CMAKE_SOURCE_DIR} )

if (NOT DEFINED SILENCE)
Expand Down Expand Up @@ -87,7 +93,7 @@ include(${IDF_PATH}/tools/cmake/project.cmake)

project(esp-at)

add_custom_target(factory_bin ALL DEPENDS app)
add_custom_target(factory_bin ALL DEPENDS customized_bin)
add_custom_command(TARGET factory_bin
POST_BUILD
COMMAND mkdir -p $ENV{ESP_AT_PROJECT_PATH}/build/factory
Expand Down
16 changes: 14 additions & 2 deletions components/customized_partitions/CMakeLists.txt
Expand Up @@ -4,6 +4,7 @@ idf_build_get_property(build_dir BUILD_DIR)
idf_build_get_property(project_dir PROJECT_DIR)

set(flash_customized_partition_args ${build_dir}/flash_customized_partition_args)
set(module_info ${build_dir}/module_info)

STRING(REGEX REPLACE ".*/(.*)\.csv" "\\1" customize_bin ${CONFIG_AT_CUSTOMIZED_PARTITION_TABLE_FILE})
set(customize_bin_full_name ${customize_bin}.bin)
Expand All @@ -14,11 +15,10 @@ execute_process (
esptool_py_flash_project_args(${customize_bin} ${CONFIG_AT_CUSTOMIZED_PARTITION_TABLE_OFFSET} ${build_dir}/${customize_bin_full_name} FLASH_IN_PROJECT)

execute_process (
COMMAND ${PYTHON} ${COMPONENT_DIR}/raw_data/raw_data_bin_gen.py
COMMAND ${PYTHON} ${COMPONENT_DIR}/raw_data/at_customized_partition_parse.py
--sdkconfig_file ${project_dir}/sdkconfig
--dependency_file ${COMPONENT_DIR}/AT_partition_dependency
--partition_file ${project_dir}/${CONFIG_AT_CUSTOMIZED_PARTITION_TABLE_FILE}
--tools_dir ${COMPONENT_DIR}/generation_tools
--output_dir ${build_dir}/${COMPONENT_NAME}
--flash_args_file ${flash_customized_partition_args}
)
Expand All @@ -35,3 +35,15 @@ foreach(partition_args ${customized_partition_args})

esptool_py_flash_project_args(${file_name} ${offset} ${file_path} FLASH_IN_PROJECT)
endforeach(partition_args)

add_custom_target(customized_bin ALL DEPENDS app)
add_custom_command(TARGET customized_bin
POST_BUILD
COMMAND mkdir -p ${build_dir}/include
COMMAND cp ${build_dir}/config/sdkconfig.h ${build_dir}/include/sdkconfig.h
COMMAND ${PYTHON} ${COMPONENT_DIR}/raw_data/at_customized_partition_gen.py
--tools_dir ${COMPONENT_DIR}/generation_tools
--output_dir ${build_dir}/${COMPONENT_NAME}
--flash_args_file ${flash_customized_partition_args}
COMMENT "Create customized_bin..."
)
Expand Up @@ -31,8 +31,8 @@ RAW_DATA_FOLDER=$ESP_AT_PROJECT_PATH/components/customized_partitions/raw_data/f
MODULE_FILE=$(ls $RAW_DATA_FOLDER/factory_param_data.csv | awk '{print $1}')
DEFINE_FILE=$(ls $RAW_DATA_FOLDER/factory_param_type.csv | awk '{print $1}')

LOG_FILE=$ESP_AT_PROJECT_PATH/build/factory/factory_parameter.log
LOG_FILE=$(dirname ${TARGET_FOLDER})/factory/factory_parameter.log

echo "generating factory_param.bin($MODULE_NAME): python $TOOL_PATH -t $TARGET_FOLDER/$PARTITION_NAME.bin $MODULE_FILE"
echo "generating factory_param.bin($ESP_AT_MODULE_NAME): python $TOOL_PATH -t $TARGET_FOLDER/$PARTITION_NAME.bin $MODULE_FILE"

python $TOOL_PATH --platform $ESP_AT_PROJECT_PLATFORM --module $ESP_AT_MODULE_NAME --bin_name $TARGET_FOLDER/$PARTITION_NAME.bin --define_file $DEFINE_FILE --module_file $MODULE_FILE --log_file $LOG_FILE
6 changes: 4 additions & 2 deletions components/customized_partitions/generation_tools/fatfs.sh
Expand Up @@ -23,6 +23,7 @@
#

ESP_AT_IMAGE_SIZE_STR=$3
BUILD_DIR_BASE=$(dirname $2)

if [ ${ESP_AT_IMAGE_SIZE_STR: -1} == K ]
then
Expand All @@ -32,6 +33,7 @@ else
let ESP_AT_IMAGE_SIZE=$[ESP_AT_IMAGE_SIZE_STR]
fi

make mkfatfs
# make mkfatfs
make -C $ESP_AT_PROJECT_PATH/tools/mkfatfs BUILD_DIR_BASE=${BUILD_DIR_BASE}

"$ESP_AT_PROJECT_PATH"/tools/mkfatfs/src/mkfatfs -c "$ESP_AT_IMAGE_DIR" -s $ESP_AT_IMAGE_SIZE $2/$1.bin
${BUILD_DIR_BASE}/mkfatfs/mkfatfs -c "$ESP_AT_IMAGE_DIR" -s $ESP_AT_IMAGE_SIZE $2/$1.bin
@@ -0,0 +1,58 @@
#
# ESPRESSIF MIT License
#
# Copyright (c) 2020 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
#
# Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP32 only, in which case,
# it is free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished
# to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
import os
import sys
import stat
import argparse
import subprocess

def main():
""" main """
parser = argparse.ArgumentParser()
parser.add_argument("--tools_dir", default=".", help="the tools directory")
parser.add_argument("--output_dir", default="output", help="the output bin directory")
parser.add_argument("--flash_args_file", default="flash_args_file", help="the file to store flash args")
args = parser.parse_args()

tools_dir = args.tools_dir
output_dir = args.output_dir
flash_args_file = args.flash_args_file

if os.path.exists(output_dir) == False:
os.mkdir(output_dir)

with open(flash_args_file, 'r') as args_file:
for line in args_file.readlines():
line_str = line.strip()
str_list = line_str.split(' ')
full_filename = str_list[1]
file_size = str_list[2]
file_name = os.path.basename(full_filename)
partition_name = os.path.splitext(file_name)[0]
tool_name = os.path.join(tools_dir, ''.join([partition_name, '.sh']))
if not os.access(tool_name, os.X_OK):
os.chmod(tool_name, stat.S_IRUSR | stat.S_IXUSR)
subprocess.call([tool_name, partition_name, output_dir, file_size], shell = False)

if __name__ == '__main__':
main()
Expand Up @@ -48,23 +48,21 @@ def parse_partition_tables (partition_file):
if str_list[0] in generation_tools:
offset = str_list[3]
size = str_list[4]
generation_tools.update({str_list[0] : {'offset' : offset}})
generation_tools.update({str_list[0] : {'offset' : offset, 'size' : size}})

def main():
""" main """
parser = argparse.ArgumentParser()
parser.add_argument("--dependency_file", help="dependency")
parser.add_argument("--sdkconfig_file", help="sdkconfig")
parser.add_argument("--partition_file", help="at_customize.csv")
parser.add_argument("--tools_dir", default=".", help="the tools directory")
parser.add_argument("--output_dir", default="output", help="the output bin directory")
parser.add_argument("--flash_args_file", default="flash_args_file", help="the file to store flash args")
args = parser.parse_args()

sdkconfig_file = args.sdkconfig_file
dependency_file = args.dependency_file
partition_file = args.partition_file
tools_dir = args.tools_dir
output_dir = args.output_dir
flash_args_file = args.flash_args_file
parse_generation_tools(dependency_file, sdkconfig_file)
Expand All @@ -75,14 +73,9 @@ def main():

with open(flash_args_file, 'w+') as args_file:
for partition in generation_tools:
script = ''.join([partition, '.sh'])
tool = os.path.join(tools_dir, script)
if not os.access(tool, os.X_OK):
os.chmod(tool, stat.S_IRUSR | stat.S_IXUSR)
cmd = ' '.join([tool, partition, output_dir, generation_tools[partition]['offset']])
subprocess.call([tool, partition, output_dir], shell = False)
args_file.write(''.join([generation_tools[partition]['offset'], ' ']))
args_file.write(''.join([os.path.join(output_dir, partition), '.bin\r\n']))
args_file.write(''.join([os.path.join(output_dir, partition), ''.join(['.bin', ' '])]))
args_file.write(''.join([generation_tools[partition]['size'], '\r\n']))

if __name__ == '__main__':
main()
8 changes: 5 additions & 3 deletions examples/at_http_webserver/Makefile
Expand Up @@ -18,9 +18,11 @@ EXTRA_CFLAGS += -DSDK_GIT=IDF_VER
include $(IDF_PATH)/make/project.mk

factory_bin:
$(PYTHON) $(ESP_AT_PROJECT_PATH)/tools/esp32_at_combine.py \
--bin_directory $(ESP_AT_PROJECT_PATH)/build \
$(PYTHON) $(ESP_AT_PROJECT_PATH)/tools/esp_at_factory_bin_combine.py \
--module_name $(ESP_AT_MODULE_NAME) \
--bin_directory $(PWD)/build \
--flash_mode $(CONFIG_ESPTOOLPY_FLASHMODE) \
--flash_size $(CONFIG_ESPTOOLPY_FLASHSIZE) \
--flash_speed $(CONFIG_ESPTOOLPY_FLASHFREQ)
--flash_speed $(CONFIG_ESPTOOLPY_FLASHFREQ) \
--download_config $(PWD)/build/download.config

2 changes: 1 addition & 1 deletion examples/at_http_webserver/components/atparse/cmdparse.c
Expand Up @@ -1232,7 +1232,7 @@ static int8_t at_bledisconn_pack(at_cmd_arg* cmd_arg)
static int8_t at_bleadvparam_pack(at_cmd_arg* cmd_arg)
{
uint32_t cmd_len = 0;
char cmd_tmp[30];
char cmd_tmp[60];

if (cmd_arg->bleadvparam.adv_filter_policy != -1 && cmd_arg->bleadvparam.peer_addr_type != -1 && strlen(cmd_arg->bleadvparam.peer_address) > 0) {
cmd_len = snprintf(cmd_tmp, sizeof(cmd_tmp), "AT+BLEADVPARAM=%d,%d,%d,%d,%d,%d,%d,%s\r\n", cmd_arg->bleadvparam.adv_int_min, cmd_arg->bleadvparam.adv_int_max, cmd_arg->bleadvparam.adv_type, cmd_arg->bleadvparam.addr_type, cmd_arg->bleadvparam.channel, cmd_arg->bleadvparam.adv_filter_policy, cmd_arg->bleadvparam.peer_addr_type, cmd_arg->bleadvparam.peer_address);
Expand Down
4 changes: 2 additions & 2 deletions examples/at_http_webserver/components/atparse/esp_parse_at.c
Expand Up @@ -1432,8 +1432,8 @@ esp_err_t esp_at_init_parse(void)
#if CONFIG_ESP_WIFI_MODE_AP
// set softAP ssid: AT_HTTP_WEBSERVER, password: 12345678
memset(&cmd_arg, 0x0, sizeof(at_cmd_arg));
strncpy(cmd_arg.cwsap.ssid, CONFIG_ESP_WIFI_SSID, strlen(CONFIG_ESP_WIFI_SSID));
strncpy(cmd_arg.cwsap.pwd, CONFIG_ESP_WIFI_PASSWORD, strlen(CONFIG_ESP_WIFI_PASSWORD));
strncpy(cmd_arg.cwsap.ssid, CONFIG_ESP_WIFI_SSID, sizeof(cmd_arg.cwsap.ssid));
strncpy(cmd_arg.cwsap.pwd, CONFIG_ESP_WIFI_PASSWORD, sizeof(cmd_arg.cwsap.pwd));
cmd_arg.cwsap.chl = 8;
cmd_arg.cwsap.ecn = 4;
at_result = at_add_cmd(AT_CWSAP, &cmd_arg);
Expand Down
1 change: 0 additions & 1 deletion module_config/module_wrover-32/sdkconfig.defaults
Expand Up @@ -132,7 +132,6 @@ CONFIG_FATFS_LFN_HEAP=y

####
CONFIG_VFS_SUPPORT_TERMIOS=n
CONFIG_NEWLIB_NANO_FORMAT=y
CONFIG_ESP32_DEBUG_OCDAWARE=n
CONFIG_ESP32_DEBUG_STUBS_ENABLE=n
CONFIG_ESP_ERR_TO_NAME_LOOKUP=n
Expand Down
1 change: 0 additions & 1 deletion module_config/module_wrover-32/sdkconfig_silence.defaults
Expand Up @@ -132,7 +132,6 @@ CONFIG_FATFS_LFN_HEAP=y

####
CONFIG_VFS_SUPPORT_TERMIOS=n
CONFIG_NEWLIB_NANO_FORMAT=y
CONFIG_ESP32_DEBUG_OCDAWARE=n
CONFIG_ESP32_DEBUG_STUBS_ENABLE=n
CONFIG_ESP_ERR_TO_NAME_LOOKUP=n
Expand Down
2 changes: 1 addition & 1 deletion tools/esp_at_factory_bin_combine.py
Expand Up @@ -75,7 +75,7 @@ def esp32_at_combine_bin(modlule, flash_mode, flash_size, flash_speed, build_dir
print("Create %s for %s finished"%(factory_bin, modlule_name))

else:
factory_bin = os.path.join(os.path.dirname(parameter_file), 'factory.bin')
factory_bin = os.path.join(build_dir, 'factory.bin')
with open(factory_bin, 'wb') as f:
f.write(bin_data)
print("Create %s finished"%(factory_bin))
Expand Down
Empty file removed tools/mkfatfs/CMakeLists.txt
Empty file.

0 comments on commit 1329b6e

Please sign in to comment.