Beaglebone: GPIO Programming on ARM Embedded Linux

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ก.ย. 2024
  • Note: This video was made before the Linux device tree was implemented on the beaglebone (beaglebone black uses Linux 3.8.11). I have a new video coming in a few days that explains how to do the same thing on the beaglebone black using device tree overlays.
    In this video I extend my series on introducing the Beaglebone and developing applications using embedded Linux to demonstrate how we can build an application that uses its GPIOs (General Purpose Input/Outputs). The example demonstrates a simple LED output circuit and a simple pushbutton input circuit that we can connect to the Beaglebone GPIOs directly. I then go through the steps on how we can configure and access these GPIOs using Sysfs in embedded linux and then demonstrate how we can write a C/C++ program that works directly with these pins. Finally I demonstrate how we can use polling to wait for a GPIO input such as a button press or key press. This application is relevant to all flavours of embedded Linux.
    The code that the final application is based on is available at: www.ridgerun.c....
    The source code in this video is available through githhub: git clone git://github.com/derekmolloy/beaglebone
    The 4,500 page document that I mention 15 minutes in is available for download from Texas Instruments' Website. It is called "AM335x ARM(r) Cortex(TM)-A8 Microprocessors(MPUs)". The version I have is "Literature Number: SPRUH73C" from Oct'11(revised Dec'11).
    
    If you use this video in your research, please cite:
    Molloy, D. [DerekMolloyDCU]. (2012, May, 3). Beaglebone: GPIO Programming on ARM Embedded Linux [Video file]. Retrieved from www.youtube.com....
    Please find more information on these videos at: www.derekmolloy...

ความคิดเห็น • 77

  • @googiwaumer
    @googiwaumer 11 ปีที่แล้ว

    Many thanks! VERY rare to see hardware tutorials this complete, cogent, and well presented. Terrifically informative. Take VERY GOOD CARE of yourself Mr. Molloy -- we need you!

  • @TomBennettMagic
    @TomBennettMagic 10 ปีที่แล้ว +1

    Amazing Tutorial, now I have a good understanding how hardware access in linux is done

  • @AuctorisVideo
    @AuctorisVideo 12 ปีที่แล้ว

    Another great video Derek: very clear explanation of how to get BeagleBone working with GPIO. Thanks very much for sharing!

  • @austinmcelroy8035
    @austinmcelroy8035 12 ปีที่แล้ว

    Outstanding video! Thank you so much for posting a comprehensive video that goes into the Linux shell commands and explaining how they tie into the C/C++ code. Well done!

  • @bhrtom
    @bhrtom 12 ปีที่แล้ว

    This is one of the best and most useful videos I have ever seen on youtube !!!
    I would like to see more tutorials about how to work with peripherals with Linux.
    Keep it going on !

  • @teuluPaul
    @teuluPaul 12 ปีที่แล้ว

    Great video Derek - thanks. For those following, the documentation mentioned at 15:27 is the technical reference manual (4500 pages!) about the processor, available for download from Ti.

  • @MrNiceone99
    @MrNiceone99 8 ปีที่แล้ว

    One of the best educational channel in TH-cam :) Cheers from Sri Lanka :) Thank you :)

  • @christopherve7alb
    @christopherve7alb 12 ปีที่แล้ว

    Awesome Video! Got me up and running with the I/O pins on the BeagleBone!

  • @cemerdogan7955
    @cemerdogan7955 11 ปีที่แล้ว

    awesome Derek, videos are very educational. i thank you for your effort.

  • @bsulli
    @bsulli 11 ปีที่แล้ว

    Hi Tony, In addition to what Derek said, there are also courses dedicated to this kind of thing. I'm currently studying a double degree in Mechatronic Engineering and Software Engineering and that covers all your bases when it comes to these topics.

  • @2011supra
    @2011supra 11 ปีที่แล้ว

    Excellent! I will wait for Next-gen BeagleBone.

  • @michaelpowell1308
    @michaelpowell1308 9 ปีที่แล้ว

    definitely want to digest this one. in the *nix vocabulary (or, grammar, if you will), 'everything is a file', or more appropriately, 'everything is a file descriptor'. this is definitely no exception. just a 'simple' matter of getting acclimated to the environment you're working with, I/O, mappings, etc. thank you...

  • @markusmuller279
    @markusmuller279 11 ปีที่แล้ว

    Thanks for these great videos!!!
    Can't find anything that usefull in the net

  • @DerekMolloyatDCU
    @DerekMolloyatDCU  11 ปีที่แล้ว

    Hi Tony, that is a difficulty question and one that you will only solve by reading the list of modules that are available on each programme. If you see modules like "embedded systems", "computer architectures" and "digital electronics" etc. then it will likely cover both. My experience is that "electrical engineering" & "computer science" programmes don't typically cover the hw/sw integration well, whereas "electronic engineering" & "computer applications" courses do. Check individual modules!

  • @DerekMolloyatDCU
    @DerekMolloyatDCU  11 ปีที่แล้ว

    Thanks Jacob. I will have a new video out shortly that will redo this video for linux 3.8+ which uses the device tree model and means that TI no longer use the omap_mux. It's only slightly more complicated using device tree overlays - I just need a few days to put the video together.

  • @AndrewMontag
    @AndrewMontag 12 ปีที่แล้ว

    Firstly, thank you for this comprehensive video, it has helped me a great deal, and from what I found was one of very few knowledge sources on this topic.
    Secondly, I have done a bit of work using the beaglebone gpio's and would like to share.
    Check out github gist for gist number 4013192 (since it appears youtube does not allow urls in the comments?)
    This is a program that listens for a button press and measures the duration of the press. Enjoy!

  • @DerekMolloyatDCU
    @DerekMolloyatDCU  11 ปีที่แล้ว

    Hi Peter - I am far from a Guru! I'm just someone who is interested in the board and spreading the word... I'm getting closer to understanding the device tree model and hope to make a video soon to explain the changes, which are as a result of changes to the Linux kernel and not specific to the BB or BBB. It's just a pity that such a radical change to the kernel has happened at the same time as the release of the BBB. You can go back to an older kernel/distribution for the moment.

  • @AsHxxxxAsH
    @AsHxxxxAsH 12 ปีที่แล้ว

    Thanks foe the quick response, i was going over the tutorials in order and I did not notice that you implemented the pin muxing function in the I2C video.. I
    It will be great if you can get a UART video for C/C++, all the examples online uses Python and I am planning to force my self to stay with C/C++

  • @juanpablozerda1639
    @juanpablozerda1639 11 ปีที่แล้ว

    It's a pull-up resistor. When you dont press the switch, the input is left unconnected. To avoid that, the pin is connected to Vcc through a a resistor

  • @KelvinLeUT
    @KelvinLeUT 12 ปีที่แล้ว

    Thank you! keep posting videos!

  • @smartwerker
    @smartwerker 11 ปีที่แล้ว

    computer engineering is a subset of electrical engineering. The first computer engineers were electrical engineers. Most schools separate the disciplines, but in some schools the discipline is combined. UC Berkeley uses the "computer and electrical engineering" format (or did). Additionally, for computer science when you pull out a multimeter all bets are off. Many computer scientists get specs of the hardware to program for and never touch the hardware in any capacity.

  • @gentux
    @gentux 11 ปีที่แล้ว

    I'm using the BeagleBone Black, I don't know if is too late for this but I had the same problem, I'm using Linux Arch so I thought that was the problem but apperently isn't. Now, you'll find the leds in /sys/class/leds/beaglebone:gree:usrX/brightness to on/off your user leds and the GPIOs are on /sys/class/gpio but you have to create the device first (like waking up them) try this "echo 60 | tee /sys/class/gpio/export" with that you create the gpio 60. I hope it is still useful for someone.

  • @rickpontificates3406
    @rickpontificates3406 2 ปีที่แล้ว

    Your schematic shows an NPN transistor and I see it's a gen purpose 2n2222, so you've wired E and C of the transistor backwards as the pin on the right (in the breadboard orientation you show) is the collector (output) and the pin on the left is the emitter (ground), with the base in the center (as you correctly have).

  • @RicardoCalderon821
    @RicardoCalderon821 10 ปีที่แล้ว

    Thank you this videos! They are very helpful for us trying to work their way from MCUs to embedded computers. Do you think you might include a video about the PRU-ICCS? There aren't many resources available about it.

  • @wootdafuq
    @wootdafuq 11 ปีที่แล้ว

    It was my mistake, I had already testet with both types of the bb (black and white). But there isn't a big diffrence between the timings of the toggling GPIO-Pin. I have read that there is another way to access the GPIOs. It's called memory mapping and should increase the speed to 5MHz (0,2µs). But without a tutorial by Derek it'll be hard for me to program this 'cause I'm new to C/C++, Linux, Arm and everything else around the beaglebone :'-D

  • @qzorn4440
    @qzorn4440 ปีที่แล้ว

    Wow these are wonderful engineering videos. I wish Mr. Derek Molloy would make some DIY GPIO PWM I2C videos on the: Amazon $149.99 Orange Pi 5 16GB uses Rockchip RK3588S new generation 8-core 64-bit processor, quad-core A76+quad-core A55, with 8nm process design, up to 2.4GHz main frequency, integrated ARM Mali-G610 GPU, embedded high-performance 3D/2D image acceleration module, built-in NPU with 6Tops computing power. The OPi5 needs videos like the Beaglebone SBC instructions. 😎 Best regards and thank you.

  • @terachip
    @terachip 6 ปีที่แล้ว +4

    Any chance of this video getting a refresher based on Debian Stretch, the new kernel, and the config-pin utility?

  • @haynzieboy
    @haynzieboy 11 ปีที่แล้ว

    great stuff cheers!

  • @majidwisam
    @majidwisam 12 ปีที่แล้ว

    Excellent. thanks

  • @AmolMahurkar
    @AmolMahurkar 12 ปีที่แล้ว

    Thanks.. I 'll try dat out...

  • @KynikossDragonn
    @KynikossDragonn 12 ปีที่แล้ว

    Nice video. Thanks.

  • @thomasandrews1074
    @thomasandrews1074 10 ปีที่แล้ว

    Absolutely awesome tutorials Derek! Just one "FYI" - ubuntu is pronounced "ooboontoo" rather than "youbuntoo". Just thought you might like to know ;)

  • @roxa8651
    @roxa8651 12 ปีที่แล้ว

    Thank you for a really good and educating video!
    If you have the knowledge, could you show how to implement UART communication in C on the beaglebone? I am looking forward for the next video!

  • @DerekMolloyatDCU
    @DerekMolloyatDCU  11 ปีที่แล้ว

    Interesting you should say that - I only noticed the same thing at the weekend when I built my own Angstrom distribution - I thought that I had set something wrong in building the kernel. I even tried mounting debugfs using "mount -t debugfs none /sys/kernel/debug". An early read suggests /sys/kernel/debug/ is gone from debugfs in recent Linux kernel releases! The question has to be what is the replacement?

  • @milanjayatilaka
    @milanjayatilaka 11 ปีที่แล้ว

    Hey Jacob, I too was looking for more information on the pin mux. While waiting for Prof. Molloy's video (which I eagerly await too), you might want to check out Jason Kridner's (jadonk) gihub page, under the validation-scripts repository. The readme gives a comprehensive overview of Device Tree Overlays in the context of the BBB. I tried them out on Angstrom though. Not too sure about Ubuntu.

  • @jacobstockton4793
    @jacobstockton4793 11 ปีที่แล้ว

    Derek, great job with the videos! I find them extremely informative, and I especially like your presentation. One question, these videos jump right into an ubuntu installation of linux, but none of your tutorials outline where to get said installation. As Haris S. pointed out, the newest install of angstrom has no omap_mux. I was wondering if you could point me toward installation instructions and the specific version of ubuntu so I can recover the functionality shown in your videos. Thanks!

  • @rodstartube
    @rodstartube 12 ปีที่แล้ว

    hello, can you do an example using interrupts on any edge detect on 2 pins? (so I can program a quadrature-encoder reader [decoder]) or, if you can't, a few tips so i can investigate... your tuts have opened my eyes into this plattform, thx! priceless

  • @AmolMahurkar
    @AmolMahurkar 12 ปีที่แล้ว

    You just made BeagleBone (BB) more simpler to use... :) .. thankyou... I have one question in mind.. Now after copying executable file X in BB.. now if I want to use BB as standalone (without having PC interface) .. how can I run that file X (as standalone)... just as the non-OS controllers do.. like AVR..

  • @dandy4547
    @dandy4547 11 ปีที่แล้ว

    Derek, I have a doubt.... why did you change what we were using last time (fopen, fwrite, etc...) to these other open, write.... are these libraries better??
    in the other form we didnt have to include unistd.h and fcntl.h .... thank you very much... and great videos!

  • @juanpablozerda1639
    @juanpablozerda1639 11 ปีที่แล้ว

    If I were you, I would have a look to ARM335 datasheet, and check if there is any pin with your requirements. Perhaps you need beaglebone black, which has a faster processor

  • @AsHxxxxAsH
    @AsHxxxxAsH 12 ปีที่แล้ว

    Great video!!! Is there any reason you did not implement the pin muxing in the C app?

  • @2011supra
    @2011supra 11 ปีที่แล้ว

    When I get new Next-gen BeagleBone. I will work on c++.

  • @0redthunder0
    @0redthunder0 11 ปีที่แล้ว

    Hi Derek, awesome videos, instead of writing the hexadecimal value to set whether a pin is an input or output, could echo in to the direction, like when you set a pin as an output? Cheers,

  • @michaelpowell1308
    @michaelpowell1308 9 ปีที่แล้ว

    I did watch the C++ / Eclipse video. good stuff, will keep in mind for future reference. I've also gone 'hardcore' and subscribed to Sourcery CodeBench, which I take it is a commercialized Eclipse / C++ IDE. probably could do the same and 'only' use the open source, for that matter, now that I think about it and am more comfortable. that said... isn't there a better way to build, deploy, and debug? I seem to remember being able to do this through Sourcery, at any rate. beyond the scope of this video subject, per se...

  • @siddhiq74
    @siddhiq74 12 ปีที่แล้ว

    Very good Tutorial. Do you have the gpio header /cpp?
    Siddhiq

  • @FaramirEowyn
    @FaramirEowyn 12 ปีที่แล้ว

    Your videos are literally idiot proof, which is why they're perfect for me!

  • @jaimeramirez5506
    @jaimeramirez5506 10 ปีที่แล้ว

    Dr. Molloy:
    I was able to run the first 3 videos with no major problem, Do you have a sample on how to read the analog inputs and serial ports on C++ for Angstrom V2012.12?
    Best Regards
    Jaime

  • @rodstartube
    @rodstartube 12 ปีที่แล้ว

    hello, can you do an example using interrupts on any edge detect on 2 pins?

  • @iKPavan
    @iKPavan ปีที่แล้ว

    Hi, we are working on a project where we are trying to read the push button as input and turn on a LED. We are trying to reference the code, however, the link that was shared in the description is not available. Could you please share the updated link and also any references of the same code available in 'C' language? @Derek Molly

  • @microkle8309
    @microkle8309 12 ปีที่แล้ว

    I have noticed you used an external pull-up for the button.
    does the beaglebone have an internal pull-up mode?

  • @sinefinehabitarevolo
    @sinefinehabitarevolo 11 ปีที่แล้ว

    Hello, I'm a aspiring EE student and I was curious about one thing. At 3:40, when you are showing the schematics to your circuit, why do you have to put 10k ohm resistor? How do you know when to put resistors like that or is it just basic application rule?

  • @NGinuity
    @NGinuity 11 ปีที่แล้ว

    Is there a way to interact with the GPIO without using the abstraction of the BeagleBone? As in, could you talk to pins with their direct address or does that cause problems?

  • @microkle8309
    @microkle8309 12 ปีที่แล้ว

    have you try to pull up one of the gpio as an input?
    i having problem with that (Operation not permitted)
    do you know how to change OMAP_PIN_OUTPUT_PULLUP to OMAP_PIN_INPUT_PULLUP?

  • @fxuchun
    @fxuchun 11 ปีที่แล้ว

    Not possible to talk to the pins directly. Because the Linux OS provides an abstraction layer called file system. Any thing you do must interact with this layer, instead directly with the hardware layer.

  • @maksimhazardous4225
    @maksimhazardous4225 10 ปีที่แล้ว

    Hello Derek. I'm a newbie with linux. Nice lessons and very helpful. I have a few questions: can I use eclipse Kepler instead of indigo? Can I use your developed methodology for working with Beaglebone apply to another board, say imx287?

    • @onepredator
      @onepredator 10 ปีที่แล้ว

      This user hasn't been here lately... I wonder if he might have other stuff or contact info he uses more often for questions like twitter...

    • @bluehornet6752
      @bluehornet6752 10 ปีที่แล้ว

      For anyone reading this now (July 2014), yes...you can use Kepler. The newer versions of Eclipse now seem to include the remote system explorer (RSE) right out of the box, so you don't need to do that installation. Also, if you get Eclipse CDT, you'll also get the C/C++ development environment straightaway.
      I am using Eclipse Juno on 64-bit Ubuntu, and other than installing Hover Help (which didn't seem to be installed by default for some reason), I didn't have to do anything special.

  • @SlappyMcK
    @SlappyMcK 12 ปีที่แล้ว

    How did you figure how to set the mode of gpmc_ben1? I understand that cat gpmc_ben1 displays the contents of the file gpmc_ben1, but the contents of the file itself don't seem to provide any hints... I'm utterly perplexed by the lack of instruction on how to make use of the various pins!

  • @wootdafuq
    @wootdafuq 11 ปีที่แล้ว

    Hi Derek, I followed your instructions to set up the dev. environment and programming the gpio's. It works but it seems that the GPIO's are too slow. I just let 1 GPIO Pin toggling all the time and measure the time with an oscilloscope. It needs 135µs to set the Pin from 0 to 1 and 1 to 0. The Problem is that I need it to do this in 25µs...-.-. So is there a faster way to access GPIO Pins?

  • @mickavelimckenzy3689
    @mickavelimckenzy3689 9 ปีที่แล้ว

    I dont know what i am doing wrong but the omax mux folder is missing on my bbb. Anyone came across this??

  • @kishensomeshwar4905
    @kishensomeshwar4905 10 ปีที่แล้ว

    Which image are you using on your beaglebone is it angstrom or debian or something else. I currently have an ubuntu image installed. Is it good enough or is angstrom necessary?

  • @PCPointerDE
    @PCPointerDE 8 ปีที่แล้ว

    Whats the difference between the first and the second part of this video? I have been working for 1 year with Arduino and the basic IDE. But you are working directly with the linux console. And in the second part you are working without a BeagleBone Black lib like "Blacklib". Whats the difference between the a lib like "Blacklib" and your code only with the basic iostream, string and stdio lib? Thanks!

    • @bluehornet6752
      @bluehornet6752 6 ปีที่แล้ว

      In the first instance he's using the shell built-in commands like "echo" and "cat" to do operations on files directly from the command line interface (CLI), while in the second case he's using standard C library calls like fopen() and fwrite() do to the same things from inside his program written in the C language. It's just easier to use the C standard library to do file operations, when you're running a program written in C or C++.
      Since both the Beaglebone and the Beaglebone Black (and the Raspberry Pi for that matter) are running Linux, you can just manipulate the "files" (pretty much everything in Linux is a file) directly from the CLI using shell built-in commands. And you could write a shell script to do this stuff automatically, without having to manually enter each command separately on the command line. But then it wouldn't have the execution speed of an application written in C or C++, so that's when you write an application using C or C++.
      If you haven't gotten it already (since you posted a year ago), you should get one of Derek's books. He has a book both on the RPi and the BBB devices--and he goes into significant details on using shell scripts, as well as doing similar things with Python, Java, JavaScript and of course C/C++. They are pretty much the definitive reference(s) for using those boards.

  • @jacobstockton4793
    @jacobstockton4793 11 ปีที่แล้ว

    My permissions are denied for changing the LED brightness property. Any ideas?

  • @ShravankumarMalagihal
    @ShravankumarMalagihal 10 ปีที่แล้ว

    how to change mode value of mcasp0_ahclkx in armstrong os because i am not finding omap_mux directory.

  • @peterpohlmann7946
    @peterpohlmann7946 11 ปีที่แล้ว

    Dear Guru, if you don't know , how should we know ?

  • @abdallahal-dalleh6453
    @abdallahal-dalleh6453 8 ปีที่แล้ว

    I can't apply this video on my BeagleBone Green as I can't find the omap_mux directory. Any help?

    • @bluehornet6752
      @bluehornet6752 6 ปีที่แล้ว

      They've long-since changed the sysfs file structure on those devices, as I recall. Ever since the Beaglebone Black came out, they've done things a bit differently in terms of paths to files and such. They are still using the sysfs theme as far as I know, it's just that the hardware mappings are different. So there isn't an omap_mux directly in the OS any longer, and that's why you saw that error.

  • @VENUEATHENS
    @VENUEATHENS 11 ปีที่แล้ว

    Hi is this considered computer engineering or electrical? I'm considering majoring in computer engineering, because I am interested in both the hardware/software of electronics... I am just doing some research before becoming committed to a program. Would anyone like to offer any helpful feedback or advice? Thanks =]

  • @cdtelting
    @cdtelting 12 ปีที่แล้ว

    I can't believe the IO interface. It really needs a proper driver.

  • @aah134-K
    @aah134-K 11 ปีที่แล้ว

    and because they get more programming classes

  • @RyeonLok
    @RyeonLok 7 ปีที่แล้ว

    I am lost...

  • @peterpohlmann7946
    @peterpohlmann7946 11 ปีที่แล้ว

    I have not even seen any documentation on Beaglebone BLACK . Documentation needs more work.

  • @smartwerker
    @smartwerker 11 ปีที่แล้ว

    computer engineering... my answer to you.

  • @Omer60Faruk
    @Omer60Faruk 10 ปีที่แล้ว

    yok artık