Accessing GPIO Pins on Linux Embedded Running on a Raspberry Pi 3 - embedded-linux

I am trying to currently make a c program that will make a light blink on a Raspberry Pi 3 with embedded linux installed. I am currently building the image for the OS using yocto, poky with the raspberry pi 3 and open embedded. The OS installs on the SD card and I can have managed to add the layer that runs applications and have made a simple hello world. I am now trying to access the GPIO pins but having trouble with this.

There are lot of resources that talk about blink LED on Raspberry.
Check here, here, here, or here
Your question is related to Yocto, because once you constructed the image and boot it correctly, you just need to know how to develop a userspace example to control your desired GPIO.
NOTES:
You may encounter that GPIO is not exported in userspace, so check this answer.

Related

How can I interface graphical lcd with raspberry pi with yocto build image

I am newbie to yocto world, learning and trying to develop small projects.
I want to interface graphical lcd with raspberry pi 3, what interface should I use?
I have build a yocto image for raspberry pi and running on it.
What changes do I need to make in yocto image to display something on glcd.
To begin with, you will have to read the specification of the lcd you have chosen. This way you will be able to see if it is LVDS, RGB, etc as well as calculate the timings according to your requirements so that the display works as expected. Here is some information.
Once you have that background you need to know about how Linux displays images, I leave you another resource here. Basically you have to add the previously collected information to the kernel driver that manages the KMS interface (Kernel Mode Setting, part of the Direct Rendering Manager (DRM) interface.
It will also be important that you supply the kernel with the desired display resolution, among other things, in the kernel argument line.

Flashing ESP32's memory without installing the whole IDF?

Problem
I'm looking for a way to flash an ESP32 module's memory without installing the whole IDF software suite.
Why
Because I want to integrate ESP32 onto a custom board along with a low-performance ARM-powered CPU which runs a tiny Linux distro (based on Debian), and I want to flash ESP32 from this tiny Linux distro.
I know I could use the bootloader, but who will upload the initial bootloader? I don't want to do extra steps, so my idea is to embed the ESP32 module onto my custom board, and let the Linux to flash it from factory-state (when it's flash is empty, ie. no preloaded bootloader). Or is the serial bootloader always preinstalled on all ESP32 modules (like on ESP-WROOM-32)?
Why I don't want to use IDF? Because I don't want to build or debug anything, I just want to flash myprogram.bin onto ESP32. Also, as the board is low-performance, it would take ages to download everything for running IDF.
Current state
The ESP32 module is now visible via UART (RX,TX,GND), and if I held low the GPIO0, it runs the bootloader (my current module is embedded onto a NodeMCU - but there is no USB connected, this is raw UART!):
rst:0x1 (POWERON_RESET),boot:0x3 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
waiting for download
Could I expect the same behavior (controlling GPIO0 for running the bootloader) for all ESP32 modules, or this works just because guys at NodeMCU preprogrammed already some bootloader onto it?
I'm looking for a way to flash this ESP32 preferrably without any python script.
The ESP32 has a first-stage bootloader in ROM capable of writing to Flash - that's what's printing your output. You can talk to it if you know the protocol - this is implemented by the Python scripts in ESP IDF. If you don't want to use the official implementation because it's too heavy, you'll have to write your own implementation of this protocol which scratches your specific itch. Fortunately it's more or less documented and you can likely reverse engineer any missing knowledge from official Python scripts.
Actually Espressif also provides a nice and small binary for flashing ESPs:
https://github.com/espressif/esp-serial-flasher
Serial flasher component provides portable library for flashing Espressif SoCs (ESP32, ESP32-S2, ESP8266) from other host microcontroller. Espressif SoCs are normally programmed via serial interface (UART). Port layer for given host microcontroller has to be implemented, if not available.
One more (but very important) addition:
You have to modify this repo to make it work correctly, and also you might have to upload not just your binary, but also bootloader and partition_table.

Using Shields with Raspberry Pi 2

I want to use an RPI2 for SMS messaging. I got a Raspberry Pi Itead SIM800 GSM/GPRS V2 Link Here
Where do I begin using shields? Is it as simple as setting the shield into the pins on the RPI2? Do I have to program the GPIO pins in some manner?
Yep, you pop it on to your Raspberry Pi 2, and you communicate with it via serial interface, like you'd normally do. An example can be found here. Very informative article with useful links on how to set-up the software part of your Raspberry Pi can be found here. You have to use the AT commands described in the manual linked at the bottom of the page you mention in your question. GPIO is not really required unless you want to power-on/power-off or reset your add-on programmatically.
I got mine yesterday in the mail, and got the basics working just in a few hours.

controlling hub power from linux shell

I am using a buildroot image (3.12 kernel) running on my raspberry Pi with a USB LED light connected to it and I want to control on/off through the CLI.
I went through this. However, there is no control or level file in the power folder.
Is there any kernel configuration that I have to enable to get this ?
Found the answer to this. I have to enable PM_SUSPEND in the kernel configuration to get the class files. But then, as mentioned in the comments, RaspberryPi has the power lines directly connected to the power rails

raspberry pi : writing Linux device driver

I have some basics knowledge on Linux (RHEL 5.4) Device Driver and Kernel internals and wish to gain expertise on same. I came to know of raspberry pi board.
My question is that the same code that I write on a Linux server will work there - is their architecture and concepts same. Kindly note that if it is not the same case then I need to buy a desktop PC otherwise for offline practicing purpose.
Note - I was unable to add raspberry pi group hence needed to remove the same and add the below ones.
Yes it depends on Architecture and the same code compiled on x86 will not wrok on Pi. However, there are ways to get around it.
As mentioned in the above post, use a cross compile toolchain(that comes with its own libc) to comile your code (kernel/userspace) to try it out on R pi. Again doing this, you will still not be able to test your code. To do that get a VM tool like qemu. I am not sure if there is a qemu port for R pi but in general a ARM 11 (ARMv6) based qemu should do. The following link should get you going with initial kernel development on your PC without owning a R pi.
http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/
Cheers
Subbu
Is their architecture and concepts same??
I would like to clarify that Rasperry Pi is ARM based board. Mostly I guess your server is running on X86.
Device drivers meant for devices. Rasperry Pi should have the device which you are writing driver for.
I suggest you to study the data sheet of rasperry pi and linux driver model.
Linux driver model is architexture independent only. so you need only some effort for porting your X86 driver to ARM. You need to concentrate on hardware part.
You might need to cross compile your code for ARM arch. if you are using x86 machine on your Linux Server.You can cross compile your modules for ARM using GNU ARM toolchain and then run on Raspberry pi.

Resources