Introduction #
Propeller Programming Script - For the Parallax Propeller 1 Microcontroller
This batch script provides a way to achieve one-click updates for customers, using a standard Windows batch script for compatibility with the widest range of Windows versions.
This avoids the need to use an IDE programmer or to share the Propeller Source Code files with the customer. Instead this script allows a compiled binary file of the code to be shared for deployment.
Script Settings #
The script has two settings near the top that allow customisation:
set "firmware_filename=Blink_LEDs_26_27.binary"
Change the filename shown after the equals sign to match whatever name you gave your Propeller binary file. Make sure to keep the quote mark at the end of the line!
rem set "save_to=/eeprom"
Either keep or remove the "rem" keyword at the start of the line to determine how the script functions:
rem is short for remark in Windows scripting language. It's the "Windows way" of commenting out a line of code!
Keeping the "rem" will ensure the instruction is ignored, and so the script will load and run the program in voltatile memory only. ie. it will be lost after a reset or powercycle.
Removing the "rem" will include the instruction, and will make the script save the new code to permanent memory in the Propeller 1 microcontroller, before running the new code.
Binary file vs Source code #
This programming script works with a Propeller binary format file, which is a compiled version of the Propeller source code. It is a portable file format for sharing your code files, and prevents the source code being easily edited or copied.
To generate a binary file, press F8 in Propeller Tool or SPIN Tools IDE, then follow the options to download a binary file.
For help, please ask at our forums https://forums.parallax.com or contact support@parallax.com
Deployment #
Send 3 files to your customers:
- The "Propeller Programming Script" Windows batch script file (.bat)
- The Parallax Propeller code loader, called "Propellent.exe" and available in the OBEX demo file linked below
- Your Propeller code binary file
Usage Instructions #
To program a Propeller, connect the USB cable to your Propeller and ensure the Propeller module is powered on. Then run (double click) the script (.bat) file and follow the prompts.
A complete demo, including the sample binary file which is suitable for the Propeller FLiP module or Propeller Activity Board can be found at the OBEX link below.
Code Snippet #
@echo off
rem Propeller Programming Script - For the Parallax Propeller 1 Microcontroller
rem https://www.parallax.com/propeller-multicore-concept/
rem - This programming script works with a Propeller binary format file
rem - To generate a binary file, press F8 in Propeller Tool or SPIN Tools IDE
rem - For help, please ask at our forums https://forums.parallax.com
rem - or contact support@parallax.com
rem - Adjust the following line to the filename of your Propeller Binary file
set "firmware_filename=Blink_LEDs_26_27.binary"
rem - Choose to save program to EEPROM (permanent memory), or
rem - to run only in ram (temporary memory, lost after reset or power cycle)
rem - Type rem before the following line to skip EEPROM programming, and only load to RAM
rem set "save_to=/eeprom"
rem - Scan for Propeller 1
Propellent.exe /id /port AUTO /gui OFF > tmpFile
rem - Check for errors
findstr /m /c:"Propeller chip version 1 found on" tmpFile >Nul
if %errorlevel% NEQ 0 (
goto :somethingfailed
)
rem - Most likely that a valid com port found!
rem - Find line with COM port number; extract the number
for /f "tokens=2 delims=COM" %%a in ('type tmpFile^|find "Propeller chip version 1 found on "') do (
set "comport=%%a" & goto :continue
)
:continue
rem - Store COM port number to local variable, trim off last character (the fullstop)
set "comport=%comport:~0,-1%"
rem - Remove the temporary file
del tmpFile
rem - Inform user of progress
echo.
echo **************************************************
echo.
echo Propeller Programming Tool
echo.
echo Found Propeller on COM%comport%
echo Firmware file: %firmware_filename%
if "%save_to%"=="/eeprom" ( echo Programming EEPROM... ) else ( echo Loading RAM... )
rem - Program the Propeller chip
propellent %save_to% /port COM%comport% %firmware_filename% > tmpFile
rem - Verify if programming succeeded
findstr /m /c:"451-Success" tmpFile >Nul
if %errorlevel% NEQ 0 (
goto :somethingfailed
)
rem - Remove the temporary file
del tmpFile
rem - All done!
goto :theend
:somethingfailed
rem - Inform user if something went wrong
echo.
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo !Failed to find or program the Propeller!
echo ! Check the USB connection and try again!
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo.
rem - As something failed, pause for user to respond before exit
@pause
exit
:theend
echo.
echo **************************************************
echo Success! Programming completed.
echo **************************************************
echo.
rem - Wait for 6 seconds, then close the command prompt
rem - or user could press a key to close prompt immediately
timeout /t 6
rem - exit
Resources #
https://www.parallax.com/propeller-multicore-concept/