Skip to content

This project bypasses an IDE, using the AVR-GCC toolchain to compile the code and AVRDude to flash it onto the microcontroller.

Notifications You must be signed in to change notification settings

Sreyz03/arduino_baremetal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arduino Bare-Metal LED Blink

A bare-metal programming demonstration for the Arduino Uno (ATmega328P) to blink the onboard LED using direct register-level C programming. This project uses only AVR-GCC and AVRDude, with no Arduino libraries.

✨ Features

  • Toggles the onboard LED (pin 13 / PB5) every 500ms.
  • Utilizes direct AVR register manipulation for maximum efficiency.
  • Simple build and flash process using a Makefile.
  • Compatible with a VS Code + PlatformIO workflow.
  • Version-controlled with Git & GitHub.

🛠️ Hardware & Software Requirements

Hardware

  • Microcontroller: ATmega328P (on an Arduino Uno board)
  • Onboard LED: Connected to Pin 13 (Port B, Pin 5)
  • Connection: Standard USB cable

Software

  • Linux ( Ubuntu).
  • Visual Studio Code (or any text editor)
  • AVR Toolchain: gcc-avr, avr-libc, avrdude
  • make utility
  • Git for version control

To install the required tools on a Debian/Ubuntu system:

sudo apt update
sudo apt install gcc-avr avr-libc avrdude

📂 Project Structure

arduino_baremetal/
├── blink.c          # Main C source code for the blinking logic
├── Makefile         # Build and flash automation script
├── .gitignore       # Optional: Specifies files for Git to ignore
└── README.md        # This documentation file

🚀 Usage Instructions

1. Clone the Repository (or setup your own)

git clone https://github.com/Sreyz03/arduino_baremetal.git
cd arduino_baremetal

2. Build the Project

Compile the source code to generate the executable .hex file.

make all

This command compiles blink.cblink.oblink.elfblink.hex.

3. Flash the Arduino

First, connect your Arduino and identify its serial port:

ls /dev/ttyACM*

Update the PORT variable in the Makefile if it's different from /dev/ttyACM0.

Then, upload the compiled code to the Arduino:

make flash

The onboard LED should now be blinking!

4. Clean Up

To remove all generated files (.o, .elf, .hex):

make clean

📜 Makefile Targets

Target Description
all Compiles the C code and generates the .hex file.
flash Uploads the generated .hex file to the Arduino.
clean Removes all compiled object and hex files.

📄 License

This project is licensed under the MIT License.


About

This project bypasses an IDE, using the AVR-GCC toolchain to compile the code and AVRDude to flash it onto the microcontroller.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published