Prerequisites
Before you begin, ensure you have the following hardware and software:Required hardware
- PICkit 3 or PICkit 4 - For programming and debugging the PIC24FJ1024GA606
- BlueBus hardware - Either a production unit or development board (v1.x or v2.x)
- USB cable - For serial communication and firmware updates
- BMW vehicle - With I-Bus for testing (E38, E39, E46, E53, E83, E85/E86, or R50/R52/R53)
Required software
- MPLAB X IDE - Microchip’s integrated development environment
- XC16 Compiler - Version 2.10 or compatible (C compiler for 16-bit devices)
- Python 3.x - For firmware upload tools
- Git - For version control
Installation steps
Install MPLAB X IDE
Download and install MPLAB X IDE from Microchip’s website.The BlueBus project uses NetBeans project files (
nbproject/) for build configuration.Install XC16 compiler
Download and install the XC16 compiler version 2.10 from Microchip’s website.After installation, verify the compiler is accessible:
The project is configured to use XC16 v2.10. While newer versions may work, you may encounter compatibility issues with compiler flags or optimization settings.
Clone the repository
Clone the BlueBus repository to your local machine:The repository structure includes:
firmware/application/- Main application firmwarefirmware/bootloader/- USB bootloader firmwarehardware/- PCB design files (v1 and v2)utility/- Python tools for firmware management
Install Python dependencies
Install the required Python packages for the firmware tools:This installs:
pyserial- Serial port communicationintelhex- Intel HEX file parsingtk_tools- GUI components
Open the project in MPLAB X
Launch MPLAB X IDE and open the firmware project:
- Go to File → Open Project
- Navigate to
firmware/application/ - Select the project and click Open
application configuration pre-selected.Building the firmware
Once your environment is set up, you can build the firmware:Build targets
The Makefile supports the following targets:Build from MPLAB X IDE
- Click the Build button (hammer icon) in the toolbar
- Monitor the Output window for compilation progress
- The build artifacts are created in
dist/application/production/
application.production.hex- Intel HEX file for programmingapplication.production.elf- Executable and Linkable Format fileapplication.production.map- Memory map file
Build from command line
You can also build from the terminal:The build system uses NetBeans-generated makefiles in
nbproject/Makefile-impl.mk. Direct invocation of make relies on these auto-generated files.Flashing the firmware
You can flash firmware to the BlueBus hardware using two methods:Method 1: USB bootloader (recommended)
For production units with the bootloader installed, use the Python firmware tool:- Detect the BlueBus device on the serial port
- Enter bootloader mode
- Erase the application flash region (up to 0xAA800)
- Write the new firmware
- Verify the write
- Reset and start the application
Method 2: ICSP with PICkit
For initial programming or bootloader updates, use MPLAB X with a PICkit:-
Connect the PICkit to the ICSP header on the BlueBus board:
- MCLR (Pin 1)
- VDD (Pin 2)
- VSS (Pin 3)
- PGD (Pin 4)
- PGC (Pin 5)
- In MPLAB X, click Make and Program Device (green arrow icon)
- The IDE will build, program, and verify the firmware
When using ICSP, ensure the BlueBus is powered either from the vehicle or an external 12V supply. The PICkit does not provide sufficient power for the BM83 Bluetooth module.
Verifying the installation
After flashing, verify the firmware is running correctly:- Connect to the BlueBus serial port at 115200 baud, 8N1
-
You should see the boot message:
-
Type
helpto see available CLI commands -
Check the firmware version with
version
Next steps
Now that your development environment is ready:- Review the code style guide for coding standards
- Learn about testing procedures for validation
- Explore the codebase structure:
lib/- Core libraries (I-Bus, UART, I2C, Bluetooth)handler/- Event handlers for I-Bus and Bluetoothui/- User interface implementations (BMBT, MID, CD53)main.c- Application entry point and initialization