Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package rkdeveloptool for openSUSE:Factory 
checked in at 2026-11-04 19:45:00
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rkdeveloptool (Old)
 and      /work/SRC/openSUSE:Factory/.rkdeveloptool.new.3759290 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rkdeveloptool"

Wed Nov  4 19:45:00 2026 rev:3 rq:1394796 version:20250307

Changes:
--------
--- /work/SRC/openSUSE:Factory/rkdeveloptool/rkdeveloptool.changes      
2021-11-24 23:54:58.652377306 +0100
+++ /work/SRC/openSUSE:Factory/.rkdeveloptool.new.3759290/rkdeveloptool.changes 
2026-11-04 19:45:36.846798647 +0100
@@ -1,0 +2,11 @@
+Fri Oct 23 17:07:48 UTC 2026 - Martin Pluskal <[email protected]>
+
+- Update to version 20250307 (git snapshot 304f073):
+  * Add new cs command to switch boot storage (eMMC, SD, SPINOR).
+  * udev rules: add RK3566 USB ID.
+  * Copy the chip string safely; fix mingw-w64 build.
+  * Replace sprintf with snprintf; add autogen.sh wrapper.
+- Spec cleanup: drop Group tag, reorder tags, use %{optflags} form,
+  add pkgconfig BuildRequires.
+
+-------------------------------------------------------------------

Old:
----
  rkdeveloptool-1.32~git.20210408.46bb4c0.tar.xz

New:
----
  rkdeveloptool-20250307.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rkdeveloptool.spec ++++++
--- /var/tmp/diff_new_pack.LReQ5F/_old  2026-11-04 19:45:38.049848971 +0100
+++ /var/tmp/diff_new_pack.LReQ5F/_new  2026-11-04 19:45:38.051849055 +0100
@@ -16,23 +16,22 @@
 #
 
 
-%define build_cxxflags %optflags -flto=auto
-
+%define build_cxxflags %{optflags} -flto=auto
 Name:           rkdeveloptool
-Version:        1.32~git.20210408.46bb4c0
+Version:        20250307
 Release:        0
-URL:            https://github.com/rockchip-linux/rkdeveloptool
 Summary:        Utility for Rockchip SoCs
 License:        GPL-2.0-or-later
-Group:          System/Boot
+URL:            https://github.com/rockchip-linux/rkdeveloptool
 Source0:        rkdeveloptool-%{version}.tar.xz
 BuildRequires:  autoconf
 BuildRequires:  automake
 BuildRequires:  gcc-c++
+BuildRequires:  pkgconfig
 BuildRequires:  systemd-rpm-macros
 BuildRequires:  pkgconfig(libusb-1.0)
 Requires(post): udev
-Requires(postun):udev
+Requires(postun): udev
 
 %description
 rkdeveloptool provides ways to read/write rockusb devices.

++++++ rkdeveloptool-1.32~git.20210408.46bb4c0.tar.xz -> 
rkdeveloptool-20250307.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rkdeveloptool-1.32~git.20210408.46bb4c0/.gitignore 
new/rkdeveloptool-20250307/.gitignore
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/.gitignore      1970-01-01 
01:00:00.000000000 +0100
+++ new/rkdeveloptool-20250307/.gitignore       2025-03-07 08:34:30.000000000 
+0100
@@ -0,0 +1,11 @@
+*.o
+.deps
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+config.log
+config.status
+configure
+rkdeveloptool
+rkdeveloptool*bz2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/rkdeveloptool-1.32~git.20210408.46bb4c0/99-rk-rockusb.rules 
new/rkdeveloptool-20250307/99-rk-rockusb.rules
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/99-rk-rockusb.rules     
2021-04-08 05:34:59.000000000 +0200
+++ new/rkdeveloptool-20250307/99-rk-rockusb.rules      2025-03-07 
08:34:30.000000000 +0100
@@ -14,5 +14,7 @@
 ATTRS{idVendor}=="2207", ATTRS{idProduct}=="330a", MODE="0666", GROUP="users"
 # RK3399
 ATTRS{idVendor}=="2207", ATTRS{idProduct}=="330c", MODE="0666", GROUP="users"
+# RK3566
+ATTRS{idVendor}=="2207", ATTRS{idProduct}=="350a", MODE="0666", GROUP="users"
 
 LABEL="end_rules"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/rkdeveloptool-1.32~git.20210408.46bb4c0/DefineHeader.h 
