CN / EN
CN / EN

提问

设计支持

您的项目私密技术问题如需获得一对一支持,请点击下方联系我们。

OTA升级,内存覆盖检查报错 GR551x

188***541

2024-11-29 10:43

基于github开源iOS源码,OTA升级,生成小程序源码。硬件sdk1.7.0,芯片是GR5515IGND,DFU升级(非FastDFU).现在出现地址覆盖检测,报错。用官方app升级可以。想咨询下这个有什么排查和解决方案

0收藏

0赞成

wangzhi

汇顶员工
2024-12-17 09:07

请按以下方式更新GR5xxxDFU2.swift 中的函数。

public func updateFirmware(dfuData:Data, isCopyMode:Bool, copyAddress:UInt32, isFastMode:Bool=false, listener:DfuListener?=nil, ctrlCmd:Data?=nil, reconnectScanFilter:ScanFilter?=nil)throws{
        let db: DfuDatabase = DfuDatabase()
        if !isCopyMode{
            db.dfuMode = 0
            db.address = 0
        }else{
            db.dfuMode = 1
            db.address = copyAddress
        }
        db.fwFile = FirmwareAndResource(data: dfuData)
        //外部数据(来自用户)
        db.isExFlash = false
        //新版dfu
        db.isFastMode = isFastMode
        //内部数据(来自固件)
        db.scaStartAddress = 0
        db.bootInfo = nil
        db.peerEncrypted = false
        //新版dfu
        db.dfuVersion = 0
        db.position = 0
        db.commendSaveAddress = 0
        db.appInfo = nil
        //旧版dfu
        db.imgList = nil

        if (!(db.fwFile?.isFirmware ?? false)){
            DispatchQueue.main.async {
                listener?.dfuStopWithError(errorMsg: "Can't find image infomation data.");
            }
            throw ErrorMsg.error(msg: "Can't find image infomation data.")
        }

        //run
        DispatchQueue.main.async {
            listener?.dfuStart();
        }
        progress(listener, "start...", 0)
        if isSupportAppbootloaderSch{
            //发送dfuenter指令,防止固件端dfu任务未启动
            try setDfuEnter()
            //获取各种固件端信息
            progress(listener, "Loading device info...", 0)
            let getChipInfoRes:GetChipInfoRes = try getChipInfo()
            db.dfuVersion = getChipInfoRes.dfuVersion
            db.scaStartAddress = getChipInfoRes.scaStartAddress
            let getBootInfoRes:GetBootInfoRes = try getBootInfo(scaStartAddress: db.scaStartAddress)
            db.bootInfo = getBootInfoRes.bootInfo
            db.peerEncrypted = getBootInfoRes.peerEncrypted
            let getExtraInfoRes:GetExtraInfoRes = try getExtraInfo()
            db.position = getExtraInfoRes.position
            db.commendSaveAddress = getExtraInfoRes.commendSaveAddress
            db.appInfo = getExtraInfoRes.appInfo
            
            //覆盖检查
            progress(listener, "Checking memory coverage...", 0)
            try checkOverlapNew(db: db)
            
            //加密状态匹配检查
            try checkEncryptMath(dfuDatabase: db)
            
            //设置dfu mode、重连设备
            if db.dfuMode == 0 && db.position == 0x01{
                try setDfuMode(dfuMode: db.dfuMode)
                progress(listener, "Jumping to boot mode...", 5)
                Thread.sleep(forTimeInterval: 0.2)
                try self.blockBle?.disconnectPeripheral()
                Thread.sleep(forTimeInterval: 0.2)
                
                if let filter = reconnectScanFilter {
                    //根据过滤器得到可重连设备
                    try self.blockBle?.connectPeripheral(timeout: 10_000, filter: filter)
                }else{
                    //默认重连名字为Bootloader OTA的设备
                    try self.blockBle?.connectPeripheral(timeout: 10_000, deviceName: "Bootloader_OTA")
                }
                try self.blockBle?.discoverServices()
                try self.bondTo(blockingBle: blockBle!)
            }
            else if db.dfuMode == 1{
                try setDfuMode(dfuMode: db.dfuMode)
                Thread.sleep(forTimeInterval: 0.5)
            }
            
            //下载数据
            progress(listener, "Downloading...", 0)
            if db.isFastMode{
                try programStartFast(dfuMode: db.dfuMode, dfuFw: db.fwFile!, address: db.address, isExFlash: false, dfuVersion: db.dfuVersion)
                try programFlashFast(dfuFw: db.fwFile!, listener: { progress in
                    if (Thread.current.isCancelled){
                        DispatchQueue.main.async {
                            listener?.dfuCancelled(progress: progress)
                        }
                        Thread.exit()
                    }else {
                        self.progress(listener, "Downloading...", progress)
                    }
                })
            }
            else{
                try programStart(dfuMode: db.dfuMode, dfuFw: db.fwFile!, address: db.address,isExFlash: false,dfuVersion: db.dfuVersion)
                try programFlash(dfuMode: db.dfuMode, dfuFw: db.fwFile!, address: db.address, isExFlash: false,listener: { progress in
                    if (Thread.current.isCancelled){
                        DispatchQueue.main.async {
                            listener?.dfuCancelled(progress: progress)
                        }
                        Thread.exit()
                    }else {
                        self.progress(listener, "Downloading...", progress)
                    }
                })
            }
            try programEnd(dfuMode: db.dfuMode, dfuFw: db.fwFile!, dfuVersion: Int(db.dfuVersion), isExFlash: db.isExFlash, isFastMode: db.isFastMode)
            self.progress(listener, "Downloading", 100)
        }
        else{
            //发送dfuenter指令,防止固件端dfu任务未启动
            try setDfuEnter()

            progress(listener, "Jumping to boot mode...", 5)
            Thread.sleep(forTimeInterval: 0.2)
            try self.blockBle?.disconnectPeripheral()
            Thread.sleep(forTimeInterval: 0.2)

            if let filter = reconnectScanFilter {
                //根据过滤器得到可重连设备
                try self.blockBle?.connectPeripheral(timeout: 10_000, filter: filter)
            }else{
                //默认重连名字为Goodix_DFU的设备
                try self.blockBle?.connectPeripheral(timeout: 10_000, deviceName: "Goodix_DFU")
            }
            try self.blockBle?.discoverServices()
            try self.bondTo(blockingBle: blockBle!)

            //获取各种固件端信息
            progress(listener, "Loading device info...", 0)
            let getChipInfoRes:GetChipInfoRes = try getChipInfo()
            db.dfuVersion = getChipInfoRes.dfuVersion
            db.scaStartAddress = getChipInfoRes.scaStartAddress
            let getBootInfoRes:GetBootInfoRes = try getBootInfo(scaStartAddress: db.scaStartAddress)
            db.bootInfo = getBootInfoRes.bootInfo
            db.peerEncrypted = getBootInfoRes.peerEncrypted
            let getImgListRes:GetImgListRes = try getImgList(scaStartAddress: db.scaStartAddress)
            db.peerEncrypted = getImgListRes.peerEncrypted
            db.imgList = getImgListRes.imgList

            //覆盖检查
            progress(listener, "Checking memory coverage...", 0)
            try checkOverlapOld(db: db)

            //加密状态匹配检查
            try checkEncryptMath(dfuDatabase: db)

            //imglist整理
            progress(listener, "Arranging image list...", 5)
            try tidyImgList(targetBootInfo: db.fwFile!.fwbootInfo!, bootInfo: db.bootInfo!, imgList: db.imgList!, scaStartAddress: db.scaStartAddress)

            //下载数据
            progress(listener, "Downloading...", 0)
            try programStart(dfuMode: db.dfuMode, dfuFw: db.fwFile!, address: db.address, isExFlash: db.isExFlash, dfuVersion: db.dfuVersion)
            try programFlash(dfuMode: db.dfuMode, dfuFw: db.fwFile!, address: db.address, isExFlash: false,listener: { progress in
                if (Thread.current.isCancelled){
                    DispatchQueue.main.async {
                        listener?.dfuCancelled(progress: progress)
                    }
                    Thread.exit()
                }else {
                    self.progress(listener, "Downloading...", progress)
                }
            })
            try programEnd(dfuMode: db.dfuMode, dfuFw: db.fwFile!, dfuVersion: Int(db.dfuVersion),isExFlash: db.isExFlash, isFastMode: db.isFastMode)
            progress(listener, "Downloading...", 100)
        }
        DispatchQueue.main.async {
            listener?.dfuComplete()
        }
    }


0条评论

0赞成

0收藏

您的评论

Ping

汇顶员工
2024-12-06 12:59

小程序开发可以参考我们github上的开源代码:

https://github.com/goodix-ble/GoodixBleDFU.wechat


0条评论

0赞成

0收藏

您的评论

wangzhi

汇顶员工
2024-11-29 16:18

您好, 请详细描述下生成小程序源码的流程,以及测试的软硬环境, 官方APP升级是可以的,是否在生成小程序源码时出现了流程或逻辑错误?

0条评论

0赞成

0收藏

您的评论

登录后可回答问题,请 注册

我们时刻倾听您的声音
联系销售

扫描关注公众号

打开微信,使用“扫一扫”即可关注