F1C

来自Jack's Lab
(版本间的差异)
跳转到: 导航, 搜索
(Notes)
(Notes)
第136行: 第136行:
 
             };
 
             };
 
  };
 
  };
 +
</source>
 +
 +
<br>
 +
 +
'''I2C:'''
 +
 +
<source lang=bash>
 +
        i2c0: i2c@1C27000 {
 +
            compatible = "allwinner,sun6i-a31-i2c";
 +
            reg = <0x01C27000 0x400>;
 +
            interrupts = <7>;
 +
            clocks = <&ccu CLK_BUS_I2C0>;
 +
            resets = <&ccu RST_BUS_I2C0>;
 +
            pinctrl-names = "default";
 +
            pinctrl-0 = <&i2c0_pins>;
 +
            status = "disabled";
 +
            #address-cells = <1>;
 +
            #size-cells = <0>;
 +
        };
 
</source>
 
</source>
  

2021年2月8日 (一) 17:08的版本

目录

1 F1C100s Overview

  • ARM926-EJS, up to 900MHz
  • 32KB I-Cache, 16KB D-Cache, 5-stage pipeline
  • 32MB SiP DDR1 (F1C200s is 64MB SiP DDR1)
  • RGB LCD interface
  • USB 2.0 OTG
  • SDIO
  • SPI x2
  • TWI x3
  • UART x3
  • TV out x 1, TV in x 2


  • PWM x2
  • LRADC x1
  • Speaker x2 + Mic x1


F1C100s-blockdiagram.jpg


F1C100s-typical-app.jpg



2 Roadmap

F1C-roadmap.png



3 Pinmap

F1C100s-pinmap.jpg


3.1 荔枝派 Pin Map

Lichee-nano-pin-map.png

  • UART
    • UART0_RX --- PE0
    • UART0_TX --- PE1
    • dtb 中默认系统启动的串口 serial0:115200n8
    • UART1_RX --- PD3 --- D5
    • UART1_TX --- PD4 --- D6
    • UART2_RX --- PD14 --- D20
    • UART2_TX --- PD13 --- D19


  • SPI1
    • PA0 - SPI1_CS
    • PA1 - SPI1_MOSI
    • PA2 - SPI1_SCK
    • PA3 - SPI1_MISO
    • PE3 -- Reset -- D0
    • PE4 -- Interrupt -- D1


  • USB
    • 右上角,PCLK 右边为 USB_DM (D-)
    • 右上角,PCLK 左边为 USB_DP (D+)


  • I2C0
    • PE11 --- SCL
    • PE12 --- SDA


  • GPIO
    • PE3 --- D0
    • PE4 --- D1


https://fdvad021asfd8q.oss-cn-hangzhou.aliyuncs.com/migrate/Lichee_nano.pdf



4 Linux Kernel

$ git clone https://github.com/Icenowy/linux.git

$ sudo vim /etc/hosts
# 添加下面两行
192.30.253.112  github.com
151.101.73.194 github.global.ssl.fastly.net

# 可自行通过dns检测网站检测github.global.ssl.fastly.net,更换为更快的ip地址
# 完整拉取linux极大,建议只拉取单层分支,减少等待时间:
$ git clone --depth=1 -b f1c100s-480272lcd-test https://github.com/Icenowy/linux.git

.config: http://dl.sipeed.com/LICHEE/Nano/SDK/config http://nano.lichee.pro/_static/step_by_step/lichee_nano_linux.config

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

4.1 Notes

SPI:

# CONFIG_SPI_SUN4I is not set
CONFIG_SPI_SUN6I=y


GPIO:

 leds {
             compatible = "gpio-leds";
             blue_led {
                     label = "licheepi:blue:usr";
                     gpios = <&pio 4 4 GPIO_ACTIVE_LOW>; /* PE4 */
             };
             green_led {
                     label = "licheepi:green:usr";
                     gpios = <&pio 4 5 GPIO_ACTIVE_LOW>; /* PE5 */
                     default-state = "on";
             };
             red_led {
                     label = "licheepi:red:usr";
                     gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PE6 */
             };
 };


I2C:

        i2c0: i2c@1C27000 {
            compatible = "allwinner,sun6i-a31-i2c";
            reg = <0x01C27000 0x400>;
            interrupts = <7>;
            clocks = <&ccu CLK_BUS_I2C0>;
            resets = <&ccu RST_BUS_I2C0>;
            pinctrl-names = "default";
            pinctrl-0 = <&i2c0_pins>;
            status = "disabled";
            #address-cells = <1>;
            #size-cells = <0>;
        };


