Skip to main content

Firmware (PX-41CX)

px-41cx
px-41cx

Introduction #

The PX-41CX allows the user to update the firmware using the enclosed USB serial connection cable. For details I suggest you download the PX-41CX documentation from Pierre Houbert’s hompage. The documentation describes how to update the firmware using Python and Microsoft windows. For macOS and Linux you need a shell script version of UPD_PX41CX.cmd.

Preparation #

In addition to python you need and the script below you need the DxCore Tools. Easiest way to get them is to use git to clone them into the directory containing UPD_PX41CX.command

macOS #

On macOS you can use the following commands.

brew install"	\
    "wget"	\
    "python3"

git clone https://github.com/SpenceKonde/DxCore.git
Download Install.command

Windows & Linux #

Windows installation is described in Pierre Houbert’s document and for Linux you use the package manager of your distribution.

Using git clone #

Alternatively you can clone git clone Calculator-Scripts project with it’s sub modules which will set up everything with correct directory structure:

git clone https://git.code.sf.net/p/calculator-scripts/code calculator-scripts
cd calculator-scripts
git checkout --track master
git submodule init
git submodule update
Utilities/Install.command
cd PX-41CX/Firmware

On Linux use the your package manager

Usage #

The script expects the firmware file with the same file name and directory structure they are packed by paxer.net. If the file is not found then the scripts attempts to download and unpack the zip file.

>./UPD_PX41CX.command
Version to install (0901, 0902, …)? 0902
File «px41cx_v0902/px41cx_V0902.hex» not found.
Trying to download «px41cx_v0902.zip» from https://paxer.net.
--2024-09-03 17:03:19--  https://paxer.net/px41cx/downloads/px41cx_v0902.zip
Auflösen des Hostnamens paxer.net (paxer.net)… 44.227.62.171
Verbindungsaufbau zu paxer.net (paxer.net)|44.227.62.171|:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Could not parse Strict-Transport-Security header
Länge: 151606 (148K) [application/zip]
Wird in »px41cx_v0902.zip« gespeichert.

px41cx_v0902.zip        100%[===================================>] 148,05K   363KB/s    in 0,4s

2024-09-03 17:03:21 (363 KB/s) - »px41cx_v0902.zip« gespeichert [151606/151606]

Archive:  px41cx_v0902.zip
   creating: px41cx_v0902/
  inflating: px41cx_v0902/readme.txt
  inflating: px41cx_v0902/px41cx_v0902.hex
SerialUPDI
UPDI programming for Arduino using a serial adapter
Based on pymcuprog, with significant modifications
By Quentin Bolsee and Spence Konde
Version 1.3.0.3 - Jul 2023
Using serial port /dev/tty.usbserial-14440 at 115200 baud.
Target: avr128da28
Set fuses: ['5:0b11001001', '6:0x04', '7:0x00', '8:0x00']
Action: write
File: px41cx_v0902/px41cx_V0902.hex
pymcuprog.programmer - INFO - Setting up programming session for 'avr128da28'
pymcuprog.deviceinfo.deviceinfo - INFO - Looking for device avr128da28
pymcuprog.serialupdi.physical - INFO - Opening port '/dev/tty.usbserial-14440' at '115200' baud

...

pymcuprog.serialupdi.physical - INFO - Closing port '/dev/tty.usbserial-14440'

Source #

The script is written for macOS and ZShell but should work on any Linux system as well.

#!/bin/zsh

setopt Err_Exit

# Set device parameter either from setup file or by trying to guess the device
# name. This will only work on macOS and Linux user should change the next
# three lines.
#
typeset USB_Serial_Device="${USB_Serial_Device-$(echo /dev/tty.usbserial-14*)}"
typeset USB_Serial_Speed="${USB_Serial_Speed-115200}"
typeset Python_Packages="$(python3 -c "import sysconfig; print(sysconfig.get_path('purelib'))")"

# Read version number of Firmware to install.
#
read  "Num_Version?Version to install (0901, 0902, …)? "

typeset Image_File="px41cx_v${Num_Version}/px41cx_V${Num_Version}.hex"

# check if file is available and if not tries to download file.
#
if test ! -e "${Image_File}"; then
    typeset Zip_File="px41cx_v${Num_Version}.zip"

    echo "File «${Image_File}» not found."
    echo "Trying to download «${Zip_File}» from https://paxer.net."

    wget "https://paxer.net/px41cx/downloads/${Zip_File}"

    unzip "${Zip_File}" -x '__MACOSX/*'
fi

# Flash the firmware using the prog tool from DxCore
#
python3 -u "DxCore/megaavr/tools/prog.py"		\
    -t "uart"						\
    -u "${USB_Serial_Device}"				\
    -b "${USB_Serial_Speed}"				\
    -d "avr128da28"					\
    --fuses "5:0b11001001" "6:0x04" "7:0x00" "8:0x00"	\
    -f "${Image_File}"					\
    -a write						\
    -v

Download UPD_PX41CX.command Download UPD_PX41CX.cmd