DSchndr / charge-me-up

Custom Firmware / Patches for clone iMax B6 charger (CMS32L051)
4 stars 0 forks source link

write_flash.cfg not working #1

Closed alferezalberto closed 9 months ago

alferezalberto commented 9 months ago

During firmware writing on the charger the following code error is displayed:

"write_flash.cfg:55: Error: invalid command name "binary" in procedure 'script' at file "embedded:startup.tcl", line 28 at file "C:\openocddir\bin\write_flash.cfg", line 55"

After giving the code a look, I cannot seem to solve the issue.

Any help?

Thanks for the work on this charger btw, stellar job

DSchndr commented 9 months ago

Which openocd version are you using/where did you get it from? It should have that (binary) command, thats wierd. I have to look it up later but I think this was the working version which I pushed.

Without that byte swap every word which gets written to flash is byte swapped (so from AA BB CC DD -> DD CC...), that code can be removed if you have some other tool to do this step.

alferezalberto commented 9 months ago

I've found the problem, but still not the solution, It seems that some of the OpenOCD distributions for windows got trimmed and some commands removed. I've thought of ways of working arround this command but still every atempt has ended up in disaster,

my openocd version is 20231002

Thank you for your help!

alferezalberto commented 9 months ago

After some investigation, Openocd uses jim-Tcl, a simplified version of TCL, (Without some comands, such as "binary"). I've been trying without luck to code the write flash script without the binary command but nothing works. How did you get Openocd to run the full TCL command list?

EDIT: after looking the documentation of jim -TCL it should include that binary command... that's weird...

Thanks for your help

DSchndr commented 9 months ago

Hi, i've added the binary which i used to the repo. Its weird that it does not work with some versions, but I could make some code which reverses the byte order per word without openocd so that it gets properly written to flash when I have time.

If you remove the byte reversal part and try to flash, you will see the exact problem when you dump it again from the chip and compare.

alferezalberto commented 9 months ago

Thanks for the executable!, now binary function works as expected and the firmware uploaded corretly. I think that there is a bug with Openocd... it's kind of weird... Where did you get the Openocd binaries?

thanks again for the help