Flashing/Erasing boards using SPSDK integrated within GUI with python 3.12

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flashing/Erasing boards using SPSDK integrated within GUI with python 3.12

Jump to solution
2,120 Views
Kateb
Contributor I

Seasons Greeting,

I'm using KW45B41Z with VID:PID=1FC9:0143 and SER=E2KIV02VWSX53.

My intent is to Flash and/or Erase, Set parameters, etc... using 

spsdk.mboot.mcuboot.py and other pieces of code from the spsdk integrated within python 3.12 GUI. 

But when running the GUI Erase function calling mcuboot flash_erase_all() for example, I get this kind of errors:

Exception in Tkinter callback
Traceback (most recent call last):
File "c:\Python312\Lib\tkinter\__init__.py", line 1948, in __call__
return self.func(*args)
^^^^^^^^^^^^^^^^
File "C:\_dev\spsdk\examples\bmw-poc-gui.py", line 1133, in <lambda>
erase_board_button = tb.Button(blhost_frame, text='Erase Board', command= lambda: self.board.erase_board(self.vid_pid) , bootstyle = INFO)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\_dev\spsdk\examples\bmw-poc-gui.py", line 404, in erase_board
mb.reset(reopen=False)
File "C:\_dev\spsdk\spsdk\mboot\mcuboot.py", line 730, in reset
status = self._process_cmd(cmd_packet).status
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\_dev\spsdk\spsdk\mboot\mcuboot.py", line 129, in _process_cmd
assert isinstance(response, CmdResponse)
AssertionError

the piece of code I use :

    def erase_board(self, vid_pid
        interfaces = MbootUSBInterface.scan()
        if not interfaces:
            print("Not founded MCU-BOOT device")
            sys.exit()        
        with McuBoot(interfaces[1], True) as mb:
            try:
                mb.flash_erase_all()
            except McuBootCommandError as e:
                if e.error_value != StatusCode.ROMLDR_UNEXPECTED_COMMAND:
                    raise
            except subprocess.CalledProcessError as e:
                print(f"Command failed with return code {e.returncode}")
            except Exception as err:
                print(f"Command failed with return code {err}")
                print(err.args)     # arguments stored in .args
                x = err.args
                print(x)                    
            except McuBootError as e:
                print(str(e))
                sys.exit()                          
            mb.reset(reopen=False)
 

Thank for the help and for the work of the great team behind the great SPSDK library

Kateb

 
0 Kudos
Reply
1 Solution
1,942 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi, @Kateb 

Sorry, I forgot to attach the attachment in previous comment.

Please see here, just put the blhost.exe in the same folder with the KW45_ProgrammingTool, then you can directly use.

 

Best regards,

Christine.

View solution in original post

Tags (1)
0 Kudos
Reply
9 Replies
2,095 Views
Kateb
Contributor I

Thanks Christine.

The requirement of the python application is to allow our client to Flash/Erase etc...without having to put the board in mode ISP (Bootloader) manually.

Putting the board in mode ISP (Bootloader) and Resetting the board normal mode are  to be done programmaticaly by the python application (using GUI buttons)

Is these functionalities possible by integrating SPSDK within the python GUI application??

Thanks and Happy Holidays.

Kateb

0 Kudos
Reply
2,077 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi, @Kateb 

May I know your SPSDK version?

You can get version by "spsdk --version" command.

And about your KW45, which SDK version are you using? What's the example in your board right now?

 

Best regards,

Christine.

0 Kudos
Reply
2,075 Views
Kateb
Contributor I

Hi Christine,

Please see my comments below in green

May I know your SPSDK version?

SPSDK version is 2.0.1

And about your KW45, which SDK version are you using?

SDK 2.12.6

What's the example in your board right now?

FreeRtos digital-key-device

Thanks ...Kateb

0 Kudos
Reply
2,070 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi, @Kateb 

Thanks for your feedback.

Without GUI, just putting the board in mode ISP (Bootloader) and Resetting the board normal mode manually, does it work well?

Is these functionalities possible by integrating SPSDK within the python GUI application?

==>Actually, I think in theory, I think it is possible. But as I know, there is no customer to do in this way. I need to check with our internal team to double confirm.

Do you have full logs?

I checked the logs you provided, it seems it raises " No Response, Timeout Error !"

Christine_Li_1-1703762523409.png

Best regards,

Christine.

 

 

 

0 Kudos
Reply
2,050 Views
Kateb
Contributor I

Without GUI, just putting the board in mode ISP (Bootloader) and Resetting the board normal mode manually, does it work well?

putting the board in mode ISP works well on all boards, but one is refusing .... don't know why...

Is these functionalities possible by integrating SPSDK within the python GUI application?

==>Actually, I think in theory, I think it is possible. But as I know, there is no customer to do in this way. I need to check with our internal team to double confirm.

thanks

Do you have full logs?

Can't figure out where SPSDK is hiding the logs.....

0 Kudos
Reply
1,962 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi, @Kateb 

Thanks for your reply and HAPPY NEW YEAR!

I discussed with our internal team, we have a GUI tool can use. I will attach it as attachment.

Hope this tool can provide you some conveniece.

And about the error in your program, we need more time to discuss and track why.

But we have a suggestion that in your GUI program, you can use blhost to call flash-erase-all like below:

blhost.exe -p COM3,115200 flash-erase-all 0

Please have a try and remember to choose correct COM port.

And also, we have a guide: Updating KW45 Radio Firmware via ISP using SPSDK .

If you don't know before, this AN may bring some help to you.

 

Best regards,

Christine.

Tags (1)
0 Kudos
Reply
1,943 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi, @Kateb 

Sorry, I forgot to attach the attachment in previous comment.

Please see here, just put the blhost.exe in the same folder with the KW45_ProgrammingTool, then you can directly use.

 

Best regards,

Christine.

Tags (1)
0 Kudos
Reply
1,331 Views
Kateb
Contributor I
Hi Christine,
7zip is asking for password to unzip....Thanks
0 Kudos
Reply
2,097 Views
Christine_Li
NXP TechSupport
NXP TechSupport

Hi, @Kateb 

I will deal with this case and check it on my local side, once have any updates, will let you know.

 

Best regards,

Christine.