RTT 全志D1s跑tina linux
刚毕业那会抽奖抽了一块RTT的D1S开发板,看了一下打印log就放下吃灰了。跑RT-thread的感觉折腾起来太麻烦了就让他吃灰了。最近手头有一块屏幕和一个2欧的小喇叭打算驱动一下。 正好这块板子也出来好多年了。玩一玩。首先我找到了百问网的哪吒开发板他也是D1S的,直接把他的SDK给搞下来编译,根据开发板的配置正好是个贴片的SD卡,正好有SD卡的配置
直接选6,可以正常烧录,但是烧录后boot完,不进行下一步的打印。我怀疑烧录的地方不对,找了一大圈之后发现机器是能正常启动的。因为ADB这些东西都是正常化的可以执行一些相关的操作。经过一下午的折腾现在终于是可以正常的打印启动的相关log了,现在记录一下操作过程。网上也有相关帖子。主要是参考他们的,在此过程中对全志的SDK进一步的熟悉了。
首先是修改debug的调试串口,这个关乎到生成的镜像文件 /home/shy/d1s/tina-d1-h/device/config/chips/d1s/configs/nezha_sd/sys_config.fex
[uart_para]
uart_debug_port = 3
uart_debug_tx = port:PG8<5><1><default><default>
uart_debug_rx = port:PG9<5><1><default><default>
调试产口改到串口3.
改uboot中相关内容
/home/shy/d1s/tina-d1-h/lichee/brandy-2.0/u-boot-2018/configs/sun20iw1p1_defconfig
添加
CONFIG_SPECIFY_CONSOLE_INDEX=y
CONFIG_CONS_INDEX=4 #说明:这里是UART3+1 = 4 串口号+1
修改/home/shy/d1s/tina-d1-h/device/config/chips/d1s/configs/nezha_sd/uboot-board.dts
&card0_boot_para { /* Avoid dtc compiling warnings. @TODO: Developer should modify this to the actual value /
/ reg = <0x0 0x2 0x0 0x0>; [> Avoid dtc compiling warnings. @TODO: Developer should modify this to the actual value <] */
device_type = "card0_boot_para";
card_ctrl = <0x0>;
card_high_speed = <0x1>;
card_line = <0x4>;
pinctrl-0 = <&sdc0_pins_a>; //取消这段代码的注释
};
接下来是修改启动介质这个修改后就支持线刷了
/home/shy/d1s/tina-d1-h/lichee/brandy-2.0/u-boot-2018/drivers/sunxi_flash/mmc/sdmmc.c
int sunxi_sprite_mmc_probe(void)
{
#ifndef CONFIG_MACH_SUN50IW11
return sdmmc_init_for_sprite(0, 0); //02 这里是从sd卡进行启动
#else
int workmode = uboot_spare_head.boot_data.work_mode;
if (workmode == WORK_MODE_CARD_PRODUCT)
return -1;
else
return sdmmc_init_for_sprite(0, 0);
#endif
}
接下来是修改kernel
/home/shy/d1s/tina-d1-h/lichee/linux-5.4/arch/riscv/boot/dts/sunxi/sun20iw1p1.dtsi
chosen {
bootargs = "console=ttyS3,115200n8 debug loglevel=7,initcall_debug=1 init=/init earlycon=sbi";
stdout-path = "serial0:115200n8";
linux,initrd-start = <0x42000000>;
linux,initrd-end = <0x43000000>;
};
uart3: uart@2500c00 {
compatible = "allwinner,sun20i-uart";
device_type = "uart3";
reg = <0x0 0x02500c00 0x0 0x400>;
interrupts-extended = <&plic0 21 IRQ_TYPE_LEVEL_HIGH>;
sunxi,uart-fifosize = <256>;
clocks = <&ccu CLK_BUS_UART3>;
clock-names = "uart3";
resets = <&ccu RST_BUS_UART3>;
uart3_port = <3>;
uart3_type = <4>;
status = "okay";
};
/home/shy/d1s/tina-d1-h/device/config/chips/d1s/configs/nezha_sd/board.dts
&uart3 {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&uart3_pins_a>;
pinctrl-1 = <&uart3_pins_b>;
status = "okay";
};
uart3_pins_a: uart3_pins@0 { /* For EVB1 board */
// pins = "PB6", "PB7";
pins = "PG8", "PG9";
function = "uart3";
muxsel = <7>;
drive-strength = <10>;
bias-pull-up;
};
uart3_pins_b: uart3_pins@1 { /* For EVB1 board */
// pins = "PB6", "PB7";
pins = "PG8", "PG9";
function = "gpio_in";
};
还有环境变量的修改 /home/shy/d1s/tina-d1-h/device/config/chips/d1s/configs/default/env.cfg
# #kernel command arguments
# earlyprintk=sunxi-uart,0x02500000
# initcall_debug=0
# console=ttyS3,115200
#kernel command arguments
earlyprintk=sunxi-uart,0x02500C00 //此处的地址根据实际串口外设地址修改
initcall_debug=0
console=ttyS3,115200 //此处的ttyS3需要根据相应的实际串口修改,如串口3则是ttyS3
nand_root=/dev/ubiblock0_5
mmc_root=/dev/mmcblk0p5
nor_root=/dev/mtdblock5
mtd_name=sys
rootfstype=squashfs
root_partition=rootfs
boot_partition=boot
init=/sbin/init
loglevel=8
cma=0M
mac=
wifi_mac=
bt_mac=
specialstr=
keybox_list=widevine,ec_key,ec_cert1,ec_cert2,ec_cert3,rsa_key,rsa_cert1,rsa_cert2,rsa_cert3
dsp0_partition=dsp0
#set kernel cmdline if boot.img or recovery.img has no cmdline we will use this
setargs_nand=setenv bootargs ubi.mtd=${mtd_name} ubi.block=0,${root_partition} earlyprintk=${earlyprintk} clk_ignore_unused initcall_debug=${initcall_debug} console=${console} loglevel=${loglevel} root=${nand_root} rootfstype=${rootfstype} init=${init} partitions=${partitions} cma=${cma} snum=${snum} mac_addr=${mac} wifi_mac=${wifi_mac} bt_mac=${bt_mac} specialstr=${specialstr} gpt=1
setargs_nand_ubi=setenv bootargs ubi.mtd=${mtd_name} ubi.block=0,${root_partition} earlyprintk=${earlyprintk} clk_ignore_unused initcall_debug=${initcall_debug} console=${console} loglevel=${loglevel} root=${nand_root} rootfstype=${rootfstype} init=${init} partitions=${partitions} cma=${cma} snum=${snum} mac_addr=${mac} wifi_mac=${wifi_mac} bt_mac=${bt_mac} specialstr=${specialstr} gpt=1
setargs_mmc=setenv bootargs earlyprintk=${earlyprintk} clk_ignore_unused initcall_debug=${initcall_debug} console=${console} loglevel=${loglevel} root=${mmc_root} init=${init} partitions=${partitions} cma=${cma} snum=${snum} mac_addr=${mac} wifi_mac=${wifi_mac} bt_mac=${bt_mac} specialstr=${specialstr} gpt=1
setargs_nor=setenv bootargs ubi.mtd=${mtd_name} ubi.block=0,${root_partition} earlyprintk=${earlyprintk} clk_ignore_unused initcall_debug=${initcall_debug} console=${console} loglevel=${loglevel} root=${nor_root} rootfstype=${rootfstype} init=${init} partitions=${partitions} cma=${cma} snum=${snum} mac_addr=${mac} wifi_mac=${wifi_mac} bt_mac=${bt_mac} specialstr=${specialstr} gpt=1
#nand command syntax: sunxi_flash read address partition_name read_bytes
#0x4007f800 = 0x40080000(kernel entry) - 0x800(boot.img header 2k)
boot_dsp0=sunxi_flash read 45000000 ${dsp0_partition};bootr 45000000 0 0
boot_normal=sunxi_flash read 41000000 ${boot_partition};bootm 41000000
boot_recovery=sunxi_flash read 45000000 recovery;bootm 45000000
boot_fastboot=fastboot
#uboot system env config
bootdelay=1
#default bootcmd, will change at runtime according to key press
#default nand boot
bootcmd=run setargs_nand boot_normal
期间参考了 https://blog.csdn.net/qq_39838924/article/details/136534361
https://www.cnblogs.com/yddeboke/p/17191230.html
https://blog.51cto.com/u_15380233/5815815