Author Topic: Update firmware from Linux  (Read 524 times)

earl

  • Newby
  • *
  • Posts: 12
Update firmware from Linux
« on: August 14, 2019, 04:42:24 PM »
I see there was a Python program available sometime back for updating the firmware on the Classic (150).

I would like to use it as I am running strictly linux boxes (no windows).

Is it available ?


mike90045

  • Hero Member
  • *****
  • Posts: 739
    • The Ranch (via facebook re-direct)
Re: Update firmware from Linux
« Reply #1 on: August 14, 2019, 07:36:37 PM »
Zathras wants too .  windoze is lame for important stuff.
http://tinyurl.com/LMR-Solar

Classic 200| 2Kw PV, 160Voc | Grundfos 10 SO5-9 with 3 wire Franklin Electric motor (1/2hp 240V 1ph )| Listeroid 6/1, st5 gen head | XW6048 inverter/chgr | midnight ePanel & 4 SPDs | 48V, 800A NiFe battery bank | MS-TS-MPPT60 w/3Kw PV

boB

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3065
Re: Update firmware from Linux
« Reply #2 on: August 14, 2019, 11:51:15 PM »

Here are a couple of files.  These are very old but at least used to work.

If you are good at Linux and serial protocols, you should have no problem getting this to work after a bit of playing with it.

You will of course need the .ctl files for the Classic and/or the .rem file for the remote (MNGP)...  The latest ones of those should be on the Midnite Solar web site under firmware.

When the Classic powers up, its USB port comes alive and the host PC can quickly make a connection.  It waits a few seconds for a command, if there, to update the Classic or MNGP remote.

The .CTL file for the Classic only needs a single 12 ASCII digit command after bootup to tell the Classic it has new code for it so if the Classic sees this command string within the first few seconds of being powered up, it won't boot but will wait for more information from the host computer which is the data in the .CTL file.

The .rem  MNGP file and python code first sends an ASCII command that tells the Classic to create a bridge through the Classic's USB to the top serial port plug on the Classic control board to the MNGP and then the host sends the command again so that the MNGP can receive it through that bridge just made in the first second or 2.  This all happens within the first 2.5 or 3 seconds after the Classic powers up.  If the Classic and MNGP do not hear the special 12 ASCII character withing the first 3 seconds or so, they continue booting normally.

Actually, not only does the Classic's USB jack listen for these commands and code update, but so does the bottom of the three jacks but it takes RS-232 instead which would need an adapter of some sort and you have to kind of time things with the Classic power and hitting the buttons on the host PC, typically.

If the Classic successfully reads the command to update, the Classic's flash will be erased and won't work until it is successfully updated.  The bootloader in the Classic or MNGP will not be erased though so you should not be able to brick it.


K7IQ

earl

  • Newby
  • *
  • Posts: 12
Re: Update firmware from Linux
« Reply #3 on: August 15, 2019, 09:44:10 AM »

Wow! Thanks greatly! I was told that midnite had the best support! Glad I bought one! and not just because I thought it was the best one :)

I am still putting my system together (16 Trina 280W panels, MS4448PAE, Midnite Classic 150, 48V Lithium 220A batteries)  but when I do I will share some pictures and some code back.

I plan to hook up a Raspberry Pi to it and do some monitoring too.

Thanks again for the code!  I will get it working for sure (its my area of expertise) but still learning about solar stuff.. 

KyleM

  • Administrator
  • Full Member
  • *****
  • Posts: 141
Re: Update firmware from Linux
« Reply #4 on: August 15, 2019, 12:52:21 PM »
Earl,

I keep an old way underpowered windows 7 laptop around just for updates. It was running XP and shoehorned 7 into it.

The updater is tiny and takes almost no resources. So if you just cannot get it to work in Linux you won't need an expensive windows machine to update the Classics. Any junky old machine with a good working USB connection will work just fine.

-Kyle

boB

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3065
Re: Update firmware from Linux
« Reply #5 on: August 15, 2019, 01:02:52 PM »

