一、电路
具备FLASH下载,TF卡座,摄像头,LCD,MIC,UART等
一、原理图:如需PDF源文件可到资源下载。 原理图资料
二、电路:如需PDF源文件可到资源下载。
三、实物
二、Win上测试 此次测试的目的是尝试使用USB给NorFlash烧录镜像。
1、安装USB驱动。使用的操作系统是win8。 在网上下载zadig-2.3.exe。接入设备后,会产生未知设备。然后进行如图操作即可。
2、使硬件进入fel模式。 在FLASH和TF卡都没有系统或为空时,插电即可进入fel模式。如果没有进入,则
若FLASH中有系统,需通过:短接FLASH芯片的1、4两脚,即按住开发板上boot按键,重新拔插USB或电源开关重新开关一次,即可进入fel模式。
3、刷机
(1)、在网上下载或我的资源包中下载,用与在windows下刷机的工具。解压到某个文件下。
(2)、使用win+R或其他方式打开windows命令行窗口
首先进入到刷机工具目录:cd C:\Users\Administrator\Downloads\刷机\sunxi-tools-win32_f1_flash
查看信息:sunxi-fel.exe ver。我是用的是F1C100S的镜像,也可以驱动F1C200S。
查看SPIFLASH信息:sunxi-fel.exe spiflash-info。我的demo板上使用的是32MFLASH,尽管镜像使用的是16MFLASH,也可以进行驱动,理论上只会无法访问后半段FLASH。
烧录镜像:sunxi-fel.exe -p spiflash-write 0 sysimage-nor.img 100%。这里我将sysimge-nor.img文件拷贝到sunxi-tools-win32_f1_flash文件夹内。
4、运行结果
三、Linux上测试 原思路即是在Linux系统下,对SPIFLASH进行烧录测试,但遇到了一些问题,导致Linux虚拟机无法识别到该设备。进而产生了上一文档的windows下烧录测试。通过在Windows下烧录测试,也验证了设备烧录、测试、各个文件均没有问题。
主要导致在Linux下无法测试的问题是:Vbox无法筛选USB设备,导致Linux虚拟机加载不到开发板。
正确过程:
1、要使windows能正确安装设备驱动。按照上一章文档进行CSDN 3、增强功能安装后,添加筛选器。我这里使用的手动添加。
筛选参数按照window系统中驱动信息进行填写。
4、打开Linux虚拟机后,进入到命令行模式。 1 2 3 4 5 6 7 8 git clone https://github.com/Icenowy/sunxi-tools.git -b f1c100s-spiflash sudo apt install libz libusb-1.0-0-dev make && sudo make install sudo sunxi-fel ver 输出信息: "AWUSBFEX soc=00001663(F1C100s) 00000001 ver=0001 44 08 scratchpad=00007e00 00000000 00000000" sudo sunxi-fel -l sudo sunxi-fel -p spiflash-write 0 u-boot-sunxi-with-spl.bin
查看支持的芯片:sudo sunxi-fel -l。
查看开发板信息:sudo sunxi-fel ver。
查看SPIFLASH信息:sudo sunxi-fel spiflash-info。
烧录镜像到SPIFLASH:sudo sunxi-fel -p spiflash-write 0 Nano_flash_800480.bin 100%。这里使用的是荔枝派的Nano的FLASH。
5、显示正常,使用串口调试助手能看到有效信息。表示操作无误。
四、TF卡启动 思来想去,发现使用SIPFLASH也不是百分百完美,也终于明白为何最小demo板要首推TF卡启动了。
主要是现在想学Linux驱动,但使用SPIFLASH就需要用uboot和kernel两个同时打包为一个镜像,这样编译和打包都会影响速度。使用TF卡,就可以把三个板块分开,单独操作而互不干扰。
这里操作步骤需要摸清楚:1、uboot获取,编译,烧录。2、kernel获取,编译,烧录。3、文件系统搭建。
获取uboot:git clone https://github.com/Lichee-Pi/u-boot -b nano-v2018.01&&cd u-boot
获取时出现的问题:从网上别人博客里是:git clone https://github.com/Lichee-Pi/u-boot.git -b nano-v2018.01&&cd u-boot,发现获取不到。
解决方法:去掉.git后获取正常。
编译uboot:make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- licheepi_nano_defconfig
make ARCH=arm menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j12
编译时出现的问题:make: arm-linux-gnueabi-gcc: Command not found。
解决方法:sudo apt install gcc-arm-linux-gnueabi。
编译时出现的问题:unable to execute ‘swig’: No such file or directory。
解决方法:sudo apt install swig。
编译时出现的问题:scripts/dtc/pylibfdt/libfdt_wrap.c:149:11: fatal error: Python.h: 没有那个文件或目录。
解决方法:1、查看版本:python -V,2、获取对应文件:sudo apt install python2.7-dev。(这里的2.7要修改为和查看的版本相匹配)
烧录uboot:sudo dd if=u-boot-tf.bin of=/dev/sdb bs=1024 seek=8
sudo cp suniv-f1c100s-licheepi-nano.dtb /media/one/UBOOT/
拷贝镜像文件:sudo cp tf-zImage /media/one/UBOOT/
拷贝文件系统:sudo tar -xvf rootfs-tf.tar.gz -C /media/one/rootfs/
需要将TF卡分成两个区:uboot fat16 64M 和 rootfs ext4 (TF卡剩余所有空间)。
查看磁盘:sudo fdisk -l 和 查看挂载:df|grep sd
以上烧录使用的是Lichee-pi-nano的标准文件,并未使用我编译的文件,可以正常运行,输出启动参数。
经过测试,当SPIFLASH和TF卡里都有系统时,优先运行TF卡中系统。
在2021年9月16日,终于指导了uboot和Linux等的关联和基本操作了。虽然前面都在串口调试助手上显示了启动信息,但仔细查看,始终没看到运行kernel。今天终于搞明白了,这三大板块放到TF卡中应该正确操作的流程了。
开机后,串口调试助手上会输出信息,但仅仅是输出uboot的信息,会停留在uboot的命令行。需要在这里使用命令行,配置kernel引导参数,从而执行Linux。
也可以按照uboot传递参数 — 荔枝派Nano 全流程指南 documentation 生成一个boot.scr文件,复制到TF卡的第一分区,就能自动运行LINUX,无需再再串口调试助手中输入这些指令。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 以下是串口调试助手完整输出信息,红色部分则是要人为发送的启动信息。 [2021-09-16 12:03:07.143] RX: U-Boot SPL 2018.01-05679-g013ca457fd (Sep 03 2021 - 09:23:32) DRAM: 64 MiB Trying to boot from MMC1 [2021-09-16 12:03:07.311] RX: U-Boot 2018.01-05679-g013ca457fd (Sep 03 2021 - 09:23:32 +0800) Allwinner Technology DRAM: 64 MiB [2021-09-16 12:03:07.842] RX:MMC: SUNXI SD/MMC: 0 [2021-09-16 12:03:07.918] RX:*** Warning - bad CRC, using default environment In: serial@1c25000 Out: serial@1c25000 Err: serial@1c25000 Net: No ethernet found. starting USB... No controllers found Hit any key to stop autoboot: 2 [2021-09-16 12:03:08.942] RX: 1 [2021-09-16 12:03:09.943] RX: 0 [2021-09-16 12:03:10.006] RX:switch to partitions mmc0 is current device [2021-09-16 12:03:10.556] RX:Scanning mmc 0:1... [2021-09-16 12:03:10.705] RX:reading /suniv-f1c100s-licheepi-nano.dtb 7583 bytes read in 21 ms (352.5 KiB/s) [2021-09-16 12:03:10.773] RX:starting USB... No controllers found USB is stopped. Please issue 'usb start' first. starting USB... No controllers found No ethernet found. missing environment variable: pxeuuid missing environment variable: bootfile Retrieving file: pxelinux.cfg/00000000 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/0000000 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/000000 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/00000 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/0000 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/000 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/00 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/0 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/default-arm-sunxi No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/default-arm No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/default No ethernet found. Config file not found starting USB... No controllers found No ethernet found. No ethernet found. => 人为发送的启动信息 [2021-09-16 12:03:12.310] TX:setenv bootargs console=tty0 console=ttyS0,115200 panic=5 rootwait root=/dev/mmcblk0p2 rw [2021-09-16 12:03:12.313] RX:setenv bootargs console=tty0 console=ttyS0,115200 panic=5 rootwait root=/dev/mmcblk0p2 rw => => 人为发送的启动信息 [2021-09-16 12:03:13.539] TX:load mmc 0:1 0x80C00000 suniv-f1c100s-licheepi-nano.dtb [2021-09-16 12:03:13.544] RX:load mmc 0:1 0x80C00000 suniv-f1c100s-licheepi-nano.dtb reading suniv-f1c100s-licheepi-nano.dtb 7583 bytes read in 21 ms (352.5 KiB/s) => => 人为发送的启动信息 [2021-09-16 12:03:15.421] TX:load mmc 0:1 0x80008000 zImage [2021-09-16 12:03:15.424] RX:load mmc 0:1 0x80008000 zImage reading zImage [2021-09-16 12:03:15.635] RX:3838016 bytes read in 194 ms (18.9 MiB/s) => => 人为发送的启动信息 [2021-09-16 12:03:17.540] TX:bootz 0x80008000 - 0x80C00000 [2021-09-16 12:03:17.543] RX:bootz 0x80008000 - 0x80C00000 Booting using the fdt blob at 0x80c00000 Loading Device Tree to 816fb000, end 816ffd9e ... OK Starting kernel ... [2021-09-16 12:03:18.737] RX:[ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Linux version 4.15.0-rc8-licheepi-nano+ (one@one-VirtualBox) (gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)) [ 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] random: fast init done [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 16256 [ 0.000000] Kernel command line: console=tty0 console=ttyS0,115200 panic=5 rootwait root=/dev/mmcblk0p2 rw [ 0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes) [ 0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes) [ 0.000000] Memory: 55172K/65536K available (6144K kernel code, 236K rwdata, 1388K rodata, 1024K init, 244K bss, 10364K 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 : 0xc4800000 - 0xff800000 ( 944 MB) [ 0.000000] lowmem : 0xc0000000 - 0xc4000000 ( 64 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) ( 237 kB) [ 0.000000] .bss : 0x(ptrval) - 0x(ptrval) ( 245 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.000044] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns [ 0.000107] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns [ 0.000634] Console: colour dummy device 80x30 [ 0.001547] console [tty0] enabled [ 0.001649] Calibrating delay loop... 203.16 BogoMIPS (lpj=1015808) [ 0.070270] pid_max: default: 32768 minimum: 301 [ 0.070605] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes) [ 0.070691] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes) [ 0.072128] CPU: Testing write buffer coherency: ok [ 0.073790] Setting up static identity map for 0x80100000 - 0x80100058 [ 0.076353] devtmpfs: initialized [ 0.082594] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns [ 0.082753] futex hash table entries: 256 (order: -1, 3072 bytes) [ 0.083054] pinctrl core: initialized pinctrl subsystem [ 0.085012] NET: Registered protocol family 16 [ 0.086414] DMA: preallocated 256 KiB pool for atomic coherent allocations [ 0.088228] cpuidle: using governor menu [ 0.112653] SCSI subsystem initialized [ 0.113054] usbcore: registered new interface driver usbfs [ 0.113256] usbcore: registered new interface driver hub [ 0.113505] usbcore: registered new device driver usb [ 0.113994] pps_core: LinuxPPS API ver. 1 registered [ 0.114073] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it> [ 0.114196] PTP clock support registered [ 0.114675] Advanced Linux Sound Architecture Driver Initialized. [ 0.116219] clocksource: Switched to clocksource timer [ 0.141314] NET: Registered protocol family 2 [ 0.142762] TCP established hash table entries: 1024 (order: 0, 4096 bytes) [ 0.142912] TCP bind hash table entries: 1024 (order: 0, 4096 bytes) [ 0.143002] TCP: Hash tables configured (established 1024 bind 1024) [ 0.143302] UDP hash table entries: 256 (order: 0, 4096 bytes) [ 0.143408] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes) [ 0.143903] NET: Registered protocol family 1 [ 0.145154] RPC: Registered named UNIX socket transport module. [ 0.145261] RPC: Registered udp transport module. [ 0.145309] RPC: Registered tcp transport module. [ 0.145352] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 0.147636] NetWinder Floating Point Emulator V0.97 (double precision) [ 0.149450] Initialise system trusted keyrings [ 0.150062] workingset: timestamp_bits=30 max_order=14 bucket_order=0 [ 0.167180] NFS: Registering the id_resolver key type [ 0.167334] Key type id_resolver registered [ 0.167393] Key type id_legacy registered [ 0.180354] Key type asymmetric registered [ 0.180460] Asymmetric key parser 'x509' registered [ 0.180692] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) [ 0.180785] io scheduler noop registered [ 0.180833] io scheduler deadline registered [ 0.181596] io scheduler cfq registered (default) [ 0.181690] io scheduler mq-deadline registered [ 0.181743] io scheduler kyber registered [ 0.182841] sun4i-usb-phy 1c13400.phy: Couldn't request ID GPIO [ 0.192424] suniv-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver [ 0.354497] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled [ 0.361118] console [ttyS0] disabled [ 0.381429] 1c25000.serial: ttyS0 at MMIO 0x1c25000 (irq = 23, base_baud = 6250000) is a 16550A [ 0.852908] console [ttyS0] enabled [ 0.863244] panel-simple panel: panel supply power not found, using dummy regulator [ 0.872677] SCSI Media Changer driver v0.25 [ 0.880398] m25p80 spi0.0: found w25q256, expected w25q128 [ 0.886477] m25p80 spi0.0: w25q256 (32768 Kbytes) [ 0.893635] ehci_hcd: USB 2.0 ' Enhanced' Host Controller (EHCI) Driver [ 0.900355] ehci-platform: EHCI generic platform driver [ 0.905917] ohci_hcd: USB 1.1 ' Open' Host Controller (OHCI) Driver [ 0.912272] ohci-platform: OHCI generic platform driver [ 0.918003] usbcore: registered new interface driver usb-storage [ 0.924980] udc-core: couldn' t find an available UDC - added [g_cdc] to list of pending drivers[ 0.934113] i2c /dev entries driver [2021-09-16 12:03:19.352] RX:[ 0.996353] sunxi-mmc 1c0f000.mmc: base:0x0db647ea irq:19 [ 1.003836] usbcore: registered new interface driver usbhid [ 1.009596] usbhid: USB HID core driver [ 1.031128] NET: Registered protocol family 17 [ 1.035884] Key type dns_resolver registered [ 1.042602] Loading compiled-in X.509 certificates [ 1.058564] sun4i-drm display-engine: bound 1e60000.display-backend (ops 0xc0739498) [ 1.067512] sun4i-drm display-engine: bound 1c0c000.lcd-controller (ops 0xc073877c) [ 1.075259] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013). [ 1.082015] [drm] No driver support for vblank timestamp query. [2021-09-16 12:03:19.511] RX:[ 1.138455] Console: switching to colour frame buffer device 60x34 [ 1.140705] mmc0: host does not support reading read-only switch, assuming write-enable [ 1.142989] mmc0: new high speed SDHC card at address 59b4 [ 1.144075] mmcblk0: mmc0:59b4 SD 15.0 GiB [ 1.146386] mmcblk0: p1 p2 [ 1.208313] sun4i-drm display-engine: fb0: frame buffer device [ 1.227575] [drm] Initialized sun4i-drm 1.0.0 20150629 for display-engine on minor 0 [ 1.249110] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator [ 1.279822] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver [ 1.298514] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 1 [ 1.321574] hub 1-0:1.0: USB hub found [ 1.332130] hub 1-0:1.0: 1 port detected [ 1.344233] using random self ethernet address [ 1.355304] using random host ethernet address [ 1.367912] usb0: HOST MAC 96:a7:62:ad:40:54 [ 1.378730] usb0: MAC 32:68:5e:ee:7c:4e [ 1.389004] g_cdc gadget: CDC Composite Gadget, version: King Kamehameha Day 2008 [ 1.408933] g_cdc gadget: g_cdc ready [ 1.419690] cfg80211: Loading compiled-in X.509 certificates for regulatory database [ 1.449709] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7' [ 1.468828] ALSA device list: [ 1.478044] [ 1.487901] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2 [ 1.508671] cfg80211: failed to load regulatory.db [ 1.521906] EXT4-fs (mmcblk0p2): couldn't mount as ext3 due to feature incompatibilities [2021-09-16 12:03:20.009] RX:[ 1.653047] EXT4-fs (mmcblk0p2): recovery complete [ 1.669691] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null) [ 1.690011] VFS: Mounted root (ext4 filesystem) on device 179:2. [ 1.710548] devtmpfs: mounted [ 1.724192] Freeing unused kernel memory: 1024K [2021-09-16 12:03:20.248] RX:[ 1.892543] EXT4-fs (mmcblk0p2): re-mounted. Opts: data=ordered [2021-09-16 12:03:20.361] RX:Starting logging: [2021-09-16 12:03:20.403] RX:OK [2021-09-16 12:03:20.483] RX:Initializing random number generator... [2021-09-16 12:03:20.591] RX:done. [2021-09-16 12:03:20.710] RX: Welcome to Lichee Pi Lichee login: [2021-09-16 12:03:26.235] TX:root [2021-09-16 12:03:26.239] RX:root Password: [2021-09-16 12:03:27.220] TX:licheepi [2021-09-16 12:03:27.224] RX: [2021-09-16 12:03:27.283] RX:# # [2021-09-16 12:03:29.020] TX:poweroff [2021-09-16 12:03:29.025] RX:poweroff [2021-09-16 12:03:29.148] RX:# # [2021-09-16 12:03:29.212] RX:Saving random seed... done. Stopping logging: [2021-09-16 12:03:29.275] RX:OK umount: devtmpfs busy - remounted read-only [2021-09-16 12:03:29.403] RX:[ 11.047017] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null) The system is going down NOW! Sent SIGTERM to all processes [2021-09-16 12:03:30.425] RX: Sent SIGKILL to all processes Requesting system poweroff [2021-09-16 12:03:31.428] RX:[ 13.072847] reboot: System halted
五、Linux初学1 1、获取源码;2、编译源码;3、烧录可执行文件;4、显示效果
一直在了解源码,但怎么都学不会,直到现在也没能在屏幕上输出个hello world。现在想要在自己的板上,一步一步学习使用。第一件事就是把别人做好的源码进行编译输出个东西,然后再去修改。
一、u-boot 1、获取源码 git clone https://github.com/Lichee-Pi/u-boot.git -b nano-v2018.01
2、生成配置文件
3、编译
make V=1 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j12
二、Linux 1、获取源码:
git clone –depth=1 -b f1c100s-480272lcd-test https://github.com/Icenowy/linux.git
不知道为何我克隆时,上面.git后缀必须要去掉。
wget http://dl.sipeed.com/LICHEE/Nano/SDK/config
mv config .config
2、编译源码:
make ARCH=arm menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j12
三、烧录可执行文件: 编译完成后将linux/arch/arm/boot下的“zImage”文件和linux/arch/arm/boot/dts下的“suniv-f1c100s-licheepi-nano.dtb”文件拷贝到TF卡第一分区。
在第一分区中放入boot.scr文件。其他按照前面文章进行即可运行。
四、显示效果: 串口调试助手会输出运行信息,界面也会显示信息。在串口调试助手上可以使用Linux命令进行基本操作。
使用的是800x480的屏,但Linux配置的是480x272的显示,因此显示不是全屏。这也变成了后期学习的一点。
六、裸机寄存器点灯 按照《嵌入式Linux应用开发 完全手册》,了解寄存器的操作,编译流程,硬件执行流程。
1、修改LED源码 按照书上编辑修改LED源代码:其中寄存器地址与IO偏移按照芯片手册和电路实际IO进行修改。我的电路使用PA0、PA1作为按键输入,PA2、PA3作为LED输出。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 #define PA_CFG0 (*(volatile unsigned long *)(0x01C20800+(0*0x24+0x00))) #define PA_DAT (*(volatile unsigned long *)(0x01C20800+(0*0x24+0x10))) #define BIT0 0 #define BIT1 1 #define BIT2 2 #define BIT3 3 static void delay (void ) ; int main (void ) { PA_CFG0 &= ~(0x7 << (4 * BIT0)); PA_CFG0 &= ~(0x7 << (4 * BIT1)); PA_CFG0 &= ~(0x7 << (4 * BIT2)); PA_CFG0 &= ~(0x7 << (4 * BIT3)); PA_CFG0 |= 0x1 << (4 * BIT2); PA_CFG0 |= 0x1 << (4 * BIT3); PA_DAT |= 0x1 << BIT2; PA_DAT |= 0x1 << BIT3; while (1 ) { PA_DAT &= ~(0x1 << BIT2); delay(); PA_DAT |= 0x1 << BIT2; delay(); if ((PA_DAT & (0x1 << BIT0)) != 0x0 ) { PA_DAT |= 0x1 << BIT3; } else { PA_DAT &= ~(0x1 << BIT3); } } } static void delay (void ) { __asm volatile ( " ldr r0, =76480 \n" " loop:cmp r0,#0 \n" " beq exit \n" " sub r0,r0,#1 \n" " b loop \n" "exit:nop \n" ) ;}
2、编写start.s文件,makefile文件 原本按照书上编写了start.s文件,makefile文件,但经过多次尝试后发现书上的不能照抄。在网上查资料,发现全志的芯片需要一个tools工具,能够将代码端放到指定位置,以及各种初始化。从网上下载源码后,发现其中有F1C100.s对应了书上的start.s。但并不能按照书上简单组合,还需要各种辅助文件。文件已上传在我的资源中。
3、编译后,烧写到SD卡,运行效果
这个灯在500ms闪烁。按住PA0,会使PA3点亮。
参考:【荔枝派Nano】F1C100S的boothead和BROM - 哔哩哔哩
七、Linux初学2 1、uboot移植、修改LED灯;2、学习uboot代码;3、阅读代码的取巧方法
1、uboot移植 认知:使用uboot指令控制LED灯,在uboot/cmd文件中找到led指令文件,在uboot/cmd/makefile文件中查看是否链接led指令文件,如果未链接则需要添加。原有添加方式中需要判断UBOOT_CMD_LED的值,需要在uboot/.config中设置UBOOT_CMD_LED=y,将led指令文件编译连接到指令中。
编译后,下载到demo板,打开串口调试工具,输入help指令,可以看到有led指令,在输入了的指令,可以看到介绍,对比介绍与led指令文件中一致,表示指令过程正确。
但现在的指令不能执行硬件动作,猜测需要修改驱动和设备树,以支持led设备。
2、学习uboot代码 利用正确的Uboot代码,输出信息到串口调试助手:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 [20:57:46.566]收←◆ U-Boot SPL 2018.01-05679-g013ca457fd-dirty (Feb 16 2022 - 14:45:21) DRAM: 64 MiB Trying to boot from MMC1 U-Boot SPL 2018.01-05679-g013ca457fd-dirty (Feb 16 2022 - 14:45:21) DRAM: 64 MiB Trying to boot from MMC1 [20:57:46.926]收←◆ U-Boot SPL 2018.01-05679-g013ca457fd-dirty (Feb 16 2022 - 14:45:21)preloader_console_init\spl.c DRAM: 64 MiBsunxi_board_init\board.c Trying to boot from MMC1boot_from_devices\spl.c [20:57:47.096]收←◆ U-Boot 2018.01-05679-g013ca457fd-dirty (Feb 16 2022 - 14:45:21 +0800) Allwinner TechnologyU_BOOT_VERSION_STRING\version.h display_options_get_banner_priv\display_options.c CPU: Allwinner F Series (SUNIV)print_cpuinfo\cpu_info.c Model: Lichee Pi Nanoshow_board_info\board_info.c DRAM: 64 MiBannounce_dram_init+show_dram_config\board_f.c+display_options.c [20:57:47.628]收←◆MMC: SUNXI SD/MMC: 0initr_mmc+mmc_initialize+print_mmc_devices\board_r.c+mmc.c+mmc_legasy.c [20:57:47.706]收←◆*** Warning - bad CRC, using default environment In: serial@1c25000 Out: serial@1c25000 Err: serial@1c25000 __led_init: failed requesting GPIO0! Net: No ethernet found. starting USB... No controllers found Hit any key to stop autoboot: 2 [20:57:48.734]收←◆ 1 [20:57:49.735]收←◆ 0 [20:57:49.798]收←◆switch to partitions #0, OK mmc0 is current device [20:57:50.345]收←◆Scanning mmc 0:1... [20:57:50.489]收←◆reading /suniv-f1c100s-licheepi-nano.dtb 4393 bytes read in 25 ms (170.9 KiB/s)[20:57:50.561]收←◆starting USB... No controllers found USB is stopped. Please issue 'usb start' first. starting USB... No controllers found No ethernet found. missing environment variable: pxeuuid missing environment variable: bootfile Retrieving file: pxelinux.cfg/00000000 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/0000000 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/000000 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/00000 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/0000 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/000 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/00 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/0 No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/default-arm-sunxi No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/default-arm No ethernet found. missing environment variable: bootfile Retrieving file: pxelinux.cfg/default No ethernet found. Config file not found starting USB... No controllers found No ethernet found. No ethernet found. =>
然后按照这个输出信息,一条一条找到执行位置,上面标红为函数接口,蓝色为接口所在源文件。
屏蔽以上代码后,下面的输出信息依旧存在,表示下面的输出信息位于执行borad_init_f()之前。
在指定位置添加调试信息,发现以下部分信息属于borad_init_f()内
1 2 3 4 5 U-Boot 2018.01-05679-g013ca457fd-dirty (Feb 16 2022 - 14:45:21 +0800) Allwinner Technology ++++++++ DRAM: 64 MiB
这之后的信息属于board_init_r()内。
前几天不是纠结uboot中函数在何处调用问题吗,今天找到一个笨办法了,就是把函数本身名修改成另一个,然后再编译,就会提示哪个位置有错误或警告,那就是被调用位置呐。****阅读代码的取巧方法。
使用上述方法后终于找到了所有输出信息对应的位置。
时发现了这个BUG,就是代码是灰色的,但是却是会执行的。下一步是想办法控制LED亮灭。
相关链接(侵删)
自制F1C200S demo板(一、电路)
自制F1C200S demo板(二、Win上测试)
自制F1C200S demo板(三、Linux上测试)
自制F1C200S demo板(四、TF卡启动)
自制F1C200S demo板(五、Linux初学1)
自制F1C200S demo板(六、裸机寄存器点灯)
自制F1C200S demo板(七、Linux初学2)
=================我是分割线=================
欢迎到公众号来唠嗑: