Lichee Pi

From ElectroDragon
(Redirected from LPI)
Jump to navigation Jump to search

Zero

Ready to use images

  • minX_dd.tar.bz2 –>包含X的最小系统
  • mindb_dd.tar.gz –>Debian,含gcc、python等
  • brpy_dd.tar.bz2 –>buildroot系统,包含python
  • brmin_dd.tar.bz2 –>buildroot最小系统
  • minmin_dd.tar.bz2 –>最小Debian
  • lichee_zero_test_Debian_LXDE.tar.bz2 –>带LXDE桌面的Debian系统

Flash firmware by Win32DiskManger

Flash firmware zero lichee pi.gif
  • unzip and choose dd file
  • flash by win32diskmanager directly
  • see the GIF animation on right

Structure Brief

  • 0x0 u-boot
  • 0x40000 dtb -> device tree
  • 0x50000 kernel -> kernel
  • 0x510000 rootfs -> root file system

Zero Toolchain

install prequiste

apt-get install gcc make pkg-config libusb-1.0-0-dev libncurses5-dev
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev gcc-multilib x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils
apt-get install gcc-arm-linux-gnueabihf device-tree-compiler mtd-utils
  • GCC Linaro
wget https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz
tar xvf gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz
mv gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu /opt/
vim /etc/bash.bashrc
# add: PATH="$PATH:/opt/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/bin"
arm-linux-gnueabihf-gcc -v

Uboot

For SPI Flash version

or normal version


config file include/configs/sun8i.h

For TF card boot ?

#define CONFIG_BOOTCOMMAND   "setenv bootm_boot_mode sec; " \
                           "load mmc 0:1 0x41000000 zImage; "  \
                           "load mmc 0:1 0x41800000 sun8i-v3s-licheepi-zero-dock.dtb; " \
                           "bootz 0x41000000 - 0x41800000;"
#define CONFIG_BOOTARGS      "console=ttyS0,115200 panic=5 rootwait root=/dev/mmcblk0p2 earlyprintk rw  vt.global_cursor_default=0"
or for SPI Flash boot
#define CONFIG_BOOTCOMMAND   "sf probe 0; "                           \
                            "sf read 0x41800000 0x100000 0x10000; "  \
                            "sf read 0x41000000 0x110000 0x400000; " \
                            "bootz 0x41000000 - 0x41800000"
#define CONFIG_BOOTARGS      "console=ttyS0,115200 earlyprintk panic=5 rootwait " \
                            "mtdparts=spi32766.0:1M(uboot)ro,64k(dtb)ro,4M(kernel)ro,-(rootfs) root=31:03 rw rootfstype=jffs2"

Menuconfig

  • config generate default configuration file
cd u-boot
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_800x480LCD_defconfig
#or make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero480x272LCD_defconfig
#or make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_defconfig
  • config in menu -> ARCH=arm make menuconfig
  • Architecture select - ARM
  • ARM architecture
Target select (Support sunxi (Allwinner) SoCs) 
(360) sunxi dram clock speed          config dram speed
(14779) sunxi dram zq value           config dram ZQ value,是用来动态加强DDR3的
-*- Board uses DDR2 DRAM             use DDR2 DRAM使用DDR2 DRAM
[*] Enable graphical uboot console on HDMI, LCD or VGA   这个就是在显示设备上使能串口控制
[ ] VGA via LCD controller support             使能支持VGA通过LCD的控制器,就是LCD和VAG转换需要的控制器
(x:800,y:480,depth:18,pclk_khz:33000,le:87,ri:40,up:31,lo:13,hs:1,vs:1,sync:3,vmode:0) LCD pane
> 该选项就是配置LCD的分辨率的配置选项可以看到x是800 y是480 等等一些关于LCD的配置内容,点击回车进去可以对其进行修改。
(1)   LCD panel display clock phase               这个是LCD的显示时钟相位
()    LCD panel power enable pin               LCD的电源使能引脚
()    LCD panel reset pin                                             LCD的复位引脚
(PB4) LCD panel backlight pwm pin                    背光PWN引脚 这个应该是调节亮度的引脚PB4
[*]   LCD panel backlight pwm is inverted            反转PWN背光引脚
[ ]   LCD panel needs to be configured via i2c
   LCD panel support (Generic parallel interface LCD panel)  --->     这个选择支持的LCDpanel
           (X) Generic parallel interface LCD panel                   这里选择支持通用的并行的LCD接口
           ( ) Generic lvds interface LCD panel                       这个是LVDS接口
           ( ) MIPI 4-lane, 513Mbps LCD panel via SSD2828 bridge chip
           ( ) eDP 4-lane, 1.62G LCD panel via ANX9804 bridge chip
           ( ) Hitachi tx18d42vm LCD panel
           ( ) tl059wv5c0 LCD panel
