Microcontroller Programming without IDE (Makefile + Toolchain) | Embedded System Project Series #5

  Рет қаралды 17,553

Artful Bytes

Artful Bytes

Күн бұрын

There are two common ways to set up a development environment for a microcontroller (embedded) project:
IDE - Use the integrated development environment (IDE) provided by the vendor.
CLI - Use the toolchain from the command-line (CLI), build with make (Makefile), and use your code editor of choice.
In the last video, I focused on the first approach and set up an IDE, Code Composer Studio (CCStudio). In this video, I focus on the second approach. I talk about toolchains, the advantages of building from the command-line, and show how to install a GCC-based toolchain and use it to compile the same blink LED project (MSP430) as in the last video. Finally, I create a Makefile from scratch to make building easier.
0:00 Intro
1:00 Video outline
2:18 Why build from command-line?
4:10 Toolchains
06:48 Download GCC-based toolchain
09:15 Build blink project with gcc
15:35 Compiler options
20:30 Add more source files
24:10 Vim editor
25:01 Makefile intro
26:35 Create new Makefile
28:41 Add variables
30:07 More compiler flags
33:31 Separate compilation and linking
35:54 Pattern rule
36:46 Automatic variables
37:52 Put build files in separate directory
40:30 Substitution reference and patsubst
43:01 Phony targets all and clean
44:37 Flash microcontroller using make
47:10 Makefile finished
47:51 What about CMake?
49:01 Recap
49:38 General advice
🖥️ Code
gist.github.com/niklasab/78b1...
🌍 Links mentioned in this video
interrupt.memfault.com/blog/b...
www.artfulbytes.com/makefile-...
⌨️ My development environment
www.artfulbytes.com/devenv
🌍 Links
GitHub - github.com/artfulbytes
Website - www.artfulbytes.com
👨‍💻 About me
Hi and welcome. I'm Niklas, an embedded systems engineer from Sweden. On this channel, I make practical videos about embedded systems or, in general terms, about building and programming hardware.

