更新nandflash分区为单分区模式。默认开启单分区模式 1230/1 1230/head 1231/target/1
authorSnickerSun <snickersun@163.com>
Mon, 21 Oct 2024 05:27:00 +0000 (13:27 +0800)
committerSnickerSun <snickersun@163.com>
Mon, 21 Oct 2024 05:27:00 +0000 (13:27 +0800)
SINGLE_USER_PARTITION
        'single_user_partition': 'True', == true or false

52 files changed:
code/sdk/application/brandy/brandy_recovery/recovery_display.c
code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp
code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownModel.h
code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageModel.cpp
code/sdk/application/wearable/fd230app/nativeui/safemodemanager/src/SafeModeManagerModel.cpp
code/sdk/application/wearable/fd230app/nativeui/system/include/Systemupgrade.h
code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdateModel.h
code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c
code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp
code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp
code/sdk/application/wstp/at_service/app/app_at_process.c
code/sdk/application/wstp/at_service/app/app_test_fs.c
code/sdk/application/wstp/at_service/app/app_test_fs.h
code/sdk/build/config/target_config/brandy/config.py
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/create_fs_checksumfile.py
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/music/ring/alarm.mp3 [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/music/ring/alarm.mp3 with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/music/ring/calling.mp3 [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/music/ring/calling.mp3 with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/music/ring/findwatch.mp3 [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/music/ring/findwatch.mp3 with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/music/ring/ring.mp3 [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/music/ring/ring.mp3 with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/music/test3.txt [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/music/test3.txt with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/system/KUMI_LOGO.bin [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/KUMI_LOGO.bin with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/system/OTAUpdata.bin [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/OTAUpdata.bin with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/system/OTAUpdataRecover.bin [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/OTAUpdataRecover.bin with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/system/cat1ota/EventMesh.py [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/cat1ota/EventMesh.py with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/system/cat1ota/cat1Service.py [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/cat1ota/cat1Service.py with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/system/cat1ota/checkota.py [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/cat1ota/checkota.py with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/system/cat1ota/china_mobile_dmp.py [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/cat1ota/china_mobile_dmp.py with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/system/cat1ota/main.py [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/cat1ota/main.py with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/system/cat1ota/main_init.py [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/cat1ota/main_init.py with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/system/cat1ota/slipService.py [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/cat1ota/slipService.py with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/system/cat1ota/telecom_dmp.py [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/cat1ota/telecom_dmp.py with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/update/test2.txt [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/update/test2.txt with 100% similarity]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/mkyaffs2tool.py
code/sdk/build/script/cmake_builder.py
code/sdk/drivers/drivers/driver/mmc/mmc_init.c
code/sdk/drivers/drivers/driver/nand_flash/nand/nandflash_config.c
code/sdk/drivers/peripheral/config/include/ConfigModel.h
code/sdk/drivers/peripheral/config/src/ConfigModel.cpp
code/sdk/drivers/peripheral/slip/cat1Service/cat1_tcpServer.cpp
code/sdk/drivers/peripheral/utils/custom_resfile_check.c
code/sdk/drivers/peripheral/utils/custom_utils.c
code/sdk/middleware/chips/brandy/update/include/upg_common_porting.h
code/sdk/middleware/services/gui/uikit/proprietary/src/service/src/graphic_service_wrapper.cpp
code/sdk/open_source/openharmony/foundation/appexecfwk/appexecfwk_lite/include/appexecfwk/appexecfwk_lite/services/bundlemgr_lite/include/bundle_common.h
code/sdk/open_source/openharmony/third_party/icu/icu4c/source/ohos/init_data.cpp
mkota_single_user.sh [new file with mode: 0644]
tools/scripts/gen_fs_otapkg_singleuser.sh [new file with mode: 0644]
tools/scripts/search_folder_files.py
tools/scripts/unyaffs2tool_singleuser.py [new file with mode: 0644]

index 2b46643..10e2321 100644 (file)
@@ -110,7 +110,11 @@ void recovery_display_sample(void)
        </imageRes>
     */
     // memset_s((void *)surface.phy_addr, surface.size, 0xFF, surface.size);
+#ifdef SINGLE_USER_PARTITION
+    recovery_dispay_read_image_and_savein_surface("/user/system/OTAUpdataRecover.bin",&surface);
+#else
     recovery_dispay_read_image_and_savein_surface("/system/OTAUpdataRecover.bin",&surface);
+#endif
     ret = uapi_dpu_create_layer(&layer_info, &dpu_handle);
     if (ret != ERRCODE_SUCC) {
         return;
index 8b3af69..5cc06d6 100644 (file)
@@ -915,7 +915,11 @@ int AlarmClockModel::AlarmPlayerInit(void)
     std::string pureName = strSongName.substr(0, strSongName.rfind(".")); // 播放音乐的路径需要引用.号
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayerInit, url:%s ", sliceId);
     //std::string strSrcMusic(APP_MUSIC_PATH);
+ #ifdef SINGLE_USER_PARTITION   
+    std::string strSrcMusic("/user/music/ring");
+ #else
     std::string strSrcMusic("/music/ring");
+ #endif
     std::string tempStr("/");
     std::string strName = sliceId;
     uri = strSrcMusic + tempStr + strName;
index 0642536..674c403 100644 (file)
@@ -1,8 +1,8 @@
 /*\r
  * @Author: luozheng 1732036298@qq.com\r
  * @Date: 2024-04-07 18:15:53\r
- * @LastEditors: luozheng 1732036298@qq.com\r
- * @LastEditTime: 2024-10-11 16:08:37\r
+ * @LastEditors: SnickerSun snickersun@163.com\r
+ * @LastEditTime: 2024-10-21 11:35:37\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/countdown/include/CountDownModel.h\r
  */\r
 #ifndef COUNTDOWN_MODEL_H\r
@@ -116,8 +116,11 @@ namespace OHOS
         AudioSession sessionId;\r
         AudioInterrupt interrupt;\r
         // const char *RingMusicPath = "/user/music/alarm.mp3"; // 铃声路径\r
+#ifdef SINGLE_USER_PARTITION   \r
+        const char *RingMusicPath = "/user/music/ring/alarm.mp3"; // 铃声路径\r
+#else\r
         const char *RingMusicPath = "/music/ring/alarm.mp3"; // 铃声路径\r
-\r
+#endif\r
         std::string countdownDuration{nullptr};\r
         std::string RingTime{"00:00:00"};  // 响铃时间\r
         std::string CountTime{"00:00:00"}; // 倒计时时间\r
index b2b9f02..26730c3 100644 (file)
@@ -300,7 +300,11 @@ namespace OHOS
         std::string pureName = strSongName.substr(0, strSongName.rfind(".")); // 播放音乐的路径需要引用.号
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayerInit, url:%s ", uri.c_str());
         //std::string strSrcMusic(APP_MUSIC_PATH);
+#ifdef SINGLE_USER_PARTITION   
+        std::string strSrcMusic("/user/music/ring");
+#else
         std::string strSrcMusic("/music/ring");
+#endif
         std::string tempStr("/");
         std::string strName = uri;
         uri = strSrcMusic + tempStr + strName;
index 2c2fb89..3277a55 100644 (file)
@@ -43,9 +43,11 @@ const char *get_version_string(void);
 
 bool resfile_checksum_thread(void);
 }
-
+#ifdef SINGLE_USER_PARTITION
+static const char *CHECK_DIFFERENTIAL_FILE = "/user/system/check_differential.txt";
+#else
 static const char *CHECK_DIFFERENTIAL_FILE = "/system/check_differential.txt";
-
+#endif
 void repair_file_start() {
   OHOS::SafeModeManagerModel::GetInstance()->RepairStart();
 }
index 588b3c3..7caa5aa 100644 (file)
 #define JSON_URL "http://snicker.com.cn:8089/fd230otanew.jsp?product=FD230&imei=%s&pkgver=%s"//获取升级url
 #endif
 
-#define UPDATAJSONPATH "/update/ota_start_.json"//获取升级的得到的json
+#ifdef SINGLE_USER_PARTITION
 
-#define UPDATAREPORT "/update/ota_start_reported_.json"//点升级后保存下来的json
+#define UPDATAJSONPATH "/user/update/ota_start_.json"//获取升级的得到的json
+#define UPDATAREPORT "/user/update/ota_start_reported_.json"//点升级后保存下来的json
+#define UPDATAFWPKGPATH "/user/update/update.fwpkg" //升级包
+#define UPDATAREPORT_  "/user/update/ota_report_.json"//上报升级得到的json
 
-#define UPDATAFWPKGPATH "/update/update.fwpkg" //升级包
+#else
 
+#define UPDATAJSONPATH "/update/ota_start_.json"//获取升级的得到的json
+#define UPDATAREPORT "/update/ota_start_reported_.json"//点升级后保存下来的json
+#define UPDATAFWPKGPATH "/update/update.fwpkg" //升级包
 #define UPDATAREPORT_  "/update/ota_report_.json"//上报升级得到的json
 
+#endif
 
 namespace OHOS
 {
index c0c4244..2e0675a 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-05-07 11:26:14
- * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-05-07 16:31:17
+ * @LastEditors: SnickerSun snickersun@163.com
+ * @LastEditTime: 2024-10-21 11:38:16
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/systemupdate/include/SystemUpdateModel.h
  */
 
 #define JSON_URL "http://snicker.com.cn:8089/fd230otanew.jsp?product=FD230&imei=%s&pkgver=%s"//获取升级url
 #endif
 
+#ifdef SINGLE_USER_PARTITION
+
+#define UPDATAJSONPATH "/user/update/ota_start_.json"//获取升级的得到的json
+
+#define UPDATAREPORT "/user/update/ota_start_reported_.json"//点升级后保存下来的json
+
+#define UPDATAFWPKGPATH "/user/update/update.fwpkg" //升级包
+
+#define UPDATAREPORT_  "/user/update/ota_report_.json"//上报升级得到的json
+
+#else
 #define UPDATAJSONPATH "/update/ota_start_.json"//获取升级的得到的json
 
 #define UPDATAREPORT "/update/ota_start_reported_.json"//点升级后保存下来的json
@@ -50,6 +61,8 @@
 
 #define UPDATAREPORT_  "/update/ota_report_.json"//上报升级得到的json
 
+#endif
+
 #define  UPDATAFWPKGPATHURL 256
 
 #define  MSG_LEN 64
index 348a391..9bbea7b 100644 (file)
@@ -112,7 +112,11 @@ void test_paly(uint8_t falg)
 {
     if(falg)
     {
+#ifdef SINGLE_USER_PARTITION
+        testPlayerStart_("/user/music/ring/ring.mp3");
+#else
         testPlayerStart_("/music/ring/ring.mp3");
+#endif
     }
     else
     {
index 0e3f498..c7c804a 100644 (file)
@@ -3914,9 +3914,14 @@ static void GetSDSpaceCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *total
         uint64_t free_size=0;\r
         int i;\r
         struct statfs file_buf = {0};\r
+#ifdef SINGLE_USER_PARTITION\r
+        static const char * const g_volume_names[1] = { "/user/"};\r
+        for (i = 0; i < 1; i++) {\r
+#else\r
         static const char * const g_volume_names[4] = {"/system/", "/update/", "/music/", "/user/"};\r
-\r
+        \r
         for (i = 0; i < 4; i++) {\r
+#endif\r
             /* 获取文件系统状态 */\r
             if (statfs(g_volume_names[i], &file_buf) != 0) {\r
                 return ;\r
@@ -6820,7 +6825,7 @@ errcode_t decode_ota_data(ble_read_data *buffer_handle,uint8_t *data,uint16_t da
                 buffer_handle->file_recv_stat.lrcvalue = 0;\r
                 if (buffer_handle->file_recv_stat.file_type == 1)\r
                 {\r
-                    buffer_handle->file_recv_stat.file = fopen("/update/update.fwpkg","w+");\r
+                    buffer_handle->file_recv_stat.file = fopen("/user/update/update.fwpkg","w+");\r
                       WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"create file /update/update.fwpkg %X\n",buffer_handle->file_recv_stat.file);\r
 \r
                 }\r
@@ -8046,7 +8051,7 @@ errcode_t handle_recv_file(ble_read_data *buffer_handle,uint8_t *data, uint16_t
         buffer_handle->file_recv_stat.lrcvalue = 0;\r
         if (buffer_handle->file_recv_stat.file_type == 1)\r
         {\r
-            buffer_handle->file_recv_stat.file = fopen("/update/update.fwpkg","w+");\r
+            buffer_handle->file_recv_stat.file = fopen("/user/update/update.fwpkg","w+");\r
               WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"create file /update/update.fwpkg %X\n",buffer_handle->file_recv_stat.file);\r
 \r
         }\r
index 3de15f5..ba29c7d 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-03-25 17:31:19
- * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-09-09 21:29:37
+ * @LastEditors: SnickerSun snickersun@163.com
+ * @LastEditTime: 2024-10-21 11:49:04
  * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h
  */
 #ifndef FIND_WATCH_NOTIFICATION_H
@@ -101,7 +101,11 @@ namespace OHOS
         std::shared_ptr<FindWatchRingPlayerListener> playerInterruptListener{nullptr};
         AudioSession sessionId;
         AudioInterrupt interrupt;
+#ifdef SINGLE_USER_PARTITION
+        const char *RingMusicName = "/user/music/ring/findwatch.mp3";
+#else
         const char *RingMusicName = "/music/ring/findwatch.mp3";
+#endif
         const char * path_{nullptr};
         bool FindWatchNotifyFlag{false}; // 判断是查找手表, 由notify生成界面
         bool X_DRAG_FLAG{false};
index 18a26d0..25170f5 100644 (file)
@@ -930,7 +930,11 @@ void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req)
 
         if(true != ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()) && true != ConfigModel::GetInstance()->GetSilentMode())
         {
+#ifdef SINGLE_USER_PARTITION
+            AlarmClockModel::GetInstance()->testPlayerStart("/user/music/ring/ring.mp3");
+#else
             AlarmClockModel::GetInstance()->testPlayerStart("/music/ring/ring.mp3");
+#endif
         }
 
         CallerLogModel::GetInstance()->SetoperateNumber(call_data,strlen(call_data));
index d8170ac..1f1649c 100755 (executable)
@@ -637,7 +637,11 @@ namespace OHOS
 
     void AlarmViewEventListener::PopAlarmRing()
     {
+#ifdef SINGLE_USER_PARTITION
+        FindWatchViewEventListener::GetInstance().PopInterPlayMusic("/user/music/ring/alarm.mp3");//播放铃声
+#else
         FindWatchViewEventListener::GetInstance().PopInterPlayMusic("/music/ring/alarm.mp3");//播放铃声
+#endif
     }
 
     void AlarmViewEventListener::CancelAlarmRing()
index 39f2cb2..3fa03c4 100644 (file)
@@ -330,7 +330,11 @@ namespace OHOS
     {
         // 本地播放文件路径和状态
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RingPlayerInit start!");
+#ifdef SINGLE_USER_PARTITION
+        std::string strSrcMusic("/user/music/ring");
+#else
         std::string strSrcMusic("/music/ring");
+#endif
         std::string tempStr("/");
         std::string strName = RingMusicName;
         uri = strSrcMusic + tempStr + strName;
index 51c92af..8696c17 100755 (executable)
 #define CALENDAR_PARAM_LEN                 0x6\r
 #ifdef CFG_DRIVERS_MMC\r
 #define FS_VOLUMES_NUM 4\r
-#define FS_VOLUME_STRS "/system/", "/user/", "/update/", "/music/"\r
+#define FS_VOLUME_STRS "/user/system/", "/user/", "/user/update/", "/user/music/"\r
 extern unsigned int mmc_set_clock_with_way2(struct hci_softc *sc, unsigned int cfg_clock);\r
 uint32_t g_app_emmc_clk = SDIOM_SRC_CLK_FREQ_LVL_98M_VAL;\r
 #endif\r
 \r
 #ifdef CFG_DRIVERS_NANDFLASH\r
 #ifndef MEMORY_MINI\r
+#ifdef SINGLE_USER_PARTITION\r
+#define FS_VOLUMES_NUM 1\r
+#define FS_VOLUME_STRS "/user/"\r
+#else\r
 #define FS_VOLUMES_NUM 4\r
-#define FS_VOLUME_STRS "/system/", "/update/", "/music/", "/user/"\r
+#define FS_VOLUME_STRS "/system/", "/user/update/", "/user/music/", \r
+#endif\r
 #else\r
 #define FS_VOLUMES_NUM 1\r
 #define FS_VOLUME_STRS "/user/"\r
index 7c426a7..3435a11 100755 (executable)
@@ -188,8 +188,13 @@ void file_basic_test(const char* path)
 void app_fs_test_basic(void)\r
 {\r
     file_basic_test("/user/user_test.log");\r
+#ifdef SINGLE_USER_PARTITION\r
+    file_basic_test("/user/update/upd_test.log");\r
+    file_basic_test("/user/music/music_test.log");\r
+#else\r
     file_basic_test("/update/upd_test.log");\r
     file_basic_test("/music/music_test.log");\r
+#endif\r
 }\r
 \r
 #ifdef CFG_DRIVERS_MMC\r
index c687ed7..2a37462 100755 (executable)
@@ -50,10 +50,10 @@ extern "C" {
 #define MAX_FILE_PATH_SIZE      25
 #define TCXO_ERROR              40
 
-#define FS_PARTITION_NAME_SYSTEM "/system"
-#define FS_PARTITION_NAME_USER "/user"
-#define FS_PARTITION_NAME_UPDATE "/update"
-#define FS_PARTITION_NAME_MUSIC "/music"
+// #define FS_PARTITION_NAME_SYSTEM "/system"
+// #define FS_PARTITION_NAME_USER "/user"
+// #define FS_PARTITION_NAME_UPDATE "/update"
+// #define FS_PARTITION_NAME_MUSIC "/music"
 
 typedef struct {
     uint32_t randm;
index b49a257..d202759 100755 (executable)
@@ -147,6 +147,7 @@ target = {
                     'SUPPORT_TCPIP',                                   
                     'SUPPORT_HID_SERVICE',
                     'SUPPORT_BAIDU_MAP',
+                    'SINGLE_USER_PARTITION',
                     'CFG_FLASH_SIZE=16'
                     ],
         'ram_component': ["algorithm", "dfx_port_brandy", "dfx_update", 'dfx_nv', "osal", "arch_port", "-:testsuite",
@@ -190,8 +191,10 @@ target = {
         'dsp_version': 'max',
         'packet': True,
         'image_analysis': False,
+        'single_user_partition': 'True',
         #  'fs_image_path':'evb4',
         'fs_image': True
+
     },
        #native-js-user: liteos + uikit + nandflash + mipi + psram + audio  典型合封UIKIT版本
     #离线日志版本
index 7556cf9..0ef3f62 100644 (file)
@@ -60,11 +60,11 @@ target_filelist_name=""
 
 if __name__ == '__main__':
     target_tmp_dir = sys.argv[1]+"/fs"
-    target_filelist_name=target_tmp_dir+"/system/fileschecksum.txt"
+    target_filelist_name=target_tmp_dir+"/user/fileschecksum.txt"
     if os.path.exists(target_filelist_name):
         os.remove(target_filelist_name)
     filelist=getAllFiles(target_tmp_dir)
-    create_dirs(target_tmp_dir+"/system/")
+    create_dirs(target_tmp_dir+"/user/")
     with open(target_filelist_name, 'w') as file:
         for f in filelist:
             fullpath=target_tmp_dir+f
index 0052ed3..8a6bb3b 100644 (file)
@@ -26,25 +26,27 @@ image_name = "file"
 # 配置nandflash信息
 cfg_page_size = 2048
 cfg_obb_size = 64
-
+single_user_partition = False
 # 配置分区信息,请根据实际情况进行配置,添加格式为[分区路径, 分区大小]
 # 分区大小需要根据按照百分系统分配好后的blocks数进行计算,大小=blocks(文件块个数)*pages_per_block(每个文件块包含的页数)*bytes_per_page(每页包含字节数)
 # 前面按照比例分好分区,最后分区置成null,即代表剩下所有blocks
 # drivers/drivers/driver/nand_flash/nand/nandflash_config.c 
 # #ifndef MEMORY_MINI
-# #define YF_NAME_STRS "/system/", "/update/", "/music/", "/user/"
+# #define YF_NAME_STRS "/user/system/", "/user/update/", "/user/music/", "/user/"
 # uint32_t yf_volume_percent[YF_VOLUMES_NUM] = { 1, 1, 1, 97 };
 #                                               0x140000
 #                                                10 10 10 70
 #                                               0xcc0000
 
-
 partition_list = [
     [os.path.join(cur_dir, 'fs', 'system'), "0xcc0000"],
     [os.path.join(cur_dir, 'fs', 'update'), "0xcc0000"],
     [os.path.join(cur_dir, 'fs', 'music'), "0xcc0000"],
     [os.path.join(cur_dir, 'fs', 'user'), "null"]
 ]
+partition_list_single = [
+    [os.path.join(cur_dir, 'fs', 'user'), "null"]
+]
 
 # 将生成image文件转换大小端,保存成另外文件
 def convert(src_file, dest_file):
@@ -77,14 +79,17 @@ def get_obb_type(obb_size):
 if __name__ == "__main__":
     image_file = os.path.join(cur_dir, "%s.bin" %image_name)
     tmp_file = os.path.join(cur_dir, "%s_tmp.bin" %image_name)
-    if len(sys.argv) == 3 :
+    if len(sys.argv) == 4 :
         out_path = os.path.join(sys.argv[1], "%s.bin" %image_name)
         if sys.argv[2] == '128' :
             cfg_obb_size = 128
+        if sys.argv[3] == 'True':
+            single_user_partition = True
     else:
         print("need give parms output path and oobsize!")
         sys.exit(1)
 
+    print("=========== oobsize {} single_user_partition {}".format(cfg_obb_size,single_user_partition))
     if sys.platform == 'linux2' or sys.platform == 'linux':
         partition_total = 0
         page_type =  get_page_type(cfg_page_size)
@@ -94,15 +99,24 @@ if __name__ == "__main__":
             os.remove(tmp_file)
         if os.path.exists(image_file):
             os.remove(image_file)
-
-        for partition in partition_list:
-            if (partition[1] != "null"):
-                partition_total = partition_total + int(partition[1][2:], 16)
-                command = mkyaffstool + " " + partition[0] + " " + tmp_file + page_type + obb_type + (" 0x%x" %partition_total)
-            else:
-                command = mkyaffstool + " " + partition[0] + " " + tmp_file + page_type + obb_type
-            print(command)
-            os.system(command)
+        if single_user_partition :
+            for partition in partition_list_single:
+                if (partition[1] != "null"):
+                    partition_total = partition_total + int(partition[1][2:], 16)
+                    command = mkyaffstool + " " + partition[0] + " " + tmp_file + page_type + obb_type + (" 0x%x" %partition_total)
+                else:
+                    command = mkyaffstool + " " + partition[0] + " " + tmp_file + page_type + obb_type
+                print(command)
+                os.system(command)
+        else:
+            for partition in partition_list:
+                if (partition[1] != "null"):
+                    partition_total = partition_total + int(partition[1][2:], 16)
+                    command = mkyaffstool + " " + partition[0] + " " + tmp_file + page_type + obb_type + (" 0x%x" %partition_total)
+                else:
+                    command = mkyaffstool + " " + partition[0] + " " + tmp_file + page_type + obb_type
+                print(command)
+                os.system(command)
         convert(tmp_file, image_file)
 
     if os.path.exists(image_file):
index 0af478d..8e2b16b 100755 (executable)
@@ -150,10 +150,16 @@ class CMakeBuilder(BuildEnvironment):
                 output_path = env.get_output_path()
                 print(output_path)
                 # errcode = exec_shell([self.python_path, fs_script_path], None, True)
+                if env.get("single_user_partition") == 'True' :
+                    single_user_partition = 'True'
+                else:
+                    single_user_partition = 'False'
+
                 if env.get("nandflash_oobsize") :
-                    errcode = exec_shell([self.python_path, fs_script_path, output_path, env.get("nandflash_oobsize")], None, True)
+                    oobsize=env.get("nandflash_oobsize")
                 else :
-                    errcode = exec_shell([self.python_path, fs_script_path, output_path, '64' ], None, True)
+                    oobsize = '64' 
+                errcode = exec_shell([self.python_path, fs_script_path, output_path, oobsize,single_user_partition], None, True)
                 if errcode != 0:
                     print("creat fs image error!")
                     self.print_build_result(target, errcode)
index 6155f99..edbf424 100755 (executable)
@@ -43,7 +43,6 @@ extern "C" {
 #endif /* __cplusplus */
 #endif /* __cplusplus */
 
-#define FF_VOLUMES_NUM 4
 #define EMMC_PINMUX_NUM 10
 #define EMMC_PAD_PINMUX_NUM 9
 #define SDIO_PINMUX_NUM 6
@@ -53,8 +52,15 @@ extern "C" {
 #define EMMC_MSLEEP_20 20
 #define EMMC_ACCESS_OFFSET 20
 #define EMMC_SECTOR_TO_KB 2
+#ifdef  SINGLE_USER_PARTITION
+#define FF_VOLUMES_NUM 1
+#define FF_VOLUME_NAME_STRS "/user/"
+uint32_t g_volume_percent[FF_VOLUMES_NUM] = { 100 };
+#else
+#define FF_VOLUMES_NUM 4
 #define FF_VOLUME_NAME_STRS "/user/", "/system/", "/update/", "/music/"
 uint32_t g_volume_percent[FF_VOLUMES_NUM] = { 11, 11, 8, 70 };
+#endif
 static const char * const g_volume_names[FF_VOLUMES_NUM] = { FF_VOLUME_NAME_STRS };
 int32_t g_fail_mount_index = 0;
 
index 44800fb..d44636c 100755 (executable)
 #include "nandflash.h"
 #include "hal_nandflash.h"
 
-#ifndef MEMORY_MINI
-#define YF_VOLUMES_NUM 4
-#else
-#define YF_VOLUMES_NUM 1
-#endif
 
 #define NAND_BYTE_ALIGN 4
 #define ERASE_ALL_TIMES 10
@@ -46,10 +41,18 @@ uint8_t buffer_oob_verify[128] __attribute__((aligned(4))); // 128 is one max oo
 int has_nandflash_init = 0;
 
 #ifndef MEMORY_MINI
-#define YF_NAME_STRS "/system/", "/update/", "/music/", "/user/"
+#ifdef  SINGLE_USER_PARTITION
+#define YF_VOLUMES_NUM 1
+#define YF_NAME_STRS "/user/"
+uint32_t yf_volume_percent[YF_VOLUMES_NUM] = {100};
+#else
+#define YF_VOLUMES_NUM 4
+#define YF_NAME_STRS "/user/system/", "/user/update/", "/user/music/", "/user/"
 uint32_t yf_volume_percent[YF_VOLUMES_NUM] = { 10, 10, 10, 70 };
 // uint32_t yf_volume_percent[YF_VOLUMES_NUM] = { 1, 1, 1, 97 };
+#endif
 #else
+#define YF_VOLUMES_NUM 1
 #define YF_NAME_STRS "/user/"
 uint32_t yf_volume_percent[YF_VOLUMES_NUM] = {100};
 #endif
index 47e6dfa..3180949 100644 (file)
@@ -447,7 +447,11 @@ namespace OHOS
         cJSON *get_item(ConfigItem item);
 
     private:
+#ifdef  SINGLE_USER_PARTITION
+        const std::string filePath = "/user/system/ConfigModel.json";
+#else
         const std::string filePath = "/system/ConfigModel.json";
+#endif
         cJSON *cjson_json{nullptr};
 #endif
     
index 6810e6b..6732f9f 100644 (file)
@@ -753,7 +753,11 @@ namespace OHOS
         }
 
         //UtilsSetEnv从ScreenModels.cpp移动到此,因此不收 USE_KVSTORE_STORE_CONFIG管理只是为了使用KVStore时更方便。
+#ifdef  SINGLE_USER_PARTITION
+        int rets = UtilsSetEnv("/user/system");
+#else
         int rets = UtilsSetEnv("/system");
+#endif
         WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "UtilsSetEnv /system ret = %d", rets);
 #ifdef  USE_KVSTORE_STORE_CONFIG
 
index daf9468..a72079e 100644 (file)
@@ -66,8 +66,11 @@ static uint8_t g_skip_cat1_service_udp_transfer = 0;
 
 /** 0: old format 1字节cmd, 1: new format 2字节cmd */
 static uint8_t g_msg_format_type = 0;
-
+#ifdef  SINGLE_USER_PARTITION
+#define CAT1_PY_PATH "/user/system/cat1ota" //存放需要升级的py文件路径
+#else
 #define CAT1_PY_PATH "/system/cat1ota" //存放需要升级的py文件路径
+#endif
 #define CAT1_REPLYA_FILE_SIZE_FUN 1  //是否需要CAT1回复文件大小一致传输完单个文件是否与SIZE大小匹配比较
 static osTimerId_t file_transfer_timer=NULL;
 static uint8_t timerOut_count = 0;
index dc8cd5c..8ea3c8c 100644 (file)
 
 #define MAX_FILE_NAME_LEN 256
 #define MAX_FILE_CHECKSUM_STR_LEN (256 + 64)
+#ifdef  SINGLE_USER_PARTITION
+#define RESFILE_CHECKSUM_FILE "/user/system/fileschecksum.txt"
+#define CHECK_DIFFERENTER_FILE "/user/system/check_differential.txt"
+#else
 #define RESFILE_CHECKSUM_FILE "/system/fileschecksum.txt"
 #define CHECK_DIFFERENTER_FILE "/system/check_differential.txt"
+#endif
 // #define ENABLE_RESFILECHECK_LOG
 #ifdef ENABLE_RESFILECHECK_LOG
 #define LOG_RESCHECK printf
index f7cc525..478f58e 100644 (file)
@@ -2070,10 +2070,18 @@ void uapi_restore_factory_setting(void)
     //恢复存储
     resume_report_log();
     
+#ifdef  SINGLE_USER_PARTITION
+    char *filebuf[] = {"/user/system/ConfigModel.json",
+                    "/user/userdata",
+                    "/user/system/kvstore",
+                    };
+
+#else
     char *filebuf[] = {"/system/ConfigModel.json",
                     "/user/userdata",
                     "/system/kvstore",
                     };
+#endif
     for(int i = 0; i < (sizeof(filebuf)/sizeof(filebuf[0])); i++)
         uapi_delete_files(filebuf[i]);
     
@@ -2948,9 +2956,14 @@ uint8_t uapi_get_cywee_static_state(void)
 }
 
 #ifdef CYWEE_MAC_ACTIVE
+#ifdef  SINGLE_USER_PARTITION
+#define CYWEE_MAC_KEY_PATH "/user/system/cywee_mac_key.bin"
+#else
 #define CYWEE_MAC_KEY_PATH "/system/cywee_mac_key.bin"
 #endif
 
+#endif
+
 
 void uapi_cywee_save_mac_key(const uint8_t *key_data,uint16_t len)
 {
index ad8fe59..8dfde2e 100755 (executable)
@@ -20,10 +20,17 @@ extern "C" {
 #define UPG_RES_INDEX_PATH              "/user/res_index.bin"
 #define UPG_FILE_NAME                   "/user/update.fwpkg"
 #else
+
+#ifdef  SINGLE_USER_PARTITION
+#define UPG_FILE_PATH                   "/user/update/"
+#define UPG_RES_INDEX_PATH              "/user/update/res_index.bin"
+#define UPG_FILE_NAME                   "/user/update/update.fwpkg"
+#else
 #define UPG_FILE_PATH                   "/update/"
 #define UPG_RES_INDEX_PATH              "/update/res_index.bin"
 #define UPG_FILE_NAME                   "/update/update.fwpkg"
 #endif
+#endif
 
 #define UPG_FLASH_SIZE                  (FLASH_MAX_END - FLASH_START)
 #define UPG_FLASH_PAGE_SIZE             FLASH_PAGE_SIZE /* Bytes per sector */
index 87c6c68..e71fdc0 100755 (executable)
@@ -76,16 +76,25 @@ static app_task_definition_t taskcfg={0};
 #ifdef QSPI_DISPLAY
 #define IMAGE_OPEN_LOGO_PATH "/user/res/OPEN_LOGO_QSPI.bin"
 #else
+#ifdef  SINGLE_USER_PARTITION
+#define IMAGE_OPEN_LOGO_PATH "/user/system/KUMI_LOGO.bin"
+#define IMAGE_OTA_LOGO_PATH "/user/system/OTAUpdata.bin"
+#else
 #define IMAGE_OPEN_LOGO_PATH "/system/KUMI_LOGO.bin"
 #define IMAGE_OTA_LOGO_PATH "/system/OTAUpdata.bin"
 #endif
+#endif
 
 #ifdef CUSTOM_Z1
 #ifdef IMAGE_OPEN_LOGO_PATH
 #undef IMAGE_OPEN_LOGO_PATH
 #endif
+#ifdef  SINGLE_USER_PARTITION
+#define IMAGE_OPEN_LOGO_PATH "/user/system/z1bootlogo.bin"
+#else
 #define IMAGE_OPEN_LOGO_PATH "/system/z1bootlogo.bin"
 #endif
+#endif
 
 
 static void FreeImagePathsArray(const char **imagePaths, const int numImages)
index 3ca3154..3941f20 100755 (executable)
@@ -127,8 +127,13 @@ const char DATA_PATH[] = "/storage/app/data";
 const char JSON_PATH[] = "/storage/app/etc/bundles/";
 const char EXTEANAL_INSTALL_PATH[] = "/sdcard/app/run";
 const char EXTEANAL_DATA_PATH[] = "/sdcard/app/data";
+#ifdef  SINGLE_USER_PARTITION
+const char SYSTEM_BUNDLE_PATH[] = "/user/system/internal";
+const char THIRD_SYSTEM_BUNDLE_PATH[] = "/user/system/external";
+#else
 const char SYSTEM_BUNDLE_PATH[] = "/system/internal";
 const char THIRD_SYSTEM_BUNDLE_PATH[] = "/system/external";
+#endif
 const char UNINSTALL_THIRD_SYSTEM_BUNDLE_JSON[] = "/storage/app/etc/uninstalled_delbundle.json";
 const char THIRD_SYSTEM_BUNDLE_JSON[] = "/storage/app/etc/third_system_bundle.json";
 const char UID_GID_MAP[] = "uid_gid_map";
index 84a87a7..ecdc474 100755 (executable)
 #include "init_data.h"
 
 namespace {
+#ifdef  SINGLE_USER_PARTITION
+const char* g_hwDirectory = "/user/system/usr/ohos_icu";
+#else
 const char* g_hwDirectory = "/system/usr/ohos_icu";
+#endif
 }
 
 /**
diff --git a/mkota_single_user.sh b/mkota_single_user.sh
new file mode 100644 (file)
index 0000000..cde062e
--- /dev/null
@@ -0,0 +1,124 @@
+#!/bin/bash
+
+if [ "$#" == "2" ] || [ "$#" == "3" ] ; then
+SOURCE_DIR=$1
+SOURCE_VERSION=`basename $SOURCE_DIR`
+TARGET_DIR=$2
+TARGET_VERSION=`basename $TARGET_DIR`
+RES_DIR=$3
+ROOTDIR=`basename $PWD`
+ADDITIONAL_RES_DIR=$PWD/code/sdk/output/additional_fs
+OTA_ALL_FLAG_PATH=$PWD/code/sdk/output/ota_all
+OTA_ALL_WITH_NV_FLAG_PATH=$PWD/code/sdk/output/ota_all_with_nv
+RES_ONLY_FLAG_PATH=$PWD/code/sdk/output/res_only
+OTA_DIFF_FLAG_PATH=$PWD/code/sdk/output/ota_diff
+if [ ! -d "$PWD/code/sdk/output" ] ; then
+mkdir -p $PWD/code/sdk/output
+fi
+
+chmod +x ./tools/* -R
+if [ ! -d "$SOURCE_DIR" ] ; then
+echo "$SOURCE_DIR not exist , skip create ota package"
+echo ""
+exit 0
+fi
+if [ ! -d "$TARGET_DIR" ] ; then
+echo "$TARGET_DIR not exist , skip create ota package"
+echo ""
+exit 0
+fi
+
+rm $OTA_ALL_FLAG_PATH $RES_ONLY_FLAG_PATH $OTA_DIFF_FLAG_PATH $OTA_ALL_WITH_NV_FLAG_PATH -f
+if [ "$3" == "ota_all" ]; then
+touch $OTA_ALL_FLAG_PATH
+OTA_PKG_HEAD=ota_all_
+elif [ "$3" == "ota_all_with_nv" ]; then
+touch $OTA_ALL_WITH_NV_FLAG_PATH
+OTA_PKG_HEAD=ota_all_nv_
+elif [ "$3" == "ota_diff" ]; then
+touch $OTA_DIFF_FLAG_PATH
+OTA_PKG_HEAD=ota_diff_
+elif [ "$3" == "res_only" ]; then
+touch $RES_ONLY_FLAG_PATH
+OTA_PKG_HEAD=res_only_
+else
+OTA_PKG_HEAD=ota_
+fi
+
+
+mkdir code/sdk/output/brandy/TestOTA/ -p
+rm -rf code/sdk/output/brandy/TestOTA/*
+
+cp -r $SOURCE_DIR  code/sdk/output/brandy/TestOTA/oldsoftware
+cp -r $TARGET_DIR  code/sdk/output/brandy/TestOTA/newsoftware
+
+
+OLD_COMMIT_VERSION=`cat  code/sdk/output/brandy/TestOTA/oldsoftware/readme.txt | awk '$1 == "commit" { print $2}'`
+NEW_COMMIT_VERSION=`cat  code/sdk/output/brandy/TestOTA/newsoftware/readme.txt | awk '$1 == "commit" { print $2}'`
+
+TMPDIR=../PATCHES/${ROOTDIR}_FSOTA_F
+rm -rf $TMPDIR
+echo ./tools/scripts/gen_fs_otapkg_singleuser.sh $OLD_COMMIT_VERSION $NEW_COMMIT_VERSION F
+#./tools/scripts/gen_fs_otapkg_git.sh $OLD_COMMIT_VERSION $NEW_COMMIT_VERSION F
+./tools/scripts/gen_fs_otapkg_singleuser.sh $OLD_COMMIT_VERSION $NEW_COMMIT_VERSION F
+if [ $? != 0 ];
+then
+    echo gen_ota_fs_diff failed!
+    exit 1
+fi
+if [ -d "$TMPDIR" ] ; then
+RES_DIR=$TMPDIR
+fi
+# echo resdir = $RES_DIR  = $TMPDIR
+if [ -d "$RES_DIR" ] ; then
+cp -r $RES_DIR/fs code/sdk/output/brandy/TestOTA/res_file
+fi
+
+if [ -e "$RES_DIR/diff/deletedfiles.txt" ]; then
+echo cp -f $RES_DIR/diff/deletedfiles.txt code/sdk/output/brandy/TestOTA/delfiles
+cp -f $RES_DIR/diff/deletedfiles.txt code/sdk/output/brandy/TestOTA/delfiles
+fi
+
+if [ -d "$ADDITIONAL_RES_DIR/fs" ]; then
+echo cp -rf $ADDITIONAL_RES_DIR/fs/ code/sdk/output/brandy/TestOTA/res_file/
+cp -rf $ADDITIONAL_RES_DIR/fs/ code/sdk/output/brandy/TestOTA/res_file/
+else
+echo $ADDITIONAL_RES_DIR/fs not exist, you can put additional resource file to there.
+fi
+
+if [ -e "$ADDITIONAL_RES_DIR/delfiles" ]; then
+cat $ADDITIONAL_RES_DIR/delfiles >> code/sdk/output/brandy/TestOTA/delfiles
+else
+echo $ADDITIONAL_RES_DIR/delfiles not exist, you can put filelist to this file , for adding them to del list in fota file.
+fi
+
+cd $PWD/code/sdk/
+./build/config/target_config/brandy/build_brandy_update.py
+if [ $? != 0 ];
+then
+    echo create ota file failed!
+    cd - 
+    exit 1
+fi
+cd -
+
+mkdir release/ota -p
+
+target_fwpkg_filepath=release/ota/${OTA_PKG_HEAD}${SOURCE_VERSION}_2_${TARGET_VERSION}.fwpkg
+cp code/sdk/output/brandy/TestOTA/upgrade/update.fwpkg $target_fwpkg_filepath
+if [ $? != 0 ];
+then
+    echo copy firmware failed!
+    exit 1
+fi
+fwpkg_filesize=`ls $target_fwpkg_filepath -lh|awk '{print $5}'`
+
+echo create ota file $target_fwpkg_filepath $fwpkg_filesize done
+else
+
+echo ""
+echo "usage: $0 source_release target_release [ota_all]"
+echo ""
+
+fi
+
diff --git a/tools/scripts/gen_fs_otapkg_singleuser.sh b/tools/scripts/gen_fs_otapkg_singleuser.sh
new file mode 100644 (file)
index 0000000..33014fc
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/bash
+#set -ex
+
+DATE=$(date  +%Y%m%d.%H%M%S)
+if ! [ "$3" = "" ] 
+then
+DATE=$3
+fi
+
+HOMEDIR=$PWD
+TMPDIR=/tmp/${USER}_${DATE}
+
+NEWVERSION=`dirname $0`/../../code/sdk/output/brandy/TestOTA/newsoftware
+OLDVERSION=`dirname $0`/../../code/sdk/output/brandy/TestOTA/oldsoftware
+
+UNYAFFS_SCRIPT=$HOMEDIR/tools/scripts/unyaffs2tool_singleuser.py
+COMPARE_FOLDER_SCRIPT=$HOMEDIR/tools/scripts/compare_folder.py
+SEARCH_FOLDER_SCRIPT=$HOMEDIR/tools/scripts/search_folder_files.py
+
+
+echo $0
+echo $NEWVERSION
+echo $OLDVERSION
+echo TMPDIR=$TMPDIR
+echo HOMEDIR=$HOMEDIR
+
+# echo get diff $OLDVERSION ... $NEWVERSION to $TMPDIR
+
+BACKUPDIR_HOME=$HOMEDIR/../PATCHES/$(basename $HOMEDIR)_FSOTA_${DATE}
+rm -rf $BACKUPDIR_HOME
+mkdir -p $BACKUPDIR_HOME
+
+python $UNYAFFS_SCRIPT $NEWVERSION/bin/file.bin  $BACKUPDIR_HOME/new
+if [ $? != 0 ]
+then
+exit 1
+fi
+python $UNYAFFS_SCRIPT $OLDVERSION/bin/file.bin  $BACKUPDIR_HOME/old
+if [ $? != 0 ]
+then
+exit 2
+fi
+python $SEARCH_FOLDER_SCRIPT $BACKUPDIR_HOME/new $BACKUPDIR_HOME/new
+if [ $? != 0 ]
+then
+exit 3
+fi
+
+python $COMPARE_FOLDER_SCRIPT $BACKUPDIR_HOME/new $BACKUPDIR_HOME/old $BACKUPDIR_HOME
+if [ $? != 0 ]
+then
+exit 4
+fi
+
+
+echo done
+
+
+
index b269fc1..4b43da1 100644 (file)
@@ -68,11 +68,11 @@ if __name__ == '__main__':
     aPath = sys.argv[1]
     target_tmp_dir = sys.argv[2]
     print("{},{}".format(aPath,target_tmp_dir))
-    target_filelist_name=target_tmp_dir+"/system/fileschecksum.txt"
+    target_filelist_name=target_tmp_dir+"/user/fileschecksum.txt"
     if os.path.exists(target_filelist_name):
         os.remove(target_filelist_name)
     filelist=getAllFiles(aPath)
-    create_dirs(target_tmp_dir+"/system/")
+    create_dirs(target_tmp_dir+"/user/")
     with open(target_filelist_name, 'w') as file:
         for f in filelist:
             fullpath=aPath+"/"+f
diff --git a/tools/scripts/unyaffs2tool_singleuser.py b/tools/scripts/unyaffs2tool_singleuser.py
new file mode 100644 (file)
index 0000000..bf2652a
--- /dev/null
@@ -0,0 +1,185 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import os
+import sys
+import time
+import struct
+import shutil
+
+"""
+介绍:
+    本脚本主要实现调用mkyaffs2image工具生成文件镜像
+    请注意使用本脚本时支持的python版本,本脚本只支持python3版本。
+    请根据实际情况配置对应信息,主要是nandflash的信息,以及分区信息
+
+"""
+
+#tools/scripts/unyaffs2tool.py
+cur_dir = os.path.dirname(os.path.abspath(__file__))
+#tools/unyaffs_0.9.7/unyaffs
+image_tool_path = os.path.realpath(os.path.join(cur_dir, '..','unyaffs_0.9.7'))
+
+# 配置生成文件镜像工具路径
+unyaffstool = os.path.join(image_tool_path, 'unyaffs')
+
+# 配置nandflash信息
+cfg_page_size = 2048
+cfg_obb_size = 64
+
+
+#code/sdk/tools/bin/platform_tool/mkyaffs2image/mkyaffs2image code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/file_tmp.bin 1 2 0xcc0000
+#code/sdk/tools/bin/platform_tool/mkyaffs2image/mkyaffs2image code/sdk/build/config/target_config/brandy/mk_fs_image/fs/update code/sdk/build/config/target_config/brandy/mk_fs_image/file_tmp.bin 1 2 0x1980000
+#code/sdk/tools/bin/platform_tool/mkyaffs2image/mkyaffs2image code/sdk/build/config/target_config/brandy/mk_fs_image/fs/music code/sdk/build/config/target_config/brandy/mk_fs_image/file_tmp.bin 1 2 0x2640000
+#code/sdk/tools/bin/platform_tool/mkyaffs2image/mkyaffs2image code/sdk/build/config/target_config/brandy/mk_fs_image/fs/user code/sdk/build/config/target_config/brandy/mk_fs_image/file_tmp.bin 1 2
+# pagesize 2048 oobsize 64
+# 配置分区信息,请根据实际情况进行配置,添加格式为[分区路径, 分区大小]
+# 分区大小需要根据按照百分系统分配好后的blocks数进行计算,大小=blocks(文件块个数)*pages_per_block(每个文件块包含的页数)*bytes_per_page(每页包含字节数)
+# 前面按照比例分好分区,最后分区置成null,即代表剩下所有blocks
+# drivers/drivers/driver/nand_flash/nand/nandflash_config.c 
+# #ifndef MEMORY_MINI
+# #define YF_NAME_STRS "/user/system/", "/user/update/", "/user/music/", "/user/"
+# uint32_t yf_volume_percent[YF_VOLUMES_NUM] = { 1, 1, 1, 97 };
+#                                               0x140000
+#                                                10 10 10 70
+#                                               0xcc0000
+
+
+partition_list = [
+    # ["system","0x0", "0xcc0000"],
+    # ["update","0xcc0000","0xcc0000"],
+    # ["music", "0x1980000","0xcc0000"],
+    ["user", "0x2640000","null"]
+]
+
+# 将生成image文件转换大小端,保存成另外文件
+def convert(src_file, dest_file):
+    fp_src = open(src_file, 'rb')
+    fp_dest = open(dest_file, 'wb')
+    src_size = os.path.getsize(src_file)
+    for i in range(int(src_size / 4)):
+        data = fp_src.read(4)
+        rw = struct.pack('BBBB', data[3], data[2], data[1], data[0])
+        fp_dest.write(rw)
+    fp_src.close()
+    fp_dest.close()
+
+def splitimg(src_file,dest_file,startaddr,imgsize):
+    fp_src = open(src_file, 'rb')
+    fp_dest = open(dest_file, 'wb')
+    src_size = os.path.getsize(src_file)
+    print("{} {} {} {}".format(src_file,dest_file,startaddr,imgsize))
+    for i in range(int(src_size / 4)):
+        data = fp_src.read(4)
+        if  i*4 >= startaddr and i*4 < (startaddr+imgsize):
+            # print(" write {} size {}".format(i*4,readsize))
+            rw = struct.pack('BBBB', data[3], data[2], data[1], data[0])
+            fp_dest.write(rw)            
+    fp_src.close()
+    fp_dest.close()
+
+def unyaffs_img(binname,target_dir):
+    if not os.path.exists(target_dir):
+        try:
+            os.makedirs(target_dir)
+        except OSError as exc: # Guard against race condition
+            if exc.errno != errno.EEXIST:
+                raise
+    command = "cd " + target_dir +" && " + unyaffstool + " -c 2 -s 64 -b " + binname + " && cd -"
+    os.system(command)
+    os.remove(binname)
+
+def split_img(src_file,target_dir):
+    if not os.path.exists(target_dir):
+        try:
+            os.makedirs(target_dir)
+        except OSError as exc: # Guard against race condition
+            if exc.errno != errno.EEXIST:
+                raise
+    fileindex = 0
+    fp_src = open(src_file, 'rb')
+    dest_file = os.path.join(target_dir, "%s_tmp.bin" %partition_list[fileindex][0])
+    dest_partition_dir = os.path.join(target_dir, "%s" %partition_list[fileindex][0])
+    src_size = os.path.getsize(src_file)
+    fp_dest = open(dest_file, 'wb')
+    # YFSS
+    yaffsheader = struct.pack('BBBB', 0x59,0x46, 0x53, 0x53)
+    print("read {} ".format(yaffsheader))
+    #读取所有数据,一次4字节
+    for i in range(int(src_size / 4)):
+        data = fp_src.read(4)
+        rw = struct.pack('BBBB', data[3], data[2], data[1], data[0])
+        if data[0]==0x53 and data[1]==0x53 and data[2]==0x46 and data[3]==0x59:
+            #如果是yaffs的header,关闭前一个文件,创建新的对应分区文件,
+            fp_dest.close()
+            if i > 0 :
+                print("write {} size {}".format(dest_file,os.path.getsize(dest_file)))
+                unyaffs_img(dest_file,dest_partition_dir)
+            dest_file = os.path.join(target_dir, "%s_tmp.bin" %partition_list[fileindex][0])
+            dest_partition_dir = os.path.join(target_dir, "%s" %partition_list[fileindex][0])
+            fp_dest = open(dest_file, 'wb')
+            fileindex+=1
+        #读取的4字节写入分区文件
+        fp_dest.write(rw)            
+    fp_src.close()
+    fp_dest.close()
+    print("write {} size {}".format(dest_file,os.path.getsize(dest_file)))
+    unyaffs_img(dest_file,dest_partition_dir)
+
+
+def get_page_type(page_size):
+    if page_size == 2048:
+        return " 1"
+    elif page_size == 4096:
+        return " 2"
+    else:
+        return " 0"
+
+def get_obb_type(obb_size):
+    if obb_size == 64:
+        return " 2"
+    elif obb_size == 128:
+        return " 4"
+    else:
+        return " 0"
+
+if __name__ == "__main__":
+    image_file=sys.argv[1]
+    tmpdir=sys.argv[2]
+    # image_file = os.path.join(cur_dir, "file.bin")
+
+    if sys.platform == 'linux2' or sys.platform == 'linux':
+        partition_total = 0
+        # page_type =  get_page_type(cfg_page_size)
+        # obb_type = get_obb_type(cfg_obb_size)
+        page_type = " 1"
+        obb_type = " 2"
+
+        imgfilesize = os.path.getsize(image_file)
+
+        split_img(image_file,tmpdir)
+
+        # unyaffstool                
+            
+            # os.system(command)
+        # convert(tmp_file, image_file)
+        #unyaffs V0.9.7 - extract files from a YAFFS2 file system image.
+
+        # Usage: unyaffs [options] <image_file_name> [<extract_directory>]
+
+        # Options:
+        #     -d               detection of flash layout, no extraction
+        #     -b               spare contains bad block information
+        #     -c <chunk size>  set chunk size in KByte (default: autodetect, max: 16)
+        #     -s <spare size>  set spare size in Byte  (default: autodetect, max: 512)
+        #     -t               list image contents
+        #     -v               verbose output
+        #     -V               print version
+        
+        # unyaffs -c 2 -s 64 -b -t system_tmp.bin
+
+    # if (len(sys.argv) == 2 and os.path.exists(image_file)):
+        # out_path = os.path.join(sys.argv[1], "%s.bin" %image_name)
+        # shutil.copyfile(image_file, out_path)
+
+    print("make yaffs image file over!")