(0) GMAC Transmit Clock Delay Chain
  • Boot images - (1008000000) CPU clock frequency
  • delay in seconds before automatically booting - 2s

SPL / TPL ---> 这个就是SPL相关的配置了

[*]   MMC raw mode: by sector                       按扇区
(0x50)  Address on the MMC to load U-Boot from  mmc加载uboot的地址
[*] Support GPIO                                 支持GPIO
[*] Support I2C                                 支持I2C
[*] Support common libraries                    支持通用lib
[*] Support disk paritions                      支持分区
[*] Support generic libraries                   支持一般lib库
[*] Support MMC                                 支持MMC
[*] Support power drivers                  支持电源驱动
[*] Support serial                               支持串口

complie

  • time make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- 2>&1 | tee build.log
  • ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make
  • or ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make -j3
  • 第一个time命令完全可以去掉,time主要为了计算该编译需要花费的时间
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  • 这个之前的config也说了,其实就是给变量ARCH赋值arm
  • 给CROSS_COMPILE赋值arm-linux-gnueabihf-
  • 也可以先省去,剩下的:
make 2>&1 | tee build.log
  • tee 这个命令是把make生成的log写入到build.log文件中,这样编译之后的log文件可以保留存有备份,也可以省去。
make 2>&1
  • 查了下资料 数字2对应stderr 数字1对应stdout
  • 这里即将标准err输出 &作为连接符表示‘与’的意思,即标准输出和标准error输出都进行输出。
  • 其实真正执行编译的是下面的命令:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  • 小伙伴可以试下,该命令是否可以编译出u-boot-sunxi-with-spl.bin文件,其他的命令都是辅助编译的命令,用于调试的时候开启。亲测直接make CROSS_COMPILE=arm-linux-gnueabihf- 也是可以的。

Linux Kernel

  • git clone default linux 获取Linux源码(zero-4.13.y分支对网卡支持比较好)
git clone --depth=1 -b zero-4.10.y https://github.com/Icenowy/linux.git # only branch zero-4.10.y and depth 1
git clone https://github.com/Lichee-Pi/linux.git -b zero-4.13.y

Config

  • generate default config file 生成荔枝派Zero 默认配置文件
CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm make licheepi_zero_defconfig
  • make ARCH=arm menuconfig
For SPI Flash
Device Drivers ‣ Memory Technology Device (MTD) support   --> tick Command line partition table parsing
and SPI NOR device support
Add jffs2 file support ==> File systems ‣ Miscellaneous filesystems ‣ Journalling Flash File System v2 (JFFS2) support

Config device tree file

  • Config device tree file , no need change default: nano arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dts
for SPI Flash, add node
&spi0 {
       status ="okay";
       mx25l25635e:mx25l25635e@0 {
               compatible = "jedec,spi-nor";
               reg = <0x0>;
               spi-max-frequency = <50000000>;
               #address-cells = <1>;
               #size-cells = <1>;
       };
};

Compile

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16 INSTALL_MOD_PATH=out modules
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16 INSTALL_MOD_PATH=out modules_install

Or

kernel -> make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4
devie three compiler -> make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs

Buildroot file system

ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL    // 串口登录使能


Nano Hardware

  • Default Debug UART is UART0, 115200

Nano Toolchain

  • Toolchain
apt-get install gcc-arm-none-eabi
apt-get install gcc-arm-linux-gnueabi 
sudo apt install build-essential checkinstall zlib1g-dev libssl-dev flex bison -y

make

make ARCH=arm menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j16    #请自行修改编译线程数


Flash

  • Support either SPI Flash or TF card boot
  • For nano, find file folder Nano_Pub_V4 enter into build folder

WIN Flash for TF Card

  • win32disk
  • flash the *.dd suffix file, packed by dd

Linux DD Flash for TF Card

  • flash the *.dd suffix file, packed by dd
  • sudo dd if=源路径 of=/dev/r卷标 bs=1m [‘r’ 会让命令执行加快一点] [‘bs’为一次填充的容量]
  • sudo fdisk -l
  • sudo dd if=/path/to/your-dd-image of=/your/tf-card && sync


  • run commands ./write_all.sh

All in one Configuration "Zero Imager"

