How to Load Custom Firmware on a CFA735 or CFA835

The two available colors of the CFA835
CFA835 Graphic LCD Display with a Keypad

Hack a CFA735 or CFA835 to Run Your Own Firmware

Do you have a project that needs a display, a key pad, and some memory, but the preloaded firmware on the Crystalfontz CFA735 or CFA835 module isn’t quite what you’re looking for? You’re in luck – these modules can be modified to load custom firmware.

The CFA735 and CFA835 are versatile intelligent LCD modules. Both the Crystalfontz CFA735 and CFA835 are based on the CFA10052 hardware module, so during this tutorial the CFA735 and/or CFA835 will be referred to as the CFA10052. The CFA10052 can be reprogrammed to run your own custom firmware.

CFA10052 hardware features:

  • STMicroelectronics STM32F401 microcontroller
  • ARM 32-bit Cortex™-M4 CPU @ 84 MHz
  • 256K Flash, 64K RAM
  • 244 x 68 pixel backlit LCD
  • Sitronix ST7529 32 grayscale graphic LCD controller
  • Buck-boost switching supply allows wide supply voltage range
  • Separate switching LED brightness controllers for keypad and LCD backlights
  • 6 button backlit keypad
  • 4x bi-color (red/green) LEDs
  • USB2 interface
  • microSD card slot
  • Up to 20 general purpose IO pins (GPIO’s)
  • Multiple serial/SPI/I2C/CAN interfaces (depending on GPIO use)
  • Analog to digital converter

Custom Firmware

This tutorial will show you how to replace the firmware that ships on a CFA10052. For the purposes of the tutorial, we’ll be using some example firmware, but we expect that you’d write and load your own firmware.