5 Quick Start

5.1 Toolchain

$ wget http://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabi/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar.xz
$ tar -vxJf gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar.xz

$ git clone -b f1c100s-spiflash https://github.com/Icenowy/sunxi-tools.git
$ cd sunxi-tools
$ make && sudo make install

如果出现:fel_lib.c:26:20: fatal error: libusb.h: No such file or directory,那需要安装libusb:

 sudo apt-get install libusb-1.0-0-dev

sunxi-tools:

新到的一片 Nano ,基本上是上电无反应的,LCD亮但无内容,此时 Nano 自动进入fel下载模式,可以通过命令 sudo sunxi-fel ver 来确认有无成功进入fel模式。

此时有两种方式进行程序下载:

# 1.以 uboot file-with-spl形式进行(单次运行,测试时个人推荐)
$ sunxi-fel uboot /your/path/to/u-boot-sunxi-with-spl.bin  # 请自行修改到本机地址

# 2.烧进 spi-flash (开机自启)
$ sunxi-fel -p spiflash-write 0 /your/path/to/u-boot-sunxi-with-spl.bin
# note: 重新烧录或重进fel模式时,请在上电时拉低SPI flash 的 CS引脚

# 查看芯片信息
$ sudo sunxi-fel ver
AWUSBFEX soc=00001663(F1C100s) 00000001 ver=0001 44 08 scratchpad=00007e00 00000000 00000000

# 列出所有芯片的信息
$ sudo sunxi-fel -l

# 加载并执行 uboot 的 spl
$ sudo sunxi-fel spl [文件名]

# 把文件内容写入内存指定地址(-p 是显示写入进度) 
$ sudo sunxi-fel -p write [地址] [文件名]

# 调用指定地址的函数
$ sudo sunxi-fel exec [地址]

# 显示spiflash的信息
$ sudo sunxi-fel spiflash-info

# 读取spiflash指定地址的数据并写入到文件
$ sudo sunxi-fel spiflash-read [地址] [长度] [存放数据的文件路径]

# 写入指定文件的指定长度的内容到spiflash的指定地址
$ sudo sunxi-fel spiflash-write [地址] [长度] [存放数据的文件路径]


5.2 U-Boot

$ git clone https://github.com/Lichee-Pi/u-boot.git
$ cd u-boot
# 切换到 Nano 分支
$ git checkout nano-v2018.01
# 此处告知make采用arm-linux-gnueabi下的所有交叉编译工具,目标架构为Arm,设定各项默认配置为 nano 的spiflash支持版
# 若不带spi-flash的板子,请换成 licheepi_nano_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- licheepi_nano_spiflash_defconfig
  sudo apt-get install python-setuptools


5.3 ROOTFS


5.3.1 Buildroot

$ wget https://buildroot.org/downloads/buildroot-2020.11.2.tar.gz
$ tar xvf buildroot-2020.11.2.tar.gz
$ cd buildroot-2017.08/
$ make menuconfig

.config files: https://fdvad021asfd8q.oss-cn-hangzhou.aliyuncs.com/migrate/buildroot.config


5.3.2 OpenWRT

$ git clone -b licheepi-nano https://github.com/qinfengling/openwrt
cat > .config << EOL
CONFIG_TARGET_sunxi=y
CONFIG_TARGET_sunxi_arm9=y
CONFIG_TARGET_sunxi_arm9_DEVICE_suniv-f1c100s-licheepi-nano=y
CONFIG_DEVEL=y
CONFIG_BRCMFMAC_SDIO=y
CONFIG_BRCMFMAC_USB=y
CONFIG_DRIVER_11AC_SUPPORT=y
CONFIG_DRIVER_11N_SUPPORT=y
CONFIG_PACKAGE_MAC80211_DEBUGFS=y
CONFIG_PACKAGE_MAC80211_MESH=y
CONFIG_PACKAGE_brcmfmac-firmware-usb=y
CONFIG_PACKAGE_hostapd-common=y
CONFIG_PACKAGE_iw=y
CONFIG_PACKAGE_iwinfo=y
CONFIG_PACKAGE_kmod-ata-ahci-platform=y
CONFIG_PACKAGE_kmod-ata-core=y
CONFIG_PACKAGE_kmod-ata-sunxi=y
CONFIG_PACKAGE_kmod-brcmfmac=y
CONFIG_PACKAGE_kmod-brcmutil=y
CONFIG_PACKAGE_kmod-cfg80211=y
CONFIG_PACKAGE_kmod-libphy=y
CONFIG_PACKAGE_kmod-mac80211=y
CONFIG_PACKAGE_kmod-mmc=y
CONFIG_PACKAGE_kmod-nls-base=y
CONFIG_PACKAGE_kmod-of-mdio=y
CONFIG_PACKAGE_kmod-rtc-sunxi=y
CONFIG_PACKAGE_kmod-scsi-core=y
CONFIG_PACKAGE_kmod-sun4i-emac=y
CONFIG_PACKAGE_kmod-usb-core=y
CONFIG_PACKAGE_libiwinfo=y
CONFIG_PACKAGE_swconfig=y
CONFIG_PACKAGE_wireless-regdb=y
CONFIG_PACKAGE_wpad-mini=y
CONFIG_SOFT_FLOAT=y
CONFIG_TARGET_OPTIONS=y
EOL
$ ./scripts/feeds update -a && ./scripts/feeds install -a
$ make defconfig
$ make world

