Get the App
SLTechnology News&Howtos  ›  Servers  › 

Am335x lights up LED under linux

Shulou Source: shulou.com Published: 2022-06-03 02:23:31 11月15日 Update

First, borrow a diagram to illustrate the relationship between the linux application and the kernel.

Different from the bare metal program, the application development under linux does not access the hardware directly, but the application program calls the driver to access the hardware. This is the system structure of linux. For details, please refer to the complete Manual of embedded linux Application Development.

Back to am335x, the operation of LED has been realized in uboot, the basic principle is the same, set the GPIO output, and light the LED at low level. If you want to access GPIO by manipulating files in kernel space, you can refer to BeagleBone's GPIO control

The led-related files are stored in the driver/leds directory in linux3.2, and the led driver module is written here. The code refers to the GPIO control example under Am335x

Add file leds-run.c

`

# include # define TEST_IO_NUM 89#define NAME_MISC "GpioTest" # define NAME_MOUDULE "GpioTest1" # define USE_MISC_MODE 1static int major = 251 void GpioTest (void); static long GpioIOctl (struct file * filp, unsigned cmd, unsigned long arg) {GpioTest (); return 1;} void GpioTest (void) {int iCount = 0 for (iCount = 0; iCount)

Tags: Kernel program application file run application directory reference development driver code application development module hardware control compilation difference consistency success principle Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Linux MySQL vpn Shulou Tech Info