[Feature]add MT2731_MP2_MR2_SVN388 baseline version
Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/lynq/lib/liblynq-log/log-riltel/log.c b/src/lynq/lib/liblynq-log/log-riltel/log.c
new file mode 100644
index 0000000..3606536
--- /dev/null
+++ b/src/lynq/lib/liblynq-log/log-riltel/log.c
@@ -0,0 +1,489 @@
+#include "liblog.h"
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <log/log.h>
+
+
+void hextostring(unsigned char val, char *buf);
+
+#define LOG_NAME_LEN 128
+
+static unsigned int log_level = 0; //logµÈ¼¶£¬ÐèÒª¿ª·¢ÈËÔ±¶¯Ì¬ÅäÖÃlogµÈ¼¶£¬Ä¬Èϵȼ¶Îª0
+static unsigned char log_name_arr[LOG_NAME_LEN] = {0};
+/*********************************************************************************************************
+** Function name: lynq_log_output
+** Description lynq_log_output
+** Input parameters: Tag:TagÀàÐÍ(log_level_enum)
+ Level:TagÏ´òÓ¡level(log_tag_enum)
+ format:printf´òÓ¡µÄ²»¶¨³¤²ÎÊý
+** Returned value: None
+** Created by:
+*********************************************************************************************************/
+void lynq_log_output(log_tag_enum Tag,log_level_enum Level,const char *format,...)
+{
+#if LOG_ENABLE
+ if((Tag >= LOG_TAG_MAX)||(Level >= LOG_LEVEL_MAX))
+ return;
+// printf("mo:%d---le:%d---Level:%d\n",LogTagEnableInfoTable[Tag],log_level,Level);
+// printf("rmodule:%d---rlevel:%d\n",((LogTagEnableInfoTable[Tag] >> Level)&0x00000001),((log_level >> Level)&0x00000001));
+ if(((LogTagEnableInfoTable[Tag] >> Level)&0x00000001)&((log_level >> Level)&0x00000001))
+ {
+ va_list args;
+
+ //TagName
+ printf("[%s]",LogTagNameInfoTable[Tag]);
+
+ //LevelName
+ printf("[%s]:",LogLevelNameInfoTable[Level]);
+
+ va_start(args,format);
+ vprintf(format,args);
+ va_end(args);
+ }
+ return ;
+#endif //LOG_ENABLE
+}
+
+
+void lynq_log_global_output(log_level_enum Level,const char *format,...)
+{
+#if LOG_ENABLE
+
+ char out_buf[1100] = {0};
+ char buf[1024] = {0};
+
+ if(Level >= LOG_LEVEL_MAX)
+ return;
+ if((log_level >> Level)&0x00000001)
+ {
+ va_list args;
+
+ //TagName
+ if(log_name_arr[0] > 0)
+ {
+ printf("[%s]",log_name_arr);
+ }
+
+ //LevelName
+ printf("%s:",LogLevelNameInfoTable[Level]); //lt dele @2021.7.22 for []
+
+ va_start(args,format);
+ vprintf(format,args);
+ vsnprintf(buf, sizeof(buf), format, args); //lt add @2021.7.22 for write buf
+ va_end(args);
+ printf("\r\n");
+
+ sprintf(out_buf, "%s %s", LogLevelNameInfoTable[Level], buf);//lt add @2021.7.22 for write outbuf
+ __android_log_print(ANDROID_LOG_DEBUG,log_name_arr, "%s",out_buf); //lt add @2021.7.22 for write syslog.log
+ }
+ return ;
+#endif //LOG_ENABLE
+}
+
+
+
+void lynq_log_configuration_set(char *log_name,char log_data_arr)
+{
+ char log_data_buf[LOG_NAME_LEN] = {"persist."};
+ char log_data_str[32] = {0};
+ if(log_name == NULL)
+ {
+ return ;
+ }
+ if(log_data_arr < LOG_LEVEL_MAX)
+ {
+ sprintf(log_data_str,"%d",log_data_arr);
+// printf("log_data_str:%s\n",log_data_str);
+ if((strlen(log_name)) < (LOG_NAME_LEN - 9))
+ {
+ strcat(log_data_buf,log_name);
+ property_set(log_data_buf,log_data_str);
+ }
+ }
+ lynq_log_configuration_init(log_name);
+}
+
+void lynq_deal_with_level(unsigned int get_log_level)
+{
+ switch(get_log_level)
+ {
+ case LOG_DEBUG:
+ log_level |= ENABLE(LOG_DEBUG);
+ case LOG_INFO:
+ log_level |= ENABLE(LOG_INFO);
+ case LOG_WARNING:
+ log_level |= ENABLE(LOG_WARNING);
+ case LOG_ERROR:
+ log_level |= ENABLE(LOG_ERROR);
+ case LOG_VERBOSE:
+ log_level |= ENABLE(LOG_VERBOSE);
+ break;
+ default:
+ log_level |= ENABLE(LOG_VERBOSE);
+ break;
+ }
+}
+
+void lynq_log_configuration_init(char *log_name)
+{
+ char log_data_buf[LOG_NAME_LEN] = {"persist."};
+ char get_propty_log_data[32] ={0};
+ unsigned int get_log_level = 0;
+
+ if(log_name == NULL)
+ {
+ return ;
+ }
+ if((strlen(log_name)) < (LOG_NAME_LEN - 9))
+ {
+ strcpy(log_name_arr,log_name);
+ strcat(log_data_buf,log_name);
+ if(property_get(log_data_buf,(char *)get_propty_log_data,NULL) > 0)
+ {
+ get_log_level = atoi(get_propty_log_data);
+// printf("get_log_level:%d\n",get_log_level);
+ }
+ else
+ {
+ log_level = 0;
+// printf("get propty data fail\n");
+ }
+
+ }
+ lynq_deal_with_level(get_log_level);
+
+}
+
+/*********************************************************************************************************
+** Function name: lynq_update_log_output
+** Description ÖØÐ»ñÈ¡logµÈ¼¶²¢Ê¹ÆäÉúЧ
+** Input parameters: Tag:TagÀàÐÍ(log_level_enum)
+ Level:TagÏ´òÓ¡level(log_tag_enum)
+ format:printf´òÓ¡µÄ²»¶¨³¤²ÎÊý
+** Returned value: None
+** Created by:
+*********************************************************************************************************/
+void lynq_update_log_output(log_tag_enum Tag,log_level_enum Level,const char *format,...)
+{
+#if LOG_ENABLE
+ lynq_enable_log_serve();
+ if((Tag >= LOG_TAG_MAX)||(Level >= LOG_LEVEL_MAX))
+ return;
+// printf("mo:%d---le:%d---Level:%d\n",LogTagEnableInfoTable[Tag],log_level,Level);
+// printf("rmodule:%d---rlevel:%d\n",((LogTagEnableInfoTable[Tag] >> Level)&0x00000001),((log_level >> Level)&0x00000001));
+ if(((LogTagEnableInfoTable[Tag] >> Level)&0x00000001)&((log_level >> Level)&0x00000001))
+ {
+ va_list args;
+
+ //TagName
+ printf("[%s]",LogTagNameInfoTable[Tag]);
+
+ //LevelName
+ printf("[%s]:",LogLevelNameInfoTable[Level]);
+
+ va_start(args,format);
+ vprintf(format,args);
+ va_end(args);
+ }
+ return ;
+#endif //LOG_ENABLE
+}
+
+
+/*********************************************************************************************************
+** Function name: lynq_log_printf_output
+** Description ·â×°printf
+** Input parameters: Tag:TagÀàÐÍ(log_level_enum)
+ Level:TagÏ´òÓ¡level(log_tag_enum)
+ format:printf´òÓ¡µÄ²»¶¨³¤²ÎÊý
+** Returned value: None
+** Created by:
+*********************************************************************************************************/
+void lynq_log_printf_output(log_tag_enum Tag,log_level_enum Level,const char *format,...)
+{
+#if LOG_ENABLE
+ if((Tag >= LOG_TAG_MAX)||(Level >= LOG_LEVEL_MAX))
+ return;
+
+ va_list args;
+
+ //TagName
+ printf("[%s]",LogTagNameInfoTable[Tag]);
+
+ //LevelName
+ printf("[%s]:",LogLevelNameInfoTable[Level]);
+
+ va_start(args,format);
+ vprintf(format,args);
+ va_end(args);
+
+ return ;
+#endif //LOG_ENABLE
+}
+
+/*********************************************************************************************************
+** Function name: lynq_fget_log_level
+** Description ¿ªÆôlogÈÕÖ¾µÈ¼¶
+** Input parameters: open_log_level:¿ªÆôlogÈÕÖ¾µÈ¼¶
+ open_module_log_num:¿ªÆôÈÕ־ģ¿éµÄ¸öÊý
+ open_module_log:¿ªÆôÈÕ×Ó·þÎñµÄÄ£¿é
+** Returned value: None
+** Created by:
+*********************************************************************************************************/
+void lynq_fget_log_level(log_level_str level_str)
+{
+ log_level = 0;
+ switch(level_str.open_log_level)
+ {
+ case LOG_DEBUG:
+ log_level |= ENABLE(LOG_DEBUG);
+ case LOG_INFO:
+ log_level |= ENABLE(LOG_INFO);
+ case LOG_WARNING:
+ log_level |= ENABLE(LOG_WARNING);
+ case LOG_ERROR:
+ log_level |= ENABLE(LOG_ERROR);
+ case LOG_VERBOSE:
+ log_level |= ENABLE(LOG_VERBOSE);
+ break;
+ default:
+ log_level |= ENABLE(LOG_VERBOSE);
+ break;
+ }
+
+ for(int i = 0; i < level_str.open_module_log_num; i++)
+ {
+ LogTagEnableInfoTable[level_str.open_module_log[i]] = ENABLE(LOG_VERBOSE)|ENABLE(LOG_DEBUG)|ENABLE(LOG_INFO)|ENABLE(LOG_WARNING)|ENABLE(LOG_ERROR);
+ }
+ return ;
+}
+
+/*********************************************************************************************************
+** Function name: lynq_store_log_deploy
+** Description ±£´æÈÕÖ¾ÅäÖÃÐÅÏ¢
+** Input parameters: open_log_level:¿ªÆôlogÈÕÖ¾µÈ¼¶
+ open_module_log_num:¿ªÆôÈÕ־ģ¿éµÄ¸öÊý
+ open_module_log:¿ªÆôÈÕ×Ó·þÎñµÄÄ£¿é
+** Returned value: None
+** Created by:
+*********************************************************************************************************/
+void lynq_store_log_deploy(log_level_str *log_level_write_level_str)
+{
+ char *log_level_writefile = "persist.store_log_level";
+ char store_log_str_buf[512] = {0};
+
+ store_log_str_buf[0] = '+';
+ hextostring(log_level_write_level_str->open_log_level,&store_log_str_buf[1]);
+ hextostring(log_level_write_level_str->open_module_log_num,&store_log_str_buf[3]);
+ for(int i = 0; i < log_level_write_level_str->open_module_log_num; i++)
+ {
+ hextostring(log_level_write_level_str->open_module_log[i],&store_log_str_buf[5+i*2]);
+ }
+
+ property_set(log_level_writefile,(char *)store_log_str_buf);
+ return ;
+}
+
+/*********************************************************************************************************
+** Function name: lynq_fget_log_level
+** Description ¶ÁÈ¡ÈÕÖ¾ÅäÖÃÐÅÏ¢
+** Input parameters: open_log_level:¿ªÆôlogÈÕÖ¾µÈ¼¶
+ open_module_log_num:¿ªÆôÈÕ־ģ¿éµÄ¸öÊý
+ open_module_log:¿ªÆôÈÕ×Ó·þÎñµÄÄ£¿é
+** Returned value: 0£º³É¹¦£¬-1£ºÊ§°Ü
+** Created by:
+*********************************************************************************************************/
+int lynq_read_store_log_deploy(log_level_str *log_level_read_level_str)
+{
+ char *log_level_readfile = "persist.store_log_level";
+
+ if(property_get(log_level_readfile,(char *)log_level_read_level_str,NULL) > 0)
+ {
+// printf("read log level deploy success!!!\n");
+ return 0;
+ }
+ else
+ {
+// printf("get file error!!!\n");
+ return -1;
+ }
+}
+
+int itoa(int val, char *buf,int size) //16½øÖÆ×ª»»³É×Ö·û´®
+{
+ char *p = buf;
+ char t = '0';
+ int len = 0;
+ int slen = size;
+ while(val > 0 && len < slen) {
+ t = val % 16;
+ val -= t;
+ val /= 16;
+ if (t > 9) {
+ *p++ = t- 10 + 'a';
+ } else {
+ *p++ = t + '0';
+ }
+ ++len;
+ }
+ for (int i = 0;i < len/2;++i) {
+ char c = buf[i];
+ buf[i] = buf[len-1-i];
+ buf[len-1-i] = c;
+ }
+ buf[len] = '\0';
+ return len;
+}
+
+void hextostring(unsigned char val, char *buf)
+{
+ char strbuf[64] = {0};
+ itoa(val,strbuf,2);
+ memcpy(buf,strbuf,3);
+ if((val >= 0) && (val <= 15))
+ {
+ buf[0] = '0';
+ buf[1] = strbuf[0];
+ buf[2] = '\0';
+ }
+}
+
+static int pows(int x, int y)
+{
+ int result = 1;
+
+ while (y--)
+ result *= x;
+ return result;
+}
+
+int string2hex(const char *buffer, int cnt)
+{
+ int c = 0;
+ char t = 0;
+ int count = cnt;
+
+ while (count--) {
+ t = *(buffer + cnt - count - 1);
+ if (t >= 'A' && t <= 'F')
+ c += ((t - 'A') + 10) * pows(16, count);
+ else if (t >= 'a' && t <= 'f')
+ c += ((t - 'a') + 10) * pows(16, count);
+ else if (t >= '0' && t <= '9')
+ c += (t - '0') * pows(16, count);
+ else
+ c = -1;
+ }
+ return c;
+}
+
+int get_hexbuffer(char *data_buffer, char *hex_buffer)
+{
+ char *ptr = data_buffer;
+ int index = 0;
+ int data_offset = 0;
+
+ while (*ptr && *++ptr) {
+ *(hex_buffer + index++) = string2hex(ptr - 1, 2);
+ ptr++;
+ data_offset++;
+ }
+ *(hex_buffer + index) = 0;
+ return data_offset;
+}
+/*********************************************************************************************************
+** Function name: lynq_enable_log_serve
+** Description ʹÄÜÈÕÖ¾·þÎñ
+** Input parameters: None
+** Returned value: None
+** Created by:
+*********************************************************************************************************/
+void lynq_enable_log_serve(void)
+{
+ log_level_str read_level_str;
+ int scanf_ret = 0;
+ char read_buf[] = {0};
+ char shift_read_buf[128] = {0};
+ static char stcp_read_buf[128] = {0};
+ char *log_level_readfile = "persist.store_log_level";
+
+ if(property_get(log_level_readfile,&read_buf,NULL) > 0)
+ {
+ if(strcmp(read_buf,stcp_read_buf) == 0)
+ {
+// printf("strcmp(read_buf,stcp_read_buf) == 0\n");
+ return ;
+ }
+ strcpy(stcp_read_buf,read_buf);
+
+ if(read_buf[0] == '+')
+ {
+// printf("start\n");
+ scanf_ret = sscanf(&read_buf[1],"%128s",shift_read_buf);
+// printf("scanf_ret:%s\n",read_buf);
+ if(scanf_ret)
+ {
+
+ get_hexbuffer(shift_read_buf,read_buf);
+ read_level_str.open_log_level = read_buf[0];
+ read_level_str.open_module_log_num = read_buf[1];
+ memcpy(read_level_str.open_module_log,&read_buf[2],read_level_str.open_module_log_num);
+// printf("data:%d %d\n",read_level_str.open_log_level,read_level_str.open_module_log_num);
+ }
+
+ }
+ else
+ {
+ lynq_read_store_log_deploy(&read_level_str);
+ }
+ if((read_level_str.open_log_level < LOG_LEVEL_MAX) && (read_level_str.open_module_log_num < LOG_TAG_MAX))
+ {
+ lynq_fget_log_level(read_level_str);
+ }
+ }
+}
+
+/*********************************************************************************************************
+** Function name: lynq_store_log_test
+** Description ÅäÖÃÈÕÖ¾ÐÅÏ¢£¨ÅäÖÃÍê³Éºó£¬Èô²»ÐÞ¸ÄÅäÖÃÐÅÏ¢£¬¿ÉÒÔºöÂÔ£©
+** Input parameters: None
+** Returned value: None
+** Created by:
+*********************************************************************************************************/
+#define MODULE_LOG_NUM 6
+void lynq_store_log_test(void)
+{
+ log_level_str write_level_str;
+ log_level_str read_level_str;
+
+ char open_log_level = LOG_WARNING;
+ char module_log_buf[MODULE_LOG_NUM] = {LOG_MQTT,LOG_SPI,LOG_THREADTEST_DBUS, LOG_THREADHANDLE, LOG_HTTP, LOG_FTP};
+
+ write_level_str.open_log_level = open_log_level;
+ write_level_str.open_module_log_num = MODULE_LOG_NUM;
+ memcpy(write_level_str.open_module_log,module_log_buf,MODULE_LOG_NUM);
+ if(lynq_read_store_log_deploy(&read_level_str) != 0)
+ {
+ lynq_store_log_deploy(&write_level_str);
+ lynq_store_log_deploy(&write_level_str);
+ }
+
+// printf("write log deploy success!!!\n");
+ return ;
+}
+
+/*********************************************************************************************************
+** Function name: lynq_read_set_log_test
+** Description ʹÄÜÅäÖÃÐÅÏ¢
+** Input parameters: None
+** Returned value: None
+** Created by:
+*********************************************************************************************************/
+void lynq_read_set_log_test(void)
+{
+ lynq_enable_log_serve();
+}
+
diff --git a/src/lynq/lib/liblynq-log/log-riltel/lynq_nand.c b/src/lynq/lib/liblynq-log/log-riltel/lynq_nand.c
new file mode 100644
index 0000000..1ab4e01
--- /dev/null
+++ b/src/lynq/lib/liblynq-log/log-riltel/lynq_nand.c
@@ -0,0 +1,240 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <fcntl.h>
+#include <pthread.h>
+
+#include "mtk_device_wrap.h"
+#include "lynq_nand.h"
+
+#if 1
+#define NAND_LOG_PATCH "/dev/mtd19"
+#else
+#define NAND_LOG_PATCH "/dev/mtd19/lynq_log.txt"
+#endif
+
+#define NAND_PRIMITIVE_OFFSET 2*1024
+#define NAND_TOTAL_SIZE 20*1024*1024
+#define NAND_CURRENT_LEN 2*1024
+#define NAND_OLD_CURRENT_LEN 0
+
+static int lynq_nand_offset_global = 0;
+static pthread_mutex_t nand_mutex = PTHREAD_MUTEX_INITIALIZER;
+char nand_count = 0;
+
+void lynq_store_nand_offset_data(char *store_nand_offset_data);
+int lynq_read_nand_offset_data(char *read_nand_offset_data);
+
+
+int lynq_nand_store_log_message(char *log_message,size_t log_message_len)
+{
+ pthread_mutex_lock(&nand_mutex);
+ int fd;
+ int err = 0;
+ char nand_current_buf[NAND_CURRENT_LEN] = {0};
+ unsigned int nand_page = 0;
+ int nand_offset_count = 0;
+ char nand_offset_buf[8] = {0};
+ char read_nand_buf[8] = {0};
+
+ if(log_message_len == 0)
+ {
+ return -1;
+ }
+
+ fd=mtk_device_wrap_open(NAND_LOG_PATCH,O_RDWR);
+ if(fd < 0)
+ {
+ perror("open nand log message error1!!!!");
+ return fd;
+ }
+
+ if(lynq_read_nand_offset_data(nand_offset_buf) == 0)
+ {
+ nand_offset_count = atoi(nand_offset_buf);
+ lynq_nand_offset_global = nand_offset_count;
+ }
+
+ ((log_message_len % 2048) == 0 ) ? (nand_page = log_message_len / 2048) : (nand_page = (log_message_len / 2048)+1);
+//printf("nand_page:%d\n",nand_page);
+ while(1)
+ {
+ err = mtk_device_wrap_seek(fd, lynq_nand_offset_global, SEEK_SET);
+ if(err == -1)
+ {
+ perror("seek nand log message error8!!!!");
+ return err;
+ }
+ mtk_device_wrap_read(fd, read_nand_buf, 8);
+ if(((read_nand_buf[0] == 0xff) && (read_nand_buf[1] == 0xff) && (read_nand_buf[2] == 0xff) &&(read_nand_buf[3] == 0xff)) ||\
+ ((lynq_nand_offset_global % (128 *1024) ) == 0))
+ {
+ for(int i = 0; i < nand_page; i++)
+ {
+ memset(nand_current_buf,0,NAND_CURRENT_LEN);
+ err = mtk_device_wrap_seek(fd, lynq_nand_offset_global, SEEK_SET);
+ if(err == -1)
+ {
+ perror("seek nand log message error8!!!!");
+ return err;
+ }
+ if((i+1) == nand_page)
+ {
+ memcpy(nand_current_buf,&log_message[i*NAND_CURRENT_LEN],(log_message_len-(i*2048)));
+// printf("(i+1) == nand_page---%d\n",(log_message_len-(i*2048)));
+ }
+ else
+ {
+ memcpy(nand_current_buf,&log_message[i*NAND_CURRENT_LEN],NAND_CURRENT_LEN);
+ printf("(i+1) != nand_page\n");
+ }
+
+ err = mtk_device_wrap_write(fd, nand_current_buf, NAND_CURRENT_LEN);
+ if(err == -1)
+ {
+ perror("write nand log message error9!!!!");
+ return err;
+ }
+ lynq_nand_offset_global += NAND_CURRENT_LEN;
+ if(lynq_nand_offset_global > NAND_TOTAL_SIZE)
+ {
+ lynq_nand_offset_global = 0;
+ }
+ }
+ break;
+ }
+//printf("lynq_nand_offset_global:%d---nand_offset_count:%d\n",lynq_nand_offset_global,nand_offset_count);
+ lynq_nand_offset_global += NAND_CURRENT_LEN;
+ if(lynq_nand_offset_global > NAND_TOTAL_SIZE)
+ {
+ lynq_nand_offset_global = 0;
+ }
+ }
+
+ if(nand_count >= 64)
+ {
+ nand_count = 0;
+ sprintf(nand_offset_buf,"%d",lynq_nand_offset_global);
+ lynq_store_nand_offset_data(nand_offset_buf);
+ }
+
+ err = mtk_device_wrap_close(fd);
+
+ pthread_mutex_unlock(&nand_mutex);
+ return 0;
+}
+
+
+int lynq_nand_get_log_message(char *log_message,size_t log_message_len,off_t offset)
+{
+ int fd;
+ int err = 0;
+
+ pthread_mutex_lock(&nand_mutex);
+
+ unsigned int lynq_nand_offset_part = 0;
+
+ fd=mtk_device_wrap_open(NAND_LOG_PATCH,O_RDONLY);
+ if(fd < 0)
+ {
+ perror("open nand log message error!!!!");
+ return fd;
+ }
+
+ lynq_nand_offset_part = NAND_PRIMITIVE_OFFSET + offset;
+//printf("lynq_nand_offset_part 13:%d\n",lynq_nand_offset_part);
+ err = mtk_device_wrap_seek(fd, lynq_nand_offset_part, SEEK_SET);
+//printf("lynq_nand_offset_part 14:%d----nand seek 4:%d\n",lynq_nand_offset_part,err);
+ if(err == -1)
+ {
+ perror("seek nand log message error 15!!!!");
+ return err;
+ }
+
+ mtk_device_wrap_read(fd, log_message, log_message_len);
+
+ err = mtk_device_wrap_close(fd);
+
+ pthread_mutex_unlock(&nand_mutex);
+ return err;
+}
+
+
+int lynq_nand_read_data_test(void)
+{
+ int fd;
+ FILE *file_fd = NULL;
+ int err;
+ char log_data_buf[6*1024] = {0};
+ char log_nand_buf[2048] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99};
+ static unsigned int nand_offset_test = 0;
+ char *filePath = "/usr/local/lnand_log.txt";
+
+ system("touch /usr//local/lnand_log.txt");
+ system("chmod 777 /usr//local/lnand_log.txt");
+
+ fd=mtk_device_wrap_open(NAND_LOG_PATCH,O_RDWR);
+
+ if(fd < 0)
+ {
+ perror("open nand log message error!!!!");
+ return fd;
+ }
+
+ file_fd = fopen(filePath,"rt+");
+ if(NULL == file_fd)
+ {
+ perror("file_fd");
+ return -1;
+ }
+
+ for(int i = 0 ;i < 100; i++)
+ {
+ memset(log_data_buf,0,6*1024);
+ err = mtk_device_wrap_seek(fd, nand_offset_test, SEEK_SET);
+
+
+ if(err == -1)
+ {
+ perror("seek nand log message error!!!!");
+ return err;
+ }
+
+ fseek(file_fd,nand_offset_test,SEEK_SET);
+
+ mtk_device_wrap_read(fd, log_data_buf, 6*1024);
+ nand_offset_test += (6*1024);
+
+ fwrite(&log_data_buf,sizeof(log_data_buf), 1, file_fd);
+
+ }
+
+ fclose(file_fd);
+ mtk_device_wrap_close(fd);
+
+}
+
+
+
+void lynq_store_nand_offset_data(char *store_nand_offset_data)
+{
+ char *log_level_writefile = "persist.store_nand_data";
+ property_set(log_level_writefile,(char *)store_nand_offset_data);
+ return ;
+}
+
+int lynq_read_nand_offset_data(char *read_nand_offset_data)
+{
+ char *log_level_readfile = "persist.store_nand_data";
+
+ if(property_get(log_level_readfile,(char *)read_nand_offset_data,NULL) > 0)
+ {
+// printf("read log level deploy success!!!\n");
+ return 0;
+ }
+ else
+ {
+// printf("get file error!!!\n");
+ return -1;
+ }
+}
\ No newline at end of file
diff --git a/src/lynq/lib/liblynq-log/log-riltel/makefile b/src/lynq/lib/liblynq-log/log-riltel/makefile
new file mode 100644
index 0000000..3f929a2
--- /dev/null
+++ b/src/lynq/lib/liblynq-log/log-riltel/makefile
@@ -0,0 +1,101 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -std=gnu++14 \
+ -g -Os \
+ -flto \
+ -DRIL_SHLIB \
+ -DATCI_PARSE \
+ -DKEEP_ALIVE \
+ -DECALL_SUPPORT \
+ -fpermissive \
+
+CFLAGS += -fPIC -O2 $(INCLUDE) -D_LARGEFILE64_SOURCE
+
+$(warning ################# C2K support: $(RAT_CONFIG_C2K_SUPPORT))
+ifeq ($(strip $(RAT_CONFIG_C2K_SUPPORT)), yes)
+ LOCAL_CFLAGS += -DC2K_SUPPORT
+
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsds)
+ LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 \
+ -DANDROID_MULTI_SIM \
+ -DMODE_DSDS
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsss)
+ LOCAL_CFLAGS += -DMODE_DSSS
+endif
+
+$(warning ################# TARGET_PLATFORM: $(TARGET_PLATFORM))
+ifeq ($(strip $(TARGET_PLATFORM)), mt2731)
+#$(warning #################add for debug $(ROOT), $(includedir))
+$(warning ################# TARGET_PLATFORM_MT2731)
+ LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2731 \
+ -DMD_93_SUPPORT
+else ifeq ($(strip $(TARGET_PLATFORM)), mt2635)
+$(warning ################# TARGET_PLATFORM_MT2635)
+ LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2635 \
+ -DMD_90_SUPPORT
+endif
+
+$(warning ################# RITA ROOT: $(ROOT),includedir:$(includedir))
+LOCAL_PATH = .
+
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(LOCAL_PATH)/../include/liblog \
+ -I$(ROOT)$(includedir) \
+ -I$(ROOT)$(includedir)/logger \
+
+
+
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lstdc++ \
+ -llog \
+ -lcutils \
+ -lutils \
+ -lpower \
+ -lpal \
+ -lnandapi \
+ -lsncfg \
+
+SOURCES = $(wildcard *.c wildcard *.h)
+
+EXECUTABLE = liblynq-log.so
+
+OBJECTS=$(SOURCES:.c=.o)
+
+
+.PHONY: build clean install pack_rootfs
+
+all: build
+$(EXECUTABLE): $(OBJECTS)
+ $(CXX) -shared -Wl,--no-undefined $(OBJECTS) $(LOCAL_LIBS) $(CFLAGS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+ $(CC) $(LOCAL_C_INCLUDES) $(CFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+build: $(EXECUTABLE)
+ $(warning ########## build $(EXECUTABLE) ##########)
+
+install:
+ mkdir -p $(ROOT)$(base_libdir)/
+ install $(EXECUTABLE) $(ROOT)$(base_libdir)/
+ mkdir -p $(ROOT)$(includedir)/$(NAME)/sdk
+
+pack_rootfs:
+ mkdir -p $(PACK_INITRAMFS_TO)$(base_libdir)/
+ cp -af $(EXECUTABLE) $(PACK_INITRAMFS_TO)$(base_libdir)/
+ $(CROSS)strip $(PACK_INITRAMFS_TO)$(base_libdir)/$(EXECUTABLE)
+ mkdir -p $(PACK_TO)$(base_libdir)/
+ cp -af $(EXECUTABLE) $(PACK_TO)$(base_libdir)/
+ $(CROSS)strip $(PACK_TO)$(base_libdir)/$(EXECUTABLE)
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)