一)环境
a)ubuntu18.04
b)arm-linux-gnueabi-gcc 7.5.0 / gcc 7.5.0
c)FriendlyArm tiny4412 标准版
二)目标
a)上电从SD卡启动u-boot
b)u-boot从SD卡启动linux
c)linux从SD卡加载根文件系统
d)使用当前最新版u-boot-2020.01.tar.bz2;下载地址:ftp://ftp.denx.de/pub/u-boot/
e)使用当前最新版busybox-1.31.1.tar.bz2,下载地址:https://busybox.net/downloads/
f)使用当前最新版linux-5.5.tar.xz,下载地址:https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/
三)步骤
a)Makefile:
1)add "ARCH = arm";
2)add "CROSS_COMPILE = arm-linux-gnueabi-";
3)comment CFGCHK;
b)configs/tiny4412_defconfig:
1)cp configs/origen_defconfig configs/tiny4412_defconfig;
2)change "ORIGEN" to "TINY4412";
3)change "4210" to "4412";
4)change CONFIG_SPL_TEXT_BASE value to 0x02023400;
5)change CONFIG_DEFAULT_DEVICE_TREE to "exynos4412-tiny4412";
6)change CONFIG_ENV_SIZE to 0x4000;
7)change CONFIG_ENV_OFFSET to 0x6200;
note:please read sd_fusing.sh to set above 6) and 7)
c)include/configs/tiny4412.h:
1)cp include/configs/origen.h include/configs/tiny4412.h;
2)change "ORIGEN" to "TINY4412";
3)change "4210" to "4412";
4)add "dtbaddr=0x42000000\0" in CONFIG_EXTRA_ENV_SETTINGS;
5)add "load mmc ${mmcdev} ${loadaddr} uImage;" in CONFIG_BOOTCOMMAND;
6)add "load mmc ${mmcdev} ${rdaddr} ramdisk.img;" in CONFIG_BOOTCOMMAND;
7)add "load mmc ${mmcdev} ${dtbaddr} exynos4412-tiny4412.dtb;" in CONFIG_BOOTCOMMAND;
8)add "bootm ${loadaddr} ${rdaddr} ${dtbaddr}" in CONFIG_BOOTCOMMAND;
9)add marco "#define CONFIG_SPL_SERIAL_SUPPORT";
10)add marco "#define CONFIG_SPL_GPIO_SUPPORT";
11)add marco "#define CONFIG_DEBUG_UART";
12)add marco "#define CONFIG_DEBUG_UART_S5P";
13)add marco "#define CONFIG_DEBUG_UART_BASE 0x13800000";
14)add marco "#define CONFIG_DEBUG_UART_CLOCK (100000000)";
d)board/samsung/tiny4412:
1)cp -rf board/samsung/origen board/samsung/tiny4412;
2)cd board/samsung/tiny4412/;
3)mv origen.c tiny4412.c;
4)mv tools/mkorigenspl.c tools/mktiny4412spl.c;
5)change "origen" to "tiny4412" in Makefile;[!!Match case]
6)change "origen" to "tiny4412" in MAINTAINERS;[!!Match case]
7)change "origen" to "tiny4412" in Makefile;[!!Match case]
e)arch/arm/dts/exynos4412-tiny4412.dts:
1)cp -f arch/arm/dts/exynos4210-origen.dts arch/arm/dts/exynos4412-tiny4412.dts;
2)change model value to "Friendly Tiny4412 board based on Exynos4412";
3)change compatible value to "friendly,tiny4412", "samsung,exynos4412";
4)change "4210" to "4412";
5)change console value to "/serial@13800000" in aliases;
6)add "mmc0 = "/sdhci@12530000";" in aliases;
7)int root body, add sdhci@12530000 node like this:
sdhci@12530000
{
compatible = "samsung,exynos4412-sdhci";
samsung,bus-width = <4>;
samsung,timing = <1 2 3>;
cd-gpios = <&gpk2 2 0>;
};
f)drivers/serial/serial_s5p.c:
1)change ufcon value to 0x11 in s5p_serial_init();
2)change ucon value to 0x3c5 in s5p_serial_init();
g)arch/arm/mach-exynos/Makefile:
1)change CONFIG_EXYNOS4210 to CONFIG_EXYNOS4412;
h)arch/arm/mach-exynos/clock_init_exynos4.c:
1)void system_clock_init(void)
{
struct exynos4x12_clock *clk =
(struct exynos4x12_clock *)samsung_get_base_clock();
/* APLL= 1400 MHz MPLL=800 MHz */
writel(0x01000001, &clk->src_cpu);
sdelay(0x10000);
writel(0x10, &clk->src_leftbus);
writel(0x10, &clk->src_rightbus);
writel(0x110, &clk->src_top0);
writel(0x1111000, &clk->src_top1);
writel(0x00011000, &clk->src_dmc);
writel(CLK_SRC_FSYS_VAL, &clk->src_fsys);
writel(CLK_SRC_PERIL0_VAL, &clk->src_peril0);
writel(CLK_SRC_CAM_VAL, &clk->src_cam);
writel(CLK_SRC_MFC_VAL, &clk->src_mfc);
writel(CLK_SRC_G3D_VAL, &clk->src_g3d);
//writel(CLK_SRC_LCD0_VAL, &clk->src_lcd0);
sdelay(0x10000);
writel(0x1160730, &clk->div_cpu0);
writel(0x506, &clk->div_cpu1);
writel(0x111113, &clk->div_dmc0);
writel(0x1011713, &clk->div_dmc1);
writel(CLK_DIV_FSYS1_VAL, &clk->div_fsys1);
writel(0x4070047, &clk->div_fsys2);
writel(CLK_DIV_FSYS3_VAL, &clk->div_fsys3);
writel(CLK_DIV_PERIL0_VAL, &clk->div_peril0);
writel(CLK_DIV_CAM_VAL, &clk->div_cam);
writel(CLK_DIV_MFC_VAL, &clk->div_mfc);
writel(CLK_DIV_G3D_VAL, &clk->div_g3d);
//writel(CLK_DIV_LCD0_VAL, &clk->div_lcd0);
/* Set PLL locktime */
writel(PLL_LOCKTIME, &clk->apll_lock);
writel(PLL_LOCKTIME, &clk->mpll_lock);
writel(PLL_LOCKTIME, &clk->epll_lock);
writel(PLL_LOCKTIME, &clk->vpll_lock);
writel(0x803800, &clk->apll_con1);
writel(0x80af0300, &clk->apll_con0);
writel(0x803800, &clk->mpll_con1);
writel(0x80640300, &clk->mpll_con0);
writel(EPLL_CON1_VAL, &clk->epll_con1);
writel(EPLL_CON0_VAL, &clk->epll_con0);
writel(VPLL_CON1_VAL, &clk->vpll_con1);
writel(VPLL_CON0_VAL, &clk->vpll_con0);
sdelay(0x30000);
}
i)arch/arm/mach-exynos/dmc_init_exynos4.c:
1)struct mem_timings mem = {
.direct_cmd_msr = {
DIRECT_CMD1, DIRECT_CMD2, DIRECT_CMD3, DIRECT_CMD4
},
.timingref = 0x000000bb,//TIMINGREF_VAL,
.timingrow = 0x7a46654f,//TIMINGROW_VAL,
.timingdata = 0x46400506,//TIMINGDATA_VAL,
.timingpower = 0x52000a3c,//TIMINGPOWER_VAL,
.zqcontrol = 0xe3854c03,//ZQ_CONTROL_VAL,
.control0 = 0x7110100b,//CONTROL0_VAL,
.control1 = 0xe0000086,//CONTROL1_VAL,
.control2 = 0x00000000,//CONTROL2_VAL,
.concontrol = 0x0fff333a,//CONCONTROL_VAL,
.prechconfig = 0xff000000,//PRECHCONFIG,
.memcontrol = 0x00302640,//MEMCONTROL_VAL,
.memconfig0 = 0x40c01333,//MEMCONFIG0_VAL,
.memconfig1 = 0x80e01323,//MEMCONFIG1_VAL,
.dll_resync = FORCE_DLL_RESYNC,
.dll_on = DLL_CONTROL_ON,
};
2)in dmc_init(), after line "writel(mem.memconfig1, &dmc->memconfig1);", add:
writel(0x8000001F, &dmc->ivcontrol);
3)change "origen" to "tiny4412" in Makefile;[!!Match case]
j)arch/arm/mach-exynos/tzpc.c:
1)change "writel(DECPROTXSET, &tzpc->decprot2set);" to "writel(0xbd, &tzpc->decprot2set);";
k)arch/arm/mach-exynos/Kconfig:
1)add tiny4412 config like origen;[!!Match case]
l)arch/arm/dts/Makefile:
1)add exynos4412-tiny4412.dtb in dtb-$(CONFIG_EXYNOS4);
m)arch/arm/mach-exynos/exynos4_setup.h:
1)change "origen" to "tiny4412";[!!Match case]
n)arch/arm/mach-exynos/lowlevel_init.c:
1)change PERIPH_ID_UART3 to PERIPH_ID_UART0 in do_lowlevel_init();
o)board/samsung/common/exynos-uboot-spl.lds:
1)change IMAGE_TEXT_BASE to CONFIG_SPL_TEXT_BASE;
p)drivers/mmc/sdhci.c:
1)return 1 with doing nothing in sdhci_get_cd();
q).config:
1)cp configs/tiny4412_defconfig .config
r)menuconfig:
1)make menuconfig;
2)press [Exit];
3)press [Yes];
s)make -j12
t)fuse:
1)cp -rf sd_fuse ./
2)add ./fuse.sh, and write:
cd sd_fuse/tiny4412
sudo ./sd_fusing.sh /dev/sdb
cd ../../
3)chmod +x ./fuse.sh
4)./fuse.sh
以上步骤,本人均一一验证.
参考若干网上资料,不一一列举,在此表示感谢.
如有兴趣研究嵌入式产品的客官,可联系交流,无论技术或创业.