0% found this document useful (0 votes)
39 views10 pages

Linux Commands and Raspberry Pi GPIO Guide

The document contains a series of review questions related to Linux commands, Raspberry Pi GPIO, I²C, and SPI communication protocols. It covers topics such as command usage, device configuration, communication methods, and programming tasks. The questions are designed to test knowledge on both theoretical concepts and practical applications in embedded systems.

Uploaded by

trunggaace
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views10 pages

Linux Commands and Raspberry Pi GPIO Guide

The document contains a series of review questions related to Linux commands, Raspberry Pi GPIO, I²C, and SPI communication protocols. It covers topics such as command usage, device configuration, communication methods, and programming tasks. The questions are designed to test knowledge on both theoretical concepts and practical applications in embedded systems.

Uploaded by

trunggaace
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Review questions

1. Which command is used to list all files and directories in the current directory?

A. ls
B. pwd
C. cd
D. mv

2. What does the pwd command do?

A. Prints working devices


B. Prints working directory
C. Changes directory
D. Deletes files

3. Which command is used to change the current directory?

A. ls
B. pwd
C. cd
D. rm

4. Which command is used to display the contents of a text file?

A. ls
B. cat
C. rm
D. cd

5. What does mkdir do?

A. Make a new file


B. Delete a file
C. Create a new directory
D. Change permissions

6. Which command is used to rename or move a file?

A. mv
B. cp
C. rn
D. rm
7. What command is used to display the manual of another command?

A. info
B. man
C. help
D. doc

8. What is the effect of chmod 755 [Link]?

A. Only the owner can execute


B. Everyone can read and execute, owner can write
C. Only root can access the file
D. All users have full permissions

9. What command would add execute permission only for the owner?

A. chmod +x file
B. chmod u+x file
C. chmod 755 file
D. chmod g+x file

10. Which of the following commands updates all installed packages on a Debian-based
system?

A. yum update
B. apt upgrade
C. apt-get update
D. apt-get upgrade

11. What is the GPIO header used for?

A. Audio output
B. Powering the device
C. Connecting external sensors and components
D. Display connection

12. How many GPIO pins does the Raspberry Pi 3 Model B have?

A. 26
B. 30
C. 40
D. 50

13. What is the primary purpose of the raspi-config tool?


A. To update packages
B. To configure system settings like locale, camera, SSH, etc.
C. To manage user accounts
D. To compile code

14. What voltage do GPIO pins operate on?

A. 3.3V
B. 5V
C. 12V
D. 1.8V

15. Which protocol is commonly used to remotely access Raspberry Pi’s terminal?

A. FTP
B. HTTP
C. SSH
D. TCP

16. What file system is used on the Raspberry Pi’s SD card root partition?

A. FAT32
B. ext4
C. NTFS
D. exFAT

17. Which of the following is used to enable I2C and SPI interfaces?

A. /etc/modules
B. raspi-config
C. modprobe
D. sudo enable-i2c

18. Which hardware interface is full-duplex and ideal for high-speed communication with
multiple devices using chip select (CS)?

A. UART
B. I2C
C. SPI
D. PWM

19. What type of communication is SPI?

A. Asynchronous, full-duplex
B. Synchronous, full-duplex
C. Asynchronous, half-duplex
D. Synchronous, half-duplex

20. Which signal is used by the master to select a specific slave in SPI communication?

A. MISO
B. MOSI
C. SCLK
D. SS (Slave Select)

21. In SPI, which device generates the clock signal?

A. Slave
B. Master
C. Both Master and Slave
D. External Clock Module

22. Which of the following is a key advantage of SPI over I2C?

A. Fewer wires
B. Built-in addressing
C. Higher speed and full-duplex support
D. Multi-master support

23. How is data transferred in SPI?

A. Bits are queued and broadcast to all slaves


B. One bit at a time, synchronized by clock
C. Bytes are asynchronously sent
D. Each slave responds in parallel

24. What role does CPOL (Clock Polarity) play in SPI?

A. It sets the data bit size


B. It defines whether idle clock is high or low
C. It enables data compression
D. It selects full- or half-duplex

25. In SPI, what determines the number of slaves that can be connected to a master?

A. The master’s memory


B. The clock frequency
C. The number of dedicated Slave Select (SS) lines
D. The length of MISO line

26. In a multi-slave SPI configuration, what happens if a slave is not selected (SS = HIGH)?

A. It outputs all 0s
B. It transmits random noise
C. It ignores clock and data lines
D. It resets

27. An SPI device uses CPOL=1 and CPHA=0. What does this mean?

A. Data is sampled on the falling edge of the clock


B. Data is latched on the first rising edge
C. Data changes on the rising edge
D. Idle clock is high, and data is sampled on the leading (first) clock edge

28. If the master sends 8 bytes to a slave via SPI, how many bytes does the master
simultaneously receive?

A. 0
B. 1
C. 8
D. Depends on CPHA

29. How can you connect 8 SPI slave devices when the master has only 2 hardware SS pins?

A. Use I2C instead


