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

earl

  • Newby
  • *
  • Posts: 4
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: 713
    • 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: 2996
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: 4
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: 133
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: 2996
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: 4
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: 2996
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: 713
    • 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: 2996
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: 4
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: 2996
Re: Update firmware from Linux
« Reply #11 on: Today at 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