write_dd.sh /dev/sdX: 一键烧录dd镜像,小白专用
//以下为调试时逐个分区调试使用的烧录脚本
write_all.sh /dev/sdX: 一键烧录
write_partion.sh /dev/sdX: 对tf卡分区
write_mkfs.sh /dev/sdX: tf卡格式化
write_boot.sh /dev/sdX: 烧录uboot
write_p1.sh /dev/sdX: 烧录第一分区
write_p2.sh /dev/sdX: 烧录第二分区
write_overlay.sh /dev/sdX: 烧录overlay
write_swap.sh /dev/sdX: 启用swap

Linux 16M SPI Flash (fei Mode )

  • 先编译出u-boot, Linux, dtb 文件, 用buildroot编译出根文件系统.
  • 烧录TF卡,打开gparted, 删除TF卡所有分区
  • 将uboot写入到sd卡8k偏移处。
sudo dd if=u-boot-sunxi-with-spl_480800.bin of=/dev/sdb bs=1024 seek=8
  • 建立第一个分区,大小32M(可以随意填写), 格式FAT16, 把zImage, sun8i-v3s-licheepi-zero-dock.dtb拷贝到 这个分区
  • 建立第二个分区,用尽剩余空间,格式ext4, 把buildroot产生的rootfs.tar解压到该分区根目录
  • short connect Pin 1 and PIN4, then boot up board via USB power
  • sudo sunxi-fel -p spiflash-write 0 Your-Flash-BIN

sunxi tools programmer for SPI Flash

Sunxi fel flash USB.png
  • Make sure use correct branch for board chips.
  • Remove perpherials like LCDs, camera, etc to avoid interferences, use high quality USB cable

For Zero do

For nano do

  • 进入工具目录执行 make && sudo make install
  • plug use device: Onda (unverified) V972 tablet in flashing mode [02B3]
  • Make sure no TF card or SPI flash
sudo sunxi-fel version              #查看连接的cpu信息
AWUSBFEX soc=00001681(V3s) 00000001 ver=0001 44 08 scratchpad=00007e00 00000000 00000000
sudo sunxi-fel spiflash-info        #显示flash信息
Manufacturer: Unknown (C2h), model: 20h, size: 33554432 bytes.

Reference

Applications

Software

Hardware

  • USB devices, USB hub, USB-ethernet

Touch Screen

ls /dev/input   # check if device exist or not, input/event0
# load module 若不存在,找到触摸模块并加载
insmod goodix.ko
# 如根文件系统未找到goodix.ko,请在linux源码的output目录下查找并放入根文件系统下
# 若存在
evtest /dev/input/event0  # 使用evtest测试输入的xy坐标数据
# 直观的测试
ts_test
# 触摸校准工具
ts_calibrate

"TF" SDIO Wifi

ESP8089

Reference

rtl8723bs
  • enable by default: drivers->staging
  • For zero:
find and download ko file in root folder, run
insmod r8723bs.ko
ifconfig wlan0 up
编辑好 /etc/wpa_supplicant.conf 后,执行 connect_wx.sh 来连接网络。
More reference

USB Wifi

Other options

Logs

System spi flash.png
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:  2 ��� 1 ��� 0 
SF: Detected w25q128bv with page size 256 Bytes, erase size 64 KiB, total 16 MiB
device 0 offset 0x100000, size 0x4000
SF: 16384 bytes @ 0x100000 Read: OK
device 0 offset 0x110000, size 0x400000
SF: 4194304 bytes @ 0x110000 Read: OK
## Flattened Device Tree blob at 80c00000
   Booting using the fdt blob at 0x80c00000
   Loading Device Tree to 80e4c000, end 80e51326 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.15.0-next-20180202-licheepi-nano+ (biglion@biglion-MRC-WX0) (gcc version 7.2.0 (Ubuntu/Linaro 7.2.0-6ubuntu1)) #107 Sat May 19 11:56:16 CST 2018
