单片机开发只能在线调试和串口看log?No No No,或许我们也能能像linux那样通过串口终端潇洒的使用命令进行调试。
来自于github作者 @JingoC
https://github.com/JingoC/terminal
灵活的终端设置允许您毫不费力地将其与任何微控制器集成。
特征:
灵活的设置
独立于平台
日志记录命令
中止执行的机制
可用键 键左键、键右键、删除键、退格键、主页、结束键、Tab键
程序存储器中所需空间,最低工作配置为约 10 KB
来自俄罗斯大兄弟的代码,阅读代码后从中闻到了毛子味。。。
将他移植到 STM32f103上,禁止了动态内存申请,修复了参数输入不能多空格的bug,可以从我的仓库fork试一试,感觉还不错。
https://github.com/zhuolin2211/terminal
我能想到的应用,PID调参,读取系统参数,灵活修改寄存器等等。
只需要添加命令对应函数实现和参数接收代码,并将其添加到命令队列当中,即可通过串口命令行灵活调用。
/*来点个灯吧,通过CLI_GetArgDec类接口接受参数*/
void LED_ctr(void)
{
HAL_GPIO_WritePin(LED_GPIO_Port,LED_Pin, CLI_GetArgDec(0)?0:1);
}
/*添加命令,指定命令名,参数个数,帮助信息*/
CLI_AddCmd("LED", LED_ctr, 1, TMC_None, "set led output");
启动界面,还原度还不错。
内置了几个有用的命令,读取时间,设置读取寄存器,复位等
感兴趣就加入到自己项目中来吧!
@卓林
这个WiFi驱动搞定了?
已经被迪卡大神搞定了,参考
https://whycan.com/t_4149.html
如题,来到挖坑网潜伏数月,终于在前辈的肩膀上完成了这块板子,我打算用这块板子做了桌面小音箱,能联网播放音乐和显示日历天气。
硬件在立创开源广场开源
https://oshwhub.com/zhuolin/ji-yu-F1C200Sde-duo-mei-ti-zhong
软件会在github开源,正在完善中。。。还不全,我会整理好再上传,希望不被删帖 0.0
这真的不是一篇粗制滥造的开源文章,平时太忙,没有时间整理,呜呜呜。。
F1C100s跑QT应该是不适合的,可以试试其他轻量级的UI,如果是内存不够,试试F1C200s,可能会好那么一点点。
https://www.cnblogs.com/aaron911/p/11002338.html
我觉得可能是内存不足了,可以看到io占用67%实际我的程序没有读写文件,可能启动交换分区了
卓林 说:kernel中关闭framebuff Console相关的东西
https://whycan.com/files/members/6376/QQ截图20211029090509.png
好像没得选,另外两个还取消不了
你可以看看Kconfig文件,需要启动专家模式(Expert Mode)才能改
General setup ---> Configure standard kernel features (expert users)
之前因为要用的921600的波特率所以修改了分频,分频后串口为120M。然后有时候会出现如下报错
https://whycan.com/files/members/6914/QQ截图20211026145940.png
接近1M的波特率就不建议使用了,今天我就遇到类似的问题,开启1M波特率有时候会导致uart fifo溢出,这是因为接收中断来不及处理数据。如果真的需要1M的话建议使用外围usb转串口或者spi转串口的芯片,带有深度的fifo缓冲那种。当然前提还是你传输的数据不能太频繁,不然就一直会溢出。
卓林 说:真的是非常抱歉,问题解决了。我也不知道怎么回事,我把整个内核重新编译一遍之后就可以了。
非常感谢您的回复@司徒卓林兄,能把内核分享出来吗?谢谢
https://github.com/zhuolin2211/linux_f1cxxx_4.15
可以去我仓库看看, f1c100s-480272lcd-test 分支,应该都在上边了,默认是uboot,SD卡启动,没有弄spi启动的分支。
目前LCD-RGB800*480,触摸,声卡,按键,air724网卡,驱动都没问题了
@司徒
非常抱歉这么晚回复您,社区没有任何消息提醒。
1.我没有使用defconfig来展开.config 我直接下载官方配置好的文件来使用。
http://dl.sipeed.com/LICHEE/Nano/SDK/config
2.是的,我确实修改了内核代码,使他能编译通过。
在devicetree.dts 增加后,提示
linux-5.4.99 devicetree.dtb
DTC arch/arm/boot/dts/devicetree.dtb
Error: arch/arm/boot/dts/devicetree.dts:296.31-32 syntax error
FATAL ERROR: Unable to parse input tree
scripts/Makefile.lib:285: recipe for target 'arch/arm/boot/dts/devicetree.dtb' failed
make[3]: *** [arch/arm/boot/dts/devicetree.dtb] Error 1
Makefile:1262: recipe for target 'devicetree.dtb' failed
make[2]: *** [devicetree.dtb] Error 2
package/pkg-generic.mk:266: recipe for target '/home/fly/mangopi/buildroot-mangopi-r/output/build/linux-5.4.99/.stamp_built' failed
make[1]: *** [/home/fly/mangopi/buildroot-mangopi-r/output/build/linux-5.4.99/.stamp_built] Error 2
Makefile:84: recipe for target '_all' failed
make: *** [_all] Error 2
缺少头文件
#include <dt-bindings/input/input.h>
@司徒
首先非常感谢大神的回复,我比较了我的dts和codec
应该是一致的,我的疑问是为何编译进系统不能加载驱动,但是编译成模块能加载。
suniv.dtsi
dma: dma-controller@1c02000 {
compatible = "allwinner,suniv-dma";
reg = <0x01c02000 0x1000>;
interrupts = <18>;
clocks = <&ccu CLK_BUS_DMA>;
resets = <&ccu RST_BUS_DMA>;
#dma-cells = <2>;
};
codec: codec@1c23c00 {
compatible = "allwinner,suniv-codec";
reg = <0x01c23c00 0x400>;
interrupts = <21>;
clocks = <&ccu CLK_BUS_CODEC>,
<&ccu CLK_CODEC>;
clock-names = "apb", "codec";
resets = <&ccu RST_BUS_CODEC>;
dmas = <&dma 0 12>, <&dma 0 12>;
dma-names = "rx", "tx";
status = "disabled";
};
suniv-code.c
static const struct of_device_id sun4i_codec_of_match[] = {
{
.compatible = "allwinner,sun4i-a10-codec",
.data = &sun4i_codec_quirks,
},
{
.compatible = "allwinner,sun6i-a31-codec",
.data = &sun6i_a31_codec_quirks,
},
{
.compatible = "allwinner,sun7i-a20-codec",
.data = &sun7i_codec_quirks,
},
{
.compatible = "allwinner,sun8i-a23-codec",
.data = &sun8i_a23_codec_quirks,
},
{
.compatible = "allwinner,sun8i-h3-codec",
.data = &sun8i_h3_codec_quirks,
},
{
.compatible = "allwinner,sun8i-v3s-codec",
.data = &sun8i_v3s_codec_quirks,
},
{
.compatible = "allwinner,suniv-codec",
.data = &suniv_f1c100s_codec_quirks,
},
{}
};
另外上传一下我的patch文件
linux_patch.tar
非常感谢楼主的慷慨无私,我已经解决问题了。
记录一下:
1.按照楼主说的修改menuconfig和驱动,注意,我使用的板子是白嫖的air724,USB的vid和pid是0x1782和0x4e00;
2.menuconfig中,我直接将驱动编译进内核,没有使用模块加载,编译遇到报错,直接在menuconfig中搜多对应的模块,看不懂就全加上,编译通过。
3.注意到一点,在插上模块之后,看到注册的设备是eth0,楼主的是usb0,这可能更驱动有关系,小白不懂,以后再研究,反正又不是不能用,哈哈;
这个导致我一直在ifconfig中看到不到我的网卡,原因是在etc/network/interfaces中
auto usb0
iface usb0 inet dhcp
改为
auto eth0
iface eth0 inet dhcp
或者手动ifconfig eth0 up
再手动 udhcpc -i eth0
哈哈,没想到困扰我一晚上的事情是自己眼瞎了。
# ifconfig
eth0 Link encap:Ethernet HWaddr AC:4B:B3:B9:EB:E5
inet addr:192.168.5.8 Bcast:192.168.5.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:668 (668.0 B) TX bytes:772 (772.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
usb0 Link encap:Ethernet HWaddr 92:50:ED:2C:61:50
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
# ping www.baidu.com
PING www.baidu.com (39.156.66.18): 56 data bytes
64 bytes from 39.156.66.18: seq=0 ttl=52 time=70.221 ms
64 bytes from 39.156.66.18: seq=1 ttl=52 time=39.622 ms
64 bytes from 39.156.66.18: seq=2 ttl=52 time=44.108 ms
最后感谢楼主大帅逼,无私奉献,无私分享,家和万事兴!@大帅
[ 1526.819255] usb 1-1: new high-speed USB device number 8 using musb-hdrc
[ 1527.779254] usb 1-1: new high-speed USB device number 9 using musb-hdrc
[ 1527.963969] rndis_host 1-1:1.0 eth0: register 'rndis_host' at usb-musb-hdrc.1.auto-1, RNDIS device, ac:4b:b3:b9:eb:e5
[ 1527.976257] option 1-1:1.2: GSM modem (1-port) converter detected
[ 1527.984359] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
[ 1527.992359] option 1-1:1.3: GSM modem (1-port) converter detected
[ 1528.000486] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
[ 1528.008418] option 1-1:1.4: GSM modem (1-port) converter detected
[ 1528.016821] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
# ifconfig
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
usb0 Link encap:Ethernet HWaddr 92:50:ED:2C:61:50
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
#
为什么我按照你说的改完内核和配置还是找不到网卡呢,有ttyUSB1-3三个节点,
我的usb查U盘没有响应,也没有打印设备信息是为什么?
U-Boot SPL 2018.01-05688-ga9729b3 (Jan 17 2021 - 06:03:27)
DRAM: 32 MiB
Trying to boot from MMC1
U-Boot 2018.01-05688-ga9729b3 (Jan 17 2021 - 06:03:27 -0800) Allwinner Technology
CPU: Allwinner F Series (SUNIV)
Model: Lichee Pi Nano
DRAM: 32 MiB
MMC: SUNXI SD/MMC: 0
SF: Detected xt25f128b with page size 256 Bytes, erase size 4 KiB, total 16 MiB
Setting up a 800x480 lcd console (overscan 0x0)
In: serial@1c25000
Out: serial@1c25000
Err: serial@1c25000
Net: No ethernet found.
starting USB...
No controllers found
Hit any key to stop autoboot: 0
reading zImage
3844976 bytes read in 218 ms (16.8 MiB/s)
reading suniv-f1c100s-licheepi-nano.dtb
8047 bytes read in 26 ms (301.8 KiB/s)
## Flattened Device Tree blob at 83000000
Booting using the fdt blob at 0x83000000
Loading Device Tree to 80e03000, end 80e07f6e ... OK
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.15.0-rc8-licheepi-nano (root@ubuntu) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #14 Fri Jan 22 05:25:06 PST 2021
[ 0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=0005317f
[ 0.000000] CPU: VIVT data cache, VIVT instruction cache
[ 0.000000] OF: fdt: Machine model: Lichee Pi Nano
[ 0.000000] Memory policy: Data cache writeback
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 8128
[ 0.000000] Kernel command line: console=ttyS0,115200 panic=5 root=/dev/mmcblk0p2 rootwait rw
[ 0.000000] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[ 0.000000] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.000000] Memory: 22684K/32768K available (6144K kernel code, 237K rwdata, 1392K rodata, 1024K init, 236K bss, 10084K reserved, 0K cma-reserved, 0K highmem)
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
[ 0.000000] vmalloc : 0xc2800000 - 0xff800000 ( 976 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xc2000000 ( 32 MB)
[ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
[ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
[ 0.000000] .text : 0x(ptrval) - 0x(ptrval) (7136 kB)
[ 0.000000] .init : 0x(ptrval) - 0x(ptrval) (1024 kB)
[ 0.000000] .data : 0x(ptrval) - 0x(ptrval) ( 238 kB)
[ 0.000000] .bss : 0x(ptrval) - 0x(ptrval) ( 237 kB)
[ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[ 0.000051] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
[ 0.000121] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[ 0.000757] Console: colour dummy device 80x30
[ 0.000851] Calibrating delay loop... 203.16 BogoMIPS (lpj=1015808)
[ 0.070245] pid_max: default: 32768 minimum: 301
[ 0.070580] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.070630] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.072199] CPU: Testing write buffer coherency: ok
[ 0.074102] Setting up static identity map for 0x80100000 - 0x80100058
[ 0.076812] devtmpfs: initialized
[ 0.082259] random: get_random_u32 called from bucket_table_alloc+0x80/0x1a4 with crng_init=0
[ 0.083558] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.083633] futex hash table entries: 256 (order: -1, 3072 bytes)
[ 0.083915] pinctrl core: initialized pinctrl subsystem
[ 0.086272] NET: Registered protocol family 16
[ 0.088189] DMA: preallocated 256 KiB pool for atomic coherent allocations
[ 0.090149] cpuidle: using governor menu
[ 0.117495] SCSI subsystem initialized
[ 0.117865] usbcore: registered new interface driver usbfs
[ 0.118054] usbcore: registered new interface driver hub
[ 0.118284] usbcore: registered new device driver usb
[ 0.118831] pps_core: LinuxPPS API ver. 1 registered
[ 0.118857] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[ 0.118920] PTP clock support registered
[ 0.119509] Advanced Linux Sound Architecture Driver Initialized.
[ 0.120583] random: fast init done
[ 0.121245] clocksource: Switched to clocksource timer
[ 0.150929] NET: Registered protocol family 2
[ 0.152583] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.152665] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.152723] TCP: Hash tables configured (established 1024 bind 1024)
[ 0.153091] UDP hash table entries: 256 (order: 0, 4096 bytes)
[ 0.153163] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[ 0.153690] NET: Registered protocol family 1
[ 0.154980] RPC: Registered named UNIX socket transport module.
[ 0.155022] RPC: Registered udp transport module.
[ 0.155037] RPC: Registered tcp transport module.
[ 0.155052] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.157279] NetWinder Floating Point Emulator V0.97 (double precision)
[ 0.159306] Initialise system trusted keyrings
[ 0.159931] workingset: timestamp_bits=30 max_order=13 bucket_order=0
[ 0.178375] NFS: Registering the id_resolver key type
[ 0.178485] Key type id_resolver registered
[ 0.178507] Key type id_legacy registered
[ 0.192843] Key type asymmetric registered
[ 0.192888] Asymmetric key parser 'x509' registered
[ 0.193115] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[ 0.193150] io scheduler noop registered
[ 0.193170] io scheduler deadline registered
[ 0.193970] io scheduler cfq registered (default)
[ 0.194007] io scheduler mq-deadline registered
[ 0.194025] io scheduler kyber registered
[ 0.195215] sun4i-usb-phy 1c13400.phy: Couldn't request ID GPIO
[ 0.205174] suniv-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[ 0.397101] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[ 0.404702] console [ttyS0] disabled
[ 0.424993] 1c25000.serial: ttyS0 at MMIO 0x1c25000 (irq = 23, base_baud = 6250000) is a 16550A
[ 0.899401] console [ttyS0] enabled
[ 0.910119] panel-simple panel: panel supply power not found, using dummy regulator
[ 0.919741] SCSI Media Changer driver v0.25
[ 0.927933] m25p80 spi0.0: xt25f128 (16384 Kbytes)
[ 0.934063] 4 ofpart partitions found on MTD device spi0.0
[ 0.939570] Creating 4 MTD partitions on "spi0.0":
[ 0.944507] 0x000000000000-0x000000100000 : "u-boot"
[ 0.950666] 0x000000100000-0x000000110000 : "dtb"
[ 0.956667] 0x000000110000-0x000000510000 : "kernel"
[ 0.962914] 0x000000510000-0x000001000000 : "rootfs"
[ 0.969549] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 0.976218] ehci-platform: EHCI generic platform driver
[ 0.981770] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 0.987998] ohci-platform: OHCI generic platform driver
[ 0.993724] usbcore: registered new interface driver usb-storage
[ 1.000732] udc-core: couldn't find an available UDC - added [g_cdc] to list of pending drivers
[ 1.009844] i2c /dev entries driver
[ 1.071386] sunxi-mmc 1c0f000.mmc: base:0x(ptrval) irq:19
[ 1.079144] usbcore: registered new interface driver usbhid
[ 1.084839] usbhid: USB HID core driver
[ 1.107849] NET: Registered protocol family 17
[ 1.112719] Key type dns_resolver registered
[ 1.119567] Loading compiled-in X.509 certificates
[ 1.139452] sun4i-drm display-engine: bound 1e60000.display-backend (ops 0xc0737df8)
[ 1.148377] sun4i-drm display-engine: bound 1c0c000.lcd-controller (ops 0xc07370dc)
[ 1.156176] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[ 1.162837] [drm] No driver support for vblank timestamp query.
[ 1.176148] sun4i-drm display-engine: fb0: frame buffer device
[ 1.183485] [drm] Initialized sun4i-drm 1.0.0 20150629 for display-engine on minor 0
[ 1.192651] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[ 1.204477] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[ 1.210269] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 1
[ 1.220411] hub 1-0:1.0: USB hub found
[ 1.224464] hub 1-0:1.0: 1 port detected
[ 1.229949] using random self ethernet address
[ 1.234532] using random host ethernet address
[ 1.240695] usb0: HOST MAC 72:3d:b3:2a:6e:3e
[ 1.245238] usb0: MAC 7e:b0:ca:66:2f:e0
[ 1.249178] g_cdc gadget: CDC Composite Gadget, version: King Kamehameha Day 2008
[ 1.256736] g_cdc gadget: g_cdc ready
[ 1.261516] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[ 1.279356] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[ 1.286188] ALSA device list:
[ 1.289172] #0: Loopback 1
[ 1.293017] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[ 1.301751] cfg80211: failed to load regulatory.db
[ 1.307490] Waiting for root device /dev/mmcblk0p2...
[ 1.316290] mmc0: host does not support reading read-only switch, assuming write-enable
[ 1.326578] mmc0: new high speed SDHC card at address b368
[ 1.333450] mmcblk0: mmc0:b368 USD 7.47 GiB
[ 1.340349] mmcblk0: p1 p2
[ 1.373370] EXT4-fs (mmcblk0p2): couldn't mount as ext3 due to feature incompatibilities
[ 1.452067] EXT4-fs (mmcblk0p2): recovery complete
[ 1.462188] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 1.470381] VFS: Mounted root (ext4 filesystem) on device 179:2.
[ 1.479413] devtmpfs: mounted
[ 1.486943] Freeing unused kernel memory: 1024K
[ 1.603564] EXT4-fs (mmcblk0p2): re-mounted. Opts: data=ordered
Starting logging: OK
Initializing random number generator... done.
Starting network: OK
淡定 说:占位:声音
我有一套源码。声音正常。但是颜色不对。由于没有手柄。键盘用不了,不知怎么调
颜色不对的问题可以解决,我的也是,屏幕泛蓝色。
1.framebuff颜色宽度设置错误,默认InfoNES颜色位宽16bit,所以RGB颜色前后8位被丢了,只剩下蓝色和绿色。
2.修改方法
打开源码 /linux/InfoNES_System_Linux.cpp
添加 全局变量 ,修改函数
long int lcd_bits_per_pixel;
static int lcd_fb_display_px(WORD color, int x, int y)
{
unsigned char *pen8;
pen8 = (unsigned char *)(fb_mem + y*line_width + x*px_width);
if(lcd_bits_per_pixel==32)
{
(unsigned int*)pen8=color;//32bit
}
else
{
(unsigned short*)pen8=color;//16bit
}
return 0;
}
修改函数
static int lcd_fb_init()
{
//如果使用 mmap 打开方式 必须是 读定方式
fb_fd = open("/dev/fb0", O_RDWR);
if(-1 == fb_fd)
{
printf("cat't open /dev/fb0 \n");
return -1;
}
//获取屏幕参数
if(-1 == ioctl(fb_fd, FBIOGET_VSCREENINFO, &var))
{
close(fb_fd);
printf("cat't ioctl /dev/fb0 \n");
return -1;
}
//计算参数
px_width = var.bits_per_pixel / 8;
lcd_bits_per_pixel=var.bits_per_pixel;
line_width = var.xres * px_width;
screen_width = var.yres * line_width;
lcd_width = var.xres;
lcd_height = var.yres;
printf("fb width:%d height:%d \n", lcd_width, lcd_height);
fb_mem = (unsigned char *)mmap(NULL, screen_width, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd, 0);
if(fb_mem == (void *)-1)
{
close(fb_fd);
printf("cat't mmap /dev/fb0 \n");
return -1;
}
//清屏
memset(fb_mem, 0 , screen_width);
return 0;
}
其实就是加了个参数区分是16位宽还是24位,还没试,应该可以:P
buildroot制作根文件系统的时候有两种选择,一种是使用buildroot自己的编译器,还有就是可以自己提供自己下载的编译器然后指定编译器的路径。坑网应该是有这个教程的。如果你说你编译buildroot的编译工具没有g++的话那你只能换一个编译工具编译buildroot了。arm-linux就有arm-linux-g++吧。
是的,昨天已经把arm-linux-g++生成出来了,qmake编译过了,然后。。。用生成的g++编译c程序试了试,结果原来编译可以运行的c程序也是not found了。醉了。。,不过还想请教一个问题,把烧录系统的sd卡挂载再ubuntu里,直接往文件系统里边复制文件,应该没问题吧?
卓林 说:卓林 说:请问,我将可执行程序拷贝到板子上执行,发现提示找不到文件
# ./test_qt -sh: ./test_qt: not found #
但是实际上文件是在根目录的,
# ls bin lib32 mnt run test_qt var dev linuxrc opt sbin tets2 etc lost+found proc sys tmp lib media root test usr
是什么原因呢,方便看看吗?
我把相同的代码用ubuntu的qmake编译后是可以执行的。
并且lib文件夹下也都把需要的文件复制进去了,是不是还需要配置什么东西,环境变量或者别的。看看是不是权限问题,粗暴一点,chmod 777 xxx
试过了,还是一样的。需不需要再文件系统中添加qt支持呢?我并没有做
请问,我将可执行程序拷贝到板子上执行,发现提示找不到文件
# ./test_qt -sh: ./test_qt: not found #
但是实际上文件是在根目录的,
# ls bin lib32 mnt run test_qt var dev linuxrc opt sbin tets2 etc lost+found proc sys tmp lib media root test usr
是什么原因呢,方便看看吗?
我把相同的代码用ubuntu的qmake编译后是可以执行的。
并且lib文件夹下也都把需要的文件复制进去了,是不是还需要配置什么东西,环境变量或者别的。
lichee nano官方linux config文件踩坑与填坑(常见配置误区)
http://whycan.com/t_2703.html
(出处:哇酷开发者社区【全志 V3S/F1C100s/X3】)
真是卧虎藏龙啊,????,今天太晚了,明天试试,我就说我一直没法关闭farmebuffer console support ,原来如此
结贴了,最后感谢大家的帮助,的确设备树配置错了,没有为spi设备配置 spi的pin
&spi1 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&spi1_pins>;
ssd1306@0 {
compatible = "solomon,ssd1306";
reg = <0>;
spi-max-frequency = <1000000>;
rotate = <0>;
bgr;
fps = <30>;
buswidth = <8>;
reset-gpios = <&pio 4 5 GPIO_ACTIVE_LOW>;
dc-gpios = <&pio 4 6 GPIO_ACTIVE_LOW>;
debug = <0>;
};
};
拉轰的脚踏车 说:你的设备树配错了, 不是那样配置的。
附议, 可以参考晕哥这个帖子:
H5的spi控制器驱动, 可以通过 gpio 控制 spi 片选 (转载)
http://whycan.com/t_2418.html#p18568
(出处:哇酷开发者社区【全志 V3S/F1C100s/X3】)
非常感谢,我学习一下如何配置设备树
[ 1.420327] i2c /dev entries driver
[ 1.452739] sunxi-mmc 1c0f000.mmc: base:0x8a848b4d irq:19
[ 1.460284] usbcore: registered new interface driver usbhid
[ 1.465862] usbhid: USB HID core driver
[ 1.470045] fbtft_of_value: buswidth = 8
[ 1.473982] fbtft_of_value: debug = 0
[ 1.477741] fbtft_of_value: rotate = 0
[ 1.481490] fbtft_of_value: fps = 30
[ 1.485583] ********************OLED******************/n
[ 1.621352] ********************OLED******************/n
[ 1.637891] Console: switching to colour frame buffer device 16x8
[ 1.649793] graphics fb0: fb_ssd1306 frame buffer, 128x64, 16 KiB video memory, 4 KiB buffer memory, fps=33, spi1.0 at 1 MHz
[ 1.675182] NET: Registered protocol family 17
[ 1.680016] Key type dns_resolver registered
[ 1.685866] ********************OLED******************/n
[ 1.687886] Loading compiled-in X.509 certificates
[ 1.706370] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[ 1.723364] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
从这里看出驱动应该是正确加载了的
在驱动fd_ssd1306.c 写帧数据函数内打log
static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
{
u16 *vmem16 = (u16 *)par->info->screen_buffer;
u32 xres = par->info->var.xres;
u32 yres = par->info->var.yres;
u8 *buf = par->txbuf.buf;
int x, y, i;
int ret = 0;
printk(KERN_INFO "********************OLED******************/n");
for (x = 0; x < xres; x++) {
for (y = 0; y < yres / 8; y++) {
*buf = 0x00;
for (i = 0; i < 8; i++)
*buf |= (vmem16[(y * 8 + i) * xres + x] ? 1 : 0) << i;
buf++;
}
}
/* Write data */
gpio_set_value(par->gpio.dc, 1);
ret = par->fbtftops.write(par, par->txbuf.buf, xres * yres / 8);
if (ret < 0)
dev_err(par->info->device, "write failed and returned: %d\n",
ret);
return ret;
}
最终在终端不断显示
[ 1784.147529] ********************OLED******************/n
[ 1784.357529] ********************OLED******************/n
[ 1784.567523] ********************OLED******************/n
[ 1784.777526] ********************OLED******************/n
[ 1784.987531] ********************OLED******************/n
[ 1785.197518] ********************OLED******************/n
[ 1785.407524] ********************OLED******************/n
[ 1785.617529] ********************OLED******************/n
[ 1785.827523] ********************OLED******************/n
[ 1786.037540] ********************OLED******************/n
说明fbtft应该是跑起来了,拿逻辑分析仪观察,发现spi相关的 CS MOSI CLK 均无输出,配置的GPIO RESET DC,有正常输出
如题,使用SPI1 驱动,配置了设备树
&spi1 {
status = "okay";
ssd1306@0 {
compatible = "solomon,ssd1306";
reg = <0>;
spi-max-frequency = <1000000>;
rotate = <0>;
bgr;
fps = <30>;
buswidth = <8>;
reset-gpios = <&pio 4 5 GPIO_ACTIVE_LOW>;
dc-gpios = <&pio 4 6 GPIO_ACTIVE_LOW>;
debug = <0>;
};
};
IO节点声明引脚定义 PA2 PA0 PA3 PA1
pio: pinctrl@1c20800 {
compatible = "allwinner,suniv-f1c100s-pinctrl";
reg = <0x01c20800 0x400>;
interrupts = <38>, <39>, <40>;
clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&osc32k>;
clock-names = "apb", "hosc", "losc";
gpio-controller;
interrupt-controller;
#interrupt-cells = <3>;
#gpio-cells = <3>;
spi0_pins_a: spi0-pins-pc {
pins = "PC0", "PC1", "PC2", "PC3";
function = "spi0";
};
spi1_pins: spi1-pins{
pins = "PA2","PA0","PA3","PA1";
function = "spi1";
};
SPI支持中开启 【Allwinner A31 SPI controller 】配置了SSD1306驱动相关内容