开发环境搭建
1. 板子硬件连接¶
1.1. SSC35XG主板示意图¶
电源:DC 12V,
调试串口:TTL电平,特率115200
PCB Layer:6Layer
1.2. SSD268G主板示意图¶
电源:DC 12V,
调试串口:TTL电平,特率115200
PCB Layer:4Layer
1.3. SSD261Q主板示意图¶
电源:DC 12V,
调试串口:TTL电平,特率115200
PCB Layer:4Layer
2. 准备编译环境¶
通常我们会以交叉编译的方式进行开发和调试,即“宿主机+目标机”的形式。而宿主机和目标机的连接我们一般采用串口连接或网络连接,如下图所示:
2.1. 宿主机Linux系统工具安装与设置¶
宿主机系统建议使用Ubuntu 16.04及以上。
-
默认shell配置
编译脚本默认使用的是bash,要求系统的默认shell为bash,可通过ls -la /bin/sh命令来确认。以最常用的Ububtu为例,高版本的Ubuntu默认shell为dash,修改方式如下:
# ls -la /bin/sh lrwxrwxrwx 1 root root 4 Jun 15 08:49 /bin/sh -> dash # sudo dpkg-reconfigure dash #在弹出的界面选择<NO> # ls -la /bin/sh lrwxrwxrwx 1 root root 4 Jun 15 08:49 /bin/sh -> bash
-
设置默认python版本为python2.x
python2与python3的语义有差别,SDK编译脚本使用的是python2的语义,因此需要将系统默认python版本设置为python2.x,修改方式请参考网络上的相关文档,比如使用
update-alternatives
工具来配置。 -
安装mkfs.ubifs工具
系统需已安装mkfs.ubifs工具,如Ubuntu可通过
sudo apt-get install mtd-utils
命令安装。
2.2. 安装交叉编译工具链¶
boot、kernel、project
统一使用一个交叉编译工具,Glibc:arm-linux-gnueabihf-sigmastar-9.1.0-
。
在Linux环境下将编译工具链解压到特定目录,然后将该路径添加到PATH环境变量中。可以使用如下命令在当前终端中修改PATH环境变量,或者将这条配置添加到~/.bashrc
文件中。
# export PATH=${PATH}:~/toolchains/gcc-sigmastar-9.1.0-2020.07-x86_64_arm-linux-gnueabihf/bin
2.3. 环境变量配置¶
在开始编译之前需先声明如下两个环境变量:
# declare -x ARCH="arm" # declare -x CROSS_COMPILE=" arm-linux-gnueabihf-sigmastar-9.1.0-"
3. 编译¶
发布的SDK中包含boot、kernel、project、sdk
四个压缩包,将这4个压缩包解压到同一级目录,如下:
tianhui.he@xml0bc6401:~/codes/SSD268G/release_0413/sourcecode$ ls boot kernel project sdk
本芯片支持nor flash、spi nand flash和emmc三种启动方式,因此在SDK中编译有所区分,通过不同的配置文件来实现。
3.1. 编译boot¶
# cd $/{Alkaid}/boot
-
uboot defconfig
STORE Glibc compiler Uclibc compiler uboot make config NOR arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_defconfig NAND arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_spinand_defconfig EMMC1 arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_emmc1_defconfig EMMC0 arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_emmc0_defconfig 注:请参考表格和你的存储类型做对应的编译。
# make mercury6_xxx_defconfig; //SSD261Q蓝色开发板默认使用emmc0,SSD268G黑色开发板默认使用emmc1 # make clean; # make
-
Get image
# cp u-boot.xz.img.bin ${ your_release_path } // 选择spi-nor和emmc时 # cp u-boot_spinand.xz.img.bin ${ your_release_path }// 选择spi-spinand时
3.2. 编译kernel¶
# cd $/{Alkaid}/kernel
-
SPI-NOR Kernel (ASIC)
CHIP Glibc compiler Uclibc compiler Kernel make config DTS 35XG 512x512MB arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_ssc016a_s01a_defconfig mercury6-ssc016-s01a.dts 268G,4+4lane sensor,512x512MB arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_ssc016a_s01a_dispcam_defconfig mercury6-ssc016-s01a-dispcam.dts 268G,2+4+2lane sensor,512x512MB arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_ssc016a_s01a_dispcam_2+4+2mipi_defconfig mercury6-ssc016a-s01a-dispcam-2+4+2mipi.dts 268G for usbcam, 512x512MB arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_ssc016a_s01a_usbcam_defconfig mercury6-ssc016-s01a.dts 261Q,4+2lane sensor,256MB arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_ssc019a_s01a_dispcam_defconfig mercury6-ssc019a-s01a-dispcam.dts -
SPI-NAND Kernel (ASIC)
CHIP Glibc compiler Uclibc compiler Kernel make config DTS 35XG 512x512MB arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_ssc016a_s01a_spinand_defconfig mercury6-ssc016-s01a.dts 268G,4+4lane sensor,512x512MB arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_ssc016a_s01a_spinand_dispcam_defconfig mercury6-ssc016-s01a-dispcam.dts 268G,2+4+2lane sensor,512x512MB arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_ssc016a_s01a_spinand_dispcam_2+4+2mipi_defconfig mercury6-ssc016a-s01a-dispcam-2+4+2mipi.dts 268G for usbcam, 512x512MB arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_ssc016a_s01a_spinand_usbcam_defconfig mercury6-ssc016-s01a.dts 261Q,4+2lane sensor,256MB arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_ssc019a_s01a_spinand_dispcam_defconfig mercury6-ssc019a-s01a-dispcam.dts -
EMMC Kernel (ASIC)
CHIP Glibc compiler Uclibc compiler Kernel make config DTS 268G,4+4lane sensor,512x512MB arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_ssc016a_s01a_spinand_dispcam_defconfig mercury6-ssc016-s01a-dispcam.dts 268G,2+4+2lane sensor,512x512MB arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_ssc016a_s01a_spinand_dispcam_2+4+2mipi_defconfig mercury6-ssc016a-s01a-dispcam-2+4+2mipi.dts 261Q,4+2lane sensor,256MB arm-linux-gnueabihf-sigmastar-9.1.0- mercury6_ssc019a_s01a_emmc_dispcam_defconfig mercury6-ssc019a-s01a-dispcam.dts 注:请参考表格和你的芯片版本做对应的编译。
# make xxx_kernel_make_config *(exp: make mercury6_ssc016a_s01a_spinand_defconfig)* # make clean; # make
-
Get image
# cp arch/arm/boot/uImage.xz ${ your_release_path }
3.3. 编译SDK(ALKAID)¶
注意,由于在project下执行"make image"时会自动重编kernel,如果有修改kernel的配置的话应添加到对应的defconfig中,kernel下手动"make menuconfig"生成的".config"文件会被覆盖掉。一般情况下如果不更新Uboot的话只需要在project使用以下对应config编译即可。
-
SPI-NOR flash package
CHIP Glibc Uclibc 35XG 512x512MB ipc_m6_nor.glibc-9.1.0-squashfs.016a.512x512.bga2_defconfig NA 268G,4+4lane sensor,512x512MB dispcam_m6_nor.glibc-9.1.0-squashfs.016a.512x512.bga2.demo_defconfig NA 268G,2+4+2lane sensor,512x512MB dispcam_m6_nor.glibc-9.1.0-squashfs.016a.512x512.bga2.2+4+2mipi_demo_defconfig NA 268G for usbcam, 512x512MB usbcam_m6_nor.glibc-9.1.0-squashfs.016a.512x512.bga2_defconfig NA 261Q,4+2lane sensor,256MB dispcam_m6_nor.glibc-9.1.0-squashfs.019a.256.bga1.demo_defconfig NA -
SPI-NAND flash package
CHIP Glibc Uclibc 35XG 512x512MB ipc_m6_spinand.glibc-9.1.0-squashfs.016a.512x512.bga2_defconfig NA 268G,4+4lane sensor,512x512MB dispcam_m6_spinand.glibc-9.1.0-squashfs.016a.512x512.bga2.demo_defconfig NA 268G,2+4+2lane sensor,512x512MB dispcam_m6_spinand.glibc-9.1.0-squashfs.016a.512x512.bga2.2+4+2mipi_demo_defconfig NA 268G for usbcam, 512x512MB usbcam_m6_spinand.glibc-9.1.0-squashfs.016a.512x512.bga2_defconfig NA 261Q,4+2lane sensor,256MB dispcam_m6_spinand.glibc-9.1.0-squashfs.019a.256.bga1.demo_defconfig NA -
EMMC flash package
CHIP Glibc Uclibc 268G,4+4lane sensor,512x512MB dispcam_m6_emmc.glibc-9.1.0-squashfs.016a.512x512.bga2.demo_defconfig NA 268G,2+4+2lane sensor,512x512MB dispcam_m6_emmc.glibc-9.1.0-squashfs.016a.512x512.bga2.2+4+2mipi_demo_defconfig NA 261Q,4+2lane sensor,256MB dispcam_m6_emmc.glibc-9.1.0-ext4.019a.256.bga1.demo_defconfig NA 注:请参考表格和你的芯片版本做对应的编译。
# cd $/{Alkaid}/project # make xxx_alkaid_build_config *(exp: make ipc_m6_spinand.glibc-9.1.0-squashfs.016a.512x512.bga2_defconfig)* # make image
-
Get image
编译完成后将在project/image/output/images/目录生成image,如下:
4. 烧写¶
通过第3章步骤生成的image包可以烧录到板子上运行,SDK也有已经打包好的demo板image,可以通过烧录demo板对应的image运行来检查板子的好坏。
4.1. 通过ISP Tool烧录boot¶
本方式适用于空机烧录,或者uboot已经损坏导致无法通过uboot升级的场合。重新烧录boot后,在重烧的uboot下通过TFTP或者UFU升级。目前只支持nand跟nor flash,需要注意的是必须使用如下图这种专用的串口小板才可以烧写。
4.1.1 SPI-NOR-Flash¶
-
默认分区
No range size IPL 0x00000000-0x00010000 64KB IPL_CUST 0x00010000-0x00020000 64KB MXPT 0x00020000-0x00030000 64KB UBOOT 0x00030000-0x0004F000 124KB UBOOT_ENV 0x0004F000-0x00050000 4KB BOOT 0x00000000-0x00050000 320KB KERNEL 0x00050000-0x00250000 2048KB ROOTFS 0x00250000-0x00650000 4096KB NVRSERVICE 0x00650000-0x00950000 3072KB CUSTOMER 0x00950000-0x01000000 6848KB -
ISP工具烧录
offset Binary放置目录 IPL.bin 0x00000 ${ALKAID}\project\image\output\images\boot\IPL.NO_JTAG.bin IPL_CUST.bin 0x10000 ${ALKAID}\project\image\output\images\boot\IPL_CUST.NO_JTAG.bin MXP_SF.bin 0x20000 ${ALKAID}\project\image\output\images\boot\MXP_SF.bin u-boot.xz.img.bin 0x30000 ${ALKAID}\project\image\output\images\boot\u-boot.xz.img.bin 注:6Layer板IPL.bin和IPL_CUST.bin为IPL.2133_4X.ext_NANYA_DDR3_6L.bin和IPL_CUST.2133_4X.ext_NANYA_DDR3_6L.bin,下面选择也要相应更改。IPL的选择具体请参考《IPL相关》
-
烧录步骤
Step 1. 关闭UART链接,否则无法正常连接ISP tool。demo板系统下输入“11111”,log出现disable uart表示关闭,再次输入“11111”,log出现enable uart表示开启;demo板uboot下输入“debug 回车”,log出现debug mode on, cmdline is disabled表示关闭。pc终端也要断开uart连接。
Step 2. 执行ISP tool。
Step 3. 选择SPI tab, 点击
More
并且选择类型为SPINOR
。Step 4. 加载烧录文件并点击
Connect
。Step 5. 加载image
IPL.bin
,并点击Run
。注:需要勾选"erase file area"。
Step 6. 加载image
IPL_CUST.bin
,取消Erase Device
选项,设置Base shift
at 0x10000。注: 可能随着版本变化,Base shift的地址以ISP工具烧录表格数据为准。
Step 7. 加载image
MXP_SF.bin
,设置Base shift
at 0x20000。Step 8. 加载image
u-boot.xz.img.bin
, 设置Base shift
at 0x30000。Step 9. 重启EVB板子,关闭工具。
4.1.2. SPI-NAND Flash¶
-
默认分区
No range size CIS 0x00000000-0x0020000 128KB IPL0 0x00140000-0x00200000 768KB IPL_CUST0 0x00200000-0x00260000 384KB IPL_CUST1 0x00260000-0x002c0000 384KB UBOOT0 0x002c0000-0x00320000 384KB UBOOT1 0x00320000-0x00380000 384KB ENV 0x00380000-0x003c0000 256KB KERNEL 0x003c0000-0x008c0000 5120KB RECOVERY 0x008c0000-0x00dc0000 5120KB rootfs 0x00dc0000-0x013c0000 6144KB UBI 0x013c0000-0x008000000 110848KB -
ISP工具烧录
-
ISP Tool版本
请确定 Flash_Tool版本为V5.0.19.exe。
ISP Tool会在首次版本发布的时候一起打包在Tool目录下。
-
Images列表
Offset Image所在目录 GCIS.bin 0x000000 project\image\output\images\ GCIS.bin IPL.bin 0x140000 project\image\output\images\IPL.bin IPL_CUST.bin 0x200000 project\image\output\images\IPL_CUST.bin u-boot_spinand.xz.img.bin 0x2C0000 project\image\output\images\ u-boot_spinand.xz.img.bin 注:6Layer板IPL.bin和IPL_CUST.bin为IPL.2133_4X.ext_NANYA_DDR3_6L.bin和IPL_CUST.2133_4X.ext_NANYA_DDR3_6L.bin。IPL的选择具体请参考《IPL相关》
-
-
烧录步骤
Step 1. 关闭UART链接,否则无法正常连接ISP tool。demo板系统下输入“11111”,log出现disable uart表示关闭,再次输入“11111”,log出现enable uart表示开启;demo板uboot下输入“debug 回车”,log出现debug mode on, cmdline is disabled表示关闭。pc终端也要断开uart连接。
Step 2. 执行ISP tool。
Step 3. 选择SPI tab, 点击
More
并且选择类型为SPINAND
。Step 4. 加载烧录文件并点击
Connect
。Step 5. 加载image
GCIS.bin
,并点击Run
。注:需要勾选"erase all chip"。
Step 6. 加载 image
IPL.bin
, 取消Erase Device
选项, 设置Base shift
at 0x140000。Step 7. 加载image
IPL_CUST.bin
, 设置Base shift
at 0x200000。Step 8. 加载image
u-boot_spinand.xz.img.bin
, 设置Base shift
at 0x2C0000。Step 9. 重启EVB板子,关闭工具。
4.2. 在uboot下使用TFTP烧录¶
-
Run tftp (FTP server) on PC
Step 1. 使用tftp工具指向image path:project\image\output\images\,并选择正确的pc网卡ip地址。
Step 2. 连接板子的网口到PC端,连接debug串口工具到PC端,并检查连接的正确性。
-
Run tftp (FTP Client) on EVB
Step 1. 板子开机,长按回车,进入bootloader command line。
Step 2. 首次烧录请设置网络IP环境变量:(除非ip设置变更或者更换flash)
# set -f gatewayip 192.168.1.1 # set -f ipaddr 192.168.1.127 (设定FTP Client (EVB板子)使用的IP) # set -f netmask 255.255.255.0 # set -f serverip 192.168.1.100 (设定FTP server (PC) 的IP) # saveenv
注:
1. 为了保证烧录顺利,请保证PC和开发板链接同一交换机。
2. 您也可以使用独立网卡使PC端直连开发板,固定该网卡的内网ip地址,并按上述方法设定开发板。
Step 3. 在UBOOT console下执行以下指令即可自动透过ethernet烧录。
4Layer板: # estar (OR: estar auto_update.txt) 6Layer板: # estar auto_update_6layers.txt 若要单独升级某一部分可以在`estar`命令后添加参数,参考`auto_update.txt`文档中的写法,如`estar scripts/[[kernel.es`
4.3. 通过USB烧录¶
USBDownloadTool升级是在u-boot中通过gegadget mass storage driver,用SCSI command形式发送ufu command到板子usb device来完成升级,过程与使用tftp server升级相同,不同的是通过usb,而不是网口,因此,首先需要在u-boot中开启对gegadget mass storage driver和ufu command的支持。
4.3.1. 板子从uboot下ufu升级¶
-
uboot开启ufu command
# cd $/{Alkaid}/boot # make menuconfig
注意:如果选择Auto run ufu command in boot,那么u-boot就会启动跑进ufu停住,等待升级。此项用在空片升级才需要选,正常情况是不需要选上,否则会进不到kernel。
-
uboot下执行升级
Step 1. 板子启动进入u-boot命令行,执行以下两条命令:
# setenv ota_upgrade_status 1 # saveenv
Step 2. 重启,此时u-boot将进入ufu command停住,等待升级,如下图:
Step 3. 将SDK下的USBDownloadTool文件夹里文件复制到要烧录的image目录下,如下图所示:
然后运行USBDownloadTool.exe,点击
Upgrade Firmware
等待完成升级。Step 4. 升级完成,注意清除ota,然后重启,否则将会再次进入ufu command,执行:
# setenv ota_upgrade_status 0 # saveenv
4.3.2. 空片状态下ufu升级¶
USBDownloadTool可用在空片时升级,当flash为空片,ROM会进USB boot,此时USBDownloadTool可以检测到mass storage,点击Upgrade Firmware
将会先将usb_updater.bin和u-boot.bin加载到板子Dram中运行,这里u-boot.bin在编译时就选择了"Auto run ufu command in boot"(如下图),因此会自动跑进上述4.3.1. 板子从uboot下ufu升级 Step 2的ufu command中等待USBDownloadTool下发升级。在SDK包下有支持不同flash的USBDownloadTool包,EMMC要根据硬件接口选择u-boot.bin,具体看README文档。Demo板进行EMMC烧录时拨码开关要拨到对应位置,请参考4.5. 对EMMC进行烧录。
4.3.3. UVC升级¶
UVC升级是在板子device端运行UVC时,通过USBDownloadTool下发一个自定义XU command,设置ota_upgrade_status为1,然后重启,将会在u-boot时进入ufucommand,等待USBDownloadTool下发升级。
Step 1. XU command修改 在XU command添加对ota升级的处理:system("/etc/fw_setenv ota_upgrade_status 1");
Step 2. 板子端UVC运行起来,在PC端能看到uvccamera设备,然后运行USBDownloadTool.exe,点击"Upgrade Firmware",此时USBDownloadTool将会一直等待板子端进入u-boot;
Step 3. 重启板子,将进入u-bootufucommand,USBDownloadTool检测到后,就会自动下发升级,等待升级完成。
4.4. 通过sd卡烧录¶
芯片支持从SD卡启动,需将开发板上的拨码配置为SD 1st
模式。
Step 1. 从project/board/m6/boot/ipl目录下将IPL.LoadFromSD.bin
及IPL_CUST.LoadFromSD.bin
这两个文件拷贝到SD卡根目录,并依次重命名为IPL
及IPL_CUST
。
Step 2. 将编译完成后的images目录下的boot/u-boot_spinand.xz.img.bin
文件拷贝到SD卡根目录,并重命名为UBOOT
。
Step 3. 将SD卡插到板子上之后即可通过SD卡中的IPL及UBOOT启动到U-boot环境,如下图,可以看到Load from SD的提示。此时可参考4.2.在uboot下使用TFTP烧录使用网口升级,或按下一步骤从SD卡烧写image。
Step 4. 若是板子无网络,可以在编译成功后,project目录下执行./make_sd_upgrade_sigmastar.sh
命令,在交互命令中根据实际需要升级的模块选择要打包的模块,如下图:
打包完成后将在project/image/output/images/目录下生成SigmastarUpgradeSD.bin
跟upgrade_script.txt
这两个文件,将这两个文件拷贝到SD卡根目录。
Step 5. 将SD卡插到板子上之后通过SD卡中的IPL及UBOOT启动到U-boot环境,执行sdstar
命令,即可将之前打包的sd卡升级镜像写到flash中。
注意,若是无sdstar命令的话则需重编uboot,开启CONFIG_MS_SDMMC选项。
4.5. 对EMMC进行烧录¶
目前无法通过isp工具烧写EMMC,当EMMC空片或是其他原因导致无法启动到uboot环境时需使用usb口升级。
Step 1. 设置拨码开关。
-
使用268G开发板需将1~5全部拨到B端
-
使用261开发板需将1~5依次拨为BBABB
Step 2. 使用usb线将板子的usb device口连接到pc端。
Step 3. 解压“USBDownloadTool_SSD26x_emmc.rar”压缩包,根据压缩包中的README.txt文件说明重命名文件。
Step 4. 将编译出来的image文件夹下的所有文件复制到解压出来的USBDownloadTool_SSD26x_emmc目录下,按照UFU空片烧录的步骤升级即可,参考4.3.2.空片状态下ufu升级。
Step 5. 升级完成后将拨码恢复为正确的模式(4bit/8bit)即可正常启动。
注意:
使用EMMC需要配置kernel和uboot对emmc的支持,此时可参考《EMMC使用参考》。