IDE Enhancement ZX-xx MCU Reset & # of Bytes. (2 parts)

Questions and discussion about the ZBasic IDE.
Post Reply
zbasicandy
Posts: 193
Joined: 25 January 2006, 19:56 PM

IDE Enhancement ZX-xx MCU Reset & # of Bytes. (2 parts)

Post by zbasicandy »

(Part 1)

There are many times that all I want to do is to reset the ZX-40 or any other ZBasic microcontroller when my PC is serially connected to comport #1.

Under IDE "project" there is a compile selection (F seven) and a Go
(F eight) compile and download/reset.
Where is the microcontroller reset selection?

There are three reasons why I need the separate "ZX-xx microcontroller reset".

#1. For checking multiple times the bootup/restart sequence(s) of the
ZBasic microcontroller.
#2. To keep my ESD "finger of death" from reaching down and reseting
the microcontroller and zapping and destroying thru electro-static
discharge every active semiconductor on the printed circuit card.
I have a lot of static.
Please note: I don't have a reset switch because of this ESD
reason. I depend on the POR - power on reset.
(Many users / boards do have a pushbutton reset switch for this
purpose)
#3. To extract from the ZBasic microcontroller the number of bytes it has
in flash. (See below)

(Part 2)

If you have a running ZBasic microcontroller and you don't want to destroy what is in the program memory (flash) but you need to know how many bytes of program flash are in the ZBasic microcontroller. By performing a microcontroller reset (Above - Part 1) and having the firmware in the microcontroller show the number of bytes of program code along with the firmware revision in the debug window.
You can use this byte count and compare this count with the number of bytes shown when the compile (F7) selection is selected (Offline) This way you can make sure, before downloading and destroying the contents of the microcontroller, that your source program is the same as the program which resides in microcontroller memory.

For example you have source programs A, B & C.
Each has 2005, 3001 & 4500 bytes of code on compile.
If by polling or reseting, the ZBaic microcontroller
produces a byte count of 3001 then the source program is B.
This is not 100% foolproof but having the "byte count"
is better than nothing at all. Checksum(S) or CRC(s) compares would be better.

What are your thoughts?
zbasicandy
Posts: 193
Joined: 25 January 2006, 19:56 PM

Reset & number of bytes

Post by zbasicandy »

Before answering please consider these senarios.

You spent several months on your home project and you need to download to your ZBasic microcontroller but you have to be certain that your source code is the same as what you downloaded several months or years ago.

You have a piece of machinery running controlled by a Zbasic microcontroller and you have to be 100% certain that your new program is the same when you download to it or your machinery will not run without the proper source code.

Note: Most modern PLC's (programmable logic controllers) have a upload capability in which the object code is re-constructed, reproduced and a new source file is created from the uploaded object file.
(Minus the source code comments)

In other cases, both the "source file" object and the object file in the microcontroller are compared and the user is notified of this comparison result before downloading is allowed.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

Where is the microcontroller reset selection?
Adding a "Reset Device" menu item is easily done.
... extract from the ZBasic microcontroller the number of bytes it has in flash.
The VM would need to be modified to support this. The address of the last byte written is not stored anywhere. (Note that the .zxb file may specify discontiguous data sequences. The records must, however, appear in increasing address order.)

The VM can be compiled to include a means to upload part or all of the Program Memory contents. That capability is not present in the release versions of the VM, however, due to its substantial size.
- Don Kinzer
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Post by mikep »

dkinzer wrote:The VM can be compiled to include a means to upload part or all of the Program Memory contents. That capability is not present in the release versions of the VM, however, due to its substantial size.
How about simply calculating a CRC and writing that out to the console when the VM starts up. The CRC could be calculated by the host, downloaded with the program and stored in persistent memory. Then the IDE can parse the VM message output and compare with the CRCs with the program about to be downloaded and issue a "Overwrite EEPROM?" question.
Mike Perks
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

Where is the microcontroller reset selection?
The new IDE (v1.1.0) has an entry on the Options menu to reset the device.
[Have] the firmware in the microcontroller show the number of bytes of program code along with the firmware revision in the debug window...
The new IDE also has an entry on the Options menu to request identification information from the device. An example of the response is:

Code: Select all

ZX40 v1.2 0197,18c6
This indicates that the device is a ZX-40 with firmware version v1.2.0. (The variant portion, .0, is not displayed if it is zero.) The next two values in the identification are the hexadecimal representations of the size, in bytes, of the last program downloaded and the CRC-16 value of that code. These values are also output as part of the .map file so that you can cross-check as necessary.

The code size/CRC portion of the identification capability requires v1.2.0 of the compiler and v1.2.0 of the VM.
- Don Kinzer
Post Reply