Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:14 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : updating program in stealth mode???

     Page 2 of 3    
Author Message
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 593
Posted: 05:11am 16 Feb 2019
Copy link to clipboard 
Print this post


What about a MM170 acting as console to Unit in field.
It would have SPI/I2C flash to hold new code to be uploaded.

Then it would reset / ^C do "pin" and what ever to make sure its acting console
and down load the new program. With the big flash one could have multiple programs.

Using touch screen could require a password then menu to select which program
to upload.

I guess simplest would be an MM170 with SD acting as a smart pick kit.
Code on sd could be encrypted.

Just a few rambling thoughts.

 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 06:05am 16 Feb 2019
Copy link to clipboard 
Print this post

Here is the first draft.
Encoding and crunching have not been implemented yet.

The ZIP has a single exe file. Put it anywhere convenient but it does require write permission so not in Program Files etc. An inf file gets created remembering the window position and the last serial port used.

Getting your code into the uploader.
Create a shortcut on the desktop and Drag a file from Windows Explorer.
Or
With the program running,
Drag a file from Windows Explorer.
Highlight code in your editor and drag onto the program's text window.
Copy the code into the clipboard and right-click in the program text window.

Provided you have a serial port selected, the upload will start immediately.
If there is no serial port, you will be prompted to select a port then press "Program" The "program" button is usually hidden.

If the first 5 characters of the file are "MMHEX" we have an encoded file and it is decoded before uploading.

If the first line is
'encode this
the code is encoded, not uploaded. You will get the ability to save the encoded file ready for distribution.
if the first line is
'crunch this
the code is crunched before encoding.
Crunching does not remove any 'echo ... lines

Otherwise, the code is uploaded

any line starting with
'echo
is sent to the text window and NOT uploaded
This lets you send messages to the user.

Encoding and crunching have not been implemented yet.
I will add TCPIP ports to the choices (probably)
The PIN was more of a pain than I expected. It is very slow to respond (deliberately to stop brute force attacks)
I can change the PIN dialog to a 'password' type which hides the entered digits.


You only get one attempt at the PIN.



There is a bit of information there to help tech support.

  Quote   OPTION PIN 9999
'echo Program version 99.9
DO
FOR n = 1 TO 20
PRINT n
NEXT n
LOOP
'echo Hi there, you are up and running again!

The two 'echo lines are sent to the text window instead of the micromite.

I will speed up the upload using Rob's method eventually.
For now, I need some heavy destruction testing.

Jim


VK7JH
MMedit
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 986
Posted: 07:18am 16 Feb 2019
Copy link to clipboard 
Print this post

Great work Jim

OA47
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 10:12am 16 Feb 2019
Copy link to clipboard 
Print this post

Wow TassyJim! I can't wait to try this out. I'm on my way out the door, but will try it tonight when I get back from work. I like all the "features" already!!! This is going to be such a handy piece of work!

P.S. can't seem to find the zip file... I'm going blind maybe?Edited by viscomjim 2019-02-18
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 09:46pm 16 Feb 2019
Copy link to clipboard 
Print this post

OOps!
I forgot to upload the important bit.
2019-02-17_074545_MMUploader.zip

Sorry about that.

Jim
VK7JH
MMedit
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 06:39am 17 Feb 2019
Copy link to clipboard 
Print this post

I have added the encode/decode function.
It can now crunch, either before encoding or when uploading.
setting the micromite clock is another option.

If the first line is
'encode this
or
'crunch this
the file is encoded, crunched in the second case.
The resulting file will be saved with a ".bae" extension if no extension was provided.

The first line is discarded.

Then if the next (or first if not encoding) line starts with
'onload
further options are possible.
settime set the micromite clock before uploading
setRTC will eventually set the RTC
norun prevents the RUN command being sent after the upload has finished.
crunch crunches before uploading. It makes no sense to crunch now if you crunched while encoding.
so
'onload settime norun crunch
will set the time upload a crunched file and NOT run after loading

The order of the options does not matter.

2019-02-17_163412_MMUploader.zip

I have included a sample encoded file test.bae in the ZIP
After an encoded file is uploaded, a copy of the decoded file is put onto the clipboard as a temporary debugging measure. This lets you compare before and after files.
This will be removed after I am confident that the encoding/decoding is working reliably.

Jim

VK7JH
MMedit
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 01:39pm 17 Feb 2019
Copy link to clipboard 
Print this post

@TassyJim, first of all... THIS IS AWESOME! What a convenient feature to have.

Testing so far...


First Test -
fired up MM Uploader
Dragged and dropped .bas file into window
file loaded and ran perfect!

Second test -
added 'encode this (only) to first line of program
dragged and dropped .bae file into window
file loaded and ran perfect!

Third test
added 'crunch this (only) to first line of program
dragged and dropped .bae file into window
file loaded, did not run, but it seems to be encoded. Will try some more with this one.

Testing the 'onload features next... stay tuned.



Edited by viscomjim 2019-02-19
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 08:49pm 17 Feb 2019
Copy link to clipboard 
Print this post

Try this version.
2019-02-18_064053_MMUploader.zip