It sounds like Earl is one who can get Linux to update using Python.  But yes, a cheap windoze can also work if necessary.

There may also be other threads or posts here about this where others have gotten this to work.

Maybe Earl can help this effort ?

Thanks Earl for taking an interest !

boB

K7IQ

earl

  • Newby
  • *
  • Posts: 12
Re: Update firmware from Linux
« Reply #6 on: August 15, 2019, 02:16:23 PM »
Hi Guys,

I actually do have several Windows machines I could use for that purpose but please don't tell anyone. Everyone thinks I don't use windows :)

The real reason I like Linux (Red Hat [Fedora]), is because of the do it yourself 'motto'.  I would really like to understand how things work. Now that I will be living off grid and using solar, I am getting up to speed. Looking forward to hooking up arduinos and Raspberrys to all things solar.

It seems Andrew (who wrote the mnupdate.py code was changing things. The version linked by boB uses tkinter (needs a missing midnite solar moon logo graphic) and even if you get around that, it doesn't do much but put up a TK blue window widget. This must be a later version that was in progress but did not get finished?

Anyway, does not matter, I see from the code how to interact with the Classic and have already re-written it. Much simpler., command line only though.

I will connect it to an arduino (which will emulate the classic) and make sure it works then will test it on my Classic.  I am anxious to try it but won't be moving to where my system is till next month.

And YES, for sure I wll be sharing it with anyone who would like to have it.

earl

boB

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3065
Re: Update firmware from Linux
« Reply #7 on: August 15, 2019, 02:37:18 PM »
CooL !   Thanks Earl !

Will be nice to hear how your progress goes.

boB
K7IQ

mike90045

  • Hero Member
  • *****
  • Posts: 739
    • The Ranch (via facebook re-direct)
Re: Update firmware from Linux
« Reply #8 on: August 15, 2019, 02:38:12 PM »
.....And YES, for sure I wll be sharing it with anyone who would like to have it.
earl   


Thanks for that feedback earl

Mike here.  Would sure love to be able to boot from a live linux CD (only a few dozen of them !) and run the firmware implant.  I can do it from my win 98 laptop, while the HDD is still going, but I could not get the win 8 drivers to work, and I have no win 10 machine.
http://tinyurl.com/LMR-Solar

Classic 200| 2Kw PV, 160Voc | Grundfos 10 SO5-9 with 3 wire Franklin Electric motor (1/2hp 240V 1ph )| Listeroid 6/1, st5 gen head | XW6048 inverter/chgr | midnight ePanel & 4 SPDs | 48V, 800A NiFe battery bank | MS-TS-MPPT60 w/3Kw PV

boB

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3065
Re: Update firmware from Linux
« Reply #9 on: August 15, 2019, 03:02:17 PM »
.....And YES, for sure I wll be sharing it with anyone who would like to have it.
earl   


Thanks for that feedback earl

Mike here.  Would sure love to be able to boot from a live linux CD (only a few dozen of them !) and run the firmware implant.  I can do it from my win 98 laptop, while the HDD is still going, but I could not get the win 8 drivers to work, and I have no win 10 machine.


Ha !  I actually have a windoze 95 machine in my office !   I brought it in to burn some Eproms for somebody.

K7IQ

earl

  • Newby
  • *
  • Posts: 12
Re: Update firmware from Linux
« Reply #10 on: August 16, 2019, 02:39:48 PM »
Attached are two scripts. The python firmware loader (for linux) and an arduino script I used to test with (ie emulate the classic).

The only parameter the script needs is the firmware file (.ctl or .rem). Run it via:

./mfu.py Classic_Control_2193_150.ctl

or

./mfu.py MNGP-2186.rem

Load the Midnite.ino script into an Arduino Uno and run the python script while attached to the USB connection to the Arduino, if you are interested to see what the python script does and how it works before trying it on a live Classic.

To run it on a Classic,  plug in the USB cable. Then turn on the classic. The script takes care of everything else like detecting the serial port, waiting for it to be plugged in, firmware type, etc. although those things can be set/changed in the global variables (which are commented). It is very verbose in saying what it does.

I will not be able to test on a real classic for a few weeks yet.. (any alpha testers?)

However, I did want to get this out to anyone who wants to try it.

Feedback encouraged and welcome.



boB

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3065
Re: Update firmware from Linux
« Reply #11 on: August 17, 2019, 01:22:40 AM »
Earl !  That was FAST !

I was trying to remember what the "S" was for in   "uPlDcLSaLLfl"  because it stands for Upload Classic All Flash  (except for bootloader of course)

Now I think I remember...  It was just one of the ss's in the word Classic I think.

Looks like you got it !  I will see if I can try this in the next couple days.

Where in the world are you ?

boB
K7IQ

earl

  • Newby
  • *
  • Posts: 12
Re: Update firmware from Linux
« Reply #12 on: August 17, 2019, 09:32:44 AM »
Hi boB,

I am traveling right now (currently in VZ). Hopefully (not to long now) and I will be 'home'. I am having a solar system set up but not hooked up all the way. I actually want to hook it up myself so I understand it better.

I will certainly be hooking up stuff (when I get a chance) to my system and will share it gladly. I see there are others here doing the same, which is very helpful.

I have a 'hobby' web site microcontrollers.tech and blog about some things I have an interest in.

Programmers have a saying..  COST, SPEED, QUALITY  pick any two

The 'punch line' is that the one left out, the programmer gets to choose :)