Пікірлер: 89
@artfulbytes
@artfulbytes Жыл бұрын
I keep updating the Makefile throughout the video series, you find the latest version in the repository (github.com/artfulbytes/nsumo_video. For example, I forgot to track the header files in this video.
@UtkarshGaikwad988
@UtkarshGaikwad988 Ай бұрын
The link is broken
@artfulbytes
@artfulbytes Ай бұрын
@@UtkarshGaikwad988 github.com/artfulbytes/nsumo_video (I accidently included ')' at the end of the link)
@UtkarshGaikwad988
@UtkarshGaikwad988 Ай бұрын
@@artfulbytes Thanks !
@UtkarshGaikwad988
@UtkarshGaikwad988 Ай бұрын
@@artfulbytes Thanks!
@Ziferten
@Ziferten 5 ай бұрын
How the heck does this guy only have 5.64K subscribers? This is high quality content. Keep up the good work!
@DeepanshuKatre
@DeepanshuKatre 10 күн бұрын
One of the best video on makefiles creation from scratch. Keep it up.
@vvm583
@vvm583 2 жыл бұрын
Those of us learning embedded programming thank you for this video. Well done.
@artfulbytes
@artfulbytes 2 жыл бұрын
Thanks 🙏
@jonathanroberts7100
@jonathanroberts7100 12 күн бұрын
I want to sincerely thank you for the fantastic video which you put together, which has saved me many, many hours of scratching my head. This is extremely well done, concise and accurate. Thanks heaps!
@nicktyler1836
@nicktyler1836 Жыл бұрын
This is a great video. You've covered a topic that is usually sorely lacking in clear, accessible information. I feel like toolchains get treated as some spooky mystery that books/courses/colleagues etc just assume you know already. It's really nice to see everything demonstrated so clearly from scratch without assuming any prior information. Cheers!
@artfulbytes
@artfulbytes Жыл бұрын
Glad to hear it👻
@ericksagaguara
@ericksagaguara Жыл бұрын
One of the best, if the the best, embedded systems channel in youtube.
@maceb87
@maceb87 3 ай бұрын
This is the best introduction to make i have seen. Thank you! And it would be nice to see a video about cmake from you :)
@walidoulondon8107
@walidoulondon8107 Жыл бұрын
Very professional way to compile ❤
@luisantoniojonguitudindale6000
@luisantoniojonguitudindale6000 6 ай бұрын
I really enjoy Embedded SW development tech stack. This video is a clear example of the usage of CL tools for automating the whole process, pretty valuable and beautiful. Thanks for sharing, I'll keep on this video series!
@user-xn2tq1wo9z
@user-xn2tq1wo9z 4 ай бұрын
Really nice video. Exactly what I want to learn! Thank you!
@omurceran4589
@omurceran4589 Жыл бұрын
That's the video I really like and find it understandable. Thank you so much for that.
@Elkhaligy
@Elkhaligy Жыл бұрын
Amazing video, 10/10 keep going 😊
@rajesha8626
@rajesha8626 2 ай бұрын
Thank you so much for this video.
@aryangupta4252
@aryangupta4252 Жыл бұрын
Awesome video, I am a absolute beginner in embedded comming from arduino. This truly interesting to learn what goes behind. I wish you could make it bit beginer friendly but overall this is the best content I have seen on Emmbeded hope you will continue to upload more such videos
@artfulbytes
@artfulbytes Жыл бұрын
Glad you like them! Anything in particular you have in mind when you say beginner-friendly? I do assume some background knowledge from the viewer, but I'm always open for any feedback to make my videos easier to understand 👨‍🏫
@dheerajreddy3601
@dheerajreddy3601 7 ай бұрын
Love the intro! 😂
@Rahul-po9yg
@Rahul-po9yg Жыл бұрын
Thanks for such a nice video. :)
@artfulbytes
@artfulbytes Жыл бұрын
Thanks!
@truongvietdung4967
@truongvietdung4967 8 ай бұрын
I'm really looking forward to the tutorial video on setting up and using your Ubuntu configuration for programming.
@yohaninfinity8333
@yohaninfinity8333 Жыл бұрын
You are the one I have been searching for a loog time ... I have only dipped my toes in the embedded world after my one year placement year in a company and I want to pursue this field your videos have been a god send
@artfulbytes
@artfulbytes Жыл бұрын
That's a comment that really motivates me to work on this series, thanks!
@michaelbulkley9141
@michaelbulkley9141 Жыл бұрын
@@artfulbytes I am also gravitating towards the embedded world and these videos are helping me out a lot. Thank you very much for making them.
@artfulbytes
@artfulbytes Жыл бұрын
@@michaelbulkley9141 I'm glad they are helping you out! I think you will like the coding-focused videos I have in the making right now.
@abdellahessetty1336
@abdellahessetty1336 2 күн бұрын
Thanks for the video series. One thing is at 11:38. there isn't an "./include/msp430.h" in the gcc folder.
@uccoskun
@uccoskun 5 ай бұрын
This is a gold mine.
@artfulbytes
@artfulbytes 4 ай бұрын
👷‍♂
@johanliebert2048
@johanliebert2048 Жыл бұрын
It's very good that you describe the necessary minimum. Please continue at the same pace. First, do the minimum at which everyone in theory should start, and then more complex options with different variations. In many educational videos or books articles, either a very simple version is disassembled, or a very specific custom one. Then as a beginner, just wants to understand where to start? Should he specify this bit in the settings or not? Will this code run without the configuration of the other one? And so you have to Google and search for such questions and get a little dizmoral, since the question is very simple and easy. The question does not even require any mental intellectual abilities, it's just the specifics.
@artfulbytes
@artfulbytes Жыл бұрын
Thanks for feedback like this. It's sometimes hard for me to put myself in the shoes of a complete beginner even if I myself were a beginner just a few years ago.
@TonyDaExpert
@TonyDaExpert 6 ай бұрын
I want to get used to makefiles more for my work
@viswanathanr6851
@viswanathanr6851 7 ай бұрын
i cannot find msp430.ld file inside my include folder for compiler.can you help please
@manofmesopotamia7602
@manofmesopotamia7602 Жыл бұрын
do you think we can use this toolchain on a GUI like diy ide??? I want to make my own arduino like ide using stm32 MCUs😊
@artfulbytes
@artfulbytes Жыл бұрын
Arduino IDE supports STM32, see STM32duino. Or do you want to create your own GUI-based IDE from scratch? Yes, then you could use a GCC-based toolchain as backend, that's what the Arduino IDE is doing as far as I understand.
@manofmesopotamia7602
@manofmesopotamia7602 Жыл бұрын
@@artfulbytes I want to create my own GUI-based IDE from scratch
@BinGanzLieb
@BinGanzLieb 10 ай бұрын
Hello, to add the ability to program microcontrolelr without an IDE, we need debugging without an IDE. Can you make a video about debugging with gdb?
@artfulbytes
@artfulbytes 10 ай бұрын
I usually use the IDE when step-debugging, but I could perhaps make a video about how to do it with gdb from the command-line as well.
@iLuvEngineering
@iLuvEngineering Жыл бұрын
i keep getting an error: MSP430: Error initializing emulator: No USB FET was found. I am using an msp430g2553 on my MacBook air running macOS Monterey. I downloaded the same Ide and you did. I have tried a number of things to solve the problem but I haven't been able to solve it.
@artfulbytes
@artfulbytes Жыл бұрын
Not sure about how good the support is on Mac, I've only used Linux and windows myself. You may have to download separate drivers to get it working. Maybe these www.ti.com/tool/download/MSPDS-USB-DRIVERS/1.0.1.2
@johanliebert2048
@johanliebert2048 Жыл бұрын
Hi. Can you recommend any textbooks or topics for a serious entry? There are a lot of amateur projects on the Internet, but it seems that nothing worthwhile in production will work. And also, at what level is your knowledge of circuit engineering?
@artfulbytes
@artfulbytes Жыл бұрын
Making Embedded Systems is a decent intro to the field. embeddedartistry.com and interrupt.memfault.com/ are good resources. I think the best way to learn is to come up with a project you want to build and let that guide your reading. I consider myself a beginner when it comes to circuit engineering, I can design simpler PCBs, but joining a new role soon where I'm hoping to improve in that area.
@johanliebert2048
@johanliebert2048 Жыл бұрын
@@artfulbytes Would you like to make a video on the top 5 projects for people slightly above beginners in programming? It's just that there are so many videos on KZbin on how to write code for a button or a flashing light, although it wouldn't hurt to have at least one video on how to work with ssd1602 and build some kind of game with this display. Or algorithms of records in nand nor flash memory. All the examples that I found, they are kind of simple, that is, they just write it down from above and that's it.
@artfulbytes
@artfulbytes Жыл бұрын
@@johanliebert2048 Good suggestion, I might make a video like that in the future. Right now, I'm focusing on finishing up the video series. Until then, my advice is to pick a popular arduino project and simply replace the arduino with another 8-bit microcontroller or program the atmega328p on the arduino bare-metal. Note, you may find it demotivating to spend a lot of time programming something that can be thrown together with an Arduino in mere minutes, but you got to start somewhere :)
@johanliebert2048
@johanliebert2048 Жыл бұрын
@@artfulbytes Yes, I will be happy to collect projects on bare metal. It's just that sometimes my projects are not so optimal and it doesn't seem to justify itself. I think a more experienced person like you, if he shows the weak side of arduino or hal libraries, I think it will be more obvious in serious projects.
@artfulbytes
@artfulbytes Жыл бұрын
You will find that the embedded projects you do in your spare time will often not justify themselves and can often be replaced with a prototype hacked together using ready-made components and libraries. It's when you work on professional products in large quantities it truly becomes valuable and even required to incorporate more rigor. So if you want to work on embedded projects on your own, which I think you should to get into this stuff, you have to play a pretend game to some degree :) my sumobot is one big pretend game.
@iLuvEngineering
@iLuvEngineering 7 ай бұрын
Which Linux distro do you use?
@artfulbytes
@artfulbytes 6 ай бұрын
Ubuntu
@RoryIsNotACabbage
@RoryIsNotACabbage Жыл бұрын
Can we still use this method if we're using a microcontroller that needs an sdk?
@artfulbytes
@artfulbytes Жыл бұрын
Yes, but how easy it is to setup from scratch will depend on the complexity of the SDK. But many SDKs come with some minimal examples to build from command line. Any particular SDK+MCU in mind?
@RoryIsNotACabbage
@RoryIsNotACabbage Жыл бұрын
@@artfulbytes Yeah I'm using the TI CC2640R2 with it's namesake SDK. You'll understand my want to get away from CCS but it's more dire than that, I can't get the sdk added to the linux version of CCS so I've had to use a windows VM to connect with the board
@artfulbytes
@artfulbytes Жыл бұрын
@@RoryIsNotACabbage Ah yes that sounds like a hassle 😬
@ashfaquekhan7282
@ashfaquekhan7282 4 ай бұрын
can you make a video to use a Raspberry Pi ARM processor as an Arduino board or MCU board, like running small firmware in it, so the sole purpose of that ARM processor becomes to run single / multiple programs in different cores. I know I am asking a little too much 😅
@artfulbytes
@artfulbytes 4 ай бұрын
Would be an interesting challenge, though I don't see myself doing it in the near future. I think there might be some existing resources on it though, for example just found this github.com/bztsrc/raspi3-tutorial
@ashfaquekhan7282
@ashfaquekhan7282 4 ай бұрын
thanks for replying, your channel really helps a lot, keep up with this great work👍@@artfulbytes
@user-sj9kh4pf7n
@user-sj9kh4pf7n Жыл бұрын
What oscilloscope do you use?
@artfulbytes
@artfulbytes Жыл бұрын
rigol ds1054z
@user-sj9kh4pf7n
@user-sj9kh4pf7n Жыл бұрын
@@artfulbytes thanks a lot)
@user-sj9kh4pf7n
@user-sj9kh4pf7n Жыл бұрын
@@artfulbytes My apologies for one more question) How often did you have to use all four channels in the oscilloscope?
@artfulbytes
@artfulbytes Жыл бұрын
@@user-sj9kh4pf7n For most my use-cases so far I've gotten by with 1-2 channels. I mostly work on digital stuff and use a digital analyzer when I'm just interested in just looking at the data. If you tend to do analog stuff, you may need more channels more often.
@user-sj9kh4pf7n
@user-sj9kh4pf7n Жыл бұрын
​@@artfulbytes thanks again 😊
@johanliebert2048
@johanliebert2048 Жыл бұрын
Wait what.. do I have to write my own linker script? I didn't find the linker script in gcc-arm-none-eabi. Only the linker itself
@artfulbytes
@artfulbytes Жыл бұрын
You need a specific linker script for your microcontroller, but you typically don't have to write one from scratch, because usually the vendor is kind enough to provide one, or you may copy the one from the IDE. Which microcontroller do you have?
@johanliebert2048
@johanliebert2048 Жыл бұрын
@@artfulbytes I just stole startup and .ld from CubeIDE stm32f103c8t6
@artfulbytes
@artfulbytes Жыл бұрын
@@johanliebert2048 You thief 👮
@davidjohnson8199
@davidjohnson8199 3 ай бұрын
Why would you throw away your mouse?
@artfulbytes
@artfulbytes 3 ай бұрын
Pro hacker need no mouse
@user-lq7nw3zh9y
@user-lq7nw3zh9y 5 ай бұрын
oh
@artfulbytes
@artfulbytes 5 ай бұрын
😮
@EEEEMMMMKKKK
@EEEEMMMMKKKK Жыл бұрын
This is a little bit confusing, because you are showing that you downloaded the toolchain files but than you are actually using the files from CCS.... If you download only the toolchain files you wont compile this example.
@EEEEMMMMKKKK
@EEEEMMMMKKKK Жыл бұрын
I figured it out, if you want to compile it without installed CCS you need to download also the "Headers and support files" from the bottom of the page where you downloaded the toolchain.
@artfulbytes
@artfulbytes Жыл бұрын
@@EEEEMMMMKKKK Yes you are completely right, sorry for the confusion! I downloaded the support headers too, but I forgot to show it in this video. I show it in another video though, kzbin.info/www/bejne/mpmUf3l3ftSNeas.
@graflaszlo
@graflaszlo 6 ай бұрын
Man, the topic is great. But the sound is horrible! Did you listen to your video?
@fededevi1985
@fededevi1985 Жыл бұрын
Don't use make in 2022 please, embedded programming is not an excuse. There are much better alternatives nowadays. CMAKE is basically the de-facto standard and most c/c++ stuff is packaged with it. Even embedded toolchains often comes with cmake configurations so you just need to point cmake to the toolchain and you can compile any cmake project with it.
@artfulbytes
@artfulbytes Жыл бұрын
I agree with you when it comes to larger projects, but for simpler ones (10s of files, single platform, and few deps), I still think make has its place.
@fededevi1985
@fededevi1985 Жыл бұрын
I did not see the last part of the video where you taked about cmake, classic youtube comment :D... But I respectfully disagree, probably I would go for cmake even for a single file.. there are so many advantages and no disadvantages over make except the added abstraction layer probably. Make have an educational value tho, especially regarding compiler/linker flags.
@hon2468
@hon2468 Жыл бұрын
Thank you for this amazing video! Your videos have provided a lot of insight for many embedded system beginners like me! I really appreciate it! Just one question regarding software debugging. Is there any way to debug our program in vim environment (such as breakpoints, variable and expression windows, etc.)? I would like to try embedded software development without IDE but I have trouble debugging my code.🥲
@artfulbytes
@artfulbytes Жыл бұрын
Thank you! When it comes to tasks like step-debugging that's usually when I fallback to the IDE. The debugger gdb, is available as part of the toolchain and you can run that from command-line if you want (and there might even be a plugin to integrate with vim), but I prefer an IDE for this. But I agree it's a little hassle having to switch between them.
@johanliebert2048
@johanliebert2048 Жыл бұрын
I don't know what's wrong, but unfortunately I couldn't manage more than one file with stm32. The code is compiled. Then I make an object file out of it via objcopy but nothing further. After firmware nothing happens 1. arm-none-eabi-gcc -DSTM32F103xB -mthumb -mcpu=cortex-m3 -T /utils/STM32F103C8TX_FLASH.ld -I /headers/ -I /lib_inc/ --specs=nosys.specs -o main.elf main.c /lib_src/usart.c startup_stm32f103c8tx.s 2. arm-none-eabi-objcopy -O binary main.elf main.bin 3. st-flash write main.bin 0x08000000 The code itself is correct, since when transferred unchanged to stm32cubeide, everything is stitched correctly.
@artfulbytes
@artfulbytes Жыл бұрын
So the same command works when you exclude usart.c? Can you compare with the command that stm32idecube runs? Maybe it's shown in the console of the IDE? You could also try to compare the elf that stm32idecube outputs using "readelf". I don't immediately see anything wrong with your command.
@johanliebert2048
@johanliebert2048 Жыл бұрын
@@artfulbytes cubeide makes a lot of flags and it's not even clear which ones are superfluous. Yes, when I exclude usart and compile exclusively main.c with its header and all the other things that are listed above, everything is even flashed without problems. After work, I'll try to transfer the necessary piece of code directly to main.c and try to flash it.
@johanliebert2048
@johanliebert2048 Жыл бұрын
@@artfulbytes Well, I found out that my code doesn't work for some reason. ALTHOUGH if you flash through stm32cubeide everything works.
@artfulbytes
@artfulbytes Жыл бұрын
@@johanliebert2048 It doesn't work after you moved the usart code into the main.c file so you have a single file? What is your code doing?
@johanliebert2048
@johanliebert2048 Жыл бұрын
finally I CAN... arm-none-eabi-gcc -DSTM32F103xB -mthumb -mcpu=cortex-m3 -T /root/embedded/utils/STM32F103C8TX_FLASH.ld -I /root/embedded/utils/ -Wl,--gc-sections --specs=nosys.specs -o main.elf main.c startup_stm32f103c8tx.s
Nastya and SeanDoesMagic
00:16
Nastya
Рет қаралды 20 МЛН
Sigma Kid Hair #funny #sigma #comedy
00:33
CRAZY GREAPA
Рет қаралды 33 МЛН
🤔Какой Орган самый длинный ? #shorts
00:42
Microcontroller Interrupts | Embedded System Project Series #17
54:40
Makefiles: 95% of what you need to know
1:01:53
Gabriel Parmer
Рет қаралды 116 М.
How to Code a State Machine | Embedded System Project Series #26
1:03:01
How I program GPIOs in C | Embedded System Project Series #12
30:00
#0 Modern Embedded Systems Programming: Getting Started
11:54
Quantum Leaps, LLC
Рет қаралды 97 М.
Extracting Firmware from Embedded Devices (SPI NOR Flash) ⚡
18:41
Flashback Team
Рет қаралды 558 М.
Как бесплатно замутить iphone 15 pro max
0:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 4,5 МЛН
Самый тонкий смартфон в мире!
0:55
Не шарю!
Рет қаралды 175 М.
Сколько реально стоит ПК Величайшего?
0:37
НОВЫЕ ФЕЙК iPHONE 🤯 #iphone
0:37
ALSER kz
Рет қаралды 97 М.
АЙФОН 20 С ФУНКЦИЕЙ ВИДЕНИЯ ОГНЯ
0:59
КиноХост
Рет қаралды 1,1 МЛН
Телефон-електрошокер
0:43
RICARDO 2.0
Рет қаралды 1,3 МЛН