从0开玩lichee zero-1-uboot篇

·## 准备工作
sudo apt-get install gcc-arm-linux-gnueabihf
sudo apt-get install git
sudo apt-get install Python2

uboot

git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-current

config SD TF

修改u-boot/include/configs/sun8i.h文件 加入:

#define CONFIG_BOOTCOMMAND   "setenv bootm_boot_mode sec; " \
                            "load mmc 0:1 0x41000000 zImage; "  \
                            "load mmc 0:1 0x41800000 sun8i-v3s-licheepi-zero.dtb; " \
                            "bootz 0x41000000 - 0x41800000;"

#define CONFIG_BOOTARGS      "console=ttyS0,115200 panic=5 rootwait root=/dev/mmcblk0p2 earlyprintk rw  vt.global_cursor_default=0"

config spi flash

git clone -b v3s-spi-experimental https://github.com/Lichee-Pi/u-boot.git

配置Flash支持型号

执行 make ARCH=arm menuconfig 打开uboot菜单配置,进入到 Device Drivers ‣ SPI Flash Support

注意看一下自己flash的厂家名称,例如选上Macronix SPI flash support用来支持测试用的flash:MX25L25645G。

如果使用的是16MB以上的flash,需要勾选flash bank支持选项,否则最多只能读到16MB: CONFIG_SPI_FLASH_BAR

spi 分区

这里 使用 MX25L25645G, 32M SPI flash 作为启动介质,规划分区如下:

分区序号 分区大小 分区作用 地址空间及分区名
mtd0 1MB spl+uboot 0x0000000-0x0100000 : "uboot"
mtd1 64KB dtb文件 0x0100000-0x0110000: "dtb"
mtd2 4MB linux内核 0x0110000-0x0510000 : "kernel"
mtd3 剩余 根文件系统 0x0510000-0x2000000 : "rootfs"
 #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"

make

ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make LicheePi_Zero_defconfig
ARCH=arm make menuconfig
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make

编译完成后,在当前目录下生成了u-boot-sunxi-with-spl.bin,可以烧录到TF卡8K偏移处启动

注意:对于大于16M的flash,需要在menuconfig中开 CONFIG_SPI_FLASH_BAR

烧录

sd

sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8

troubleshoot

  1. <command-line>: fatal error: curses.h: No such file or directory
    解决:sudo apt-get install libncurses5-dev libncursesw5-dev

  2. Your dtc is too old, please upgrade to dtc 1.4 or newer
    解决:apt-get install device-tree-compiler

reg :https://licheezero.readthedocs.io/zh/latest/%E7%B3%BB%E7%BB%9F%E5%BC%80%E5%8F%91/SPI_flash_build.html#uboot

从0开玩lichee zero-0-固件体验

lichee zero介绍

https://licheezero.readthedocs.io/
https://wiki.sipeed.com/soft/Lichee/zh/Zero-Doc/

固件测试

因为购买时sd和板子是分开购买的,不像其他的开发板,到手就用,这个要自己烧录才能体验到板子的基本功能。 ### 固件下载 可以参考上面的这个https://wiki.sipeed.com/soft/Lichee/zh/Zero-Doc/System_Development/download_onekey.html

可能采坑的地方是对于新手,这个文档没有说清楚,下载的细节。需要解压后下载dd文件,如果你是直接下载,就会发现板子没有反应,不知所措。

这里我自己使用的是:lichee_zero-mindb_alpha.dd:

file

串口日志

按照官方指导,连接uart0,就能看到系统的开机日志:
file

账号密码

网上文档说的是root licheepi,实际验证不对。
经多方验证,有以下几种密码组合:

  1. root toortoor
  2. root licheepi
  3. root 空

从0开玩树莓派-1-开机配置

注意:如果你使用的是带HDMI的桌面版,一定要选择一个电流足够的适配器,否则会导致异常重启。

设置 root 密码

sudo passwd root

屏幕翻转

  • 带ui的新系统
    如果你的屏幕是180度倒置的,需要设置下屏幕:

    1. preferences->screen configuration
    2. 选择HDMI屏幕,右键->Orientation->inverted
  • 命令行的老系统
    1. sudo nano /boot/config.txt
    2. display_hdmi_rotate=2

开启sshd

  • 方法1:通过界面UI
    如果烧录是没有配置sshd,我们可以在进入系统以后启动:

    sudo systemctl enable ssh
    sudo systemctl start ssh
  • 方法2:通过SD
    当没有屏幕时,我们可以通过在sd boot盘的跟目录下创建SSH空文件,来启用默认的sshd配置。用户名pi,密码respberry

安装pyenv

系统默认python3,有时候你需要运行的项目是python2的,我们需要pyenv

git clone https://github.com/pyenv/pyenv.git ~/.pyenv

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo 'export PATH="$PYENV_ROOT/libexec:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init --path)"' >> ~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
exec $SHELL -l

从0开玩树莓派-0-安装和环境

Raspberry Pi 1 Model B+

file

On the other hand, the BCM2835 uses a single core and thread 32-bit microprocessor. Once again, it features a clock speed of 700 Mhz. However, it has a turbo capability to boost clock frequencies up to 1 GHz. Unfortunately, this feature is absent from the BCM2711.
The BCM2835 is an SoC that Broadcom Semiconductors developed.  As we have briefly mentioned in the introduction, SoC packages such as the BCM2835 make devices such as the Raspberry Pi Zero possible. Additionally, The Raspberry Pi Foundation features the BCM2835 in the Raspberry Pi A, A+, B, B+, and the Raspberry Pi Zero W. Moreover, you can find it in rare models such as the Raspberry Pi Compute Module 1.

Since it’s an older chip package, you’re unlikely to find it in newer microcontrollers or single-board computers. However, its capabilities and peripherals are still worth exploring.
  • Core Processor Architecture: ARM
  • Processor Speed: 700 MHz
  • Core Processor Sub-Architecture: ARM1176JZF-S processor
  • RAM: 512MB
  • SODIMM Board Size: 6.5x3.0 cm
  • Edge Connector Pins: 200
  • On-Board Flash Memory: 4GB eMMC
  • GPU: VideoCore IV GPU running at 250MHz

安装系统

准备大于8G的SD

Raspberry Pi Imager

根据前面的介绍,我们知道我们的板子是32架构,所以我们要选择32bit的系统:

file

说明:

  • 一定要选好的sd卡和读卡器,否则可能浪费很多时间。
  • 右下角的设置是可以预设一些参数的,对于无屏场景,很有用

经过耐心的等待,就会提示校验成功,可以拿下sd插入设备了。

参考

https://www.ourpcb.com/bcm2835.html

七牛的镜像存储配置说明

关于镜像存储功能简单总结:自动回源,切换无拷贝工作量,且只回源一次,在某些源不稳定的架构中,非常有用。

主要做以下几步:

空间管理

在对象存储-》空间管理里面,创建一个空间。

加速域名

加速域名其实就是你想镜像的内容入口。

  1. 需要去你的域名运营商解析处,配置cname,让域名能被重定向七牛的域名
  2. 如果原始资源是https,一定要配置https,否则无法访问

镜像回源

这里主要就是回源地址,这里非常有用的是支持端口,你懂的,内网资源呵呵呵。

file

做好以上设置,功能就基本可用了,至于其他高级数据,再按需开启。

最后需要说明的是,镜像服务是一种cdn服务,是收流量费的,在方便和钱之前,还是要实际斟酌调试的。