None of that applies though when you are doing things for 'fun' (open source model).

I think when people have a 'passion' for something, they put themselves into it and things get done. Of course experience comes into play, I am considered 'old' by some and have been coding for a long time... so that is not a problem .. the problem for me is just learning about how things work which the program will be interacting with. Some things are easy and some things more difficult, so 'FAST' is relative :)

Speaking of 'passion for things.. You (boB) and your brother? seem to have it for your work / business too?!  I've been reading all the articles/posts on the Midnite site.

A solar system is a significant investment and an owner should want to know about it and how to protect that investment, so to speak. Having a forum (with the support of the vendor) and the vendor somewhat 'open' about documentation on its products goes a long way (at least for me) in the decision process when choosing solar components. So I appreciate Midnites’ take on things!

Let me know if you encounter any problems testing my Python script.

boB

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3065
Re: Update firmware from Linux
« Reply #13 on: August 17, 2019, 02:26:07 PM »

>>>Programmers have a saying..  COST, SPEED, QUALITY  pick any two

We are always saying this at work !  It is so true !


>>>Speaking of 'passion for things.. You (boB) and your brother? seem to have it for your work / business too?!

Yes.  Electronics (+music+audio+photograhy+...) has been my passion my whole life.   We had mentors along the way that has helped tremendously, including our dad who taught me at least, how to troubleshoot and many many other things. 

I think that mentors and sharers of skills are too rare these days...  So I am a huge advocate for young people to have a passion for something and hopefully something that can get them through life.

STEM is one pathway which I think is good.

Finding good technicians and  engineers is so difficult these days.  We like to try and go to local colleges to try and find the passionate if possible and sometimes that works.

boB
K7IQ

earl

  • Newby
  • *
  • Posts: 12
Re: Update firmware from Linux
« Reply #14 on: September 07, 2019, 03:36:43 PM »
I updated my program and simulator and all worked fine (simulating).

Today, I finally got a chance to try it now that my system is all hooked up.

However, when I tried it on the Classic it did not work at all..

So I fell back to using a Windows laptop.. on one computer it only found the usb device and would not load the driver (windows 7) did not have the bootloader device..

On a 2nd windows laptop (windows 7) it went ok (there was the bootloader device to install the driver for) and I was able to load the firmware fine.

So, I am not sure whether it is the BAUD rate, timing or whatever.. that is keeping my program from working..