Hardcoded Configuration

From lechacal
Jump to navigation Jump to search


RPICT series have a convenient way to store the configuration in memory using the lcl-rpict-config.py tool.

It is found that eeprom memory might not be always stable especially in noisy industrial environment. This usually lead in having to reconfigure the card.

For users requiring high level of stability and minimum intervention we suggest the use of hardcoded configuration.

The hardcoded configuration means that all user parameters are set in the code of the firmware. This require reflashing the microcontroller. Following that parameters can only be modified by reflashing a new firmware with the updated value.

Which model can use the hardcoded configuration?

All of them. However the way to flash the microcontroller will differ from one board to another.

The RPICT produced lately will make this easier. For the former ones some special operations will be needed.

Firmware with hardcoded configuration

Getting a firmware setup with the desired parameters requires editing the code by hand and compile it. As we understand not all of you are necessarily comfortable doing so we have build a set of firmware ready to flash. This list is in IDCode.

We give each individual firmware a 8 digit random code to make sure we can identify it. For example FXOMGBOL. This code appears on the serial port output when the RPICT board boots up.

Identifying a firmware

There 2 ways to find out which firmware is loaded on a RPICT board. In both options make sure nothing is using the ttyAMA0 serial port or it will conflict.

1/ Manual reset.
Start the cat command and press the white button to reset the board.

stty -echo -F /dev/ttyAMA0 raw speed 38400
cat /dev/ttyAMA0

Then press reset. The header will appear showing the firmware version being used.

2/ Auto-reset.
Only valid for version 5.x and 3.1 units. Use the lcl-show-header.py command to show the header

wget lechacal.com/RPICT/tools/lcl-show-header.py.zip
unzip lcl-show-header.py.zip
sudo mv lcl-show-header.py /usr/local/bin/

Then run it with

lcl-show-header.py

The header will then appear. Press Control^C to exit.

Flashing a firmware

Directly from Raspberrypi

This is the easiest scenario however not all board can do this.

This is possible with models Version 5.x and version 3.1. This is not possible with any version lower than 3.1 and all the 3 CT boards that uses an attiny microchip (RPICT3T1 RPICT3V1).

To achieve this one has to install avrdude on the Raspberrypi with other bits. This is all explained in the guide below.

Upload Arduino sketch from Raspberrypi to RPICT

Once the steps in the above guide completed download the hex file from the IDCode page for the target firmware. Then upload it with

lcl-upload-sketch.sh file.hex

If you get the following error:

avrdude-original: stk500_recv(): programmer is not responding
avrdude-original: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

This probably means the microchip does not have any bootloader. We only introduced bootloader on all our production unit sometimes in 2020. If you have acquired the RPICT recently you will not be affected by this. However if you have an older unit than you should burn the bootloader on the microcontroller. Burning the bootloader requires a computer and the NanoProg. This is not too complicated to do once you have the right hardware.

Using Nanoprog

If the option directly from Raspberrypi is not possible then one has to use the Nanoprog to flash the firmware. This will work in particular for all versions lower than 3.1 and the 3CT boards.

Install Arduino IDE on your computer.
Download the ino file of the firmware that you need from the IDCode page.
Open this ino file with the Arduino software.
At the top of the file you will find a link to the RPICTlib library. Download it and install it using Sketch | Include Library | Add .ZIP Libarry.
Connect the USB port of the Nanoprog to your computer.
Connect the Nanoprog to the RPICT board as shown on the picture below.

These are photos for the version 3:

and for the version 5:

Then click on the big right arrow to upload the code to the RPICT board.

To burn a bootloader at that point just select Tools | Burn Bootloader.

For the 3CT units you should follow this guide below. How_to_program_an_Attiny85_or_Attiny84