B. Use a GPIO expander or demux to control SS lines
C. Combine all SS lines
D. Enable CS cascading

30. How can you daisy-chain SPI devices without additional SS lines?

A. Use the same SS for all


B. Chain MISO of one device into MOSI of the next
C. Enable SPI burst mode
D. Assign addresses

31. What is a likely cause if the master receives all 0xFF bytes back from the SPI slave?

A. Wrong clock polarity


B. SS pin not pulled low (slave not selected)
C. MISO wired to MOSI
D. SPI doesn’t support 0x00
32. How many wires does I²C use?

A. 1
B. 2
C. 3
D. 4

33. Which devices can initiate communication in a multi-master I²C bus?

A. Only one master


B. Any slave
C. Any master
D. The host CPU

34. What is the maximum standard I²C speed in standard mode?

A. 100 kbps
B. 400 kbps
C. 1 Mbps
D. 3.4 Mbps

35. Which bit in an I²C address byte specifies whether it's a read or write operation?

A. The MSB
B. Bit 6
C. LSB
D. Parity bit

36. How does I²C handle communication errors like NACK?

A. It retries transmission
B. It sends an interrupt
C. It shuts down the bus
D. The slave resets

37. What tool on Raspberry Pi lists I²C devices on the bus?

A. i2cdetect
B. lsusb
C. spidev
D. scan-i2c

38. How are I²C slave addresses assigned?

A. Auto-assigned by master
B. Fixed in silicon or configurable via hardware pins
C. Set by software at runtime
D. Based on device clock

39. What does a NACK indicate in I²C communication?

A. Successful write
B. Clock error
C. Slave did not acknowledge the byte
D. Line reset

40. An I²C slave device is not responding during communication. Which is the likely cause?

A. Wrong slave address


B. Pull-up resistors not installed
C. SDA or SCL line shorted
D. All of these

41. What’s the maximum number of 7-bit addressable devices theoretically possible on a
single I²C bus?

A. 127
B. 128
C. 112
D. 255

42. Why might an I²C slave never ACK a master even if the address seems correct?

A. Wrong R/W bit


B. Master used a 9-bit address mode
C. Slave in standby mode or needs time to power up
D. All of the above

43. What is the main reason not to use strong pull-up resistors (e.g., 1kΩ) on an I²C bus?

A. Increases power usage and reduces signal rise time


B. Slows down the bus
C. Prevents start conditions
D. Confuses clock stretching

44. If a 3.3V I²C master communicates with a 5V slave, what must be used?

A. No change needed
B. Pull-down resistors
C. Level shifter (bidirectional)
D. Add delay loop

45. Why can a single I²C bus support multiple devices, even with the same SDA and SCL lines?

A. Clock modulation prevents overlap


B. Device IDs are unique in firmware
C. Each slave has a unique address and only responds when addressed
D. Pull-downs synchronize them

46. What is the primary purpose of a Linux kernel driver?

A. To run background services


B. To enable user-space applications
C. To interface hardware with the kernel
D. To compile the kernel

47. Which function is used to register a character device in modern Linux kernels?

A. register_chrdev()
B. cdev_add()
C. device_create()
D. All of the above

48. Which macro is used to initialize a Linux loadable kernel module (LKM)?

A. module_entry()
B. init_module()
C. module_init()
D. mod_init()

49. Which space does a Linux kernel driver operate in?

A. User-space
B. Kernel-space
C. Hybrid-space
D. DMA-space

50. What does the struct file_operations define in a character driver?

A. Device memory map


B. Entry point functions like open, read, write, etc.
C. Load-time configuration
D. Interrupt vector table
51. What mechanism does the kernel use to communicate between drivers and user space?

A. Signals
B. ioctl system calls
C. File locking
D. Mount points

52. What’s a major number in Linux device driver development?

A. Identifies the kernel version


B. Represents the bus type
C. Uniquely identifies the driver
D. Maps to a specific hardware interrupt

53. Which of the following is a valid reason for using a platform driver?

A. For plug-and-play USB devices


B. For static embedded peripherals not discoverable automatically
C. For PCIe devices
D. For GUI applications

54. What tool allows you to inspect kernel logs related to driver loading?

A. dmesg
B. lsmod
C. insmod
D. lsof

55. What’s the typical reason for using copy_from_user() in a driver?

A. To transfer data from kernel to user


B. To perform a DMA write
C. To safely access user-provided buffers
D. To validate memory maps

56. Which of the following is NOT valid in a loadable kernel module (LKM)?

A. printf()
B. printk()
C. MODULE_AUTHOR()
D. __init

57. What could cause a wiringPiSetup() call to fail on a Raspberry Pi?


58. If pwmWrite(pin, value) does not produce the expected PWM signal, what are some
potential causes?

59. Write a C program that continuously sends a byte 0xFF every 500 milliseconds over SPI to
a device. The program should loop indefinitely and print each byte sent.

60. Write a C program that reads 4 bytes from an I2C device with the address 0x3C. The bytes
should be read starting from register 0x10. Print all four bytes in hexadecimal format.

You might also like