The example firmware:

  • Displays an alternating grid on the LCD and status information about the display backlight and contrast, and keypad backlight;
  • Controls the backlights and contrast using the keypads;
  • Sequentially changes the color of the four LEDs from red to green;
  • Enables the USART serial port on Header-1 pins 1 and 2 (115200 baud, and echoes any received data; and
  • Enables the USB virtual serial port, and echoes any received data back to the host.

Important Note

The Crystalfontz CFA10052 hardware modules ship programmed with a bootloader and CFA735 or CFA835 firmware. The bootloader and CFA735/CFA835 firmware are not open-source, and cannot be copied off of the CFA10052 by the user, nor can they be programmed onto the CFA10052 by the user. Once a CFA735 or CFA835 is programmed with custom firmware, the module will lose all CFA735/CFA835 functionality. If you end up wanting the CFA 735 or CFA835 firmware loaded back onto your module, you’ll have to ship it back to us to reload it.

Supplies

The ST Link cable spliced with a 16-pin ribbon cable to create a CFA10052 Programming cable
Our Cable

STM32CubeIDE and STM32 ST-LINK Utility

We recommend using the STM32CubeIDE to load and use this example firmware project. STM32CubeIDE is a free IDE based on Eclipse that has been modified by STMicroelectronics to include STM32 specific tools. The IDE can be downloaded on the STM32CubeIDE webpage.

To maintain the correct operation of the STM device configuration tool, you must only edit the device configuration tool created source-code between the matching “USER CODE BEGIN xxx” and “USER CODE END xxx” comment blocks.

The STM32 ST-LINK Utility is a software interface for STM32 microcontrollers. We just need it in this tutorial to disable the read-only protection on the Crystalfontz firmware. Again, find out more on the STM ST-LINK Utility webpage.

CFA10052 Programming Cable

In order to connect your CFA10052 to the ST LINK, you’ll need to make a cable. We did this by splicing our 16-pin SCAB ribbon cable to the cable that came with the ST LINK.

Connections for CFA10052 Programming Cable

ST-LINK PinCFA10052 H1 PinDescription
116+5V
711SWD-IO
912SWD-CLK
1514RESET
2015GND

Step 1: Remove the Existing CFA735/CFA835 Firmware

If your CFA10052 module is loaded with the supplied CFA735 or CFA835 firmware, you’ll need to erase it first before installing your custom firmware. The flash memory is read and write protected and this protection and the firmware must be removed.

Method 1:

A CFA10052 connected to power and to the ST Link ready to be erased
The CFA10052 connected and ready
  1. Disconnect the USB cable (or power supply) from the CFA10052 module.
  2. Connect the CFA10052 to the ST-LINK using the programming cable (see above), and the ST-LINK to the host PC.
  3. Hold the up & down keys on the CFA10052 while plugging the USB cable into the CFA10052 (or power supply).The CFA10052 should now show the Crystalfontz Bootloader screen.
  4. Run the STM32 ST-LINK Utility. In the “Target” menu, open the “Option Bytes” window. In the “Read Out Protection” box, select “Level 0”. Click Apply. The Crystalfontz firmware has now been removed and any custom firmware may now be programmed.

Method 2:

If you cannot enter the bootloader by holding the keys

Close up of CFA10052 showing the H1 header and BOOT0 test point
H1 (white) and BOOT0 (top center)
  1. Disconnect the USB cable (or power supply) from the CFA10052 module.
  2. Connect the BOOT0 test-point (a small pad on the back of the CFA10052 module, near the H1 connector) to 3.3V or 5V.
  3. Connect the CFA10052 to the ST-LINK using the programming cable (see above), and the ST-LINK to the host PC.
  4. Power on the CFA10052 (or connect it to USB power). The display should be blank.
  5. Run the STM32 ST-LINK Utility.In the “Target” menu, open the “Option Bytes” window.In the “Read Out Protection” box, select “Level 0”. Click Apply.The Crystalfontz firmware has now been removed and any custom firmware may now be programmed.
  6. Connection of the BOOT0 pin to 3.3V/5V is no longer needed.

Step 2: Compile and Load Your Custom Firmware Onto the CFA10052

Now that you’ve removed the supplied firmware, you’re ready to compile and load your own firmware. For the purposes of this tutorial, we have supplied some alternative firmware that gives keypad control of the backlight brightness and display contrast.

To compile the firmware:

  1. Open the STM32CubeIDE
  2. In the File menu, choose Import, then “Import Existing Projects Into Workspace”.
  3. In the root directory box, select the directory of this example firmware.
  4. Click the Finish button.
  5. In the Project Explorer, select the cfa10052_example project, then open the Src, and “main.c” file.
  6. In the Project menu, select “Build Project”.

To program and run the firmware on the CFA10052:

  1. Disconnect the USB cable (or power supply) from the CFA10052 module.
  2. Connect the CFA10052 to the ST-LINK using the programming cable (see above), and the ST-LINK to the host PC.
  3. Connect the USB cable (or power supply) to the CFA10052.
  4. Make sure the firmware project has been built (see steps above), and “Binaries” appears under “cfa10052_example” in the Project Explorer.
  5. If “Binaries” isn’t visible, right-click the “cfa10052_example” project and select Refresh.
  6. Select the Run menu, then “Debug Configurations”.
  7. In the debug target types selection box on the left, Right-Click “STM32 Cortex-M Application”, and select “New Configuration”.
  8. A configuration window will be shown. The default settings are OK. Click the Apply then the Close button.
  9. In the Run menu, select “Debug As”, then “STM32 Cortex Application”. STM32CubeIDE should now connect to the ST-LINK, and upload and run the firmware on the CFA10052.
The CFA10052 running some demo custom firmware
Example firmware

The above steps are only required on loading the project for the first time in STM32CubeIDE. After firmware source-code changes have been made, only re-building the project (Ctrl-B shortcut) and programming the CFA10052 (F11 key shortcut) are needed.

Firmware can also be loaded via any of the normal STM32 bootloader methods (debugging is only available using the SWD interface and a ST-LINK). For example, if using serial connection, USART1 may be used (RX=H1-Pin1 and TX=H1-Pin2).For more detailed information about the STM32 bootloader and interfaces, see the PDF here.

Support

Crystalfontz supports all of our products, but we cannot support your custom firmware. If you have a question, reach out to us via our contact page.

We love seeing your projects! Tag us on facebook, instagram, linkedIn, or twitter.