I was deleting a few too many characters from the start of the file when doing both crunching and encoding.
The old 'copy and paste' problem.

The other change is a 'cancel' button should appear during uploading to allow the user to pull out. I hide it at other times. The less there is, the less chance of mistakes.

Remember that for now, after decoding a copy of the decoded program is in the clipboard to make it easier to check things.

Jim
VK7JH
MMedit
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 11:58pm 17 Feb 2019
Copy link to clipboard 
Print this post

@TassyJim,

first line option not set, just sending .bas program - works perfect!

'encode this - works perfect!

'crunch this - works perfect!

(last two both encode)

'onload settime - works perfect! - just a note, when you send the .bae file with the 'onload settime, the utility window shows...

date$ = "17/02/2019": time$ = "18:58:26

with the last quotation mark missing, however, the time was set correctly.

I don't have an RTC set up, so after I set one up I will test that part.

Again, this is VERY COOL! I am not sure how you are endcoding, but opening a .bae file looks like an unreadable file in notepad. EXCELLENT!

My Pickit3s are going to miss traveling the country. Oh well, they will get over it I'm sure.


Edited by viscomjim 2019-02-19
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 02:44am 18 Feb 2019
Copy link to clipboard 
Print this post

The RTC setting is not implemented yet. Probably after I have mowed the lawn. Bloody rain makes things grow.

The missing quote at the end of setting the time was an error on my part. It has been added to the next installment.

Encryption is AES-256

I am adding a few 'onload options to allow uploading to Maximites and picromites, both of which use different AUTOSAVE options.

Also giving an option to send the data without AUTOSAVE so command-line options can be set. I will like that as a quick way of re-configuring devices after firmware updates.

Jim

VK7JH
MMedit
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 06:53am 18 Feb 2019
Copy link to clipboard 
Print this post

Todays installment.
I am running out of 'features' to add.
The time setting has been moved to after the upload. This helps when using the command option to configure displays which cause a reboot.

I have done some more 'idiot proofing' and finished a few onload options

'onload options are now
crunch Crunches the code before uploading
settime Sets the micromite time to computer time after upload
setrtc Sets the micromite RTC to computer time after upload
norun Prevents RUN command at the conclusion of the upload

various AUTOSAVE alternatives (use only one):
micromite AUTOSAVE ^Z (default)
maximite AUTO ^C
picromite AUTOSAVE ^C

command Used to run commands. Does not issue NEW or AUTOSAVE.

'onload command
list


2019-02-18_165048_MMUploader.zip


VK7JH
MMedit
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 01:03am 19 Feb 2019
Copy link to clipboard 
Print this post

@TassyJim,

First line = 'encode this
creates a .bae file
drag and drop .bae file and works perfect!

First line = 'onload crunch
does not seem to crunch, same size as .bas file
does not seem to encode as before.

It seems that 'onload crunch no longer encodes, which makes sense, but does not crunch.

I'll keep testing, but this is initial findings on this installment.

P.S.

I like the 'onload options. Maybe if the first line has 'onload, then you can specify the options you want ie,

'onload crunch, settime

or

'onload encode, crunch, settime

