阅读bootram代码,添加一些注释
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
OUTPUT_TYPE = 0
|
OUTPUT_TYPE = 0
|
||||||
OUTPUT_NAME = mfgtool
|
OUTPUT_NAME = mfgtool
|
||||||
|
|
||||||
SUB_DIRS = ah oem_tool lzma clzma
|
SUB_DIRS = ah oem_tool lzma clzma bootram
|
||||||
|
|
||||||
# Kl3 compiles ram.bin separately to improve compilation speed.
|
# Kl3 compiles ram.bin separately to improve compilation speed.
|
||||||
ifneq ($(target), kunlun3)
|
ifneq ($(target), kunlun3)
|
||||||
|
@@ -26,11 +26,13 @@ MODTOPDIR = $(TOPDIR)/mfgtool/bootram
|
|||||||
# predefined macro
|
# predefined macro
|
||||||
PRE_MARCO += IOT_DTEST_ONLY_SUPPORT=1 IOT_BUILD_TYPE=6
|
PRE_MARCO += IOT_DTEST_ONLY_SUPPORT=1 IOT_BUILD_TYPE=6
|
||||||
|
|
||||||
ifeq ($(bootram_secret_grade_enable), 0)
|
# 打开调试模式 命令行会开放所有命令
|
||||||
PRE_MARCO += BOOTRAM_SECRET_GRADE_ENABLE=0
|
# ifeq ($(bootram_secret_grade_enable), 0)
|
||||||
else
|
# PRE_MARCO += BOOTRAM_SECRET_GRADE_ENABLE=0
|
||||||
|
# else
|
||||||
|
# PRE_MARCO += BOOTRAM_SECRET_GRADE_ENABLE=1
|
||||||
|
# endif
|
||||||
PRE_MARCO += BOOTRAM_SECRET_GRADE_ENABLE=1
|
PRE_MARCO += BOOTRAM_SECRET_GRADE_ENABLE=1
|
||||||
endif
|
|
||||||
|
|
||||||
SUB_DIRS = $(TOPDIR)/os $(TOPDIR)/common/io_lib $(MODTOPDIR)/bootram $(MODTOPDIR)/bootram/shell/cmd_line/src $(MODTOPDIR)/bootram/executor $(MODTOPDIR)/bootram/executor/lib $(MODTOPDIR)/bootram/sub_executor \
|
SUB_DIRS = $(TOPDIR)/os $(TOPDIR)/common/io_lib $(MODTOPDIR)/bootram $(MODTOPDIR)/bootram/shell/cmd_line/src $(MODTOPDIR)/bootram/executor $(MODTOPDIR)/bootram/executor/lib $(MODTOPDIR)/bootram/sub_executor \
|
||||||
$(MODTOPDIR)/bootram/driver/src $(MODTOPDIR)/bootram/driver/src/$(hw_dep)
|
$(MODTOPDIR)/bootram/driver/src $(MODTOPDIR)/bootram/driver/src/$(hw_dep)
|
||||||
|
@@ -372,6 +372,7 @@ static uint8_t iot_bootram_tool_upload_transmit_data(uint8_t port, uint8_t *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
|
// 如果上位机发送了 0x03 ctrl+c 则退出
|
||||||
if (iot_btm_command_break_detect()) {
|
if (iot_btm_command_break_detect()) {
|
||||||
iot_bootram_xmodem_transmit_end(port);
|
iot_bootram_xmodem_transmit_end(port);
|
||||||
goto err_out;
|
goto err_out;
|
||||||
@@ -623,6 +624,8 @@ err_out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 上传flash数据
|
||||||
static uint8_t btm_executor_upload_data(int cid, uint32_t offset, uint32_t len,
|
static uint8_t btm_executor_upload_data(int cid, uint32_t offset, uint32_t len,
|
||||||
iot_btm_exe_upload_scope_e scope, uint32_t *num)
|
iot_btm_exe_upload_scope_e scope, uint32_t *num)
|
||||||
{
|
{
|
||||||
@@ -644,17 +647,20 @@ static uint8_t btm_executor_upload_data(int cid, uint32_t offset, uint32_t len,
|
|||||||
offset_tmp = offset;
|
offset_tmp = offset;
|
||||||
data_len = len;
|
data_len = len;
|
||||||
}
|
}
|
||||||
|
// 循环等待上位机发送 'c' 字符
|
||||||
ret = iot_bootram_xmodem_transmit_start_with_crc(g_exe_uart_info.btm_exe_uart_port);
|
ret = iot_bootram_xmodem_transmit_start_with_crc(g_exe_uart_info.btm_exe_uart_port);
|
||||||
if (ERR_OK != ret) {
|
if (ERR_OK != ret) {
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 使用xmodem协议发送数据
|
||||||
ret = iot_bootram_tool_send_data(g_exe_uart_info.btm_exe_uart_port,
|
ret = iot_bootram_tool_send_data(g_exe_uart_info.btm_exe_uart_port,
|
||||||
offset_tmp, data_len);
|
offset_tmp, data_len);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
// 发送结束字符
|
||||||
|
// 循环发送结束字符 0x04 ,直到上位机返回应答 0x06
|
||||||
iot_bootram_xmodem_transmit_end(g_exe_uart_info.btm_exe_uart_port);
|
iot_bootram_xmodem_transmit_end(g_exe_uart_info.btm_exe_uart_port);
|
||||||
*num = data_len;
|
*num = data_len;
|
||||||
|
|
||||||
@@ -1430,6 +1436,7 @@ int iot_btm_executor_prosecc(int cid, int p0, int p1, int p2, int p3, int p4, in
|
|||||||
|
|
||||||
int iot_btm_executor_init(void)
|
int iot_btm_executor_init(void)
|
||||||
{
|
{
|
||||||
|
// 这里会把xmodem 的串口初始化为调试串口
|
||||||
btm_executor_init_hw();
|
btm_executor_init_hw();
|
||||||
default_sfc_clk_fre = sfc_clk_div_get();
|
default_sfc_clk_fre = sfc_clk_div_get();
|
||||||
|
|
||||||
|
@@ -227,10 +227,12 @@ int iot_bootram_start(void)
|
|||||||
|
|
||||||
bootram_version_init();
|
bootram_version_init();
|
||||||
|
|
||||||
|
// 注册命令和处理命令的回调函数
|
||||||
iot_btm_executor_init();
|
iot_btm_executor_init();
|
||||||
|
|
||||||
iot_print_config(1);
|
iot_print_config(1);
|
||||||
|
|
||||||
|
// 注册命令行的命令和处理函数
|
||||||
iot_btm_shell_init();
|
iot_btm_shell_init();
|
||||||
|
|
||||||
bootram_main_loop();
|
bootram_main_loop();
|
||||||
|
@@ -137,6 +137,22 @@ static iot_bootram_cmd_line_entity_t *btm_cmd_get_entity(char *cmd, int len)
|
|||||||
return p_cmd_return;
|
return p_cmd_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static iot_bootram_cmd_line_entity_t *btm_cmd_get_entity_by_index(char *cmd, int len,int index)
|
||||||
|
{
|
||||||
|
iot_bootram_cmd_line_entity_t *p_cmd_handle = NULL;
|
||||||
|
|
||||||
|
if(index >= cline_commands.total_cnt || index < 0){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
p_cmd_handle = &(cline_commands.entity[index]);
|
||||||
|
return p_cmd_handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void btm_print_version(void)
|
static void btm_print_version(void)
|
||||||
{
|
{
|
||||||
uint32_t r_time;
|
uint32_t r_time;
|
||||||
@@ -178,6 +194,7 @@ static void btm_cmd_line_help(char *argv[], int argc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 没有输入具体命令的情况下就打印所有命令
|
||||||
if (NULL == p_ent) {
|
if (NULL == p_ent) {
|
||||||
btm_print_version();
|
btm_print_version();
|
||||||
for (i = 0; i < cline_commands.total_cnt; i++) {
|
for (i = 0; i < cline_commands.total_cnt; i++) {
|
||||||
@@ -564,6 +581,8 @@ static void btm_line_completed(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 串口数据的处理函数 赋值给 btm_data_received_callback
|
||||||
static void btm_receive_command(char *buf, int len)
|
static void btm_receive_command(char *buf, int len)
|
||||||
{
|
{
|
||||||
char *ch;
|
char *ch;
|
||||||
|
Reference in New Issue
Block a user