Root permission to configure UART1 in Beaglebone [closed]

北战南征 提交于 2019-12-24 14:16:38

问题


I use a Beaglebone black, which runs on Android, in a project I work. I need to use UART1. As I understand I have to configure the MODE of UART1. It must be MODE0. I can do it via adb with these command:

echo 20 > /sys/kernel/debug/omap_mux/uart1_rxd

echo 0 > /sys/kernel/debug/omap_mux/uart1_txd

Everything works fine like that. But real problem is, I have to do this configuration inside the application, I am coding. But I don't have permission to execute these shell command, because I'm not rooted. So:

1) How can I root my beaglebone black to execute these shell commands?

2) Or is there a way to give permission to write these files? I can execute chmod 777 /sys/kernel/debug/omap_mux/uart1_rxd via adb and have write permission inside my app. But of course it isn't a solution, because when beaglebone restarts the permissions are lost.

Simply I want to use UART1 (or any other UART) for serial communication. But all shell commands must be executed inside my app. How can I do that?


回答1:


I found the solution. I'm posting it for anyone who might need it.

1) Mount SD card, which have Android image, to your PC

2) Open console and mount rootfs partition

3) open init.rc with nano command

nano init.rc

4) There are shell commands, which run in boot section. Add following shell commands to somewhere of your choice:

chmod 0666 /sys/kernel/debug/omap_mux/uart1_rxd
write 20 /sys/kernel/debug/omap_mux/uart1_rxd 20
chmod 0666 /sys/kernel/debug/omap_mux/uart1_txd
write 0 /sys/kernel/debug/omap_mux/uart1_txd 0

5) Save file and boot your Beaglebone with the SD card.

Now you have permision to read/write to /sys/kernel/debug/omap_mux/uart1_txd and /sys/kernel/debug/omap_mux/uart1_rxd. And their modes are set to MODE0.



来源:https://stackoverflow.com/questions/19683336/root-permission-to-configure-uart1-in-beaglebone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!