PSLab Firmware
This repository contains firmware for the Pocket Science Lab (PSLab) open hardware platform.
Pocket Science Lab
The PSLab provides an array of test and measurement instruments for doing science and engineering experiments. Its built-in instruments include an oscilloscope, a waveform generator, a frequency counter, programmable voltage and current sources, and a logic analyzer. The PSLab also has UART, I2C, and SPI buses, via which external devices can be connected and controlled.
The PSLab is a fully open device, and FOSSASIA provides a complete hardware and software stack under open source licenses:
Buy
-
You can get a Pocket Science Lab device from the FOSSASIA shop
-
More resellers are listed on the PSLab website
Get in touch
- The PSLab chat channel is on Gitter
- Please also join us on the PSLab Mailing List
Dependencies
The following tools are required to build the firmware:
- xc16 compiler
- cmake
Building
This project is built with CMake. After cloning this repository, you must first initialize and update the toolchain submodule:
git submodule init
git submodule update
This will populate the external/cmake-microchip
directory, after which the
firmware can be built:
mkdir build
cd build
cmake ..
make
This will create a build artifact in the build
directory:
pslab-firmware.hex
.
Flashing
The firmware can be flashed over USB or by using a programmer such as the PICkit3.
Over USB
Firmware can be flashed over USB if the device already has the bootloader installed.
Flashing the firmware requires the pslab-python library. See pslab-python for installation instructions.
Follow these steps to flash new firmware:
- Ground the BOOT pin
- Reset or power cycle the device
- Run
pslab flash --port <portname> firmware.hex
- Unground the BOOT pin
- Reset or power cycle the device
Using a programmer
Warning
If your device contains a bootloader, flashing just the firmware HEX with a
programmer will OVERWRITE the bootloader. If for some reason you are unable
to flash over USB, it is a better idea to first create a combined HEX file
containing both the bootloader and the firmware and flash that, rather than
flashing the pure firmare HEX. See the
bootloader repository
for instructions on how to create a combined HEX.
Flashing with a programmer requires the mdb.sh script, which is distributed as
part of Microchip's MPLAB-X software suite. On Linux, the default installation
path for mdb.sh is /opt/microchip/mplabx/<version>/mplab_platform/bin/mdb.sh
.
This script is used to run the file flash.mdbscript, located in the repository
root. Before following the below steps, you may need to modify flash.mdbscript
depending on which programmer you are using and the location of the firmware
HEX.
- Disconnect the device from any power source
- Connect the programmer to the device's ICSP header
- Power on the device via USB
- Run
mdb.sh flash.mdbscript
- Disconnect the programmer
Repository structure
π¦pslab-firmware
β£ πsrc # PSLab firmware source code
β β£ πbus # Communication specific source files
β β β£ π ...
β β β πi2c.c
β β£ πhelpers # Supplementary functions
β β β£ π ...
β β β πversion.c
β β£ πinstruments # Instrument specific source files
β β β£ π ...
β β β πmultimeter.c
β β£ πregisters # PIC specific register entry files
β β β£ πcomparators
β β β β£ π ...
β β β β πic1.c
β β β£ π ... # includes converters, memory, system
β β β£ πtimers
β β β β£ π ...
β β β β πtmr1.c
β β£ πsdcard # SD Card specific file handling source files
β β£ π ...
β β£ πmain.c # Entry point to PSLab Core
β β£ πcommands.c # Entry point to function implementations
β£ πexternal
β β£ πcmake-microchip # Toolchain submodule
β£ πCMakeLists.txt
β£ πflash.mdbscript
β£ πLICENSE
β πREADME.md