new/rkdeveloptool-20250307/DefineHeader.h
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/DefineHeader.h  2021-04-08 
05:34:59.000000000 +0200
+++ new/rkdeveloptool-20250307/DefineHeader.h   2025-03-07 08:34:30.000000000 
+0100
@@ -21,12 +21,14 @@
 #include <sstream>
 #include <algorithm>
 using namespace std;
+#ifndef __MINGW32__
 typedef unsigned char BYTE, *PBYTE;
 typedef unsigned char UCHAR;
 typedef unsigned short WCHAR;
 typedef unsigned short USHORT;
 typedef unsigned int   UINT;
 typedef unsigned int   DWORD;
+#endif
 #define ALIGN(x, a)            __ALIGN_MASK((x), (a) - 1)
 #define __ALIGN_MASK(x, mask)  (((x) + (mask)) & ~(mask))
 #define RK28_SEC2_RESERVED_LEN 473
@@ -228,7 +230,7 @@
        CALL_LAST
 } ENUM_CALL_STEP;
 
-typedef void (*ProgressPromptCB)(DWORD deviceLayer, ENUM_PROGRESS_PROMPT 
promptID, long long totalValue, long long currentValue, ENUM_CALL_STEP emCall);
+typedef void (*ProgressPromptCB)(UINT deviceLayer, ENUM_PROGRESS_PROMPT 
promptID, long long totalValue, long long currentValue, ENUM_CALL_STEP emCall);
 
 //     bool WideStringToString(wchar_t *pszSrc, char *&pszDest);
 //     bool StringToWideString(char *pszSrc, wchar_t *&pszDest);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKBoot.cpp 
new/rkdeveloptool-20250307/RKBoot.cpp
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKBoot.cpp      2021-04-08 
05:34:59.000000000 +0200
+++ new/rkdeveloptool-20250307/RKBoot.cpp       2025-03-07 08:34:30.000000000 
+0100
@@ -15,11 +15,11 @@
 {
        return m_bSignFlag;
 }
-DWORD CRKBoot::GetVersion()
+UINT CRKBoot::GetVersion()
 {
        return m_version;
 }
-DWORD CRKBoot::GetMergeVersion()
+UINT CRKBoot::GetMergeVersion()
 {
        return m_mergeVersion;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKBoot.h 
new/rkdeveloptool-20250307/RKBoot.h
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKBoot.h        2021-04-08 
05:34:59.000000000 +0200
+++ new/rkdeveloptool-20250307/RKBoot.h 2025-03-07 08:34:30.000000000 +0100
@@ -88,4 +88,4 @@
        void WCHAR_To_char(WCHAR *src, char *dst, int len);
 };
 
-#endif
\ No newline at end of file
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKComm.cpp 
new/rkdeveloptool-20250307/RKComm.cpp
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKComm.cpp      2021-04-08 
05:34:59.000000000 +0200
+++ new/rkdeveloptool-20250307/RKComm.cpp       2025-03-07 08:34:30.000000000 
+0100
@@ -197,12 +197,14 @@
                case READ_CHIP_INFO:
                case READ_EFUSE:
                case READ_CAPABILITY:
+               case READ_STORAGE:
                        pCBW->ucCBWFlags= DIRECTION_IN;
                        pCBW->ucCBWCBLength = 0x06;
                        break;
                case DEVICE_RESET:              /* Reset Device         : 0xff 
*/
                case ERASE_SYSTEMDISK:
                case SET_RESET_FLAG:
+               case CHANGE_STORAGE:
                        pCBW->ucCBWFlags = DIRECTION_OUT;
                        pCBW->ucCBWCBLength = 0x06;
                        break;
@@ -554,6 +556,95 @@
        return ERR_SUCCESS;
 }
 
