From: snickersun Date: Tue, 29 Dec 2020 12:58:28 +0000 (+0800) Subject: 实现下载所有需要的所有接口,为项目多添加一个 libag3335m_dl.so X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=b00612bcdfddf9226e573eec05fd991418ae7c40;p=ag3335m_download_demo.git 实现下载所有需要的所有接口,为项目多添加一个 libag3335m_dl.so 并编译 ag333m_tool 测试工具。 测试暂未成功,只能正常进入download DA 模式,下载不成功,还需调试。 --- diff --git a/app/build.gradle b/app/build.gradle index 5d155be..c673a44 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,7 +17,7 @@ android { } ndk{ //ldLibs "log", "z", "cutils" - moduleName"ag3335m_jni" //生成的so文件名字,调用C程序的代码中会用到该名字 + moduleName"ag3335m_jni ag3335m_dl" //生成的so文件名字,调用C程序的代码中会用到该名字 abiFilters 'armeabi-v7a' //, 'armeabi','x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a' } @@ -56,7 +56,7 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - ndkVersion '20.1.5948944' +// ndkVersion '20.1.5948944' // sourceSets.main { // jniLibs.srcDir 'src/main/libs' // jni.srcDirs = [] //disable automatic ndk-build call diff --git a/app/src/main/jni/Android.mk b/app/src/main/jni/Android.mk index a156c14..1a37bb7 100644 --- a/app/src/main/jni/Android.mk +++ b/app/src/main/jni/Android.mk @@ -45,7 +45,7 @@ LOCAL_SRC_FILES := \ LOCAL_C_INCLUDES := bionic/libc/bionic $(LOCAL_PATH)/libag3335m/inc LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog -lc -LOCAL_SHARED_LIBRARIES += libag3335m_jni +LOCAL_SHARED_LIBRARIES += libag3335m_dl LOCAL_MODULE := ag333m_tool LOCAL_ALLOW_UNDEFINED_SYMBOLS := true diff --git a/app/src/main/jni/CMakeLists.txt b/app/src/main/jni/CMakeLists.txt index 79e433f..074f7fd 100644 --- a/app/src/main/jni/CMakeLists.txt +++ b/app/src/main/jni/CMakeLists.txt @@ -40,9 +40,41 @@ find_library( # Sets the name of the path variable. # can link multiple libraries, such as libraries you define in this # build script, prebuilt third-party libraries, or system libraries. +include_directories(${PROJECT_SOURCE_DIR}/libag3335m/inc/hdl_ports/) +include_directories(${PROJECT_SOURCE_DIR}/libag3335m/inc/) +include_directories(${PROJECT_SOURCE_DIR}/libag3335m/) + target_link_libraries( # Specifies the target library. ag3335m_jni # Links the target library to the log library # included in the NDK. - ${log-lib}) \ No newline at end of file + ${log-lib}) + +add_library( # Sets the name of the library. + ag3335m_dl + + # Sets the library as a shared library. + SHARED + + # Provides a relative path to your source file(s). + + libag3335m/src/hdl_demo.c + libag3335m/src/hdl_debug.c + libag3335m/src/hdl_da_cmd.c + libag3335m/src/hdl_channel.c + libag3335m/src/hdl_brom_base.c + libag3335m/src/hdl_api.c + libag3335m/src/hdl_ports/hdl_flash_api.c + libag3335m/src/hdl_ports/hdl_uart.c + libag3335m/src/hdl_ports/hdl_os_util.c + libag3335m/src/hdl_ports/md5.c + ) + +target_link_libraries( # Specifies the target library. + ag3335m_dl + + # Links the target library to the log library + # included in the NDK. + ${log-lib}) + diff --git a/app/src/main/jni/libag3335m/inc/hdl_api.h b/app/src/main/jni/libag3335m/inc/hdl_api.h index 8b5fc02..59c6615 100644 --- a/app/src/main/jni/libag3335m/inc/hdl_api.h +++ b/app/src/main/jni/libag3335m/inc/hdl_api.h @@ -49,7 +49,7 @@ typedef enum { DISCONNECT_RESET } HDL_DISCONNECT_TYPE; -bool hdl_connect(const hdl_da_info_t *da_info, const hdl_connect_arg_t *connect_arg, +bool hdl_connect(const hdl_image_t *da_info, const hdl_connect_arg_t *connect_arg, hdl_da_report_t *da_report); bool hdl_format(const hdl_format_arg_t *format_arg); bool hdl_readback(const hdl_readback_arg_t *readback_arg); diff --git a/app/src/main/jni/libag3335m/inc/hdl_brom_base.h b/app/src/main/jni/libag3335m/inc/hdl_brom_base.h index 71625aa..3936705 100644 --- a/app/src/main/jni/libag3335m/inc/hdl_brom_base.h +++ b/app/src/main/jni/libag3335m/inc/hdl_brom_base.h @@ -75,7 +75,7 @@ bool hdl_brom_write16(uint32_t addr, uint16_t data); bool hdl_brom_write32(uint32_t addr, uint32_t data); bool hdl_brom_send_da(const hdl_connect_arg_t *connect_arg, - uint32_t da_flash_pos, uint32_t da_start_addr, uint32_t da_len); + hdl_image_t *img_info, uint32_t da_start_addr, uint32_t da_len); bool hdl_brom_jump_da(uint32_t addr); diff --git a/app/src/main/jni/libag3335m/inc/hdl_config.h b/app/src/main/jni/libag3335m/inc/hdl_config.h index ca7b7bd..9452e40 100644 --- a/app/src/main/jni/libag3335m/inc/hdl_config.h +++ b/app/src/main/jni/libag3335m/inc/hdl_config.h @@ -119,43 +119,59 @@ typedef int hal_uart_baudrate_t ; //#define PSRAM_DOWNLOAD /*** - * main_region: +bootloader + file: slave_da_UART.bin + name: slave_da + begin_address: 0x00100000 + filesize : 27103 +main_region: address_type: physical rom_list: - rom: file: partition_table.bin name: PartitionTable begin_address: 0x08000000 + file size 384 - rom: file: ag3335_bootloader.bin name: BootLoader begin_address: 0x08003000 + file size 17428 - rom: file: gnss_demo.bin name: CM4 begin_address: 0x08013000 + file size 104974 - rom: file: gnss_config.bin name: GNSSConfiguration begin_address: 0x083FF000 + file size 1024 */ + +#define ROMPATH "/data/ag3335m_rom" // DA Flash Position +#define HDL_DA_FILE_PATH "slave_da_UART.bin" #define HDL_DA_FLASH_POS 0x00100000 -#define HDL_DA_SIZE 28672 +#define HDL_DA_SIZE 27103 // Test Images Flash Position in Host & Target Device -#define HDL_BL_IMAGE_HOST_FLASH_POS 0x00110000 -#define HDL_BL_IMAGE_SLAVE_FLASH_POS 0x08010000 -#define HDL_BL_IMAGE_SIZE 32768 +#define HDL_PARTITION_IMAGE_HOST_IMAGE_NAME "partition_table.bin" +#define HDL_PARTITION_IMAGE_SLAVE_FLASH_POS 0x08000000 +#define HDL_PARTITION_IMAGE_SIZE 384 +#define HDL_PARTITION_IMAGE_NAME "Partition" +#define HDL_BL_IMAGE_HOST_IMAGE_NAME "ag3335_bootloader.bin" +#define HDL_BL_IMAGE_SLAVE_FLASH_POS 0x08003000 +#define HDL_BL_IMAGE_SIZE 17428 #define HDL_BL_IMAGE_NAME "BootLoader" -#define HDL_CM4_IMAGE_HOST_FLASH_POS 0x00120000 -#define HDL_CM4_IMAGE_SLAVE_FLASH_POS 0x08020000 -#define HDL_CM4_IMAGE_SIZE 540672 +#define HDL_CM4_IMAGE_HOST_IMAGE_NAME "gnss_demo.bin" +#define HDL_CM4_IMAGE_SLAVE_FLASH_POS 0x08013000 +#define HDL_CM4_IMAGE_SIZE 104974 #define HDL_CM4_IMAGE_NAME "CM4" -#define HDL_OTHER_IMAGE_HOST_FLASH_POS 0x001F0000 -#define HDL_OTHER_IMAGE_SLAVE_FLASH_POS 0x080F0000 -#define HDL_OTHER_IMAGE_SIZE 53248 -#define HDL_OTHER_IMAGE_NAME "Other" +#define HDL_OTHER_IMAGE_HOST_IMAGE_NAME "gnss_config.bin" +#define HDL_OTHER_IMAGE_SLAVE_FLASH_POS 0x083FF000 +#define HDL_OTHER_IMAGE_SIZE 1024 +#define HDL_OTHER_IMAGE_NAME "Config" #ifdef __cplusplus } diff --git a/app/src/main/jni/libag3335m/inc/hdl_data.h b/app/src/main/jni/libag3335m/inc/hdl_data.h index 1504a54..83e9bd0 100644 --- a/app/src/main/jni/libag3335m/inc/hdl_data.h +++ b/app/src/main/jni/libag3335m/inc/hdl_data.h @@ -51,9 +51,10 @@ typedef void (*hdl_readback_cb)(void *usr_arg, uint32_t cur_flash_addr, uint32_t read_len, uint32_t readback_total_len); typedef struct { - uint32_t da_flash_addr; // Or da_ram_pointer, Or da_file if your host have file system + char *da_filepath; uint32_t da_run_addr; uint32_t da_len; + uint32_t fd; } hdl_da_info_t; typedef struct { @@ -84,11 +85,13 @@ typedef struct { } hdl_format_arg_t; typedef struct _hdl_image_t { - uint32_t image_host_flash_addr; // Or image_ram_pointer, Or image_file if your host have file system uint32_t image_slave_flash_addr; uint32_t image_len; char *image_name; + char *image_file_path; bool image_is_bootloader; + bool image_is_da; + uint32_t fd; struct _hdl_image_t *next; } hdl_image_t; diff --git a/app/src/main/jni/libag3335m/inc/hdl_ports/hdl_flash_api.h b/app/src/main/jni/libag3335m/inc/hdl_ports/hdl_flash_api.h index 0268eec..bbddc28 100644 --- a/app/src/main/jni/libag3335m/inc/hdl_ports/hdl_flash_api.h +++ b/app/src/main/jni/libag3335m/inc/hdl_ports/hdl_flash_api.h @@ -44,7 +44,7 @@ extern "C" { // ToDo Porting: Please use your platform API to implement them. // Host Flash API bool hdl_flash_init(); -bool hdl_flash_read(uint32_t start_address, uint8_t *buffer, uint32_t length); +bool hdl_flash_read(hdl_image_t *hdlimg, uint8_t *buffer, uint32_t length); bool hdl_flash_deinit(); #ifdef __cplusplus diff --git a/app/src/main/jni/libag3335m/src/hdl_api.c b/app/src/main/jni/libag3335m/src/hdl_api.c index a518977..ad830e6 100644 --- a/app/src/main/jni/libag3335m/src/hdl_api.c +++ b/app/src/main/jni/libag3335m/src/hdl_api.c @@ -76,7 +76,7 @@ exit: return success; } #else -bool hdl_connect(const hdl_da_info_t *da_info, const hdl_connect_arg_t *connect_arg, hdl_da_report_t *da_report) +bool hdl_connect(const hdl_image_t *da_info, const hdl_connect_arg_t *connect_arg, hdl_da_report_t *da_report) { if (da_info == NULL || connect_arg == NULL || da_report == NULL) { HDL_LOGE("hdl_connect fail, invalid parameter"); @@ -102,11 +102,11 @@ bool hdl_connect(const hdl_da_info_t *da_info, const hdl_connect_arg_t *connect_ HDL_Require_Noerr_Action(success, exit, "hdl_brom_disable_wdt"); // Brom Send DA - success = hdl_brom_send_da(connect_arg, da_info->da_flash_addr, da_info->da_run_addr, da_info->da_len); + success = hdl_brom_send_da(connect_arg, da_info, da_info->image_slave_flash_addr, da_info->image_len); HDL_Require_Noerr_Action(success, exit, "hdl_brom_send_da"); // Brom Jump to DA - success = hdl_brom_jump_da(da_info->da_run_addr); + success = hdl_brom_jump_da(da_info->image_slave_flash_addr); HDL_Require_Noerr_Action(success, exit, "hdl_brom_jump_da"); // DA Sync @@ -145,8 +145,8 @@ bool hdl_download(const hdl_download_arg_t *download_arg) // Check Image Flash_Addr & Size hdl_image_t *image = download_arg->download_images; while (image != NULL) { - HDL_LOGI("Download Image (%s) BL=%d 0x%08X->0x%08X %d", - image->image_name, image->image_is_bootloader, image->image_host_flash_addr, + HDL_LOGI("Download Image (%s) BL=%d fd 0x%08X slave addr 0x%08X %d", + image->image_name, image->image_is_bootloader, image->fd, image->image_slave_flash_addr, image->image_len); // image slave_flash_addr and image_len if (image->image_slave_flash_addr == 0 || image->image_len == 0) { diff --git a/app/src/main/jni/libag3335m/src/hdl_brom_base.c b/app/src/main/jni/libag3335m/src/hdl_brom_base.c index c0c3630..ffabb94 100644 --- a/app/src/main/jni/libag3335m/src/hdl_brom_base.c +++ b/app/src/main/jni/libag3335m/src/hdl_brom_base.c @@ -36,7 +36,12 @@ #include "../inc/hdl_ports/hdl_os_util.h" #include "../inc/hdl_debug.h" #include "../inc/hdl_channel.h" - +#include +#include +#include +#include +#include +#include extern uint8_t g_hdl_data_buf[]; bool g_brom_task_stop = FALSE; @@ -50,9 +55,21 @@ static void brom_start_task(void *pvParameters) HDL_LOGI("brom_start_task put_char 0xA0"); hdl_delay(50); } - hdl_delete_task(NULL); + HDL_LOGD("brom task end!"); } +void hdl_create_brom_start_task(){ + int rc; + pthread_t pt1; + + const char* msg1 = "block"; + rc = pthread_create(&pt1, NULL, (void*)&brom_start_task, (void*)msg1); + if (rc != 0) + { + HDL_LOGE("create brom task failed %d",rc); + } + // pthread_join(pt1, NULL); +} static void brom_write8_echo(uint8_t data) { HDL_LOGI("brom_write8_echo 0x%02X", data); @@ -87,7 +104,8 @@ brom_start_retry: // continuously in UART Polling mode. // For your UART, you could try to use UART DMA mode, or create task like us. g_brom_task_stop = FALSE; - hdl_create_brom_start_task(brom_start_task); + hdl_create_brom_start_task(); + ag3335m_reset(1); while (1) { hdl_delay(20); rx_data = HDL_COM_GetByte(); @@ -229,12 +247,12 @@ exit: } bool hdl_brom_send_da(const hdl_connect_arg_t *connect_arg, - uint32_t da_flash_pos, uint32_t da_start_addr, uint32_t da_len) + hdl_image_t *img_info , uint32_t da_start_addr, uint32_t da_len) { bool success = FALSE; bool ret = hdl_flash_init(); HDL_Require_Noerr_Action(ret, exit, "hdl_flash_init"); - HDL_LOGI("hdl_brom_send_da 0x%08X 0x%08X %d", da_flash_pos, da_start_addr, da_len); + HDL_LOGI("hdl_brom_send_da fd 0x%08X ,start addr 0x%08X ,len %d", img_info->fd, da_start_addr, da_len); // DA Init Callback if (connect_arg != NULL && connect_arg->conn_da_init_cb != NULL) { @@ -253,7 +271,7 @@ bool hdl_brom_send_da(const hdl_connect_arg_t *connect_arg, uint32_t local_check_sum = 0; while (total_sent_len < da_len) { unsigned int to_send_len = min(packet_len, da_len - total_sent_len); - ret = hdl_flash_read(da_flash_pos + total_sent_len, g_hdl_data_buf, to_send_len); + ret = hdl_flash_read(img_info , g_hdl_data_buf, to_send_len); if (ret) { uint32_t sent_len = HDL_COM_PutByte_Buffer(g_hdl_data_buf, to_send_len); total_sent_len += sent_len; diff --git a/app/src/main/jni/libag3335m/src/hdl_da_cmd.c b/app/src/main/jni/libag3335m/src/hdl_da_cmd.c index 4bf3cc4..d74e2df 100644 --- a/app/src/main/jni/libag3335m/src/hdl_da_cmd.c +++ b/app/src/main/jni/libag3335m/src/hdl_da_cmd.c @@ -374,7 +374,7 @@ bool hdl_da_download(hdl_image_t *image, hdl_download_cb download_cb, void *down HDL_LOGI("hdl_da_download (%s) packet %d/%d %d", image->image_name, (packet_sent_num + 1), packet_num, cur_packet_len); - bool ret = hdl_flash_read(image->image_host_flash_addr + start_offset, + bool ret = hdl_flash_read(image , g_hdl_data_buf, cur_packet_len); if (ret) { if (is_last_packet && cur_packet_len < DA_SEND_PACKET_LEN) { @@ -394,8 +394,8 @@ bool hdl_da_download(hdl_image_t *image, hdl_download_cb download_cb, void *down start_offset + cur_packet_len, image_len); } } else { - HDL_LOGE("hdl_flash_read addr=0x%08X len=0x%08X fail", - image->image_host_flash_addr + start_offset, cur_packet_len); + HDL_LOGE("hdl_flash_read fd =0x%08X len=0x%08X fail", + image->fd , cur_packet_len); continue; } @@ -421,11 +421,9 @@ bool hdl_da_download(hdl_image_t *image, hdl_download_cb download_cb, void *down da_check_success = hdl_da_check_cmd_arg(&error_status); HDL_Require_Noerr_Action(da_check_success, exit, "DA Download End"); #endif - if (packet_sent_num == packet_num && error_status == 0) { success = TRUE; } - exit: if (error_status != 0) { HDL_LOGE("hdl_da_download error_status=%d", error_status); diff --git a/app/src/main/jni/libag3335m/src/hdl_demo.c b/app/src/main/jni/libag3335m/src/hdl_demo.c index 9312291..f5d1083 100644 --- a/app/src/main/jni/libag3335m/src/hdl_demo.c +++ b/app/src/main/jni/libag3335m/src/hdl_demo.c @@ -57,82 +57,18 @@ void download_cb_demo(void *usr_arg, char *cur_image_name, uint32_t sent_bytes, cur_image_name, percent, sent_bytes, total_bytes); } -#ifndef PSRAM_DOWNLOAD -// Host Local Flash Read Buffer, only for Test Readback -uint8_t g_hdl_flash_read_buf[4096] = {0}; -bool g_readback_check_result = TRUE; -void readback_cb_demo(void *usr_arg, uint32_t cur_flash_addr, - uint8_t *readback_buf, uint32_t readback_buf_len, - uint32_t read_len, uint32_t readback_total_len) -{ - uint8_t percent = read_len * 100 / readback_total_len; - HDL_MAIN_LOG("Readback Progress %d%% (%d/%d Bytes)", percent, read_len, readback_total_len); - - uint32_t host_flash_addr = cur_flash_addr - 0x08000000 + 0x00100000; - bool ret = hdl_flash_read(host_flash_addr, g_hdl_flash_read_buf, readback_buf_len); - if (ret) { - uint8_t md5_local[16] = {0}; - uint8_t md5_readback[16] = {0}; - // ToDo Note: Use mbedTLS MD5 API to verify readback result, - // you could ignore the readback verification function. - hdl_md5(g_hdl_flash_read_buf, readback_buf_len, md5_local); - hdl_md5(readback_buf, readback_buf_len, md5_readback); - int ret = memcmp(md5_local, md5_readback, 16); - if (ret != 0) { - g_readback_check_result = FALSE; - HDL_LOGE("readback_cb_demo, check fail 0x%08X %d", cur_flash_addr, readback_buf_len); - } - } -} -#endif - void progress_cb_demo(void *usr_arg, uint8_t percent) { HDL_MAIN_LOG("%s %d%%", (usr_arg != NULL ? usr_arg : "percent "), percent); } - void hdl_host_dl_demo() { -#ifdef PSRAM_DOWNLOAD // Init Connect ARG - hdl_da_info_t da_info; - da_info.da_flash_addr = HDL_DA_FLASH_POS; - da_info.da_run_addr = HDL_DA_RUN_ADDR; - da_info.da_len = HDL_DA_SIZE; - hdl_connect_arg_t connect_arg; - connect_arg.conn_da_init_cb = init_cb_demo; - connect_arg.conn_da_init_cb_arg = "Download DA now..."; - connect_arg.conn_da_send_cb = da_send_cb_demo; - connect_arg.conn_da_send_cb_arg = ""; - connect_arg.conn_enable_log = FALSE; - - // Connect Device - bool success = hdl_connect(&da_info, &connect_arg); - HDL_Require_Noerr_Action(success, exit, "hdl_connect"); - - hdl_image_t cm4_image; - cm4_image.image_host_flash_addr = HDL_CM4_IMAGE_HOST_FLASH_POS; - cm4_image.image_slave_flash_addr = HDL_CM4_IMAGE_SLAVE_FLASH_POS; - cm4_image.image_len = HDL_CM4_IMAGE_SIZE; - cm4_image.image_name = HDL_CM4_IMAGE_NAME; - cm4_image.image_is_bootloader = FALSE; - cm4_image.next = NULL; - - hdl_download_arg_t download_arg; - download_arg.download_init_cb = init_cb_demo; - download_arg.download_init_cb_arg = "Download Images now..."; - download_arg.download_cb = download_cb_demo; - download_arg.download_cb_arg = ""; - download_arg.download_images = &cm4_image; - success = hdl_download(&download_arg); - HDL_Require_Noerr_Action(success, exit, "hdl_download"); -#else - // Init Connect ARG - hdl_da_info_t da_info; - da_info.da_flash_addr = HDL_DA_FLASH_POS; - da_info.da_run_addr = HDL_DA_RUN_ADDR; - da_info.da_len = HDL_DA_SIZE; + hdl_image_t da_info; + da_info.image_file_path = HDL_DA_FILE_PATH; + da_info.image_slave_flash_addr = HDL_DA_RUN_ADDR; + da_info.image_len = HDL_DA_SIZE; hdl_connect_arg_t connect_arg; connect_arg.conn_da_init_cb = init_cb_demo; connect_arg.conn_da_init_cb_arg = "Download DA now..."; @@ -158,27 +94,33 @@ void hdl_host_dl_demo() HDL_Require_Noerr_Action(success, exit, "hdl_format"); // Download 3 Images (Bootloader, CM4, Other) + hdl_image_t partition_image; hdl_image_t bl_image; hdl_image_t cm4_image; - hdl_image_t other_image; - bl_image.image_host_flash_addr = HDL_BL_IMAGE_HOST_FLASH_POS; + hdl_image_t config_image; + partition_image.image_file_path = HDL_PARTITION_IMAGE_HOST_IMAGE_NAME; + partition_image.image_is_bootloader = false; + partition_image.image_slave_flash_addr = HDL_PARTITION_IMAGE_SLAVE_FLASH_POS; + partition_image.image_name = HDL_PARTITION_IMAGE_NAME; + partition_image.next = &bl_image; + bl_image.image_file_path = HDL_BL_IMAGE_HOST_IMAGE_NAME; bl_image.image_slave_flash_addr = HDL_BL_IMAGE_SLAVE_FLASH_POS; bl_image.image_len = HDL_BL_IMAGE_SIZE; bl_image.image_name = HDL_BL_IMAGE_NAME; bl_image.image_is_bootloader = TRUE; bl_image.next = &cm4_image; - cm4_image.image_host_flash_addr = HDL_CM4_IMAGE_HOST_FLASH_POS; + cm4_image.image_file_path = HDL_CM4_IMAGE_HOST_IMAGE_NAME; cm4_image.image_slave_flash_addr = HDL_CM4_IMAGE_SLAVE_FLASH_POS; cm4_image.image_len = HDL_CM4_IMAGE_SIZE; cm4_image.image_name = HDL_CM4_IMAGE_NAME; cm4_image.image_is_bootloader = FALSE; - cm4_image.next = &other_image; - other_image.image_host_flash_addr = HDL_OTHER_IMAGE_HOST_FLASH_POS; - other_image.image_slave_flash_addr = HDL_OTHER_IMAGE_SLAVE_FLASH_POS; - other_image.image_len = HDL_OTHER_IMAGE_SIZE; - other_image.image_name = HDL_OTHER_IMAGE_NAME; - other_image.image_is_bootloader = FALSE; - other_image.next = NULL; + cm4_image.next = &config_image; + config_image.image_file_path = HDL_OTHER_IMAGE_HOST_IMAGE_NAME; + config_image.image_slave_flash_addr = HDL_OTHER_IMAGE_SLAVE_FLASH_POS; + config_image.image_len = HDL_OTHER_IMAGE_SIZE; + config_image.image_name = HDL_OTHER_IMAGE_NAME; + config_image.image_is_bootloader = FALSE; + config_image.next = NULL; hdl_download_arg_t download_arg; download_arg.download_init_cb = init_cb_demo; @@ -192,11 +134,15 @@ void hdl_host_dl_demo() // Disconnect Device success = hdl_disconnect(DISCONNECT_NONE); HDL_Require_Noerr_Action(success, exit, "hdl_disconnect"); -#endif + exit: HDL_SUCCESS_LOG(__func__); } +void hdl_main(){ + + hdl_host_dl_demo(); +} //static void vHostDLTask(void *pvParameters) //{ // LOG_I(main, "hdl_host_dl_demo start"); diff --git a/app/src/main/jni/libag3335m/src/hdl_ports/hdl_flash_api.c b/app/src/main/jni/libag3335m/src/hdl_ports/hdl_flash_api.c index 69630cf..dff3bd7 100644 --- a/app/src/main/jni/libag3335m/src/hdl_ports/hdl_flash_api.c +++ b/app/src/main/jni/libag3335m/src/hdl_ports/hdl_flash_api.c @@ -32,7 +32,8 @@ * AIROHA FOR SUCH AIROHA SOFTWARE AT ISSUE. */ -#include "hdl_ports/hdl_flash_api.h" +#include +#include "hdl_flash_api.h" bool hdl_flash_init() { @@ -42,12 +43,31 @@ bool hdl_flash_init() return true; } -bool hdl_flash_read(uint32_t start_address, uint8_t *buffer, uint32_t length) +bool hdl_flash_read(hdl_image_t *hdlimg, uint8_t *buffer, uint32_t length) { //hal_flash_status_t status = hal_flash_read(start_address, buffer, length); // HDL_LOGI("hdl_flash_read status=%d", status); // return (status == HAL_FLASH_STATUS_OK); - return true; + if( hdlimg->fd ==-1){ + char path[1024]={0}; + sprintf(path,"%s/%s",ROMPATH,hdlimg->image_file_path); + hdlimg->fd=open(hdlimg->image_file_path,O_RDWR); + } + if(hdlimg->fd >0){ + int ret=read(hdlimg->fd,buffer,length); + if(ret==length){ + return true; + }else{ + HDL_LOGE(" read failed! read %d != %d", ret,length); + close(hdlimg->fd); + hdlimg->fd=-1; + return false; + } + }else{ + HDL_LOGE(" fd <=0 read failed!"); + } + + return false; } bool hdl_flash_deinit() diff --git a/app/src/main/jni/libag3335m/src/hdl_ports/hdl_os_util.c b/app/src/main/jni/libag3335m/src/hdl_ports/hdl_os_util.c index 7f37118..649d23d 100644 --- a/app/src/main/jni/libag3335m/src/hdl_ports/hdl_os_util.c +++ b/app/src/main/jni/libag3335m/src/hdl_ports/hdl_os_util.c @@ -99,14 +99,14 @@ int ag3335m_reset(int enabled){ int err = 0; {// enable step counter - LOGD("ag3335m_reset ioctl"); + HDL_LOGD("ag3335m_reset ioctl"); err = ioctl(dev_fd, GH_IOCTL_CMD_RESET, &enabled); - LOGD("ag3335m_reset done"); + HDL_LOGD("ag3335m_reset done"); if (err != 0) { - LOGE("ag3335m_reset failed (%s)", strerror(errno)); + HDL_LOGE("ag3335m_reset failed (%s)", strerror(errno)); return err; } }// enable step counter end diff --git a/app/src/main/jni/test.c b/app/src/main/jni/test.c index 6c51c95..4a4621c 100644 --- a/app/src/main/jni/test.c +++ b/app/src/main/jni/test.c @@ -22,6 +22,7 @@ #include #include "hardware.h" +#include "libag3335m/inc/hdl_demo.h" #define LOG_TAG "sctool" #include @@ -98,6 +99,8 @@ void recvThread(void* arg); int main() { + +#if 0 int rc; pt_t pt1, pt2; @@ -126,6 +129,9 @@ int main() pthread_join(pt2, NULL); gps_hardware_close(); tty_hardware_close(); +#else + hdl_host_dl_demo(); +#endif return 0; } \ No newline at end of file diff --git a/app/src/main/libs/armeabi-v7a/ag333m_tool b/app/src/main/libs/armeabi-v7a/ag333m_tool index 4a91848..d1125ed 100644 Binary files a/app/src/main/libs/armeabi-v7a/ag333m_tool and b/app/src/main/libs/armeabi-v7a/ag333m_tool differ diff --git a/app/src/main/libs/armeabi-v7a/libag3335m_dl.so b/app/src/main/libs/armeabi-v7a/libag3335m_dl.so index d922f8e..34a17c9 100644 Binary files a/app/src/main/libs/armeabi-v7a/libag3335m_dl.so and b/app/src/main/libs/armeabi-v7a/libag3335m_dl.so differ