Reference:


5.4 Deploy TF

$ sudo fdisk -l     # 首先查看电脑上已插入的TF卡的设备号
$ sudo umount /dev/sdXx # 若自动挂载了TF设备,请先卸载
$ sudo fdisk /dev/sdX   # 进行分区操作
# 若已存分区即按 d 删除各个分区
# 通过 n 新建分区,第一分区暂且申请为32M(足够大了...),剩下的空间都给第二分区
# w 保存写入并退出
$ sudo mkfs.vfat /dev/sdX1 # 将第一分区格式化成FAT
$ sudo mkfs.ext4 /dev/sdX2 # 将第一分区格式化成EXT4

第一分区:

  • boot.scr
  • zImage
  • suniv-f1c100s-licheepi-nano.dtb

第二分区:

  • 根文件系统内容


6 Boot

After power-up, the F1C100s starts to fetch instructions from address 0xFFFF_0000 which is where the BROM is located at. It's an internal integrated 32 KB ROM Chip (Boot ROM or BROM).

The BROM split up into two parts: The first part (at 0xFFFF_0000) is the FEL mode and the second is the eGON.BRM (located at 0xFFFF_4000).

The reset vector is located at the very begining of FEL mode: at address 0xFFFF_0000. On reset, it jumps to 0xFFFF_0028 where it loads 0xFFFF_4000 (eGON.BRM) into the program counter to be executed next.


6.1 eGON Boot

The eGON Boot ROM performs a few tasks:

  1. do some co-processor setup (c15, (virtual) System Control Coprocessor).
  2. disables the WatchDog Timer
  3. setups CPU, AXI, AHB and APB0 clocks
  4. enables AHB Gating
  5. enables APB0 Gating
  6. sets the Stack Pointer to 32K
  7. then it jumps to 'boot' which immediately jumps to check_uboot
  8. check_uboot setups up some registers, then checks the status pin (often called FEL pin, BSP pin or uboot)
    1. if the pin is low (connected to GND) executes FEL mode at 0xFFFF_0020.
    2. If the pin is high it continues trying to boot from the following media and on failure continues to the next in order.
      1. SD Card0 also known as MMC0
      2. Internal NAND flash also known as NAND
      3. SD Card2 also known as MMC2
      4. SPI connected NOR flash also known as SPI
      5. If all fails, FEL/USB Boot mode is executed from 0xFFFF_0020

As can be seen, the SoC has several ways to boot and a lot would need to go wrong or 'fail' before entering FEL mode. This is especially important if there is a valid header in the NAND flash. Obviously this can be abused, by corrupting the header and thus forcing failure. If no other boot options are available, then FEL mode should be the final result. As a bypass mechanism, the A10 has the so called Boot Select Pin (BSP). This pin is normally internally pulled up by a 50KΩ resistor. If the pin is pulled low to GND, the A10 will try to boot into FEL mode. Otherwise the above boot-order will be tried.

boot-> check fel key pressed (yes)--> FEL mode (boot from USB OTG)
                          \  
                      (no) \
                            \-------> 1) try to boot from SMHC0 (SD card)
                                      2) try to boot from SMHC2 (eMMC)
                                      3) try to boot from SPI0 (SPI NOR Flash)
                                      4) FEL mode (boot from USB OTG)

6.2 FEL mode

  • 短接 flash 的 1、4 两脚,重新上电,上电后松开短接,即可重新进入 fel 模式
  • 在启动到内核前,回车进入 uboot,执行 sf probe 0;sf erase 0 0x100000;reset 即可重新进入 fel 模式


6.3 Reference


7 Reference









个人工具
名字空间

变换
操作
导航
工具箱