TI am335x U-boot
http://blog.chinaunix.NET/uid-28458801-id-3486399.html
參考檔案:
1,AM335x ARM Cortex-A8 Microprocessors (MPUs) Technical Reference Manual.pdf;
2,am3359.pdf;
1,am335x的cpu上電後,會跳到哪個地址去執行?
答:
晶片到uboot啟動流程 :ROM → MLO(SPL)→ uboot.img
AM335x 中bootloader被分成了 3 個部分:
第一級 bootloader:引導載入程式,板子上電後會自動執行這些程式碼,如選擇哪種方式啟動(NAND,SDcard,UART。。。),然後跳轉轉到第二級 bootloader。這些程式碼應該是存放在 176KB 的 ROM 中。
第二級 bootloader:MLO(SPL),用以硬體初始化:關閉看門狗,關閉中斷,設定 CPU 時鐘頻率、速度等操作。然後會跳轉到第三級bootloader。MLO檔案應該會被對映到 64 KB的 Internal SRAM 中。
第三級 bootloader:uboot.img,C程式碼的入口。
其中第一級 bootloader 是板子固化的,第二級和第三級是通過編譯 uboot 所得的。
2,第二級 bootloader:MLO(SPL)做了哪些事情?
MLO(SPL)記憶體分佈如下:
SPL記憶體重對映:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
< PATH :
/arch/arm/cpu/armv7/omap-common/u-boot-spl
.lds >
MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\
LENGTH = CONFIG_SPL_MAX_SIZE }
MEMORY { .sdram : ORIGIN = CONFIG_SPL_BSS_START_ADDR, \
LENGTH = CONFIG_SPL_BSS_MAX_SIZE }
OUTPUT_FORMAT(
"elf32-littlearm"
,
"elf32-littlearm"
,
"elf32-littlearm"
)
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
.text :
{
__start = .;
arch
/arm/cpu/armv7/start
.o (.text)
*(.text*)
} >.sram
. = ALIGN(4);
.rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram
. = ALIGN(4);
.data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram
. = ALIGN(4);
__image_copy_end = .;
_end = .;
.bss :
{
. = ALIGN(4);
__bss_start = .;
*(.bss*)
. = ALIGN(4);
__bss_end__ = .;
} >.sdram
}
|
1 2 3 4 5 6 7 |
<PATH : /include/configs/am335x_evm.h>
#define CONFIG_SPL_TEXT_BASE 0x402F0400
#define CONFIG_SPL_MAX_SIZE (46 * 1024)
#define CONFIG_SPL_STACK LOW_LEVEL_SRAM_STACK
#define CONFIG_SPL_BSS_START_ADDR 0x80000000
#define CONFIG_SPL_BSS_MAX_SIZE 0x80000 /* 512 KB */ <span style="font-size:16px;color:#003399;"><strong></strong></span>
|
@[email protected] 儲存啟動引數 bl save_boot_params
1 2 3 4 5 6 7 |
<PATH :
/arch/arm/cpu/armv7/start
.S>
/*
* the actual reset code
*/
reset:
bl save_boot_params
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<PATH :
/arch/arm/cpu/armv7/omap-common/lowlevel_init
.S>
.global save_boot_params
save_boot_params:
/*
* See
if
the rom code passed pointer is valid:
* It is not valid
if
it is not
in
non-secure SRAM
* This may happen
if
you are booting with the help of
* debugger
*/
ldr r2, =NON_SECURE_SRAM_START
cmp
r2, r0
bgt 1f
ldr r2, =NON_SECURE_SRAM_END
cmp
r2, r0
blt 1f
/*
* store the boot params passed from rom code or saved
* and passed by SPL
*/
cmp
r0,
#0
beq 1f
ldr r1, =boot_params
str r0, [r1]
|
1 2 3 4 5 6 7 8 |
/*《PATH: /arch/arm/include/asm/arch-ti81xx/omap.h》
* Non-secure SRAM Addresses
* Non-secure RAM starts at 0x40300000 for GP devices. But we keep SRAM_BASE
* at 0x40304000(EMU base) so that our code works for both EMU and GP
*/
#define NON_SECURE_SRAM_START 0x40304000
#define NON_SECURE_SRAM_END 0x4030E000
#define LOW_LEVEL_SRAM_STACK 0x4030B7FC
|
問題:這些引數是儲存在哪裡的?大概有哪些引數?
答:
這些引數儲存的記憶體地址為 64 KB 的 OCM RAM 中:
注:Dowloaded Image 區域:是用來儲存 MLO(SPL) 檔案的,其最大可達到 109 KB
@[email protected] 設定 CPU 為 SVC32 模式
1 2 3 4 5 6 7 8 |
<PATH :
/arch/arm/cpu/armv7/start
.S>
/*
*
set
the cpu to SVC32 mode
*/
mrs r0, cpsr
bic r0, r0,
#0x1f
orr r0, r0,
#0xd3
msr cpsr,r0
|
CPSR:程式狀態暫存器(current program status register)(當前程式狀態暫存器),在任何處理器模式下被訪問。它包含了條件標誌位、中斷禁止位、當前處理器模式標誌以及其他的一些控制和狀態位。
CPSR在使用者級程式設計時用於儲存條件碼。
SPSR:程式狀態儲存暫存器(saved program statusregister),每一種處理器模式下都有一個狀態暫存器SPSR,SPSR用於儲存CPSR的狀態,以便異常返回後恢復異常發生時的工作狀態。當特定的異常中斷髮生時,這個暫存器用於存放當前程式狀態暫存器的內容。在異常中斷退出時,可以用SPSR來恢復CPSR。由於使用者模式和系統模式不是異常中斷模式,所以他沒有SPSR。當用戶在使用者模式或系統模式訪問SPSR,將產生不可預知的後果。
CPSR格式如下所示。SPSR和CPSR格式相同。
31 30 29 28 27 26 7 6 5 4 3 2 1 0
N Z C V Q DNM(RAZ) I F T M4 M3 M2 M1 M0
詳解:http://blog.chinaunix.net/uid-28458801-id-3487199.html
@[email protected] CPU的初始化
1 2 3 4 5 |
《PATH : /arch/arm/cpu/armv7/start.S》
/* the mask ROM code should have PLL and others stable */
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
bl cpu_init_crit
#endif
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<PATH :
/arch/arm/cpu/armv7/omap-common/lowlevel_init
.S>
.globl lowlevel_init
lowlevel_init:
/*
* Setup a temporary stack
*/
ldr sp, =LOW_LEVEL_SRAM_STACK
/*
* Save the old lr(passed
in
ip) and the current lr to stack
*/
push {ip, lr}
/*
* go setup pll, mux, memory
*/
bl s_init
pop {ip, pc}
|
問題:CPU的初始化有哪些內容?
答:
@[email protected] 首先要設定堆疊區,因為將會呼叫 C函式來實現CPU的初始化
問題:這個堆疊在什麼位置,其記憶體大小是多少?
答
1 2 |
《PATH :/arch/arm/
include
/asm/arch-ti81xx/omap.h》
#define LOW_LEVEL_SRAM_STACK
0x4030B7FC
<strong></strong>
|
@[email protected] 執行 s_init() 函式,實現 CPU 的初始化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
<PATH : /board/ti/am335x/evm.c>
/*
* early system init of muxing and clocks.
*/
void
s_init(
void
)
{
/* Can be removed as A8 comes up with L2 enabled */
l2_cache_enable();
/* WDT1 is already running when the bootloader gets control
* Disable it to avoid "random" resets
*/
__raw_writel(
0xAAAA
, WDT_WSPR);
while
(__raw_readl(WDT_WWPS) !=
0x0
);
__raw_writel(
0x5555
, WDT_WSPR);
while
(__raw_readl(WDT_WWPS) !=
0x0
);
#ifdef CONFIG_SPL_BUILD
/* Setup the PLLs and the clocks for the peripherals */
pll_init();
/* Enable RTC32K clock */
rtc32k_enable();
/* UART softreset */
u32 regVal;
u32 uart_base = DEFAULT_UART_BASE;
enable_uart0_pin_mux();
/* IA Motor Control Board has default console on UART3*/
/* XXX: This is before we've probed / set board_id */
if
(board_id == IA_BOARD) {
uart_base = UART3_BASE;
}
regVal = __raw_readl(uart_base + UART_SYSCFG_OFFSET);
regVal |= UART_RESET;
__raw_writel(regVal, (uart_base + UART_SYSCFG_OFFSET) );
while
((__raw_readl(uart_base + UART_SYSSTS_OFFSET) &
UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK);
/* Disable smart idle */
regVal = __raw_readl((uart_base + UART_SYSCFG_OFFSET));
regVal |= UART_SMART_IDLE_EN;
__raw_writel(regVal, (uart_base + UART_SYSCFG_OFFSET));
/* Initialize the Timer */
init_timer();
preloader_console_init();
printf(
"\nlocation /board/ti/am335x\n"
);
//@@
/*@@*/
// led();
/*@@*/
config_am335x_ddr();
#endif
}
|
@[email protected] 使能第二級緩衝區
1 2 3 4 5 6 7 8 9 10 |
/* Can be removed as A8 comes up with L2 enabled */
l2_cache_enable();
<PATH : /arch/arm/cpu/armv7/ti81xx/cache.S>
l2_cache_enable:
push {r0, r1, r2, lr}
mrc 15, 0, r3, cr1, cr0, 1
orr r3, r3, #2
mcr 15, 0, r3, cr1, cr0, 1
pop {r1, r2, r3, pc}
|
@[email protected] 關閉看門狗(WDT)
1 2 3 4 5 6 7 |
/* WDT1 is already running when the bootloader gets control
* Disable it to avoid "random" resets
*/
__raw_writel(0xAAAA, WDT_WSPR);
while
(__raw_readl(WDT_WWPS) != 0x0);
__raw_writel(0x5555, WDT_WSPR);
while
(__raw_readl(WDT_WWPS) != 0x0);
|
1
2
3
4
相關推薦TI am335x U-boot移植(正常啟動)****************************************************************** & TI am335x U-boothttp://blog.chinaunix.NET/uid-28458801-id-3486399.html 參考檔案: 1,AM335x ARM Cortex-A8 Microprocessors (MPUs) Technical Reference AM335x U-boot d程式碼分析過程3我們繼續上一篇的程式碼,已經來到s_init()(位於arch\arm\cpu\armv7\am335x\board.c),其原始碼如下: [cpp] view plain copy pr AM335x U-boot d程式碼分析過程2題外話 之前那一篇試水了一下,我回過頭看一下,覺得還是含水量還是太大了。這個系列的部落格的目的應該是讓讀者看完以後,對armV7 cpu的u-boot有個更加深的瞭解,也讓我把知道的東西都寫出來,加深認識,作為後期複習的工具。 原始碼分析 AM335x U-boot d程式碼分析過程1題外話: 經過一段時間的學習,對u-boot-2014.10有了初步的瞭解,趁著還記著,趕緊寫下來,同時將之前還模稜兩可的部分用圖表的方式加強一下。 原始碼分析 彙編部分 之前一直看的是ARM9的u-boot, Am335x u-boot 程式碼大概流程(轉) Am335x u-boot 程式碼大概流程Am335x u-boot 程式碼大概流程 在_面之前的流程和u-boot-spl一樣,區別在於_main中。 對於u-boot 2016.03來說 ENTRY(_main) /* * Set up initial C TI davinci u-boot 編譯方法1,下載最新的 u-boot for davinci 2,下載 ARM 交叉編譯工具(請下載 linux 版本,因為 u-boot 只能在 linux 環境下編譯) TI 推薦的是: CodeSourcery GNU Toolchain for ARM Processo ti-sdk-evm-am335x-05.07 uboot分析(MLO跳轉到u-boot之前)article 相關信息 ons 區域 point put tin locate ctu ------------------------------ 基於am335x的u-boot 2013.01.01的啟動分析1,am335x的cpu上電後,會跳到哪個地址去執行? 答: 晶片到uboot啟動流程 :ROM → MLO(SPL)→ uboot.img AM335x 中bootloader被分成了 3 個部分: 第一級 bootloader:引導載入程式,板子上電後會自動執 am335x uboot2016.05 (MLO u-boot.img)執行流程(轉)eve eset dog 不同的 common 速度 star setup oba am335x的cpu上電後,執行流程:ROM->MLO(SPL)->u-boot.img 第一級bootloader:引導加載程序,板子上電後會自動執行這些代碼,如啟動方式(SD AM335x(TQ335x)學習筆記——u-boot-2014.10移植最近移植了下u-boot-2014.10到TQ335x,如果基於am335x evm進行移植,需要修改的地方並不多。 由於TI的am335x evm開發使用了一個eeprom儲存了板載配置資訊,用來區分不同板子的型號的,而TQ335x沒有這個eeprom,因此,需要修改ee 分析u-boot的Makefile選項 lin 編譯平臺 create cpp port n) ati inux 這裏分析三星s5pv210芯片官方u-boot 先看u-boot 版本號 VERSION = 1 #主版本號PATCHLEVEL = 3 #次版本號SUBLEVEL u-boot移植(一)---準備工作分享 2.3 option 什麽 bison ctu http bin 執行命令 一、工具鏈的制作 1.1 工具 軟件工具:crosstool-ng 下載地址:git clone https://github.com/crosstool-ng/crosstool-n u-boot學習(五):u-boot啟動內核cor 定義 嵌入式 code efi cpu 頭文件 ng- part u-boot的目的是啟動內核。內核位於Flash中,那麽u-boot就要將內核轉移到內存中。然後執行命令執行之。這些操作是由bootcmd命令完畢的。 bootcmd=nand read.jffs u-boot移植(四)---代碼修改---時鐘修改、SDRAMport write 啟動 tro nor ble 大小 pro 正常 最開始已經建立了新單板以及配置文件,現在就需要做的是代碼的修改,配置成適合目標板使用的u-boot。 一、時鐘修改 在代碼流程分析中,我們知道,系統的啟動是: 設置 CPU 為管理員模式 關閉 u-boot學習(六):自己寫bootloaderinclude trie depth params tee tboot config initrd passing 依照前面分析的u-boot的啟動流程,自己寫一個簡單的Bootloader。這是參考韋東山老師的視頻寫的。 1、初始化硬件:關看門狗、設置時鐘、設置SDR u-boot移植(七)---代碼修改---存儲控制器relative onf 修改 param nan 內存 literal def 定義 一、CPU訪問芯片的條件 CPU通過訪問存儲控制器,來讀取外部設備的數據。 CPU想訪問一個芯片,需要如下條件(配置信息): 地址線 數據線:8位/16位/32位數據 u-boot移植(十三)---代碼修改---裁剪及環境變量 一相關 addition 並且 width load command 啟動程序 type 入參 一、內核裁剪 內核的裁剪首先就是修改我們的配置文件,即 include/configs/jz2440.h 文件,裏面定義的很多宏,我們也許用不上的就要去掉。 1 /* u-boot移植(十三)---代碼修改---支持文件系統及補丁制作ota ons set nan 文件的 help and ole com 一、燒寫文件系統 1.1 jffs2燒寫 1.下載文件系統:tftp 30000000 fs_mini_mdev.jffs2 2.擦除文件的塊:nand erase.part rootf u-boot-201611 啟動過程分析——基於smdk2410u-bootu-boot-201611 啟動過程分析——基於smdk2410 |