CubieBoard中文论坛

 找回密码
 立即注册
搜索
热搜: unable
查看: 9690|回复: 2

[教程] 如何使用UART

[复制链接]
发表于 2014-5-31 17:40:43 | 显示全部楼层 |阅读模式
本帖最后由 stu10064 于 2014-5-31 17:44 编辑

本人是新手爬了很多文,終於弄懂CB要怎麼使用UART
整理一下使用心得

首先要修改 script.bin/script.fex
來源:http://forum.cubietech.com/forum.php?mod=viewthread&tid=141&extra=page%3D1&page=1
以下都是在CB中
1) apt-get install build-essential make gcc g++ git-core

2)fex2bin和bin2fex工具下載
git clone git://github.com/linux-sunxi/sunxi-tools.git
cd sunxi-tools
make
中間可能會發生問題
apt-get install libusb* pkg-config

3)nand的系统,script.bin在第一个分区(/dev/nanda)中
將nanda掛到 mnt資料夾底下
mount /dev/nanda /mnt

4)將script.bin複製到工具下
cp /mnt/script.bin /sunxi-tools

5)將 bin 反編譯 fex
./bin2fex ./script.bin > ./script.fex

6)修改script.fex
參考:UART修改
和GPIO腳:GPIO
vim script.fex
修改其中的:
  1. [uart_para3]
  2. uart_used = 1
  3. uart_port = 3
  4. uart_type = 4
  5. uart_tx = port:PG06<4><1><default><default>
  6. uart_rx = port:PG07<4><1><default><default>
  7. uart_rts = port:PG08<4><1><default><default>
  8. uart_cts = port:PG09<4><1><default><default>

  9. [uart_para4]
  10. uart_used = 1
  11. uart_port = 4
  12. uart_type = 2
  13. uart_tx = port:PG10<4><1><default><default>
  14. uart_rx = port:PG11<4><1><default><default>
复制代码
7) fex編譯回去
./fex2bin ./script.fex > ./script.bin

8) 複製回nanda
cp script.bin /mnt
umount /mnt
sync
reboot

9)測試
UART4 PG10 PG11 接PC 串口程式
看串口資訊: stty -F /dev/ttyS3
加入echo功能 :stty -F /dev/ttyS3 -echo
echo "AAAA" > /dev/ttyS3


謝謝指教  



回复

使用道具 举报

发表于 2014-6-1 18:25:24 | 显示全部楼层
不懂接PC 怎么测,用TTL线?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-6-1 21:50:36 | 显示全部楼层
TTL 就可以了


回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|粤ICP备13051116号|cubie.cc---深刻的嵌入式技术讨论社区

GMT+8, 2024-4-30 02:40 , Processed in 0.022479 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2012 Comsenz Inc. | Style by Coxxs

返回顶部