A Forum run by Enthusiasts of MidNite Solar

Charge Controllers and Clippers => The "Classic" charge controller => Classic and Classic Lite BETA Firmware... => Topic started by: earl on August 14, 2019, 04:42:24 PM

Title: Update firmware from Linux
Post by: earl 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 ?

Title: Re: Update firmware from Linux
Post by: mike90045 on August 14, 2019, 07:36:37 PM
Zathras wants too .  windoze is lame for important stuff.
Title: Re: Update firmware from Linux
Post by: boB 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.


Title: Re: Update firmware from Linux
Post by: earl 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.. 
Title: Re: Update firmware from Linux
Post by: KyleM 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
Title: Re: Update firmware from Linux
Post by: boB 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

Title: Re: Update firmware from Linux
Post by: earl 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
Title: Re: Update firmware from Linux
Post by: boB on August 15, 2019, 02:37:18 PM
CooL !   Thanks Earl !

Will be nice to hear how your progress goes.

boB
Title: Re: Update firmware from Linux
Post by: mike90045 on August 15, 2019, 02:38:12 PM
Quote from: earl on August 15, 2019, 02:16:23 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.
Title: Re: Update firmware from Linux
Post by: boB on August 15, 2019, 03:02:17 PM
Quote from: mike90045 on August 15, 2019, 02:38:12 PM
Quote from: earl on August 15, 2019, 02:16:23 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.

Title: Re: Update firmware from Linux
Post by: earl 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.


Title: Re: Update firmware from Linux
Post by: boB 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
Title: Re: Update firmware from Linux
Post by: earl 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.
Title: Re: Update firmware from Linux
Post by: boB 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
Title: Re: Update firmware from Linux
Post by: earl 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..

Title: Re: Update firmware from Linux
Post by: boB on September 08, 2019, 02:40:01 PM
Quote from: earl on September 07, 2019, 03:36:43 PM

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

For USB, baud rate should not be a factor.  I'm note exactly sure why it can even be set in windows ??

Maybe for when there is an actual RS-232 adapter ?   The Classic can also be updated using RS-232 and the bottom of the three jacks if you had the right adapter to the RJ-11 jack.  In that case the baud rate is 9600 baud for updating software/firmware.

Normal modbus operating speed is 19,200 baud when NOT updating.

Title: Re: Update firmware from Linux
Post by: earl on September 10, 2019, 12:25:20 AM

I will try again when I get a chance.

It would be nice if there were more info on what the Classic returns if anything when you send it the upload command. If there is nothing coming back from sending the upload command.. then all you got to go on is timing..

Title: Re: Update firmware from Linux
Post by: earl on September 12, 2019, 09:28:09 PM
Unfortunately I won't get a change to try again. I bought a system prewired from the factory Epanel, Magum Inverter and Classic 150.  The factory forgot to tighten down all the wires.. on of the battery wires are loose and when I powered on it sparked and now the Classic does not work. It powers on and seems to work but does not show any PV volts and does not charge the batteries..

So i had to replace it .. with something local .. no one sells the Classic 150 here but I may be able to get it fixed.. or replace parts..
Title: Re: Update firmware from Linux
Post by: boB on September 13, 2019, 12:11:22 AM

Earl, could you please send pictures of what was not tightened ?

Or, did you already talk to our customer service folks ?
Title: Re: Update firmware from Linux
Post by: FNG on September 13, 2019, 07:03:58 AM
Earl,
Please email me ryan@midnitesolar.com I can help with the classic and would like to tall about what wasn't tight

Ryan
Title: Re: Update firmware from Linux
Post by: earl on September 13, 2019, 09:25:17 PM
Hi Guys,

Here is what I bought.

https://www.solar-electric.com/misoprmasy4w.html

But I don't think it is under warranty anymore. I actually bought it several years ago and it has been setting around until last week when I installed it. I thought I would move sooner than I did.

I should have checked that all the lugs were tight... live and learn.

I will get a picture of where the wire was loose so you can see.

Earl

Title: Re: Update firmware from Linux
Post by: earl on September 14, 2019, 08:41:06 PM
Here is a picture of what wire was loose. It was the red battery wire that runs across the middle of the panel.

You can see the black soot on the panel where is sparked..
Title: Re: Update firmware from Linux
Post by: FNG on September 15, 2019, 08:02:12 AM
Thank you for that image, Do you know when you purchased this roughly and what distributor you purchased it from?