+int CRKUsbComm::RKU_ChangeStorage(BYTE storage)
+{
+    if ((m_deviceDesc.emUsbType != RKUSB_LOADER) && (m_deviceDesc.emUsbType != 
RKUSB_MASKROM)) {
+        if (m_log) {
+            m_log->Record("Error:RKU_ChangeStorage failed,device not support");
+        }
+        return ERR_DEVICE_NOT_SUPPORT;
+    }
+
+       CBW cbw;
+       CSW csw;
+
+       InitializeCBW(&cbw, CHANGE_STORAGE);
+       cbw.cbwcb.ucReserved = storage;
+
+       if(!RKU_Write((BYTE *)&cbw, sizeof(CBW)))
+       {
+               printf("AMO: ERR_DEVICE_WRITE_FAILED\n");
+               return ERR_DEVICE_WRITE_FAILED;
+       }
+
+       if(!RKU_Read((BYTE *)&csw, sizeof(CSW)))
+       {
+               return ERR_DEVICE_READ_FAILED;
+       }
+
+       if( !UFI_CHECK_SIGN(cbw, csw) ) {
+               bool bRet;
+               bRet = RKU_ClearBuffer(cbw, csw);
+               if (!bRet) {
+                       return ERR_CMD_NOTMATCH;
+               }
+       }
+
+       if(csw.ucCSWStatus == 1)
+               return ERR_FAILED;
+
+       return ERR_SUCCESS;
+}
+
+int CRKUsbComm::RKU_ReadStorage(BYTE* storage)
+{
+    if ((m_deviceDesc.emUsbType != RKUSB_LOADER) && (m_deviceDesc.emUsbType != 
RKUSB_MASKROM)) {
+        if (m_log) {
+            m_log->Record("Error:RKU_ReadCapability failed,device not 
support");
+        }
+        return ERR_DEVICE_NOT_SUPPORT;
+    }
+
+       CBW cbw;
+       CSW csw;
+       DWORD dwRead;
+
+       InitializeCBW(&cbw, READ_STORAGE);
+       cbw.dwCBWTransferLength = 4;
+
+       if(!RKU_Write((BYTE*)&cbw, sizeof(CBW)))
+       {
+               return ERR_DEVICE_WRITE_FAILED;
+       }
+
+       DWORD storage_bits;
+       dwRead = RKU_Read_EX((BYTE*)&storage_bits, sizeof(storage_bits));
+
+       if(dwRead != 4)
+       {
+               return ERR_DEVICE_READ_FAILED;
+       }
+
+       if(!RKU_Read((BYTE*)&csw, sizeof(CSW)))
+       {
+               return ERR_DEVICE_READ_FAILED;
+       }
+
+       if( !UFI_CHECK_SIGN(cbw, csw) )
+               return ERR_CMD_NOTMATCH;
+
+       /* search the bit index */
+       *storage = 255;
+       for (unsigned i=0; i < 32; i++) {
+               if (storage_bits & (1<<i)) {
+                       *storage = i;
+                       break;
+               }
+       }
+       return ERR_SUCCESS;
+}
+
+
 int CRKUsbComm::RKU_TestDeviceReady(DWORD *dwTotal, DWORD *dwCurrent, BYTE 
bySubCode)
 {
     if ((m_deviceDesc.emUsbType != RKUSB_LOADER) && (m_deviceDesc.emUsbType != 
RKUSB_MASKROM)) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKComm.h 
new/rkdeveloptool-20250307/RKComm.h
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKComm.h        2021-04-08 
05:34:59.000000000 +0200
+++ new/rkdeveloptool-20250307/RKComm.h 2025-03-07 08:34:30.000000000 +0100
@@ -49,6 +49,8 @@
                WRITE_NEW_EFUSE = 0x23,
                READ_NEW_EFUSE = 0x24,
                ERASE_LBA=0x25,
+               CHANGE_STORAGE = 0x2A,
+               READ_STORAGE = 0x2B,
                READ_CAPABILITY=0xAA,
                DEVICE_RESET = 0xFF
 } USB_OPERATION_CODE;
@@ -142,6 +144,8 @@
 {
 public:
        virtual int RKU_EraseBlock(BYTE ucFlashCS, DWORD dwPos, DWORD dwCount, 
BYTE ucEraseType);
+       virtual int RKU_ChangeStorage(BYTE storage);
+       virtual int RKU_ReadStorage(BYTE *storage);
        virtual int RKU_ReadChipInfo(BYTE *lpBuffer);
        virtual int RKU_ReadFlashID(BYTE *lpBuffer);
        virtual int RKU_ReadCapability(BYTE *lpBuffer);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKDevice.cpp 
new/rkdeveloptool-20250307/RKDevice.cpp
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKDevice.cpp    2021-04-08 
05:34:59.000000000 +0200
+++ new/rkdeveloptool-20250307/RKDevice.cpp     2025-03-07 08:34:30.000000000 
+0100
@@ -105,10 +105,10 @@
        return m_layerName;
 }
 
-string CRKDevice::GetLayerString(DWORD dwLocationID)
+string CRKDevice::GetLayerString(UINT dwLocationID)
 {
        char szLocation[32] = "\0";
-       sprintf(szLocation, "%d-%d", dwLocationID >> 8, dwLocationID & 0xff);
+       snprintf(szLocation, sizeof(szLocation), "%d-%d", dwLocationID >> 8, 
dwLocationID & 0xff);
        return szLocation;
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKDevice.h 
new/rkdeveloptool-20250307/RKDevice.h
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKDevice.h      2021-04-08 
05:34:59.000000000 +0200
+++ new/rkdeveloptool-20250307/RKDevice.h       2025-03-07 08:34:30.000000000 
+0100
@@ -95,7 +95,7 @@
        bool GetFlashInfo();
        int EraseAllBlocks(bool force_block_erase=false);
        bool SetObject(CRKImage *pImage, CRKComm *pComm, CRKLog *pLog);
-       string GetLayerString(DWORD dwLocationID);
+       string GetLayerString(UINT dwLocationID);
        CRKDevice(STRUCT_RKDEVICE_DESC &device);
        ~CRKDevice();
 protected:
@@ -128,4 +128,4 @@
        char  m_layerName[32];
 };
 
-#endif
\ No newline at end of file
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKImage.cpp 
new/rkdeveloptool-20250307/RKImage.cpp
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKImage.cpp     2021-04-08 
05:34:59.000000000 +0200
+++ new/rkdeveloptool-20250307/RKImage.cpp      2025-03-07 08:34:30.000000000 
+0100
@@ -6,11 +6,11 @@
  */
 #include "RKImage.h"
 
-DWORD CRKImage::GetVersion()
+UINT CRKImage::GetVersion()
 {
        return m_version;
 }
-DWORD CRKImage::GetMergeVersion()
+UINT CRKImage::GetMergeVersion()
 {
        return m_mergeVersion;
 }
@@ -35,15 +35,15 @@
        pBackupSize = (USHORT *)&m_reserved[12];
        return *pBackupSize;
 }
