Workshop at PyConf Hyderabad, Report
The "Embedded Linux Device Interfacing using Python Workshop", was held on October 7, in Hyderabad as a part of Python Conference organized by Hyderabad Python User Group at IIIT Hyderabad. The workshop was done using our in-house hardware: ZKit-ARM-VF51 and DietIO. The ZKit-ARM-VF51 is the baseboard, powered by a Vybrid VF5xx SoC. The DietIO is the add-on board, that has variety of devices for teaching and learning embedded systems and device drivers.
The Training Team
The training team consisted of Ashok Kumar, Babu, Deepak, Joses Paul, Raashid, Vijay Kumar (in alphabetical order).
Workshop
About 55 people from various colleges & organizations, attended the workshop.
Session 1: Linux in Embedded Systems
The workshop started with a discussion about what Embedded Linux was really all about. Deepak gave an demystifying introduction to Linux in embedded systems, and how to use an Embedded Linux system. Then we discussed about various Embedded Software Models, pros and cons in each such models followed by which we had a quick discussion about when & when not to use Linux in embedded systems.
Then Deepak moved on to explain the Base Board, DietIO (Add-on Board) and Peripheral details in the Embedded Linux Device (ZKit-ARM-VF51) given to attendees for hands-on. Before wrapping up the session, everyone tried connecting to the board, through the USB serial interface and booted into Linux in the target board.
Session 2: Introduction to Devices & Drivers
The core of this session was about Device interfacing. Vijay started off by explaining how CPU talks to devices using Memory Mapped IO and how USB mouse / keyboard talks to the CPU using Controller Based IO. This was then followed by an introduction to drivers in Linux, where Vijay showed off the power of file abstraction in Linux (Everything is a file, in Linux).
Vijay then explained how device files works, major number, minor number and how the kernel uses these numbers to associate and invoke the respective driver required by the device. Vijay then demonstrated how to capture inputs of mouse events using a python script. For the finale he showed how to build an one line audio player, which was just by writing the audio data to the audio device file.
Session 3: I2C
Now that the basics of devices and drivers were covered, it was time to get started with accessing devices. Babu gave an insight on the I2C protocol and demystified it by comparing it to REST API transactions. Babu explained the device files associated with I2C in Linux. He then went on to describe the I2C controller and how it is used to connect I2C devices. Babu then demonstrated how an accelerometer can be accessed from the target device. The participants where then given a try-out to access the I2C 4-way joystick, by writing a simple Python script.
Session 4: SysFS
Raashid started off this session by explaining the purpose of sysfs. He debriefed the need to access kernel data from system programs with /proc and how it is used to obtain information about system processes running in the system. He emphasized the necessity to export hardware information and eventually explained the need for sysfs, an in-memory file system that exports information from kernel-space to user-space. Raashid explained the sysfs’ one-item per file rule, and showed how it differs from /dev and /proc. To make sysfs simpler he referenced it to the Windows’ Device Manager. Later, He showed the sorcery of sysfs by turning on & off Wireless Devices – WiFi & Bluetooth using rfkill switch via sysfs by invoking a single line command form the command line.
Session 5: GPIO
Vijay explained the concepts of Digital High and Low and explained how sensors with binary output can be interfaced to the device. Then, he described how AC appliance can be turned on / off based on input using Relays. Vijay then illustrated the GPIO controller, which is a hardware which provides register interface using which the pin status can be accessed. He also discussed various terminologies associated with GPIO such as Direction, Ports, Pins, GPIO Numbering in Linux. Vijay showed how GPIO interfaces can be accessed from user space applications through sysfs. At the end of the session, participants tried controlling an RGB LED and read input from key on the target board using Python Scripts.
Session 6: ADC
The Last Session was about interfacing Analog Sensors. Babu introduced ADC and its sysfs interface. He also explained how an Analog signal can be converted into digital. Babu explained the ADC channels present in the target board followed by which a Hands-on was given to access the Potentiometer and Light Sensor which was available in the DietIO (add-on board) using python Script.
Photo Credits: PyConf Hyderabad
Thanks
We would like to thank all the participants and participating organizations, for all the enthusiasm. Stay tuned, for more exciting workshops, you can sign-up on our enquiry page, to get notifications about upcoming workshops.