Bare-Metal MCU #6: Compilers, Assemblers, and Friends

  Рет қаралды 23,343

Mitch Davis

Mitch Davis

Күн бұрын

This is the sixth video in a journey from Arduino to STM8. The goal is to begin with Arduino, which is a popular platform to serve as a starting point. I'll then break it down into a fundamental level, and then apply those fundamentals to other microcontrollers, such as the STM8.
This video focuses on what a compiler does to translate C code to machine code, and also touches on some other tools that are necessary to compile and upload a program to ATMEGA328 without arduino IDE!
-------------------------------------------
Install AVR-GCC for Mac: brew tap osx-cross/avr
brew install avr-gcc
Install AVR-GCC for Linux (Debian): apt-get install gcc-avr
Download AVR-GCC (WINAVR) for Windows: sourceforge.net/projects/winavr/files/WinAVR/
--------------------------------------------
AVR Instruction Set Datasheet: ww1.microchip.c...
ATMEGA328P Datasheet: ww1.microchip.c...
ATMEGA328 Datasheet:
ww1.microchip.c...

Пікірлер
@DanEllis
@DanEllis 4 жыл бұрын
With regard to whether or not you can upload the file directly, the answer is no. It's in ELF format, which has a lot of extra information that's typically used by an operating system. When you convert it a hex file, you flatten it by removing all that extra data so you're just left with raw code and data.
@lauriekimani
@lauriekimani 2 ай бұрын
Avrdude actually handles elf files as well,i've uploaded elf files with avrdude a couple of times.
@minhajsixbyte
@minhajsixbyte Жыл бұрын
Thanks for all the videos, keep bringing more please. The thing at 9:44 is not vim. Its a pager software called "less" You can use "less " to read text files too, or pipe something into it ""echo "hello world" | less "" its really handy
@vladl3531
@vladl3531 4 жыл бұрын
Thanks a lot for these videos! The whole series is just awesome.
@draufunddran
@draufunddran 4 жыл бұрын
Awesome series and I'm exited to see the upcoming videos... Keep up the good work.
@barowski_
@barowski_ 4 жыл бұрын
For the install on Linux, you also need to install avr-libc . It wouldn’t compile until I had that, and it didn’t install automatically
@a.inaciomorais9859
@a.inaciomorais9859 4 жыл бұрын
Thanks. AVR-GCC only worked after installing avr-libc (sudo apt-get install avr-libc). Ubuntu 20.04
@abolfazlabbasi4854
@abolfazlabbasi4854 Жыл бұрын
Thank you for the great video, The content, explanation, tips and tricks, everything was awesome. Keep up the good work.
@viks599
@viks599 3 жыл бұрын
would also need to install "avr-libc" to work with "gcc-avr"
@ilikepie1974
@ilikepie1974 4 жыл бұрын
of a channel with a heck of a lot more traffic. This is like a lite version of my ee346 class, and the color coding on your assembly/hex example was very nice. Good job m8.
@nict2618
@nict2618 3 жыл бұрын
Thank you so much for these videos.
@chiraggoyal7637
@chiraggoyal7637 4 жыл бұрын
Great video. I like how you explain the process more than what you are doing
@arjunrao9978
@arjunrao9978 2 жыл бұрын
Your Videos are Excellent 👌❤️🙏🙏🙏
@sqrtc-yc2fs
@sqrtc-yc2fs 2 жыл бұрын
great video series! thank you!
@TroyFletcherKeyboards
@TroyFletcherKeyboards 3 жыл бұрын
Fantastic video series, but I can't help but offer Vim suggestions, shift+v will give you whole line visual select so you don't have to move to the next line to include to the end of the current line.
@riskypirate
@riskypirate 4 жыл бұрын
Looking forward to the linkers and optimization content!
@armincal9834
@armincal9834 3 жыл бұрын
This guy looks like Justin Gaethje minus the brain damage :D
@jackevans2386
@jackevans2386 Жыл бұрын
1:29 is not quite correct because by using ADIW you are also writing to R25. Easier just to INC R24 or SUBI R24, -1 Why confuse everyone with ADIW's 63 max limitation when SUBI has none ?
@nakulsingh8444
@nakulsingh8444 3 жыл бұрын
Awesome explanation 👍
@jinhaolu4755
@jinhaolu4755 2 жыл бұрын
very useful. Thank you
@DanEllis
@DanEllis 4 жыл бұрын
If you think gcc's man page is long, you should see its info pages!
@amgmg2521
@amgmg2521 3 жыл бұрын
Thanks for the explanation. Can you do a video about bootloaders?
@MitchDavis2
@MitchDavis2 3 жыл бұрын
Anything specific in mind? Right now I have my hands full with the STM32 series, but I might be able to loop back around to this
@amgmg2521
@amgmg2521 3 жыл бұрын
@@MitchDavis2 Oh, I just found a video about bootloaders in your playlist. So, ignore the request. : )
@MitchDavis2
@MitchDavis2 3 жыл бұрын
@@amgmg2521 Cool, I hope that's what you were looking for. It's possible to make your own bootloader, which is what I thought you were asking. I've never actually done this myself, but it's on my list of things to learn. For example, being able to re-flash the microcontroller from an SD card or something.
@amgmg2521
@amgmg2521 3 жыл бұрын
@@MitchDavis2 Creating own bootloaders, actually, that is what I'm thinking. Also, how programmers(Atmel ice, usbasp, etc..) actually work, do they just convert USB data into SPI or anything else going on under the hood. It'll be great if you can do a detailed video about the subject.
@MitchDavis2
@MitchDavis2 3 жыл бұрын
@@amgmg2521 for now, that’s beyond my expertise. I know the ATMEGA328 datasheet describes everything though, as I’ve seen it a few times before. It explains exactly what needs to be sent over SPI to flash the microcontroller. This is the method for programming without a bootloader. Additionally, it also describes how to self-program in there as well, which are commands that you can execute from code to erase and reprogram chunks of flash memory. So in essence, a programmer just takes some input file (.hex in my examples), transmits it over USB to the programmer, and the programmer reads that data and sends whatever SPI commands are necessary to flash the microcontroller.
@UncloudedByHate
@UncloudedByHate 3 жыл бұрын
I found on linux I could flash the compiled version of blink onto the ATmega328p with the avrdude's "e" option. So with gcc-avr, avr-libc, and avrdude packages installed, I can upload code with only two commands: avr-gcc -mmcu=atmega328p blink.c avrdude -v -c /etc/avrdude.conf -p atmega328p -c stk500v1 -P /dev/ttyUSB0 -b 19200 -U flash:w:a.out:e The other way (using avr-objcopy to change to hex) seems to result in a much smaller file, but this way works w/o introducing an extra command line tool. Not sure if there's other hidden downsides to this?
@nicolaspillot5789
@nicolaspillot5789 2 жыл бұрын
@Danielle Thurow thanks for the heads up about the 'e' format, it's even listed in the video when he shows the manual but i did not notice until i read your comment. kudos !
@dineshganesh6723
@dineshganesh6723 3 жыл бұрын
Really useful bro..❤️😎
@MKRCLabs
@MKRCLabs Жыл бұрын
sir do you have some videos om bldc motor control with stm32 code which is in hover board i want to learn code writing for that
@WaldoHazeleger
@WaldoHazeleger Жыл бұрын
How about AVR inline assembly within a C-function with arguments and a return value? int addition(int a, int b) { asm (??? c = a + b ???) return c; }
@bimalrajk7
@bimalrajk7 Жыл бұрын
error : redefinition of 'i', you can use avr-g++ instead of avr-gcc to have redefinition
@razakjanjoun2648
@razakjanjoun2648 4 жыл бұрын
How to do that in Java, I mean how can I manipulate registers, e.g set them as I/O and Read/Write to the destination Arduino Pins, do I have to use special library for this is it possible to do it manually?
@Wassim-wr8jq
@Wassim-wr8jq Жыл бұрын
bro knows how to leave vim
@jayeshrathod1390
@jayeshrathod1390 3 жыл бұрын
✌✌✌✌✌
Bare-Metal MCU #7: Libraries (Preprocessor & Linker)
19:58
Mitch Davis
Рет қаралды 17 М.
Bare-Metal MCU #8: Optimizers and Bit-Banging
16:57
Mitch Davis
Рет қаралды 23 М.
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
Натурал Альбертович
Рет қаралды 4,7 МЛН
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 4,4 МЛН
Turn Off the Vacum And Sit Back and Laugh 🤣
00:34
SKITSFUL
Рет қаралды 6 МЛН
Bare-Metal MCU #9 - Review; ATTiny85 from scratch
14:25
Mitch Davis
Рет қаралды 72 М.
GPIO for any PC or Laptop: Adafruit FT232H
19:18
ExplainingComputers
Рет қаралды 205 М.
rust runs on EVERYTHING (no operating system, just Rust)
18:10
Low Level
Рет қаралды 362 М.
Machine Code Explained - Computerphile
20:32
Computerphile
Рет қаралды 124 М.
STM32 Guide #4: Generated Code, HAL, and Bare Metal
26:20
Mitch Davis
Рет қаралды 85 М.
IR Remotes & Microcontrollers - Arduino & ESP32
1:31:50
DroneBot Workshop
Рет қаралды 218 М.
Bare-Metal MCU #5 - AVRDude and fuses
20:30
Mitch Davis
Рет қаралды 35 М.
Worlds Simplest Bootloader :: Bare Metal Programming Series 4
1:08:03
Low Byte Productions
Рет қаралды 23 М.
Optimizing Arduino Code: no setup(), no loop() ⛔
9:27
Wokwi
Рет қаралды 209 М.
Как Я Брата ОБМАНУЛ (смешное видео, прикол, юмор, поржать)
00:59
Натурал Альбертович
Рет қаралды 4,7 МЛН