Coder Social home page Coder Social logo

uart2-serdev's Introduction

UART2

  • Simple slave character device on uart2 for raspberry pi 4B

  • The device is defined in the device tree. For some odd reason it doesn't work when defined in device tree overlay

  • The device driver is built upon serdev bus and currently supports just writing to the device.

  • UART2 pins (raspberry pi 4b):

  • tx - GPIO 0
  • rx - GPIO 1
  • cts - GPIO 2
  • rts - GPIO 3
  • gnd - pin 6, 9, 14, 20, 25, 30, 34, 39

To test this device and module, simply hook up logic analyzer (or arduino) to GPIO pin 0 and GND and run:

$ sudo sh -c 'echo test > /dev/serdev'

Recommended readings:

For more on serdev bus, check out these files:

  • <linux_source_root>/drivers/tty/serdev/core.c
  • <linux_source_root>/include/linux/serdev.h
  • <linux_source_root>/drivers/nfc/s3fwrn5/uart.c
  • <linux_source_root>/drivers/bluetooth/btmtkuart.c
  • <linux_source_root>/drivers/bluetooth/hci_nokia.c
  • <linux_source_root>/drivers/nfc/pn533/uart.c

Building on raspberry pi (raspbian buster)

Install dependencies:

$ sudo apt-get install raspberrypi-kernel-headers build-essential bc git wget bison flex libssl-dev make libncurses-dev
$ sudo apt install device-tree-compiler

Obtain raspberri pi kernel:

$ git clone https://github.com/raspberrypi/linux.git

Patch and build device tree

$ cd linux			# cd into raspberry pi linux kernel source tree
$ git branch uart
$ git checkout uart
$ git am uart2_device.diff	# apply patch ./uart2_device.diff
$ make bcm2711_defconfig
$ make dtbs			# build device tree

Install newly built device tree:

$ sudo cp arch/arm/boot/dts/bcm2711-rpi-4-b.dtb /boot/bcm2711-uart2-slave-rpi-4-b.dtb

Add this line to /boot/config.txt

device_tree = bcm2711-uart2-slave-rpi-4-b.dtb

TODO

  • reading from the device
  • set baud at runtime
  • hook it up to some real hardware

uart2-serdev's People

Contributors

ivbakula avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.