查看F1C的源代码
←
F1C
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
==Linux Kernel== <source lang=bash> $ git clone https://github.com/Icenowy/linux.git $ sudo vim /etc/hosts # 添加下面两行 192.30.253.112 github.com 151.101.73.194 github.global.ssl.fastly.net # 可自行通过dns检测网站检测github.global.ssl.fastly.net,更换为更快的ip地址 # 完整拉取linux极大,建议只拉取单层分支,减少等待时间: $ git clone --depth=1 -b f1c100s-480272lcd-test https://github.com/Icenowy/linux.git </source> .config: http://dl.sipeed.com/LICHEE/Nano/SDK/config http://nano.lichee.pro/_static/step_by_step/lichee_nano_linux.config <source lang=bash> $ make ARCH=arm menuconfig $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j8 #请自行修改编译线程数 $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- zImage $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- dtbs $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- M=drivers/staging/sx126x/ modules </source> <br> === DTB === <source lang=bash> arch/arm/boot/dts/suniv.dtsi arch/arm/boot/dts/suniv-f1c100s.dtsi arch/arm/boot/dts/suniv-f1c100s-tesladr.dts </source> '''arch/arm/boot/dts/Makefile:''' <source lang=bash> ...... dtb-$(CONFIG_MACH_SUNIV) += \ suniv-f1c100s-ltegw.dtb \ suniv-f1c100s-tesladr.dtb ...... ...... </source> <source lang=bash> $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- dtbs </source> <br> === Notes === 查看 DTS 中对应的设备用了哪些关键字: <source lang=bash> $ grep -r of_property drivers/spi/ | grep spi-max-frequency </source> '''SPI:''' SPI_SCLK: 3KHz ~ 100MHz * SPI Nor Flash: spi-max-frequency = <50000000>; (50MHz) * SPI 127x: spi-max-frequency = <10000000>; <source lang=bash> # CONFIG_SPI_SUN4I is not set CONFIG_SPI_SUN6I=y </source> <source lang=bash> drivers/spi/spi-bitbang.o drivers/spi/spidev.o drivers/spi/spi-gpio.o drivers/spi/spi.o drivers/spi/spi-sun6i.o </source> <br> === GPIO === <source lang=bash> leds { compatible = "gpio-leds"; blue_led { label = "licheepi:blue:usr"; gpios = <&pio 4 4 GPIO_ACTIVE_LOW>; /* PE4 */ }; green_led { label = "licheepi:green:usr"; gpios = <&pio 4 5 GPIO_ACTIVE_LOW>; /* PE5 */ default-state = "on"; }; red_led { label = "licheepi:red:usr"; gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PE6 */ }; }; </source> 命令行方式: <source lang=bash> $ cat gpio.sh #!/bin/sh -e if [ ! -e /sys/class/gpio/gpio$1 ]; then echo $1 > /sys/class/gpio/export fi echo out > /sys/class/gpio/gpio$1/direction echo $2 > /sys/class/gpio/gpio$1/value $ ./gpio.sh 105 1 </source> <pre> # A: 0 # B: 1 # C: 2 # D: 3 # E: 4 * PB5 = 32*1 + 5 = 37 * PC6= 32*2 + 6 = 70 * PD9 = 32*3 + 9 = 105 </pre> <source lang=cpp> #include <linux/gpio.h> /* * PB5 = 32*1 + 5 * PC6= 32*2 + 6 * PD9 = 32*3 + 9 = 105 */ gpio_direction_output(105, 0); // 设置 PD9 为输出状态, 默认输出低电平 gpio_set_value(105, 1); // 高电平 gpio_set_value(105, 0); // 低电平 </source> <br> === I2C === TeslaDR: <source lang=bash> /* 在 pio 节点下,添加 i2c 引脚定义 */ i2c0_pins: i2c0 { pins = "PE11", "PE12"; function = "i2c0"; }; </source> M6: <source lang=bash> i2c0_pins: i2c0 { pins = "PD12", "PD0"; function = "i2c0"; }; </source> <source lang=bash> i2c0: i2c@1C27000 { compatible = "allwinner,sun6i-a31-i2c"; reg = <0x01C27000 0x400>; interrupts = <7>; clocks = <&ccu CLK_BUS_I2C0>; resets = <&ccu RST_BUS_I2C0>; pinctrl-names = "default"; pinctrl-0 = <&i2c0_pins>; status = "disabled"; #address-cells = <1>; #size-cells = <0>; }; </source> SCL 和 SDA 必须 10K / 1K 拉高,否则 kernel 启动时会报: <source lang=bash> [ 0.972082] i2c /dev entries driver [ 3.044909] i2c i2c-0: mv64xxx: I2C bus locked, block: 1, time_left: 0 </source> pcf8563@0x51: <source lang=bash> # i2cdetect -y 0 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- </source> 常用命令: <source lang=bash> comcat@autoeco:~/f1c/linux$ date +%s -u 1758617972 # date -s @1758617972 Tue Sep 23 08:59:32 UTC 2025 # hwclock -r [ 369.265193] rtc-pcf8563 0-0051: low voltage detected, date/time is not reliable. hwclock: RTC_RD_TIME: Invalid argument # hwclock -w # hwclock -r Tue Sep 23 08:59:59 2025 0.000000 seconds </source> <br> === 电容触摸屏的支持 === 电容触摸屏的控制芯片为 GT911 使用 I2C 接口,我们要在 suniv-f1c100s-*.dts 文件中添加节点: <source lang=bash> #include <dt-bindings/input/input.h> #include <dt-bindings/interrupt-controller/irq.h> /* 添加引用 */ &i2c0 { pinctrl-0 = <&i2c0_pins>; pinctrl-names = "default"; status = "okay"; gt911: touchscreen@14 { compatible = "goodix,gt911"; reg = <0x14>; interrupt-parent = <&pio>; interrupts = <4 10 IRQ_TYPE_EDGE_FALLING>; /* (PE10) */ pinctrl-names = "default"; pinctrl-0 = <&ts_reset_pin>; irq-gpios = <&pio 4 10 GPIO_ACTIVE_HIGH>; /* (PE10) */ reset-gpios = <&pio 4 9 GPIO_ACTIVE_HIGH>; /* RST (PE9) */ /* touchscreen-swapped-x-y */ }; }; &pio { ts_reset_pin: ts_reset_pin@0 { pins = "PE9"; function = "gpio_out"; }; }; </source> 若测试的触摸屏的 xy 方向颠倒,请添加或去掉 gt911 节点下的 touchscreen-swapped-x-y 属性。 [https://item.taobao.com/item.htm?spm=a230r.1.14.87.57863beca0zG7h&id=589629409888&ns=1&abbucket=8#detail iTop 4412] <br> === 长条屏 === * 4.58 inch, 320x960, ST7701S, SPI+RGB, 40.37x117.9x2.08mm, Display 36.77x110.3mm, 40pin, 3.3V power supply ** 非 RGB 直驱,需通过 ST7701 转驱。得事先配置了 ST7701 才能够通过 RGB 口驱动。 ** ST7701一上电需要10s-20s来启动,上电后最好延时20s再启动配置 ** [https://gitee.com/tinnu/EXC_Sreen_LittelVGL_LPC54628 LittleVGL ST7701][https://www.nxpic.org.cn/module/forum/thread-622198-1-1.html 捡屏幕第一弹—5寸480x854 ST7701屏] 驱动实例: <source lang=cpp> //ST7701S+AUO4.58 SPI_WriteComm (0xFF); SPI_WriteData (0x77); SPI_WriteData (0x01); SPI_WriteData (0x00); SPI_WriteData (0x00); SPI_WriteData (0x13); ...... ...... </source> <br> * 4.95 inch, 480x854, ST7701, SPI+RGB, 65x119x2.08mm <br> === SPI TFT 屏 === * [https://www.cnblogs.com/twzy/p/15160836.html SPI TFT屏幕修改与移植] <br> === ESP8089 === * https://github.com/notabucketofspam/ESP8089-SPI * https://github.com/al177/esp8089 * https://whycan.com/t_5870.html * https://www.cnblogs.com/twzy/p/15160808.html dts: <source lang=bash> &spi1 { status = "okay"; esp8089@0 { status = "okay"; compatible = "boss,esp8089"; spi-cpol; spi-cpha; reg = <0>; spi-max-frequency = <30000000>; reset= <104>; interrupt= <103>; debug= <0>; }; }; </source> <br> === USB OTG === '''驱动'''通过读取 USB_ID 的电平,来判断是 host 模式还是 device 模式。 micro-USB 口: pin1 - vcc,pin4 - usb_id, pin5 - gnd * USB_ID 检测脚,在 dts 配置为 PE2,默认 active high * 当检测脚为高电平时,'''驱动 (driver)'''驱使硬件进入 device mode * 当检测脚为低电平时,'''驱动 (driver)'''驱使硬件进入 host mode * TeslaDR(PE2 连接 MicroUSB 的 usb_id 脚)默认把 PE2 用 10K 拉高,dts 设置 PE2 默认 HIGH,因此默认进 device mode * nano 板(PE2 连接 MicroUSB 的 usb_id 脚)默认把 PE2 用 47K 拉高,dts 设置 PE2 默认 HIGH,因此默认进 device mode * 当把 MicroUSB 的 usb_id 脚拉低时,即将 PE2 拉低,驱动驱使硬件进入 host mode <source lang=bash> &usb_otg { dr_mode = "otg"; status = "okay"; }; &usbphy { usb0_id_det-gpio = <&pio 4 2 GPIO_ACTIVE_HIGH>; /* PE2 */ status = "okay"; }; </source> USB Hub chip: gl850/gl850g <br> ==== Device Mode (USB Gadget) ==== F1C 作为 USB 设备,连接到主机。如果是 Linux 主机需要: <source lang=bash> $ sudo modprobe rndis_host $ ifconfig usb0 192.168.3.1 up maybe: $ sudo ifconfig enp0s20f0u3 192.168.3.1 up </source> 作为客户端的 F1C 则: <source lang=bash> $ </source> * https://blog.csdn.net/lan120576664/article/details/101081608 * [https://www.lotlab.org/2019/02/22/%e8%8d%94%e6%9e%9d%e6%b4%benano%e7%9a%84spi-flash%e7%b3%bb%e7%bb%9f%e7%bc%96%e8%af%91%e5%88%9b%e5%bb%ba%e5%85%a8%e8%bf%87%e7%a8%8b/ 荔枝派nano的spi-flash系统编译创建全过程] * [https://www.lotlab.org/2018/07/29/record-of-using-licheepi-part-2-using-linux-gadget/ 使用 Linux Gadget 复合设备共享网络与虚拟串口] * [https://whycan.com/t_2889.html LicheePi Nano Usb复合设备RNDIS功能问题] * [http://www.iipcb.com/blog/F1C100S_USB_DriverDebug1.html USB 裸机驱动] * https://irq5.io/2016/12/22/raspberry-pi-zero-as-multiple-usb-gadgets/ <br> === USB 条码枪 === * https://whycan.com/t_3963.html * [https://whycan.com/t_6902.html 编写F1C100S平台的CVBS IN驱动, 也就是驱动完全找不到北的TVD模块] <br> === USB Serial === <source lang=bash> CONFIG_USB_SERIAL=y CONFIG_USB_SERIAL_CH341=m CONFIG_USB_SERIAL_CP210X=m </source> * CH341 lsusb: 0x1a86:7523 (drivers/usb/serial/ch341.c) * CP210x lsusb: (drivers/usb/serial/cp210x.c) <br> === 4G === * [[EMTC]] * [http://oldask.openluat.com/article/37 Air720模块Linux USB驱动以及PPP拨号说明] * [http://oldask.openluat.com/article/79 Air720模块在linux设备上的RNDIS网卡使用] [http://wiki.jackslab.org/EMTC#AT Air724 AT 接口] 入网不成功,可能导致枚举 usb 设备失败: <source lang=bash> [ 7.780813] usb 1-1: new high-speed USB device number 2 using musb-hdrc [ 7.940764] usb 1-1: device descriptor read/64, error -71 [ 8.210885] usb 1-1: device descriptor read/64, error -71 [ 8.480803] usb 1-1: new high-speed USB device number 3 using musb-hdrc [ 8.630701] usb 1-1: device descriptor read/64, error -71 [ 8.900700] usb 1-1: device descriptor read/64, error -71 [ 9.020862] usb usb1-port1: attempt power cycle [ 9.510701] usb 1-1: new high-speed USB device number 4 using musb-hdrc [ 9.950713] usb 1-1: device not accepting address 4, error -71 [ 10.100707] usb 1-1: new high-speed USB device number 5 using musb-hdrc [ 10.540723] usb 1-1: device not accepting address 5, error -71 [ 10.546757] usb usb1-port1: unable to enumerate USB device </source> 去除 sim 卡一样的错误 log,插入一个新卡一样,换 4G sim 卡一样的现象 <br> === CAN === CAN Gateway: https://whycan.com/t_6980.html https://blog.csdn.net/lushengchu_luis/article/details/77099239 https://blog.csdn.net/a13698709128/article/details/104484467 https://blog.csdn.net/weixin_59676688/article/details/124457092 <br>
返回到
F1C
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面