Close
0%
0%

AVR: Architecture, Assembly & Reverse Engineering

Explore the hidden depths of the AVR-8 architecture, looking under the hood of the compiler and diving into the MCU's internals!

Instructors Uri ShakedUri Shaked
Friday, January 29, 2021 12:00 am GMT Local time zone:
Register for this course
Similar projects worth following

About the Instructor

Uri is a maker who loves voiding warranties; Currently building AVR8js, an open-source AVR simulator in JavaScript and working on "The Skull", an ATtiny85 reverse engineering puzzle.

Course Overview

Tickets to this course

You have probably used Arduino Uno, and know how to program it with C++. You may have also seen/written code that interfaces directly with the hardware registers of the ATmega328p chip (PORTB, TCNT0, etc.). But if you really want to dive deep, understanding the AVR architecture is key. 

This course will take you on a journey to explore the internals of the AVR architecture. We'll learn the AVR assembly language, look at the different peripherals and the registers that control their behavior, and get very intimate with the ATmega328p datasheet.

By the end of the course, you'll have hands-on experience with writing AVR assembly code, as well as understanding and reverse engineering the code generated by the compiler. You will be able to use your skills to solve CTF riddles, write cryptic code-golf programs, and whatnot. 

You DON'T Need an Expensive Debugger

Usually, learning about the internals of a microcontroller requires specific hardware that connects to the debug interface of this microcontroller. However, in this course, we're going to cheat and use AVR8js, and open-source AVR emulator. We'll learn how to connect to it with GDB and probe the internals as the machine code is executing.

Software Requirements

Modern web browser (Chrome, Firefox, etc.). We'll use the online simulator at https://wokwi.com.

Optional: Node.js + avr-gdb for interfacing with GDB (instructions will be provided prior to the relevant class).

Prerequisites / Resources

  • Bitwise Math
  • You should be fluent in Arduino programming 
  • Basic understanding of electronics (e.g. you should know what is an LED and how to properly wire it to an Arduino board).

Syllabus

Class 1 - We'll learn how the memory space is organized, explore the I/O space and the register space, become friends with the ATmega328P datasheet, and see how our C code can interact with the on-chip peripherals (such as GPIO) by directly accessing the hardware registers.

Class 2 - We'll get our hands dirty with Assembly code and learn how to use it in our Arduino code. We'll go over the basics of AVR assembly: working with registers, the program counter, performing arithmetic operations and their effect on the status register, and using the asm statement to include inline assembly in our code.

Class 3 - We'll get deeper into AVR assembly, covering topics such as: the stack pointer, branches and method calls, the interrupt vector, conditional instructions, and data transfer instructions.

Class 4 - Let's take a look under the hood! We'll take a look at the source code of the Arduino's Wiring library, and then learn how to see the assembly code produced by the Arduino compiler using avr-objdump, and start practicing reading AVR assembly code and understanding it.

Class 5 - We'll get even more hands-on AVR assembly experience by writing a complete program from scratch, learning how to set up and utilize the built-in AVR Timer peripherals.

This is going to be fun. And intense. 🙀

  • Class 5

    Lutetium01/07/2021 at 19:40 0 comments


    Class 5 - We'll get even more hands-on AVR assembly experience by writing a complete program from scratch, learning how to set up and utilize the built-in AVR Timer peripherals.

  • Class 4

    Lutetium01/07/2021 at 19:39 0 comments

    Class 4 - Let's take a look under the hood! We'll take a look at the source code of the Arduino's Wiring library, and then learn how to see the assembly code produced by the Arduino compiler using avr-objdump, and start practicing reading AVR assembly code and understanding it.


  • Class 3

    Lutetium01/07/2021 at 19:38 0 comments


    Class 3 - We'll get deeper into AVR assembly, covering topics such as: the stack pointer, branches and method calls, the interrupt vector, conditional instructions, and data transfer instructions.


  • Class 2

    Lutetium01/07/2021 at 19:38 0 comments

    Class 2 - We'll get our hands dirty with Assembly code and learn how to use it in our Arduino code. We'll go over the basics of AVR assembly: working with registers, the program counter, performing arithmetic operations and their effect on the status register, and using the asm statement to include inline assembly in our code.

  • Class 1

    Lutetium01/07/2021 at 19:37 0 comments

    Class 1 - We'll learn how the memory space is organized, explore the I/O space and the register space, become friends with the ATmega328P datasheet, and see how our C code can interact with the on-chip peripherals (such as GPIO) by directly accessing the hardware registers.

View all 5 course logs

Enjoy this course?

Share

Discussions

Chuck wrote 4 days ago point

What platform will this be live streamed on?

  Are you sure? yes | no

Uri Shaked wrote 3 days ago point

Zoom, I believe

  Are you sure? yes | no

Stig Sivertsen wrote 4 days ago point

Will this course be recorded?

  Are you sure? yes | no

Chuck wrote 4 days ago point

According to the following link, it will be.

https://hackaday.io/project/173597-hackadayu-faqs

  Are you sure? yes | no

Does this project spark your interest?

Become a member to follow this project and never miss any updates