-DWORD CRKImage::GetBootOffset()
+UINT CRKImage::GetBootOffset()
 {
        return m_bootOffset;
 }
-DWORD CRKImage::GetBootSize()
+UINT CRKImage::GetBootSize()
 {
        return m_bootSize;
 }
-DWORD CRKImage::GetFWOffset()
+UINT CRKImage::GetFWOffset()
 {
        return m_fwOffset;
 }
@@ -295,4 +295,4 @@
 bool CRKImage::GetSignFlag()
 {
        return m_bSignFlag;
-}
\ No newline at end of file
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKLog.cpp 
new/rkdeveloptool-20250307/RKLog.cpp
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/RKLog.cpp       2021-04-08 
05:34:59.000000000 +0200
+++ new/rkdeveloptool-20250307/RKLog.cpp        2025-03-07 08:34:30.000000000 
+0100
@@ -4,7 +4,13 @@
  *
  * SPDX-License-Identifier:    GPL-2.0+
  */
+
+#ifdef __MINGW32__
+#define _POSIX_THREAD_SAFE_FUNCTIONS
+#endif
+
 #include "RKLog.h"
+
 int file_stat(string strPath)
 {
        struct stat statBuf;
@@ -76,7 +82,7 @@
        FILE *file=NULL;
        time(&now);
        localtime_r(&now, &timeNow);
-       sprintf(szDateTime, "%04d-%02d-%02d.txt", timeNow.tm_year + 1900, 
timeNow.tm_mon + 1, timeNow.tm_mday);
+       snprintf(szDateTime, sizeof(szDateTime), "%04d-%02d-%02d.txt", 
timeNow.tm_year + 1900, timeNow.tm_mon + 1, timeNow.tm_mday);
        strName = m_path + m_name+szDateTime;
 
        try {
@@ -84,7 +90,7 @@
                if (!file) {
                        return false;
                }
-               sprintf(szDateTime, "%02d:%02d:%02d \t", timeNow.tm_hour, 
timeNow.tm_min, timeNow.tm_sec);
+               snprintf(szDateTime, sizeof(szDateTime), "%02d:%02d:%02d \t", 
timeNow.tm_hour, timeNow.tm_min, timeNow.tm_sec);
                text = szDateTime + text + "\r\n";
                fwrite(text.c_str(), 1, text.size() * sizeof(char), file);
                fclose(file);
@@ -111,7 +117,7 @@
        char strHex[32];
        strOutput = "";
        for (i = 0, count = 0; i < dwSize; i++, count++) {
-               sprintf(strHex, "%X", lpBuffer[i]);
+               snprintf(strHex, sizeof(strHex), "%X", lpBuffer[i]);
                strOutput = strOutput + " " + strHex;
                if (count >= uiLineCount) {
                        strOutput += "\r\n";
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rkdeveloptool-1.32~git.20210408.46bb4c0/Readme.txt 
new/rkdeveloptool-20250307/Readme.txt
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/Readme.txt      2021-04-08 
05:34:59.000000000 +0200
+++ new/rkdeveloptool-20250307/Readme.txt       2025-03-07 08:34:30.000000000 
+0100
@@ -1,15 +1,12 @@
 rkdeveloptool gives you a simple way to read/write rockusb device.let's start.
 
 compile and install
-1 install libusb and libudev
+1. install libusb and libudev
        sudo apt-get install libudev-dev libusb-1.0-0-dev dh-autoreconf
-2 go into root of rkdeveloptool
-3.aclocal
-4.autoreconf -i
-5.autoheader
-5.automake --add-missing
-4 ./configure
-5 make
+2. go into root of rkdeveloptool
+3. ./autogen.sh
+4. ./configure
+5. make
 
 rkdeveloptool usage,input "rkdeveloptool -h" to see
 
@@ -25,4 +22,4 @@
 ./configure: line 4269: `PKG_CHECK_MODULES(LIBUSB1,libusb-1.0)'
 
 You should install pkg-config libusb-1.0:
-       sudo apt-get install pkg-config libusb-1.0 
+       sudo apt-get install pkg-config libusb-1.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rkdeveloptool-1.32~git.20210408.46bb4c0/autogen.sh 
new/rkdeveloptool-20250307/autogen.sh
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/autogen.sh      1970-01-01 
01:00:00.000000000 +0100
+++ new/rkdeveloptool-20250307/autogen.sh       2025-03-07 08:34:30.000000000 
+0100
@@ -0,0 +1,2 @@
+#!/bin/bash
+autoreconf --force --install
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/rkdeveloptool-1.32~git.20210408.46bb4c0/cfg/.gitignore 
new/rkdeveloptool-20250307/cfg/.gitignore
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/cfg/.gitignore  1970-01-01 
01:00:00.000000000 +0100
+++ new/rkdeveloptool-20250307/cfg/.gitignore   2025-03-07 08:34:30.000000000 
+0100
@@ -0,0 +1,6 @@
+compile
+config*
+depcomp
+install*
+missing
+stamp*
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rkdeveloptool-1.32~git.20210408.46bb4c0/crc.cpp 
new/rkdeveloptool-20250307/crc.cpp
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/crc.cpp 2021-04-08 
05:34:59.000000000 +0200
+++ new/rkdeveloptool-20250307/crc.cpp  2025-03-07 08:34:30.000000000 +0100
@@ -191,12 +191,12 @@
        unsigned int      *b =(unsigned int *)p;
        unsigned int      *tab = crc32table_le;
        crc = crc ^ 0xFFFFFFFF;
-       if((((long)b)&3 && len)){
+       if((((uintptr_t)b)&3 && len)){
                do {
                        unsigned char *p = (unsigned char *)b;
                        DO_CRC(*p++);
                        b = (unsigned int *)p;
-               } while ((--len) && ((long)b)&3 );
+               } while ((--len) && ((uintptr_t)b)&3 );
        }
        if((len >= 4)){
                unsigned int save_len = len & 3;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rkdeveloptool-1.32~git.20210408.46bb4c0/main.cpp 
new/rkdeveloptool-20250307/main.cpp
--- old/rkdeveloptool-1.32~git.20210408.46bb4c0/main.cpp        2021-04-08 
05:34:59.000000000 +0200
+++ new/rkdeveloptool-20250307/main.cpp 2025-03-07 08:34:30.000000000 +0100
@@ -56,6 +56,7 @@
        printf("EraseFlash:\t\tef \r\n");
        printf("TestDevice:\t\ttd\r\n");
        printf("ResetDevice:\t\trd [subcode]\r\n");
+       printf("ChangeStorage:\t\tcs [storage: 1=EMMC, 2=SD, 9=SPINOR]\r\n");
        printf("ReadFlashID:\t\trid\r\n");
        printf("ReadFlashInfo:\t\trfi\r\n");
        printf("ReadChipInfo:\t\trci\r\n");
@@ -65,45 +66,45 @@
        printf("TagSPL:\t\t\ttagspl <tag> <U-Boot SPL>\r\n");
        
printf("-------------------------------------------------------\r\n\r\n");
 }
-void ProgressInfoProc(DWORD deviceLayer, ENUM_PROGRESS_PROMPT promptID, long 
long totalValue, long long currentValue, ENUM_CALL_STEP emCall)
+void ProgressInfoProc(UINT deviceLayer, ENUM_PROGRESS_PROMPT promptID, long 
long totalValue, long long currentValue, ENUM_CALL_STEP emCall)
 {
        string strInfoText="";
        char szText[256];
        switch (promptID) {
        case TESTDEVICE_PROGRESS:
-               sprintf(szText, "Test Device total %lld, current %lld", 
totalValue, currentValue);
+               snprintf(szText, sizeof(szText), "Test Device total %lld, 
current %lld", totalValue, currentValue);
                strInfoText = szText;
                break;
        case LOWERFORMAT_PROGRESS:
-               sprintf(szText, "Lowerformat Device total %lld, current %lld", 
totalValue, currentValue);
+               snprintf(szText, sizeof(szText), "Lowerformat Device total 
%lld, current %lld", totalValue, currentValue);
                strInfoText = szText;
                break;
        case DOWNLOADIMAGE_PROGRESS:
-               sprintf(szText, "Download Image total %lldK, current %lldK", 
totalValue/1024, currentValue/1024);
+               snprintf(szText, sizeof(szText), "Download Image total %lldK, 
current %lldK", totalValue/1024, currentValue/1024);
                strInfoText = szText;
                break;
        case CHECKIMAGE_PROGRESS:
-               sprintf(szText, "Check Image total %lldK, current %lldK", 
totalValue/1024, currentValue/1024);
+               snprintf(szText, sizeof(szText), "Check Image total %lldK, 
current %lldK", totalValue/1024, currentValue/1024);
                strInfoText = szText;
                break;
        case TAGBADBLOCK_PROGRESS:
-               sprintf(szText, "Tag Bad Block total %lld, current %lld", 
totalValue, currentValue);
+               snprintf(szText, sizeof(szText), "Tag Bad Block total %lld, 
current %lld", totalValue, currentValue);
                strInfoText = szText;
                break;
        case TESTBLOCK_PROGRESS:
-               sprintf(szText, "Test Block total %lld, current %lld", 
totalValue, currentValue);
+               snprintf(szText, sizeof(szText), "Test Block total %lld, 
current %lld", totalValue, currentValue);
                strInfoText = szText;
                break;
        case ERASEFLASH_PROGRESS:
-               sprintf(szText, "Erase Flash total %lld, current %lld", 
totalValue, currentValue);
+               snprintf(szText, sizeof(szText), "Erase Flash total %lld, 
current %lld", totalValue, currentValue);
                strInfoText = szText;
                break;
        case ERASESYSTEM_PROGRESS:
-               sprintf(szText, "Erase System partition total %lld, current 
%lld", totalValue, currentValue);
+               snprintf(szText, sizeof(szText), "Erase System partition total 
%lld, current %lld", totalValue, currentValue);
                strInfoText = szText;
                break;
        case ERASEUSERDATA_PROGRESS:
-               sprintf(szText, "<LocationID=%x> Erase Userdata partition total 
%lld, current %lld", deviceLayer, totalValue, currentValue);
+               snprintf(szText, sizeof(szText), "<LocationID=%x> Erase 
Userdata partition total %lld, current %lld", deviceLayer, totalValue, 
currentValue);
                strInfoText = szText;
                break;
        }
@@ -1490,7 +1491,7 @@
 static inline uint32_t convertChipType(const char* chip) {
        char buffer[5];
        memset(buffer, 0, sizeof(buffer));
-       snprintf(buffer, sizeof(buffer), "%s", chip);
+       memccpy(buffer, chip, '\0', sizeof(buffer));
        return buffer[0] << 24 | buffer[1] << 16 | buffer[2] << 8 | buffer[3];
 }
 
@@ -2263,6 +2264,52 @@
        return bSuccess;
 }
 
+bool change_storage(STRUCT_RKDEVICE_DESC &dev, BYTE storage)
+{
+       if (!check_device_type(dev, RKUSB_LOADER | RKUSB_MASKROM))
+               return false;
+       CRKUsbComm *pComm = NULL;
+       bool bRet, bSuccess = false;
+       int iRet;
+       pComm =  new CRKUsbComm(dev, g_pLogObject, bRet);
+       if (bRet) {
+               iRet = pComm->RKU_ChangeStorage(storage);
+               if (iRet != ERR_SUCCESS) {
+                       if (g_pLogObject)
+                               g_pLogObject->Record("Error: RKU_ChangeStorage 
failed, err=%d", iRet);
+                       printf("Change Storage failed!\r\n");
+                       goto failed;
+               }
+               /* No error is returned if the selected storage is not 
available.
+                * Read back the current storage to know if the change is 
effective.
+                */
+               BYTE current_storage;
+               iRet = pComm->RKU_ReadStorage(&current_storage);
+               if (iRet != ERR_SUCCESS) {
+                       if (g_pLogObject)
+                               g_pLogObject->Record("Error: RKU_ReadStorage 
failed, err=%d", iRet);
+                       printf("Change Storage failed!\r\n");
+                       goto failed;
+               }
+               if (storage == current_storage) {
+                   bSuccess = true;
+                   printf("Change Storage OK.\r\n");
+               } else {
+                   printf("Change Storage failed! Storage %u is not 
available.\r\n", storage);
+               }
+       } else {
+               printf("Change Storage quit, creating comm object failed!\r\n");
+       }
+failed:
+       if (pComm) {
+               delete pComm;
+               pComm = NULL;
+       }
+       return bSuccess;
+}
+
+
+
 bool read_flash_id(STRUCT_RKDEVICE_DESC &dev)
 {
        CRKUsbComm *pComm = NULL;
@@ -3136,6 +3183,19 @@
                                }
                        }
                }
+       } else if(strcmp(strCmd.c_str(), "CS") == 0) {
+               if (argc != 3)
+                       printf("Parameter of [CS] command is invalid, please 
check help!\r\n");
+               else {
+                       UINT uiSubCode;
+                       char *pszEnd;
+                       uiSubCode = strtoul(argv[2], &pszEnd, 0);
+                       if (*pszEnd)
+                               printf("Storage is invalid, please check!\r\n");
+                       else {
+                               bSuccess = change_storage(dev, uiSubCode);
+                       }
+               }
        } else if(strcmp(strCmd.c_str(), "TD") == 0) {
                bSuccess = test_device(dev);
        } else if (strcmp(strCmd.c_str(), "RID") == 0) {//Read Flash ID
@@ -3303,21 +3363,32 @@
        struct stat statBuf;
 
        g_ConfigItemVec.clear();
-       sprintf(szProgramProcPath, "/proc/%d/exe", getpid());
+
+#ifndef __MINGW32__
+       snprintf(szProgramProcPath, sizeof(szProgramProcPath), "/proc/%d/exe", 
getpid());
        if (readlink(szProgramProcPath, szProgramDir, 256) == -1)
                strcpy(szProgramDir, ".");
-       else {
+       else
+#else
+       strcpy(szProgramDir, ".");
+#endif
+       {
                char *pSlash;
                pSlash = strrchr(szProgramDir, '/');
                if (pSlash)
                        *pSlash = '\0';
        }
+
        strLogDir = szProgramDir;
        strLogDir +=  "/log/";
        strConfigFile = szProgramDir;
        strConfigFile += "/config.ini";
        if (opendir(strLogDir.c_str()) == NULL)
+#ifndef __MINGW32__
                mkdir(strLogDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH);
+#else
+               mkdir(strLogDir.c_str());
+#endif
        g_pLogObject = new CRKLog(strLogDir.c_str(), "log",true);
 
        if(stat(strConfigFile.c_str(), &statBuf) < 0) {

Reply via email to