[    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: 8128
[    0.000000] Kernel command line: console=ttyS0,115200 panic=5 rootwait root=/dev/mtdblock3 rw rootfstype=jffs2
[    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: 23752K/32768K available (5120K kernel code, 203K rwdata, 1148K rodata, 1024K init, 227K bss, 9016K 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)   (6112 kB)
[    0.000000]       .init : 0x(ptrval) - 0x(ptrval)   (1024 kB)
[    0.000000]       .data : 0x(ptrval) - 0x(ptrval)   ( 204 kB)
[    0.000000]        .bss : 0x(ptrval) - 0x(ptrval)   ( 228 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.000050] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
[    0.000116] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000722] Console: colour dummy device 80x30
[    0.000818] Calibrating delay loop... 239.61 BogoMIPS (lpj=1198080)
[    0.070232] pid_max: default: 32768 minimum: 301
[    0.070644] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.070685] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.071975] CPU: Testing write buffer coherency: ok
[    0.073852] Setting up static identity map for 0x80100000 - 0x80100058
[    0.076308] devtmpfs: initialized
[    0.082820] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.082883] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.083196] pinctrl core: initialized pinctrl subsystem
[    0.085365] NET: Registered protocol family 16
[    0.086573] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.088369] cpuidle: using governor menu
[    0.109092] SCSI subsystem initialized
[    0.109362] pps_core: LinuxPPS API ver. 1 registered
[    0.109388] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.109460] PTP clock support registered
[    0.111410] clocksource: Switched to clocksource timer
[    0.138937] NET: Registered protocol family 2
[    0.140414] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes)
[    0.140493] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.140548] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.140594] TCP: Hash tables configured (established 1024 bind 1024)
[    0.140973] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.141055] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.141767] NET: Registered protocol family 1
[    0.143532] NetWinder Floating Point Emulator V0.97 (double precision)
[    0.145289] Initialise system trusted keyrings
[    0.145831] workingset: timestamp_bits=30 max_order=13 bucket_order=0
[    0.159794] jffs2: version 2.2. (NAND) 漏 2001-2006 Red Hat, Inc.
[    0.173842] Key type asymmetric registered
[    0.173881] Asymmetric key parser 'x509' registered
[    0.174086] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[    0.174116] io scheduler noop registered
[    0.174132] io scheduler deadline registered
[    0.174880] io scheduler cfq registered (default)
[    0.174917] io scheduler mq-deadline registered
[    0.174933] io scheduler kyber registered
[    0.186203] suniv-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.359033] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[    0.366057] console [ttyS0] disabled
[    0.386357] 1c25000.serial: ttyS0 at MMIO 0x1c25000 (irq = 25, base_baud = 6250000) is a 16550A
[    0.806473] console [ttyS0] enabled
[    0.817299] panel-simple panel: panel supply power not found, using dummy regulator
[    0.826737] SCSI Media Changer driver v0.25 
[    0.834588] m25p80 spi0.0: w25q128 (16384 Kbytes)
[    0.839316] spi0.0: parsing partitions cmdlinepart
[    0.845289] spi0.0: got parser (null)
[    0.848979] spi0.0: parsing partitions ofpart
[    0.853437] spi0.0: got parser ofpart
[    0.857151] spi0.0: parser ofpart: 4
[    0.860723] 4 ofpart partitions found on MTD device spi0.0
[    0.866269] Creating 4 MTD partitions on "spi0.0":
[    0.871078] 0x000000000000-0x000000100000 : "u-boot"
[    0.878729] 0x000000100000-0x000000110000 : "dtb"
[    0.886079] 0x000000110000-0x000000510000 : "kernel"
[    0.893740] 0x000000510000-0x000001000000 : "rootfs"
[    0.901859] i2c /dev entries driver
[    0.936361] sunxi-mmc 1c0f000.mmc: base:0x007adfe2 irq:21
[    0.944963] NET: Registered protocol family 17
[    0.949522] Key type dns_resolver registered
[    0.956149] Loading compiled-in X.509 certificates
[    0.971575] sun4i-drm display-engine: bound 1e60000.display-backend (ops 0xc0633630)
[    0.979484] sun4i-tcon 1c0c000.lcd-controller: Missing LVDS properties, Please upgrade your DT
[    0.988169] sun4i-tcon 1c0c000.lcd-controller: LVDS output disabled
[    0.995391] sun4i-drm display-engine: bound 1c0c000.lcd-controller (ops 0xc0632848)
[    1.003183] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[    1.009786] [drm] No driver support for vblank timestamp query.
[    1.192289] Console: switching to colour frame buffer device 100x30
[    1.232105] sun4i-drm display-engine: fb0:  frame buffer device
[    1.239285] [drm] Initialized sun4i-drm 1.0.0 20150629 for display-engine on minor 0
[    1.247832] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    1.264207] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    1.270983] vcc3v3: disabling
[    1.274971] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    1.283699] cfg80211: failed to load regulatory.db
[    1.361659] random: crng init done
[    2.664673] VFS: Mounted root (jffs2 filesystem) on device 31:3.
[    2.672422] devtmpfs: mounted
[    2.680941] Freeing unused kernel memory: 1024K
Starting logging: OK
Initializing random number generator... done.
Starting network: OK

Welcome to Buildroot
nano login:


Reference

Zero

https://www.kancloud.cn/lichee/lpi0/327292