Phytec中国的wiki
support@phytec.cn
热线:0755-61802110-803
barebox入门
barebox是我们开发板使用的bootloader,它在启动时会打印相关的信息
barebox 2017.10.0-bsp-yocto-am335x-pd17.2.2 #1 Wed Jul 18 15:46:59 UTC 2018 Board: Phytec phyCORE AM335x cpsw 4a100000.ethernet: detected phy mask 0x5 mdio_bus: miibus0: probed eth0: got preset MAC address: a0:f6:fd:4d:fb:71 am335x-phy-driver 47401b00.usb-phy: am_usbphy 8ffb328c enabled musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, bulk combine, bulk split, HB-ISO Rx, HB-ISO Tx, SoftConn) musb-hdrc: MHDRC RTL version 2.0 musb-hdrc: setup fifo_mode 4 musb-hdrc: 28/31 max ep, 16384/16384 memory m25p80 m25p80@00: s25sl064p (8192 Kbytes) i2c-omap 44e0b000.i2c: bus 0 rev0.11 at 400 kHz omap-hsmmc 48060000.mmc: registered as 48060000.mmc mmc0: detected SD card version 1.0 mmc0: registered mmc0 omap_wdt 44e35000.wdt: OMAP Watchdog Timer Rev 0x01 nand: ONFI flash detected nand: NAND device: Manufacturer ID: 0x2c, Chip ID: 0xdc (Micron MT29F4G08ABADAH4), 512MiB, page size: 2048, OOB size: 64 netconsole: registered as netconsole-1 malloc space: 0x8fefee60 -> 0x9fdfdcbf (size 255 MiB) running /env/bin/init... Hit m for menu or any other key to stop autoboot: 2 type exit to get to the menu barebox@Phytec phyCORE AM335x:/
它具有一个命令行的界面,在开机时会在console口打印倒计时的信息,此时按任意键可以进入命令行界面。
进入命令行后,你可以输入help来查看所有的命令,help 命令名 来查看命令的帮助。
在barebox的命令行界面中,我们最主要做的事情是烧写镜像,这个请参考各个核心板对应的文档。
barebox命令参考文档:http://www.barebox.org/doc/latest/commands.html
barebox用户手册:http://www.barebox.org/doc/latest/user/user-manual.html
Barebox源代码:https://git.phytec.de/barebox/
barebox 设置从网络启动参考文档:开发板从网络启动 / boot board from network
修改phytec扩展模块的配置
edit /env/config-expansions
/env/config-expansions文件内容如下:
#!/bin/sh . /env/expansions/imx6qdl-mira-peb-eval-01 #. /env/expansions/imx6qdl-mira-enable-lvds #. /env/expansions/imx6qdl-phytec-peb-wlbt-01 #use this expansion when a capacitive touchscreen is connected . /env/expansions/imx6qdl-phytec-lcd-018-peb-av-02 #use this expansion when a resisitive touchscreen is connected #. /env/expansions/imx6qdl-phytec-lcd-018-peb-av-02-res # imx6qdl-phytec-lcd: 7" display (AC138 and AC156) #of_display_timings -S /display@di0/display-timings/ETM0700G0EDH6 # imx6qdl-phytec-lcd: 7" display (AC104) of_display_timings -S /display@di0/display-timings/ETM0700G0DH6 # imx6qdl-phytec-lcd: 5.7" display #of_display_timings -S /display@di0/display-timings/ETMV570G2DHU # imx6qdl-phytec-lcd: 4.3" display #of_display_timings -S /display@di0/display-timings/ETM0430G0DH6
在/env/config-expansions文件对相应的扩展板取消注释即可。
按照屏幕的提示
ctrl-c: 退出
ctrl-d: 保存
按上下左右来移动,正常方式修改。
保存后,需要用saveenv来保存配置,然后 reset 即可。
网络配置与使用
参考:http://www.barebox.org/doc/latest/user/networking.html
可以通过以下指令来查看当前网络设置
devinfo eth0
网络参数修改:
2019之前版本 | 2019及之后版本 |
---|---|
网络配置是放在一个配置文件中,可以使用edit指令来打开这个文件来修改,edit使用方法请参考之前的 “修改phytec扩展模块的配置”。 edit /env/network/eth0 saveenv 请注意其中的serverip选项是用于tftp的服务器ip。 | 通过环境变量来修改网络参数,常用的如下:
如设置eth0的ip为192.168.3.11。 nv.dev.eth0.ipaddr=192.168.3.11 |
在配置好后可以用
ifup eth0
来使能网络接口,此时可以用ping来测试接口。
ping [ip address]
要注意的是,在barebox中不能响应外部的ping,如果用主机去ping开发板是不通的。
内核启动参数修改
http://www.barebox.org/doc/latest/user/booting-linux.html
可以使用global指令来查看有哪些环境变量:
barebox@Phytec phyCORE AM335x:/ global ... * linux.bootargs.base: consoleblank=0 linux.bootargs.console: console=ttyO0,115200n8 linux.bootargs.dyn.ip: linux.bootargs.dyn.root: * linux.bootargs.rootfs: rootwait ro fsck.repair=yes linux.rootnfsopts: v3,tcp loglevel: 7 ...
可以看到给内核的参数,内核的启动参数在barebox中的变量名必须设为linux.bootargs.[*], 变量对应的值即为传给kernel command line的参数.
接下里可以增加一个内核参数,如:
barebox@Phytec phyCORE AM335x:/ nv linux.bootargs.debug='dyndbg="file edt-ft5x06.c +p"' nv variable modified, will save nv variables on shutdown barebox@Phytec phyCORE AM335x:/ saveenv saving environment
接下来可以看到内核成功加载这个变量:
Loading ARM Linux zImage '/mnt/mmc0.0/linuximage' Loading devicetree from '/mnt/mmc0.0/oftree' commandline: consoleblank=0 console=ttyO0,115200n8 dyndbg="file edt-ft5x06.c +p" root=/dev/mmcblk0p2 rootflags=data=journal rootwait ro fsck.repair=yes [ 0.000000] Booting Linux on physical CPU 0x0
也可以通过修改 /env/boot/[启动外设] 这个文件来增加。
在yocto中修改环境变量可以参考meta-phytec中的bb文件,如
https://git.phytec.de/meta-phytec/tree/recipes-bsp/barebox/barebox_2018.11.0-phy3.bb?h=2.7.1-phy2
注意在recipe修改后,需要
bitbake -c cleanall barebox
后再重新编译。
为am335x平台编译MLO.spi文件
本节描述的方法是为了生成在linux系统下烧写nor flash用的MLO.spi。在barebox下烧写nor flash不需要次步骤,会在烧写时自动转换。
进入barebox-ipl的menuconfig,增加
System Type - > OMAP feature - > build SPI binary
然后重新在yocto中编译 barebox-ipl 即可在deploy中找到MLO.spi。
怎样修改NAND分区
请参考下面这个提交
https://git.phytec.de/barebox/commit/?h=v2016.11.0-phy&id=783310cff0971deac23464dc171cc475122a7ccd
通过串口传输文件
首先,在yocto中新建sources/meta-phytec/recipes-bsp/barebox/barebox/features/load.cfg 文件
CONFIG_CMD_LOADB=y CONFIG_CMD_LOADY=y
修改sources/meta-phytec/recipes-bsp/barebox/barebox_2015.11.0-phy4.bb文件:
diff --git a/recipes-bsp/barebox/barebox_2015.11.0-phy4.bb b/recipes-bsp/barebox/barebox_2015.11.0-phy4.bb index 5515d31..6b5a216 100644 --- a/recipes-bsp/barebox/barebox_2015.11.0-phy4.bb +++ b/recipes-bsp/barebox/barebox_2015.11.0-phy4.bb @@ -12,6 +12,7 @@ GIT_URL = "git://git.phytec.de/${PN}" SRC_URI = "${GIT_URL};branch=${BRANCH}" SRC_URI_append = " \ file://no-blspec.cfg \ + file://load.cfg \ file://commonenv \ file://boardenv \ file://machineenv \
然后 bitbake barebox重新编译并烧写barebox.bin。
此时,barebox就具有了loadx功能,可以通过Kermit/xmodem/ymodem协议发送文件。
https://www.barebox.org/doc/latest/commands/boot/loadb.html
接下来测试一下,这里使用win10系统+Tera Term (http://ttssh2.osdn.jp/)
输入loadb:
barebox@Phytec phyFLEX-i.MX6 Quad Carrier-Board:/ loadb ## Ready for binary (kermit) download to 0x00000000 offset on image.bin device at 115200 bps...
选择发送文件:
发送中。。。
三个协议的速度为:
协议 | 速度(仅供参考) |
---|---|
Kermit | 2.3kB/s |
xmodem | 7kB/s |
ymodem | 10kB/s |
不推荐使用这个来升级文件系统。
操作USB储存设备上的文件
测试版本:PD19
连接一个USB存储设备,如优盘,然后:
barebox@Phytec phyCORE-i.MX6 Ultra Lite SOM with NAND:/ usb usb: USB: scanning bus for devices... usb: Bus 001 Device 001: ID 0000:0000 EHCI Host Controller usb: Bus 001 Device 002: ID 090c:1000 USB Flash Disk Using index 0 for the new disk usb: 2 USB Device(s) found
此时在/mnt下就有了优盘的分区
barebox@Phytec phyCORE-i.MX6 Ultra Lite SOM with NAND:/ ls /mnt/disk0.0/ mounted /dev/disk0.0 on /mnt/disk0.0 . .. 01.so much magnificence.OGG 02 If I Let You Go [Radio Edit].wma 08-milk_coffee_-_little_prince-cpop-2005-luna.mp3 2018????.xlsx ??8.lxe ?????? ??????.exe
如果在/mnt下没有,请查看/dev下是否有disk0.0设备,如果有则可以用以下指令来做mount。
barebox@Phytec phyCORE-i.MX6 Ultra Lite SOM:/ cd mnt/ barebox@Phytec phyCORE-i.MX6 Ultra Lite SOM:/mnt ls . .. mmc ratp tftp barebox@Phytec phyCORE-i.MX6 Ultra Lite SOM:/mnt mkdir usb barebox@Phytec phyCORE-i.MX6 Ultra Lite SOM:/mnt mount /dev/disk0.0 usb/
此时可以用来烧写nand,备份启动脚本等操作。
注意并不是所有分区格式都支持,只支持fat/fat32格式,exfat,ntfs不支持,有些超过32G的优盘使用的是exfat格式。
怎样操作GPIO/SPI/I2C
SPI
https://www.barebox.org/doc/latest/commands/hwmanip/spi.html
I2C
- https://www.barebox.org/doc/latest/commands/hwmanip/i2c_probe.html
- https://www.barebox.org/doc/latest/commands/hwmanip/i2c_read.html
- https://www.barebox.org/doc/latest/commands/hwmanip/i2c_write.html
GPIO
- https://www.barebox.org/doc/latest/commands/info/gpioinfo.html
- https://www.barebox.org/doc/latest/commands/hwmanip/gpio_set_value.html
- https://www.barebox.org/doc/latest/commands/hwmanip/gpio_get_value.html
- https://www.barebox.org/doc/latest/commands/hwmanip/gpio_direction_output.html
- https://www.barebox.org/doc/latest/commands/hwmanip/gpio_direction_input.html
注意在使用前,需要在barebox的设备树中检查对应引脚的pin mux,如没有配置为GPIO需要增加,如:
diff --git a/arch/arm/dts/imx6qdl-phytec-phycore-som.dtsi b/arch/arm/dts/imx6qdl-phytec-phycore-som.dtsi index b9a4881..c58b891 100644 --- a/arch/arm/dts/imx6qdl-phytec-phycore-som.dtsi +++ b/arch/arm/dts/imx6qdl-phytec-phycore-som.dtsi @@ -150,7 +150,17 @@ &iomuxc { pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hog>; + hog { + pinctrl_hog: hoggrp-1 { + fsl,pins = < + MX6QDL_PAD_DI0_PIN4__GPIO4_IO20 0x13030 + MX6QDL_PAD_CSI0_DAT6__GPIO5_IO24 0x13030 + >; + }; + }; + imx6qdl-phytec-phycore-som { pinctrl_ecspi1: ecspi1grp { fsl,pins = < -- 2.7.4
接下来就可以在barebox中操作gpio,其中GPIO的编号计算可以在 开发板linux外设使用指南 / how to use peripherals under linux 中找到,如上面提到的MX6QDL_PAD_DI0_PIN4__GPIO4_IO20就是116((4-1)*32+20):
设定为输出: gpio_direction_output 116 1 设定GPIO的值为0: gpio_set_value 116 0
barebox调试接口
barebox默认的loglevel为7, 如果要增加更多的调试信息, 可以loglevel设置为8.
这个loglevel的修改是在barebox的menuconfig中的Debugging--> (7) default loglevel 中配置的.