But I am not sure as the ('encode this) would probably be the only time you would create a new .bae file to send out? The rest of the options would still remain .bas readable files. So I guess if you want to encode, then the first line would be 'encode this and then the second line would be 'onload crunch, settime, etc. This would then create an encode file with the options set. Do I have this correct?

I sincerely apologize if I am confusing the operation! It's been a long damn day.










Edited by viscomjim 2019-02-20
 
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 986
Posted: 03:18am 19 Feb 2019
Copy link to clipboard 
Print this post

As I use fonts and other library files as well as Var Save to lock in IDs etc, I was wondering what is left behind after New has been issued. It looks like the libraries are maintained but you do loose the saved variables. I would normally just type in AUTOSAVE to upgrade the program and this does not clear the saved variables.

OA47
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 06:56am 19 Feb 2019
Copy link to clipboard 
Print this post

  OA47 said   I would normally just type in AUTOSAVE to upgrade the program and this does not clear the saved variables.

OA47

Not something I do but there is now a nonew option on the 'onload line.

I have made a few changes which might make things easieer to follow

'encode crunch
'onload settime norun
'OPTION PIN 0
'echo Program version 99.9
DO
FOR n = 1 TO 20 'comment
PRINT n
NEXT n
LOOP
' spare lines
' more comments

'echo Hi there, you are up and running again!

the first line starts with 'encode so that is what happens
if the line also contains crunch as in the example, the file is crunched before encoding.

The first line gets discarded before encoding.

the next line is the 'onload options
If you are not encoding, the 'onload line must be the first line of the program.
there can only be one 'onload line but you can have multiple options on the line

In the example, the file gets crunched when encoding and when decoded/uploaded, the time is set and the program doesn't run automatically.

Current options are

one of: maximite picromite micromite command (default is micromite)
plus any combination of:
crunch crunches the file before loading
norun inhibits the RUN command after loading
nonew inhibits the NEW command before loading
settime sets the time after loading
setrtc sets the RTC after loading

the order of options is not important and they can be separated by a space or comma.

Without any options the default is to load uncrunched to a micromite and RUN with
NEW
AUTOSAVE
send file
ctrl-Z
RUN
2019-02-19_165458_MMUploader.zip

Jim
VK7JH
MMedit
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 12:41am 21 Feb 2019
Copy link to clipboard 
Print this post

@TassyJim,

OK, here is what I found...

If I use 'encode and drag into the window, it creates the .bae file. If I drag the .bae file into the window, it asks again for a file name instead of downloading.

If I use 'crunch and drag into the window, the file is not crunched, same size as the .bas file. Drag into window, file loads and runs.

If I use the 'encode crunch, it works perfectly!!! It crunches and encodes. Drag .bae file into window, it loads and runs.

I have not tried the onload options yet.

This is the very last zip file you posted.

Sorry for the delay in response, got tied up by the wifey and not in a good way either...Edited by viscomjim 2019-02-22
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 03:56am 21 Feb 2019
Copy link to clipboard 
Print this post

  Quote  If I use 'encode and drag into the window, it creates the .bae file. If I drag the .bae file into the window, it asks again for a file name instead of downloading.

That was a bug. Now fixed.

  Quote  If I use 'crunch and drag into the window, the file is not crunched

That is correct. I changed it so crunch is a parameter of 'encode or 'onload, rather than a separate command.

This update has the above bug fixed and now, when you insert or remove a USB serial port, the port number is shown in the text window.
An end-user could start MMUploader before inserting the cable. Then he/she would know what the port number is.
It also handles BAS file that have the MMEdit header in them.
2019-02-21_135220_MMUploader.zip


I have been experimenting with the command option
'onload command
OPTION LCDPANEL ILI9341, RL, 4,5,6

OPTION TOUCH 7,2


GUI CALIBRATE

This configures a module I have, something that has to be done after firmware updates.
The extra blank lines were needed to give the micromite time to reboot when the display is configured.
GUI CALIBRATE has to be the last command because it take time while you do the calibration.

I intend to have one BAS file with all the different setups I have for the various devices. It is then a case of highlight the one I want and drop it into the uploader.

As it stands, MMUploader disconnects as soon as the RUN command is sent.
I am thinking of waiting a few seconds after RUN before disconnecting. That way any immediate messages from the micromite will be captured by MMUploader.
It might be useful as a way of confirming the program is running (or capturing any error messages).

JimEdited by TassyJim 2019-02-22
VK7JH
MMedit
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 10:15am 21 Feb 2019
Copy link to clipboard 
Print this post

This is working very nicely!!!! I love the com port detection, what a GREAT feature for a non-tech person. Nicely done.

'encode

'encode crunch

'onload crunch

'onload crunch settime

all work flawlessly.

Will test the RTC when new module arrives, mine seems to have died.

This turning out to be a brilliant utility. Your command options are a great idea also.

Edit...

I just tried the port detection with a large usb hub. Nailed every port. This is a great addition and I wish more programs would include this.

I wonder since you can detect this, could it automatically put it in the drop down menu on the left side of the baud rate drop down?Edited by viscomjim 2019-02-22
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 07:35pm 21 Feb 2019
Copy link to clipboard 
Print this post

  viscomjim said  
I just tried the port detection with a large usb hub. Nailed every port. This is a great addition and I wish more programs would include this.

I wonder since you can detect this, could it automatically put it in the drop down menu on the left side of the baud rate drop down?


I thought about that but decided against it.
I don't want the selected port getting changed if you plug in a second device while still playing with the first one.

I might get it to auto-select if it is the only port seen. On my PC there is a Bluetooth port always present so that idea wouldn't work for me.

The program already remembers the chosen port between sessions and if that port is not available when the program starts, none is selected. If you then plug the port in and it matches the 'old' port, it IS selected automatically.

I probably can improve things a bit.

Jim

VK7JH
MMedit
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 08:05pm 21 Feb 2019
Copy link to clipboard 
Print this post

  Quote  I thought about that but decided against it.
I don't want the selected port getting changed if you plug in a second device while still playing with the first one.


Actually, it makes perfect sense to keep it that way. Great thinking!

I was just reading through this thread and saw that you had an issue with using the PIN function due to its timing or something of that nature. Would an alternative way be to have the user connect to the micromite unpowered, (the usb cable will hold on to the com port) and then have your utility send out a bunch of exclamation points, user powers up the micromite and your program waits until it saw the "MMBasic reset completed"?

This combined with your 'encode would actually be a quite secure way of keeping prying eyes away from the code all together? Resetting erases the program that has a PIN set, based on what I understood from the manual. This is not a big issue in most of my cases as most users won't get "under the hood".

Edited by viscomjim 2019-02-23
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 11:19am 22 Feb 2019
Copy link to clipboard 
Print this post

Just had a VERY non-tech type person try this with limited written and picture type instructions. It was a pleasure to watch. New "update" loaded first attempt in very little time and zero confusion. What a great addition this is.Edited by viscomjim 2019-02-23
 
     Page 2 of 3    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025