ql_appimg2_init.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. /*================================================================
  2. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  3. Quectel Wireless Solution Proprietary and Confidential.
  4. =================================================================*/
  5. /*=================================================================
  6. EDIT HISTORY FOR MODULE
  7. This section contains comments describing changes made to the module.
  8. Notice that changes are listed in reverse chronological order.
  9. WHEN WHO WHAT, WHERE, WHY
  10. ------------ ------- -------------------------------------------------------------------------------
  11. =================================================================*/
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include <stdlib.h>
  15. #include "ql_app_feature_config.h"
  16. #include "ql_api_osi.h"
  17. #include "ql_log.h"
  18. #include "ql_pin_cfg.h"
  19. #include "nw_demo.h"
  20. #include "gpio_demo.h"
  21. #include "gpio_int_demo.h"
  22. #include "datacall_demo.h"
  23. #include "osi_demo.h"
  24. #include "ql_dev_demo.h"
  25. #include "adc_demo.h"
  26. #include "led_cfg_demo.h"
  27. #include "ql_sim_demo.h"
  28. #include "power_demo.h"
  29. #include "ql_api_dev.h"
  30. #include "app_loader.h"
  31. #include "hal_config.h"
  32. #ifdef QL_APP_FEATURE_USB
  33. #include "usb_demo.h"
  34. #endif
  35. #ifdef QL_APP_FEATURE_MMS
  36. #include "mms_demo.h"
  37. #endif
  38. #ifdef QL_APP_FEATURE_UART
  39. #include "uart_demo.h"
  40. #endif
  41. #ifdef QL_APP_FEATURE_RS485
  42. #include "rs485_demo.h"
  43. #endif
  44. #ifdef QL_APP_FEATURE_AUDIO
  45. #include "audio_demo.h"
  46. #endif
  47. #ifdef QL_APP_FEATURE_LCD
  48. #include "lcd_demo.h"
  49. #endif
  50. #ifdef QL_APP_FEATURE_LVGL
  51. #include "lvgl_demo.h"
  52. #endif
  53. #ifdef QL_APP_FEATURE_HTTP
  54. #include "http_demo.h"
  55. #endif
  56. #ifdef QL_APP_FEATURE_FTP
  57. #include "ftp_demo.h"
  58. #endif
  59. #ifdef QL_APP_FEATURE_MQTT
  60. #include "mqtt_demo.h"
  61. #endif
  62. #ifdef QL_APP_FEATURE_SSL
  63. #include "ssl_demo.h"
  64. #endif
  65. #ifdef QL_APP_FEATURE_PING
  66. #include "ping_demo.h"
  67. #endif
  68. #ifdef QL_APP_FEATURE_NTP
  69. #include "ntp_demo.h"
  70. #endif
  71. #ifdef QL_APP_FEATURE_LBS
  72. #include "lbs_demo.h"
  73. #endif
  74. #ifdef QL_APP_FEATURE_QTHSDK
  75. #include "qthsdk_demo.h"
  76. #endif
  77. #ifdef QL_APP_FEATURE_SOCKET
  78. #include "socket_demo.h"
  79. #endif
  80. #ifdef QL_APP_FEATURE_FILE_ZIP
  81. #include "zip_demo.h"
  82. #endif
  83. #ifdef QL_APP_FEATURE_BT
  84. #ifdef QL_APP_FEATURE_BT_SPP
  85. #include "bt_spp_demo.h"
  86. #endif
  87. #ifdef QL_APP_FEATURE_BT_HFP
  88. #include "bt_hfp_demo.h"
  89. #endif
  90. #ifdef QL_APP_FEATURE_BT_A2DP_AVRCP
  91. #include "bt_a2dp_avrcp_demo.h"
  92. #endif
  93. #ifdef QL_APP_FEATURE_BLE_GATT
  94. #include "ble_gatt_demo.h"
  95. #endif
  96. #endif
  97. #ifdef QL_APP_FEATURE_FILE
  98. #include "ql_fs_demo.h"
  99. #endif
  100. #ifdef QL_APP_FEATURE_SMS
  101. #include "sms_demo.h"
  102. #endif
  103. #ifdef QL_APP_FEATURE_VOICE_CALL
  104. #include "voice_call_demo.h"
  105. #endif
  106. #ifdef QL_APP_FEATURE_GNSS
  107. #include "gnss_demo.h"
  108. #endif
  109. #ifdef QL_APP_FEATURE_HD_GNSS
  110. #include "hd_gnss_demo.h"
  111. #endif
  112. #ifdef QL_APP_FEATURE_SPI
  113. #include "spi_demo.h"
  114. #endif
  115. #ifdef QL_APP_FEATURE_SPI_NOR_FLASH
  116. #include "spi_nor_flash_demo.h"
  117. #endif
  118. #ifdef QL_APP_FEATURE_SPI4_EXT_NOR_SFFS
  119. #include "spi4_ext_nor_sffs_demo.h"
  120. #endif
  121. #ifdef QL_APP_FEATURE_SPI6_EXT_NOR
  122. #include "spi6_ext_nor_flash_demo.h"
  123. #endif
  124. #ifdef QL_APP_FEATURE_SPI_NAND_FLASH
  125. #include "spi_nand_flash_demo.h"
  126. #endif
  127. #ifdef QL_APP_FEATURE_CAMERA
  128. #include "camera_demo.h"
  129. #endif
  130. #ifdef QL_APP_FEATURE_WIFISCAN
  131. #include "wifi_scan_demo.h"
  132. #endif
  133. #ifdef QL_APP_FEATURE_HTTP_FOTA
  134. #include "fota_http_demo.h"
  135. #endif
  136. #ifdef QL_APP_FEATURE_FTP_FOTA
  137. #include "fota_ftp_demo.h"
  138. #endif
  139. #ifdef QL_APP_FEATURE_DECODER
  140. #include "decoder_demo.h"
  141. #endif
  142. #ifdef QL_APP_FEATURE_APP_IMG_AT
  143. #include "app_img_at_demo.h"
  144. #endif
  145. #ifdef QL_APP_FEATURE_VOLTE
  146. #include "volte_demo.h"
  147. #endif
  148. #ifdef QL_APP_FEATURE_VSIM_ADAPT
  149. #include "vsim_adapt_demo.h"
  150. #endif
  151. #ifdef QL_APP_FEATURE_KEYPAD
  152. #include "keypad_demo.h"
  153. #endif
  154. #ifdef QL_APP_FEATURE_RTC
  155. #include "ql_rtc_demo.h"
  156. #endif
  157. #ifdef QL_APP_FEATURE_SECURE_BOOT
  158. #include "ql_api_dev.h"
  159. #endif
  160. #ifdef QL_APP_FEATURE_USB_CHARGE
  161. #include "charge_demo.h"
  162. #endif
  163. #ifdef QL_APP_FEATURE_QCLOUD_IOT
  164. #include "qcloud_demo.h"
  165. #endif
  166. #ifdef QL_APP_FEATURE_VIRT_AT
  167. #include "ql_virt_at_demo.h"
  168. #endif
  169. #ifdef QL_APP_FEATURE_TTS
  170. #include "tts_demo.h"
  171. #endif
  172. #ifdef QL_APP_FEATURE_I2C
  173. #include "I2C_demo.h"
  174. #endif
  175. #ifdef QL_APP_FEATURE_PBK
  176. #include "ql_pbk_demo.h"
  177. #endif
  178. #ifdef QL_APP_FEATURE_SDMMC
  179. #include "ql_sdmmc_demo.h"
  180. #endif
  181. #ifdef QL_APP_FEATURE_ALI_LINKSDK
  182. #include "ali_demo.h"
  183. #endif
  184. #ifdef QL_APP_FEATURE_USBNET
  185. #include "usbnet_demo.h"
  186. #endif
  187. #ifdef QL_APP_FEATURE_FS_NAND_FLASH
  188. #include "fs_nand_flash_demo.h"
  189. #endif
  190. #ifdef QL_APP_FEATURE_FS_NOR_FLASH
  191. #include "fs_nor_flash_demo.h"
  192. #endif
  193. #ifdef QL_APP_FEATURE_SFTP
  194. #include "sftp_demo.h"
  195. #endif
  196. #ifdef QL_APP_FEATURE_MXML
  197. #include "mxml_demo.h"
  198. #endif
  199. #ifdef QL_APP_FEATURE_CLOUDOTA
  200. #include "cloudota_demo.h"
  201. #endif
  202. #ifdef QL_APP_FEATURE_EMBED_NOR_FLASH
  203. #include "embed_nor_flash_demo.h"
  204. #endif
  205. #ifdef QL_APP_FEATURE_EXT_NOR_FLASH
  206. #include "ext_nor_flash_demo.h"
  207. #endif
  208. #ifdef QL_APP_FEATURE_HILINK
  209. #include "hilink.h"
  210. #endif
  211. #ifdef QL_APP_FEATURE_PSM
  212. #include "psm_demo.h"
  213. #endif
  214. #ifdef QL_APP_FEATURE_STK
  215. #include "stk_demo.h"
  216. #endif
  217. #ifdef QL_APP_FEATURE_GPRS_DATA_TRANSFER
  218. #include "gprs_data_transfer_demo.h"
  219. #endif
  220. #ifdef QL_APP_FEATURE_TP
  221. #include "tp_demo.h"
  222. #endif
  223. #ifdef QL_APP_FEATURE_ALIOTSMARTCARD
  224. #include "aliotsmartcard_demo.h"
  225. #endif
  226. #ifdef QL_APP_FEATURE_ALIPAY_IOT_SDK
  227. extern void ql_alipay_iot_sdk_app_init(void);
  228. #endif
  229. #ifdef QL_APP_FEATURE_NTRIP_RTK
  230. #include "ntrip_rtk_demo.h"
  231. #endif
  232. #ifdef QL_APP_FEATURE_ETHERNET
  233. #include "ethernet_demo.h"
  234. #endif
  235. #define QL_INIT_LOG_LEVEL QL_LOG_LEVEL_INFO
  236. #define QL_INIT_LOG(msg, ...) QL_LOG(QL_INIT_LOG_LEVEL, "ql_INIT", msg, ##__VA_ARGS__)
  237. #define QL_INIT_LOG_PUSH(msg, ...) QL_LOG_PUSH("ql_INIT", msg, ##__VA_ARGS__)
  238. static void prvInvokeGlobalCtors(void)
  239. {
  240. extern void (*__init_array_start[])();
  241. extern void (*__init_array_end[])();
  242. size_t count = __init_array_end - __init_array_start;
  243. for (size_t i = 0; i < count; ++i)
  244. __init_array_start[i]();
  245. }
  246. static void ql_init_demo_thread(void *param)
  247. {
  248. QL_INIT_LOG("init demo thread enter, param 0x%x", param);
  249. /*Caution:If the macro of secure boot and the function are opened, download firmware and restart will enable secure boot.
  250. the secret key cannot be changed forever*/
  251. #ifdef QL_APP_FEATURE_SECURE_BOOT
  252. //ql_dev_enable_secure_boot();
  253. #endif
  254. #if 0
  255. ql_gpio_app_init();
  256. ql_gpioint_app_init();
  257. #endif
  258. #ifdef QL_APP_FEATURE_LEDCFG
  259. ql_ledcfg_app_init();
  260. #endif
  261. /*
  262. 1. 验证usb虚拟U盘功能需要在target.config中打开宏CONFIG_QUEC_PROJECT_FEATURE_USB_MASS_STORAGE
  263. 2. 映射sd卡到PC端需要打开sd卡demo(ql_sdmmc_app_init)去挂载sd卡文件系统
  264. 3. 映射6线flash到PC端需要打开6线flash demo(ql_spi6_ext_nor_flash_demo_init)挂载6线flash文件系统
  265. */
  266. #ifdef QL_APP_FEATURE_USB
  267. //ql_usb_app_init();
  268. #endif
  269. #ifdef QL_APP_FEATURE_AUDIO
  270. //ql_audio_app_init();
  271. #ifdef QL_APP_FEATURE_HEADSET_DET
  272. //ql_headset_det_app_init();
  273. #endif
  274. #endif
  275. #ifdef QL_APP_FEATURE_TTS
  276. /*
  277. *demo1直接调用TTS库和audio播放api进行TTS播放,
  278. *demo2对TTS库和audio的播放api进行封装,封装后的TTS api与我司asr系列的TTS api类似
  279. *注意:由于audio播放器只有一个,因此这两个demo只能运行一个,不能两个demo同时播放
  280. *用户如需将TTS库放到内核,则在target.config中将 CONFIG_QUEC_PROJECT_FEATURE_TTS_IN_KERNEL 置为 y,
  281. 并修改分区,将内核分区增大250k左右,其余的内容不变
  282. */
  283. //ql_tts_demo1_init();
  284. //ql_tts_demo2_init();
  285. #endif
  286. #ifdef QL_APP_FEATURE_LCD
  287. //ql_lcd_app_init();
  288. #endif
  289. #ifdef QL_APP_FEATURE_LVGL
  290. //ql_lvgl_app_init();
  291. #endif
  292. //ql_nw_app_init();
  293. //ql_datacall_app_init();
  294. //ql_osi_demo_init();
  295. #ifdef QL_APP_FEATURE_SDMMC
  296. //ql_sdmmc_app_init();
  297. #endif
  298. #ifdef QL_APP_FEATURE_FILE
  299. //ql_fs_demo_init();
  300. #endif
  301. //ql_dev_app_init();
  302. //ql_adc_app_init();
  303. #ifdef QL_APP_FEATURE_UART
  304. //ql_uart_app_init();
  305. //ql_uart_rb_app_init();
  306. #endif
  307. #ifdef QL_APP_FEATURE_RS485
  308. //ql_rs485_app_init();
  309. #endif
  310. #ifdef QL_APP_FEATURE_BT
  311. #ifdef QL_APP_FEATURE_BT_SPP
  312. #endif
  313. #ifdef QL_APP_FEATURE_BLE_GATT
  314. //ql_ble_gatt_server_demo_init();
  315. //ql_ble_gatt_client_demo_init();
  316. #endif
  317. #ifdef QL_APP_FEATURE_BT_HFP
  318. //ql_bt_hfp_demo_init();
  319. #endif
  320. #ifdef QL_APP_FEATURE_BT_A2DP_AVRCP
  321. //ql_bt_a2dp_avrcp_app_init();
  322. #endif
  323. #endif
  324. //ql_sim_app_init();
  325. ql_power_app_init();
  326. #ifdef QL_APP_FEATURE_PSM
  327. //ql_psm_app_init();
  328. #endif
  329. #ifdef QL_APP_FEATURE_CLOUDOTA
  330. //ql_cloudota_app_init();
  331. #endif
  332. #ifdef QL_APP_FEATURE_PWK
  333. //ql_pwrkey_app_init();
  334. #endif
  335. #ifdef QL_APP_FEATURE_FTP
  336. //ql_ftp_app_init();
  337. #endif
  338. #ifdef QL_APP_FEATURE_HTTP
  339. //ql_http_app_init();
  340. //ql_http_post_app_init();
  341. //ql_http_put_app_init();
  342. //ql_https_get_app_init();
  343. #endif
  344. #ifdef QL_APP_FEATURE_MQTT
  345. //ql_mqtt_app_init();
  346. #endif
  347. #ifdef QL_APP_FEATURE_SSL
  348. //ql_ssl_app_init();
  349. #endif
  350. #ifdef QL_APP_FEATURE_PING
  351. //ql_ping_app_init();
  352. #endif
  353. #ifdef QL_APP_FEATURE_NTP
  354. //ql_ntp_app_init();
  355. #endif
  356. #ifdef QL_APP_FEATURE_LBS
  357. //ql_lbs_app_init();
  358. #if defined (QL_APP_FEATURE_WIFISCAN)
  359. //ql_lbs_wifi_app_init();
  360. #endif
  361. #endif
  362. #ifdef QL_APP_FEATURE_QTHSDK
  363. //ql_qthsdk_app_init();
  364. #endif
  365. #ifdef QL_APP_FEATURE_SOCKET
  366. //ql_socket_app_init();
  367. #endif
  368. #ifdef QL_APP_FEATURE_MMS
  369. //ql_mms_app_init();
  370. #endif
  371. #ifdef QL_APP_FEATURE_SMS
  372. //ql_sms_app_init();
  373. #endif
  374. #ifdef QL_APP_FEATURE_PBK
  375. //ql_pbk_app_init();
  376. #endif
  377. #ifdef QL_APP_FEATURE_STK
  378. // ql_stk_app_init();
  379. #endif
  380. #ifdef QL_APP_FEATURE_VOICE_CALL
  381. //ql_voice_call_app_init();
  382. #endif
  383. #ifdef QL_APP_FEATURE_VOLTE
  384. //ql_volte_app_init();
  385. #endif
  386. #ifdef QL_APP_FEATURE_VSIM_ADAPT
  387. //ql_vsim_adapt_init();
  388. #endif
  389. #ifdef QL_APP_FEATURE_GNSS //内置GNSS
  390. //ql_gnss_app_init();
  391. #endif
  392. #ifdef QL_APP_FEATURE_HD_GNSS //外挂华大GNSS
  393. //ql_hd_gnss_app_init();
  394. #endif
  395. #ifdef QL_APP_FEATURE_FILE_ZIP
  396. //ql_zip_app_init();
  397. #endif
  398. #ifdef QL_APP_FEATURE_SPI
  399. //ql_spi_demo_init();
  400. #endif
  401. #ifdef QL_APP_FEATURE_CAMERA
  402. /*因为camera被i2c用来演示功能,所以打开camera demo时不可同时打开i2c demo*/
  403. /*because camera as a demonstration for i2c, so camera demo can not be opened when the i2c demo open */
  404. //ql_camera_app_init();
  405. #endif
  406. #ifdef QL_APP_FEATURE_SPI_NOR_FLASH
  407. //ql_spi_nor_flash_demo_init();
  408. #endif
  409. #ifdef QL_APP_FEATURE_SPI4_EXT_NOR_SFFS
  410. //ql_spi4_ext_nor_sffs_demo_init();
  411. #endif
  412. #ifdef QL_APP_FEATURE_SPI6_EXT_NOR
  413. //ql_spi6_ext_nor_flash_demo_init();
  414. #endif
  415. #ifdef QL_APP_FEATURE_SPI_NAND_FLASH
  416. //ql_spi_nand_flash_demo_init();
  417. #endif
  418. #if defined (QL_APP_FEATURE_WIFISCAN)
  419. //ql_wifiscan_app_init();
  420. #endif
  421. #ifdef QL_APP_FEATURE_HTTP_FOTA
  422. //ql_fota_http_app_init();
  423. #endif
  424. #ifdef QL_APP_FEATURE_FTP_FOTA
  425. //ql_fota_ftp_app_init();
  426. #endif
  427. #ifdef QL_APP_FEATURE_DECODER
  428. //ql_decoder_app_init();
  429. #endif
  430. #ifdef QL_APP_FEATURE_APP_IMG_AT
  431. //ql_app_img_at_init();
  432. #endif
  433. #ifdef QL_APP_FEATURE_KEYPAD
  434. //ql_keypad_app_init();
  435. #endif
  436. #ifdef QL_APP_FEATURE_RTC
  437. //ql_rtc_app_init();
  438. #endif
  439. #ifdef QL_APP_FEATURE_USB_CHARGE
  440. //ql_charge_app_init();
  441. #endif
  442. #ifdef QL_APP_FEATURE_ALI_LINKSDK
  443. //ql_ali_sdk_mqtt_client_test_init(); /* mqtt_basic_demo.c */
  444. //ql_ali_sdk_bootstrap_test_init(); /* bootstrap_posix_demo.c */
  445. //ql_ali_sdk_cota_test_init(); /* cota_basic_demo.c */
  446. //ql_ali_sdk_das_test_init(); /* das_basic_demo.c */
  447. //ql_ali_sdk_data_model_test_init(); /* data_model_basic_demo.c */
  448. //ql_ali_sdk_devinfo_test_init(); /* devinfo_posix_demo.c */
  449. //ql_ali_sdk_diag_test_init(); /* diag_basic_demo.c */
  450. //ql_ali_sdk_dynreg_test_init(); /* dynreg_basic_demo.c */
  451. //ql_ali_sdk_dynregmq_test_init(); /* dynregmq_basic_demo.c */
  452. //ql_ali_sdk_fota_test_init(); /* fota_basic_demo.c */
  453. //ql_ali_sdk_http_client_test_init(); /* http_basic_demo.c */
  454. //ql_ali_sdk_logpost_test_init(); /* logpost_basic_demo.c */
  455. //ql_ali_sdk_mqtt_broadcast_test_init(); /* mqtt_broadcast_demo.c */
  456. //ql_ali_sdk_rrpc_test_init(); /* mqtt_rrpc_demo.c */
  457. //ql_ali_sdk_ntp_test_init(); /* ntp_posix_demo.c */
  458. //ql_ali_sdk_shadow_test_init(); /* shadow_basic_demo.c */
  459. #endif
  460. #ifdef QL_APP_FEATURE_QCLOUD_IOT
  461. //light_data_template_sample_start();/* light_data_template_sample_start_demo.c */
  462. //mqtt_sample_start(); /* mqtt_sample_start_demo.c */
  463. //data_template_sample_start(); /* data_template_sample_start_demo.c */
  464. //ota_mqtt_sample_start(); /* ota_mqtt_sample_start_demo.c */
  465. //raw_data_sample_start(); /* raw_data_sample_start_demo.c */
  466. //dynreg_dev_sample_start(); /* dynreg_dev_sample_start_demo.c */
  467. //gateway_sample_start(); /* gateway_sample_start_demo.c */
  468. #endif
  469. #ifdef QL_APP_FEATURE_VIRT_AT
  470. //ql_virt_at_app_init();
  471. #endif
  472. #ifdef QL_APP_FEATURE_I2C
  473. /*因为i2c通过camera来演示功能,所以打开i2c demo时不可同时打开camera demo*/
  474. /*because I2C uses the camera as a demonstration, so i2c demo can not be opened when the camera demo open */
  475. //ql_i2c_demo_init();
  476. #endif
  477. #ifdef QL_APP_FEATURE_USBNET
  478. //ql_usbnet_app_init();
  479. #endif
  480. #ifdef QL_APP_FEATURE_FS_NAND_FLASH
  481. //ql_fs_nand_flash_demo_init();
  482. #endif
  483. #ifdef QL_APP_FEATURE_FS_NOR_FLASH
  484. //ql_fs_nor_flash_demo_init();
  485. #endif
  486. #ifdef QL_APP_FEATURE_SFTP
  487. //ql_sftp_app_init();
  488. #endif
  489. #ifdef QL_APP_FEATURE_MXML
  490. //ql_mxml_app_init();
  491. #endif
  492. #ifdef QL_APP_FEATURE_EMBED_NOR_FLASH
  493. //ql_embed_nor_flash_app_init();
  494. #endif
  495. #ifdef QL_APP_FEATURE_EXT_NOR_FLASH
  496. //ql_ext_nor_flash_app_init();
  497. #endif
  498. #ifdef QL_APP_FEATURE_HILINK
  499. //hilink_main();
  500. #endif
  501. #ifdef QL_APP_FEATURE_GPRS_DATA_TRANSFER
  502. //ql_gprs_data_transfer_app_init();
  503. #endif
  504. #ifdef QL_APP_FEATURE_TP
  505. //ql_tp_demo_init();
  506. #endif
  507. #ifdef QL_APP_FEATURE_ALIPAY_IOT_SDK
  508. //ql_alipay_iot_sdk_app_init();
  509. #endif
  510. #ifdef QL_APP_FEATURE_ALIOTSMARTCARD
  511. //ql_aliotsmartcard_app_init();
  512. #endif
  513. #ifdef QL_APP_FEATURE_NTRIP_RTK
  514. //ql_ntrip_rtk_demo_init();
  515. #endif
  516. #ifdef QL_APP_FEATURE_ETHERNET
  517. //ql_ethernet_demo_init();
  518. #endif
  519. ql_rtos_task_sleep_ms(1000); /*Chaos change: set to 1000 for the camera power on*/
  520. /*To save logs to sdcard/nandflash, you must call this function after initializing sdcard/nandflash file system;*/
  521. /*Logs before this point can be output via USB or debug port, which can be configured in prvTraceInit of app_start*/
  522. //ql_fs_trace_init();
  523. #ifdef QL_APP_FEATURE_APPIMG2
  524. //void appimg_jump(void);
  525. //appimg_jump();
  526. #endif
  527. ql_rtos_task_delete(NULL);
  528. }
  529. int appimg_enter(void *param)
  530. {
  531. QlOSStatus err = QL_OSI_SUCCESS;
  532. ql_task_t ql_init_task = NULL;
  533. QL_INIT_LOG("init demo enter APP2: %s @ %s", QL_APP_VERSION, QL_APP_BUILD_RELEASE_TYPE);
  534. prvInvokeGlobalCtors();
  535. if(0 == strcasecmp(QL_APP_BUILD_RELEASE_TYPE, "release"))
  536. {
  537. ql_dev_cfg_wdt(1);
  538. //open the kernel log
  539. //ql_quec_trace_enable(1);
  540. }
  541. else
  542. {
  543. ql_dev_cfg_wdt(0);
  544. //close the kernel log
  545. //ql_quec_trace_enable(0);
  546. }
  547. err = ql_rtos_task_create(&ql_init_task, 1024*4, APP_PRIORITY_NORMAL, "ql_init", ql_init_demo_thread, NULL, 1);
  548. if(err != QL_OSI_SUCCESS)
  549. {
  550. QL_INIT_LOG("init failed");
  551. }
  552. return err;
  553. }
  554. void appimg_exit(void)
  555. {
  556. QL_INIT_LOG("init demo exit");
  557. }
  558. #ifdef QL_APP_FEATURE_APPIMG2
  559. void appimg_jump(void)
  560. {
  561. #if 1
  562. #ifdef CONFIG_APPIMG_LOAD_FLASH
  563. //备注:APPIMG分区编译生成的IMG只能在对应分区中运行;例如:APPIMG只能下载到在CONFIG_APPIMG_FLASH_ADDRESS到CONFIG_APPIMG_FLASH_SIZE区间内运行,
  564. // 如果下载到CONFIG_APPIMG2_FLASH_ADDRESS到CONFIG_APPIMG2_FLASH_SIZE的分区内是不能运行的,跳转的时候检查就会报错。
  565. const unsigned flash_img_address = (const unsigned)CONFIG_APPIMG_FLASH_ADDRESS;
  566. const unsigned flash_img_size = (const unsigned)CONFIG_APPIMG_FLASH_SIZE;
  567. const unsigned flash_ram_address = (const unsigned)CONFIG_APP_FLASHIMG_RAM_ADDRESS;
  568. const unsigned flash_ram_size = (const unsigned)CONFIG_APP_FLASHIMG_RAM_SIZE;
  569. #else
  570. const unsigned flash_ram_address = (const unsigned)CONFIG_APP_FILEIMG_RAM_ADDRESS;
  571. const unsigned flash_ram_size = (const unsigned)CONFIG_APP_FILEIMG_RAM_SIZE;
  572. #endif
  573. #else
  574. #ifdef CONFIG_APPIMG_LOAD_FLASH
  575. const unsigned flash_img_address = (const unsigned)CONFIG_APPIMG2_FLASH_ADDRESS;
  576. const unsigned flash_img_size = (const unsigned)CONFIG_APPIMG2_FLASH_SIZE;
  577. const unsigned flash_ram_address = (const unsigned)CONFIG_APP2_FLASHIMG_RAM_ADDRESS;
  578. const unsigned flash_ram_size = (const unsigned)CONFIG_APP2_FLASHIMG_RAM_SIZE;
  579. #else
  580. const unsigned flash_ram_address = (const unsigned)CONFIG_APP2_FILEIMG_RAM_ADDRESS;
  581. const unsigned flash_ram_size = (const unsigned)CONFIG_APP2_FILEIMG_RAM_SIZE;
  582. #endif
  583. #endif
  584. #ifdef CONFIG_APPIMG_LOAD_FLASH
  585. appImageHandler_t AppImgFlash = {};
  586. if(ql_app_image_from_flash(flash_img_address,flash_img_size,flash_ram_address,flash_ram_size,&AppImgFlash))
  587. {
  588. QL_INIT_LOG("Find app image at 0x%x", flash_img_address);
  589. AppImgFlash.enter(NULL);
  590. }
  591. else
  592. {
  593. QL_INIT_LOG("app jump failed");
  594. }
  595. #endif
  596. #ifdef CONFIG_APPIMG_LOAD_FILE
  597. appImageHandler_t AppImgFile = {};
  598. if(ql_app_image_from_file(CONFIG_APPIMG_LOAD_FILE_NAME,flash_ram_address,flash_ram_size,&AppImgFile))
  599. {
  600. QL_INIT_LOG("Find file image at " CONFIG_APPIMG_LOAD_FILE_NAME);
  601. AppImgFile.enter(NULL);
  602. }
  603. else
  604. {
  605. QL_INIT_LOG("app jump failed");
  606. }
  607. #endif
  608. }
  609. #endif