ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

顯示具有 bootloader 標籤的文章。 顯示所有文章
顯示具有 bootloader 標籤的文章。 顯示所有文章

2013年6月17日 星期一

machine_arch_type 支援多系統的 kernel

作 imx 系列時發現,不管哪一種 cpu (mx51, mx53), board (bbg, smd, loco),竟然都是用同一個 kernel config file。
同一份 kernel image,在不同的 board 上,竟然就會 run 不同的 board init code..

kernel code 是用 machine_arch_type 這個變數 作為 system 的id。

在 include/generated/machine-types.h 有machine id 的定義:
(ref: http://r40eubuntu.blogspot.tw/2013/08/machineisxxx.html)
.... #define MACH_TYPE_AQUARIUS 3009 #define MACH_TYPE_MX53_ARD 3010 #define MACH_TYPE_MX53_SMD 3011 #define MACH_TYPE_LSWXL 3012 #define MACH_TYPE_DOVE_AVNG_V3 3013 #define MACH_TYPE_SDI_ESS_9263 3014 .... #define MACH_TYPE_MX53_LOCO 3273
這個file 後面還有..配合的 function 宣告..
#ifdef CONFIG_MACH_MX53_LOCO # ifdef machine_arch_type # undef machine_arch_type # define machine_arch_type __machine_arch_type # else # define machine_arch_type MACH_TYPE_MX53_LOCO # endif # define machine_is_mx53_loco() (machine_arch_type == MACH_TYPE_MX53_LOCO) #else # define machine_is_mx53_loco() (0) #endif
這樣kernel code 就可以用 machi_is_mx53_loco( ) 來決定要不要 run 某段 code..

__machine_arch_type 是在 arch/arm/boot/compressed/misc.c 指定 (填值) 的。 unsigned long decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p, unsigned long free_mem_ptr_end_p, int arch_id) { unsigned char *tmp; output_data = (unsigned char *)output_start; free_mem_ptr = free_mem_ptr_p; free_mem_end_ptr = free_mem_ptr_end_p; __machine_arch_type = arch_id; arch_decomp_setup(); tmp = (unsigned char *) (((unsigned long)input_data_end) - 4); output_ptr = get_unaligned_le32(tmp); putstr("Uncompressing Linux..."); do_decompress(input_data, input_data_end - input_data, output_data, error); putstr(" done, booting the kernel.\n"); return output_ptr; }
這個 decompress_kernel 是由 kernel boot assembly code 呼叫的..
arch/arm/boot/compressed/head.S
b 1f .word 0x016f2818 @ Magic numbers to help the loader .word start @ absolute load/run zImage address .word _edata @ zImage end address 1: mov r7, r1 @ save architecture ID ..... ..... mov r5, r2 @ decompress after malloc space mov r0, r5 mov r3, r7 bl decompress_kernel

所以知道 machine_id 其實是 bootloader 給的..

u-boot:

結果裡面也有一份 machine-type.h
在 ./board/freescale/mx53_loco/mx53_loco.c
int board_init(void) { setup_boot_device(); setup_soc_rev(); gd->bd->bi_arch_number = MACH_TYPE_MX53_LOCO; /* board id for linux */ ..
指定給 bi_arch_number, 然後在 bootm command 時..(bootm.c):
int machid = bd->bi_arch_number; ... ... theKernel (0, machid, bd->bi_boot_params);
剛好是第二個 argument.對應 r1

2012年4月10日 星期二

u-boot boot code -- alter path of boot

boot code trace
cpu/arm_cortexa8/cpu.S 就像是以前 ads 的 startup.S

一開始就是 arm 的 interrupt vector。
後面就是 code.

從 reset 開始。
然後call cpu_init_crit (low level init ?)。
之後就是 relocate。
-- 因為 iMX51 的 bootrom 已經把DDR config 好,並且把 uboot load 到 DDR,所以不用作 reloacate 了。

設定 stack:
sp = _TEXT_BASE - #CONFIG_SYS_MALLOC_LEN - #CONFIG_SYS_GBL_DATA_SIZE - 12

clear bbs: __bss_start -- __bss_end 的區域都填 0

run board_mmu_init.
這段code 要參考 Reference Manual Chapter 2 : Memory Map. 對照 Physical Address 的內容 (其實註解已經寫得很清楚)
/* Actual Virtual Size Attributes Function */ /* Base Base MB cached? buffered? access permissions */ /* xxx00000 xxx00000 */ X_ARM_MMU_SECTION(0x000, 0x200, 0x1, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* ROM */ X_ARM_MMU_SECTION(0x1FF, 0x1FF, 0x001, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* IRAM */ X_ARM_MMU_SECTION(0x300, 0x300, 0x100, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* GPU */ X_ARM_MMU_SECTION(0x400, 0x400, 0x200, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* IPUv3D */ X_ARM_MMU_SECTION(0x600, 0x600, 0x300, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* periperals */ X_ARM_MMU_SECTION(0x900, 0x000, 0x1FF, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM */ X_ARM_MMU_SECTION(0x900, 0x900, 0x200, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM */ X_ARM_MMU_SECTION(0x900, 0xE00, 0x200, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM 0:128M*/ X_ARM_MMU_SECTION(0xB80, 0xB80, 0x10, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* CS1 EIM control*/ X_ARM_MMU_SECTION(0xCC0, 0xCC0, 0x040, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* CS4/5/NAND Flash buffer */
其中 X_ARM_MMU_SECTION 的內容,跟 MMU 的spec 一樣,一個 entry 是 1M ,所以: #define X_ARM_MMU_SECTION(abase, vbase, size, cache, buff, access) \ { \ int i; int j = abase; int k = vbase; \ for (i = size; i > 0 ; i--, j++, k++) \ ARM_MMU_SECTION(ttb_base, j, k, cache, buff, access); \ }
根據 size 以 1M 為單位,把所有的 table entry 都設完。
-- 因為 MMU 的 translation 是把bit20~31 拿去作 translate。所以單位是 1M (0~19 bit).

  1. 關於 mmu section translation 可以google 一下:https://www.google.com.tw/search?q=arm%20mmu%20section%20translation&um=1&ie=UTF-8&hl=zh-TW&tbm=isch&source=og&sa=N&tab=wi&ei=3NSDT_-eJaz0mAWizJW4Bw&biw=1366&bih=630&sei=-dSDT8-LEMycmQXnquSyBw

這 code 跟 spec 的圖結合在一起: union ARM_MMU_FIRST_LEVEL_DESCRIPTOR { unsigned long word; struct ARM_MMU_FIRST_LEVEL_FAULT fault; struct ARM_MMU_FIRST_LEVEL_PAGE_TABLE page_table; struct ARM_MMU_FIRST_LEVEL_SECTION section; struct ARM_MMU_FIRST_LEVEL_RESERVED reserved; }; 是 UNION.
ref : ARM processor MMU -- level one descriptor 的圖。

之後就可以啟動 MMU。

然後執行 start_armboot()。



start_armboot()準備 gd_t (globale_data) 的空間,然後用類似 linux init 的方式 call init function (這裡是手動): for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { if ((*init_fnc_ptr)() != 0) { hang (); } } init_fnc_t *init_sequence[] = { #if defined(CONFIG_ARCH_CPU_INIT) arch_cpu_init, /* basic arch cpu dependent setup */ #endif board_init, /* basic board dependent setup */ #if defined(CONFIG_USE_IRQ) interrupt_init, /* set up exceptions */ #endif timer_init, /* initialize timer */ env_init, /* initialize environment */ init_baudrate, /* initialze baudrate settings */ serial_init, /* serial communications setup */ console_init_f, /* stage 1 init of console */ display_banner, /* say that we are here */ #if defined(CONFIG_DISPLAY_CPUINFO) print_cpuinfo, /* display cpu info (and speed) */ #endif #if defined(CONFIG_DISPLAY_BOARDINFO) checkboard, /* display board info */ #endif #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) init_func_i2c, #endif dram_init, /* configure available RAM banks */ #if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI) arm_pci_init, #endif display_dram_config, NULL, }; 之後就是一個一個個別 hardware function 的 init... (?為什摩不在 init_sequence[] 裡作?)

然後 call check_recovery_mode()
最後是 main_loop().



check_recovery_mode( ) 就是偵測 hardware pin,然後call setup_recovery_env( )。
單純操作 env: void setup_recovery_env(void) { char *env, *boot_args, *boot_cmd; int bootdev = get_boot_device(); boot_cmd = supported_reco_envs[bootdev].cmd; boot_args = supported_reco_envs[bootdev].args; if (boot_cmd == NULL) { printf("Unsupported bootup device for recovery\n"); return; } printf("setup env for recovery..\n"); env = getenv("bootargs_android_recovery"); /* Set env to recovery mode */ /* Only set recovery env when these env not exist, give user a * chance to change their recovery env */ if (!env) setenv("bootargs_android_recovery", boot_args); env = getenv("bootcmd_android_recovery"); if (!env) setenv("bootcmd_android_recovery", boot_cmd); setenv("bootcmd", "run bootcmd_android_recovery"); }
就是改 bootcmd 為 "run bootcmd_android_recoery"。
這樣之後的 boot process,去 run bootcmd ,就會 run bootcmd_android_recovery.

2011年9月6日 星期二

fastboot : simple protocl to bootloader

在 android source : bootable/bootable/legacy/fastboot_protocol.tx  有說明
The fastboot protocol is a mechanism for communicating with bootloaders
over USB.  It is designed to be very straightforward to implement, to
allow it to be used across a wide range of devices and from hosts running
Linux, Windows, or OSX.
然後剩下的就是 protocol 內容的說明....

由於是bootloader 的 protocol,所以通常拿來作 system image 的 update 用。 以 freescale imx51 為例:
開機後,按下 ENTER 中斷 uboot 開機,進入 command console,輸入 fastboot,進入 fastboot 模式。
PC 端接上 usb,輸入 fastboot devices ,會顯示出目前連線的fastboot 裝置。

PC 端輸入 fastboot help,會顯示 fastboot command。

有關 燒錄 image : bootloader, kernel, ramdisk, system,command 是 fast flash partition file partition 是 uboot 預先定義的,以 emmc 為 boot 裝置時,partition 的切割是:
static int fastboot_init_mmc_sata_ptable(void) { .... /* MBR */ strcpy(ptable[PTN_MBR_INDEX].name, "mbr"); ptable[PTN_MBR_INDEX].start = ANDROID_MBR_OFFSET / dev_desc->blksz; ptable[PTN_MBR_INDEX].length = ANDROID_MBR_SIZE / dev_desc->blksz; /* Bootloader */ strcpy(ptable[PTN_BOOTLOADER_INDEX].name, "bootloader"); ptable[PTN_BOOTLOADER_INDEX].start = ANDROID_BOOTLOADER_OFFSET / dev_desc->blksz; ptable[PTN_BOOTLOADER_INDEX].length = ANDROID_BOOTLOADER_SIZE / dev_desc->blksz; /* kernel */ strcpy(ptable[PTN_KERNEL_INDEX].name, "kernel"); ptable[PTN_KERNEL_INDEX].start = ANDROID_KERNEL_OFFSET / dev_desc->blksz; ptable[PTN_KERNEL_INDEX].length = ANDROID_KERNEL_SIZE / dev_desc->blksz; /* uramdisk */ strcpy(ptable[PTN_URAMDISK_INDEX].name, "uramdisk"); ptable[PTN_URAMDISK_INDEX].start = ANDROID_URAMDISK_OFFSET / dev_desc->blksz; ptable[PTN_URAMDISK_INDEX].length = ANDROID_URAMDISK_SIZE / dev_desc->blksz; /* system partition */ strcpy(ptable[PTN_SYSTEM_INDEX].name, "system"); if (get_partition_info(dev_desc, CONFIG_ANDROID_SYSTEM_PARTITION_MMC, &info)) printf("Bad partition index:%d\n", CONFIG_ANDROID_SYSTEM_PARTITION_MMC); else { ptable[PTN_SYSTEM_INDEX].start = info.start; ptable[PTN_SYSTEM_INDEX].length = info.size; } /* recovery partition */ strcpy(ptable[PTN_RECOVERY_INDEX].name, "recovery"); if (get_partition_info(dev_desc, CONFIG_ANDROID_RECOVERY_PARTITION_MMC, &info)) printf("Bad partition index:%d\n", CONFIG_ANDROID_RECOVERY_PARTITION_MMC); else { ptable[PTN_RECOVERY_INDEX].start = info.start; ptable[PTN_RECOVERY_INDEX].length = info.size; } for (i = 0; i <= PTN_RECOVERY_INDEX; i++) fastboot_flash_add_ptn(&ptable[i]); 也就是...

  1. bootlaoder
  2. kernel
  3. uramdisk
  4. system
  5. recovery
其中 system, recovery 是讀取 emmc 的 parition table 得到的。
所以 eMMC 要預先partition 好..
這樣,燒路的動作就是 fastboot flash kernel uImage 和 fastboot flash uramdisk uramdisk.img 還有 fastboot flash system system.img 燒完之後可以直接下 reboot command: fastboot reboot

2011年5月18日 星期三

re-enable the splash screen in u-boot

因為原來就有了,只是後來被 disable掉,所以是 "re-enable"

從 commit log 中找出當初disable 的 rev,找出 diff:
diff --git a/include/configs/mx51_bbg_android.h b/include/configs/mx51_bbg_android.h index 7b054e3..a460954 100644 --- a/include/configs/mx51_bbg_android.h +++ b/include/configs/mx51_bbg_android.h @@ -349,7 +349,6 @@ #undef CONFIG_JFFS2_CMDLINE #define CONFIG_JFFS2_DEV "nand0" -#define CONFIG_SPLASH_SCREEN #ifdef CONFIG_SPLASH_SCREEN /* * Framebuffer and LCD 重新把他加回去。

然後grep 一下 CONFIG_SPLASH_SCREEN 的code.

function implememt 都在 common/lcd.c

hardware driver 在 drivers/video/mxc_ipuv2.c

另外還有 board specific setting 在 board/freescale/mx51_bbg/mx51_bbg.c



有兩組 DI (display Interface) : DI0, DI1,在 code 中 drivers/video/ipu_common.c 用 data structure clk 宣告一個 array ipu_clk[2] 描述兩個 interface 的 clk setting。

決定 interface 的 argument..
ipu_common.c : int ipu_probe(int di, ipu_di_clk_parent_t di_clk_parent, int di_clk_val).. if (di_clk_parent == DI_PCLK_LDB) { clk_set_parent(g_pixel_clk[di], g_di_clk[di]); } else { clk_set_parent(g_pixel_clk[0], g_ipu_clk); clk_set_parent(g_pixel_clk[1], g_ipu_clk); } clk_enable(g_ipu_clk);
所以要看 di_clk_parent 是否是 1,還有 di 的值。

在 drivers/video/mxc_ipuv3_fb.c
int ipuv3_fb_init(struct fb_videomode *mode, int di, int interface_pix_fmt, ipu_di_clk_parent_t di_clk_parent, int di_clk_val) { int ret; ret = ipu_probe(di, di_clk_parent, di_clk_val);
參數 di, di_clk_parent ...

在 board/freescale/mx51_bbg/mx51_bbg.c void lcd_enable(void) { .... .... gpio config .... ret = ipuv3_fb_init(&claa_wvga, 1, IPU_PIX_FMT_RGB565, DI_PCLK_PLL3, 0); di_parent = DI_PCLK_PLL3,
di = 1.

所以是用 DI1.



follow kernel 的內容新增一個pvi_2003a_wvga .並且把 di 由 1 改為 0.
從 kernel boot message 可以看到這個設計是以 di0 作 primary。
同時 format 改為 RGB24



檢查一下 gpio 的設定..
DI1_DISP_CLK : No Muxing ..
DI1_PIN2 : ALT0 才是 ipu. 電路作DISP1_HSYNC 用
DI1_PIN3 : ALT0 是 ipu,作 DISP1_VSYNC 用
DI1_PIN15 : No Muxing, ipu, 作 DISP1_DRDY -- 接到 image processor,當 DE 用
DISP1_DAT 0 ~ 5 : No Muxing.
DISP1_DAT 6 ~ 23 : ALT0 是 ipu

看了一下,這些 pin default 都是 ALT0.

在cls command 的 do function 加入填寫螢幕的動作,查各bit 的有效顏色..
0. 1. 2. 3. 4    - green
5. 6. 7. 8. 9.10 - blue
11.12.13.14.15    - red
所以是 565沒錯。

修改到此,可以試試看 bmp 的 function 了。因為 option 只有 CONFIG_BMP_8BPP. 所以只有 support 8bpp 的 bmp format.

follow 這一篇 U-Boot display support 產生 8bpp 的 bmp file,叫 u-boot load 進 ram 然後 show出來..

  1. 先用 gimp create 一個 800x480, backgroupe 是白色,中間隨便的圖案。
    如果是用現成的圖,先用 gimp打開,然後 save as,選 windows bmp file,save 時,advance option 選 16bit 565 的格式
  2. 使用 imagemagick 轉成 8bpp: $ convert 00.bmp -colors 256 -compress none splash.bmp
  3. copy splash.bmp 到 boot sd 的 partition 1
  4. boot,進入 uboot console.
  5. uboot load spalsh.bmp 進 memory: fatload mmc 0:1 0x92000000 splash.bmp
  6. 用 bmp display 顯示出來 bmp display 0x92000000

在 boot env 加上 splashimage=0x90800000 後,開機竟然show 一個原廠的畫面...
找了一下,發現在 boared/freescale/common 下有 bmp 的 c arrary source..

只要在 bootargument 有 define splashimage='address' 指定 splash 的 memory location,
就會把 bmp array data 顯示出來。

用 這一篇 的內容,把 splash.bmp 轉成 c array.
$ hexdump -e '16/1 "0x%02X,"' -e '"\n"' splash.bmp -v -v option 是要他不要把重複的以 '*' 代替,忠實的顯示出來。

output pipe 到 dummy_800x480.c,修改 Makefile。

完成。

2011年4月27日 星期三

u-boot memo - IF THEN

大概記一下 u-boot 有 if then 的command support,在 common/hush.c 還有 比較 的 command support 在 common/cmd_itest.c 在自己的 include/configs/XXX.h 中加入 #define CONFIG_SYS_HUSH_PARSER 1 /* Use the HUSH parser */ #ifdef CONFIG_SYS_HUSH_PARSER #define CONFIG_SYS_PROMPT_HUSH_PS2 "> " #endif 就可以了

2011年3月18日 星期五

iMX51 ddr_clk setting

Clock Control Module 李的 register : CBCMR (CCM Bus Clock Multiplexer Register).
field : 11-10 是 DDR clock multiplexer
決定 DDR 的 clock source: (1.0) * 00 : axi a * 01 : axi b * 10 : emi_slow_clk_root * 11 : ahb clock root 配合 u-boot 的 source code 就是:
static u32 __get_ddr_clk(void) { u32 ret_val = 0; u32 cbcmr = __REG(MXC_CCM_CBCMR); u32 ddr_clk_sel = (cbcmr & MXC_CCM_CBCMR_DDR_CLK_SEL_MASK) \ >> MXC_CCM_CBCMR_DDR_CLK_SEL_OFFSET; switch (ddr_clk_sel) { case 0: ret_val = __get_axi_a_clk(); break; case 1: ret_val = __get_axi_b_clk(); break; case 2: ret_val = __get_emi_slow_clk(); break; case 3: ret_val = __get_ahb_clk(); break; default: break; } return ret_val; } 現在debug output cbcmr - 0x0020C2. 所以 11.10 是 0 -- axi_a_clk.

然後 code 是去看 CBCDR ( CCM Bus Clock Divider Register ) 算出 DDR Speed。

source 有: enum pll_clocks { PLL1_CLK = MXC_DPLL1_BASE, PLL2_CLK = MXC_DPLL2_BASE, PLL3_CLK = MXC_DPLL3_BASE, };

分別是: #define AIPS2_BASE_ADDR 0x83F00000 #define PLL1_BASE_ADDR (AIPS2_BASE_ADDR + 0x00080000) #define PLL2_BASE_ADDR (AIPS2_BASE_ADDR + 0x00084000) #define PLL3_BASE_ADDR (AIPS2_BASE_ADDR + 0x00088000)
source code : lowlevel_init.S 設定 DDR 速度是修改 CBCDR. - ldr r1, =0x61E35100 + ldr r1, =0x71E35100 str r1, [r0, #CLKCTL_CBCDR]

DDR_CLK,有兩個 source 可以選,由CBCDR的 ddr_high_freq_clk_sel 決定。
  • 0 -- 有四個 source 可以選,由 CBCMR 的ddr_clk_sel 選擇
  • 1 -- 從 pll1_sw_clk (800MHz) 除頻, 除以 CBCDR 的ddr_clk_podf.(default 是 4,所以選這個會是 200MHz.


現在選的是 0,所以由四個 source 中選一個。 -- 選 0 -- form source 8.(axi_a)
這個就是 axi_a

axi_a 的第一階 source 有兩個,由CBCDR 的periph_clk_sel 決定 (這裡是選0 - pll2_sw_clk 665MHz)。

所以 最後 axi_a 就是 pll2_sw_clk 除頻,div = CBCDR:axi_a_podf+1 (預設是 3+1),所以預設的 axi_a 是 665MHz/4 = 166MHz。



所以 source code 寫錯了,沒有 考率到 ddr_clk 第一個 source select : CBCDR 的 ddr_high_freq_clk_sel 是 1 的狀況..

2010年12月27日 星期一

uboot - mmc - reading notes

common/cmd_mmc.c : do_mmcops()

drivers/mmc/mmc.c : mmc_init( )

go_idle( ) -- cmd 0
if_cmd( ) -- SD
sd_op_cond( ) --
mmc_op_cond( ) --

go_idle( )
cmd : OCR_HCS | mmc->voltages
- get  version, ocr, high_capacity from response.

mmc_startup

cmd : MMC_CMD_ALL_SEND_CID
- get CID
cmd : SD_CMD_SEND_RELATIVE_ADDR
cmdarg : mmc->rca >>16
- set relative address
cmd : MMC_SEND_CSD
- get CSD
cmd : MMC_CMD_SELECT_CARD
- set into transfer mode

mmc_change_freq( ) -- set freq  -- a lot of command
mmc_switch( ) -- set bus width (MMC_CMD_SWITCH)
mmc_set_clock( ) --


start.S start_armboot mmc_initialize --board_mmc_init ----esdhc_gpio_init ------fsl_esdhc_initialize (all the sdhc) : set host controller capability --------mmc_register

install a Master Boot Record

在 mbr 套件。 有 install-mbr 用 #install-mbr /dev/sda 可以用來在 usb driver 建立開機磁區。

2010年12月16日 星期四

worklog - uboot copy uboot from mmc0 to mmc2

>fatls mmc 0:1 / 把 mmc 0 , partition 1 的 root (/) 內容 list 出來。 lost.dir/ .android_secure/ 159684 u-boot.bin Copy 到 ram 裡: >fatload mmc 0:1 0x90800000 u-boot.bin reading u-boot.bin 159684 bytes read 再 write 到 mmc 2 的 uboot section (start from 1k). > mmc write 2 0x90800000 2 140 MMC write: dev # 2, block # 2, count 320 ... 320 blocks written: OK

2010年11月19日 星期五

iMX51 : uboot env variable location

這個 iMX51 的 SD bootloader 把 environment variable 放在.. 768K 的地方,大小是 128K
ref : uboot參數 - 強人狗夫叔叔提供
所以要backup uboot env variable: $dd if=/dev/sdc of=ubootarg.bin bs=128k skip=6 count=1
要 restore: $dd if=ubootargs.bin of=/dev/sdc bs=128k seek=6

2010年10月11日 星期一

set structure field and set function - in u-boot

看到 image_set_load( ),卻找不到 實作。 所以猜又是自動產生的 function,改 grep image_set,就發現: mage_set_hdr_l(f) \
        static inline void image_set_##f(image_header_t *hdr, uint32_t val) \
        { \
                hdr->ih_##f = cpu_to_uimage (val); \
        }
所以 image_set_load( ) 也只是在設 structure 的 load 欄位。

2010年10月7日 星期四

iMX51 the very first boot process -- configure DDR controller and load bootloader to run

當設定為 SD/MMC boot。 boot ROM 會從第3 個 sector (第 0x400byte) 讀取 DCD (Device Configuration Data)。
放在 SD/MMC 中,由 boot ROM load 進 DRAM 中 run 的 code 是 u-boot。
所以 u-boot 的 bin 檔要包含這段 DCD 在 bin 的開頭。
imx51 的 uboot 是用 flash_header.S 來完成。
flash_header.o 在 lds 會被擺在 bin 的最前頭。
flash_header.S 的開頭:
.org CONFIG_FLASH_HEADER_OFFSET另外定義 CONFIG_FLASH_HEADER_OFFSET 是 0x400。
另外,在 DCD table 最後是:
.word _end - TEXT_BASE 其中,_end 宣告在 u-boot.lds 中,是 bin 的最後。
TEXT_BASE 定義在 board 的 config.mk。是 u-boot load 到 ram 的位址。

所以在 iMX , DDR 的參數設定是由 boot-rom 的 code 做的,他會參考 boot device 的 DCD 內容設定register,然後再 load bootloader 到 DDR。
要 load 的長度和target address也是寫在 boot device 的 DCD 中。

iMX51 的 boot configuration

ref: freescale forume, freescale user manual 利用 BMOD pin 可以設定四種 boot mode:
  • 00 : Internal Boot (Boot from internal Boot ROM)
  • 01 : -- Reserved
  • 10 : Internal Boot (Boot from internal Boot ROM)
  • 11 : Serial Downloader (UART or USB)
其中 00 和 10 不一樣的地方在 internal boot rom 有沒有參考 gpio 做 boot device 的設定。 iMX51 內部有一個 Boot eFUSE。存放很多 boot configuration 的設定。 table 9-2 有列出eFUSE 中,每一個 option 的名稱,和是否可以由外部 gpio 來 overwrite。 eFUSE 是一個一次性燒錄的區域。可以利用 FreeScale 提供的 tool 來燒錄eFUSE 的值。 boot ROM 開機後,會參考 eFUSE 的內容,決定開機的裝置。
boot mode = 10 boot ROM 完全參考 eFUSE 的內容來動作。但是如果eFUSE 的內容是"un_programmed",會自動切換到 serial download mode,讓 user download boot code。 boot mode = 00 boot ROM 會參考 eFUSE 的內容和 GPIO 的內容。 在 eFUSE 的 table 中有列出哪些 option 對應到外部的 GPIO。 在這個 mode, boot rom code 會參考 GPIO 的值來開機。 這些可以 overwrite eFUSE 設定的 gpio 大多是 有 multiple function (e.g : display_data..),但是只有在 boot 的時候,boot rom 會參考這個 pin 的 high/low 值。 所以 hardware 要設定這些 pin 的 high-low,同時要考慮到不要影響他正常的 funciton 。 -- 也就是 pull-high, pull-low 電阻不可以太小。
開發和量產初期應該都是設為 00。
要使用 SD CARD 來開機,要設定 eFUSE 的:
  • BT_MEM_CTL : 11 - Expansion Device (SD/MMC/EEPROM)
  • BT_MEM_TYPE : 00 - SD/MMC/eMMC/eSD
還可以指定開機的 SD Slot:
  • BT_SRC : 00 - Slot 1, 01 - Slot 2, 10 - Slot 3, 11 - Slot 4.

BBG 上 default 是用 SD 0 開機 (底面),要改用上面的 SD 1 開機,要修改:
  • DIPSW - 6 要是 High
  • uboot 的 env virable : bootcmd 中,mmc read 0 都要改成 mmc read 1
* 可以看 uboot 的 help mmc 看 mmc 這個 command 的用法。

2010年8月23日 星期一

Worklog - MCU_P : uboot dev enviroment OK

nfs, mmc 都 OK 了 所以..現在可以開始 作u-boot function 的修改了。 server side
  • rebuild
  • copy to /var/lib/tftpboot
boar side
  • setenv ip,netmask,gateway,serverip
  • tftpboot 0xc2008000 u-boot.bin
  • cp.b 0xc2008000 0xf0004400 0x200000
重開,就可以了 重開的話,server 端的 usb0 要重新 setup. 接著來改 lcd display --- 希望可以 show splash..

u-boot : CFG_MMC_BASE

u-boot 的 SDMMC mapping 有點奇怪。 設定 #define CFG_MMC_BASE 0xF0000000 還有address 是以 byte 為單位,不是 sector。 可是 mmc 實際是要以 sector 為單位。 所以寫入時,要check
  • address 是不是 512 align
  • 最高 byte 是不是 0xF0000000

原來 u-boot 這樣設計的目的是要統一 操作的interface,這樣所有 memory , storage device 都可以用 cmd_mem.c 的 command : modify , read, write, compare 來操作。 所以,每個 memory, storage device 都被分配到一個 address range. cp.b 0x002000 0xF00000200 0x200 就會把 memory 的 0x2000 copy 到 mmc 的 0x200 (第一個block) 里。

2010年8月19日 星期四

uboot - network

uboot 的網路是從 環境變數 (env) 來取得網路參數的。 而且每個command 動作時,都會重新取一次。 所以,啟動後 setenv ipaddr 10.0.0.2 setenv netmask 255.255.255.9 setenv gateway 10.0.0.1 這樣 host 端: ifconfig usb0 10.0.0.1 netmask 255.255.255.0 up 就可以完成連線,然後: ping 10.0.0.1 checksum bad checksum bad host 10.0.0.1 is alive 代表 ping host OK
host 端可以修改 /etc/network/interfaces: auto usb0 iface usb0 inet static address 10.0.0.1 netmask 255.255.255.0 gateway 10.0.0.2

uboot - config and makefile , in a view of porting

mkconfig variant ARCH CPU BOARD VENDOR SOC 以 target smdk2410_config 來看: mkconfig smdk2410 arm arm920t smdk2410 NULL s3c24x0 所以
  • variant = smdk2410
  • ARCH = arm
  • CPU = arm920t
  • BOARD = smdk2410
  • VENDOR=
  • SOC = s3c24x0
這些variable 被使用:
  • create include/asm-CPU,, 建立 link 到 asm
  • 建立link include/asm-CPU 或 include/asm/asm-s3c24x0 到 asm-CPU/arch
  • create include/config.mk -- 定義 ARCH, CPU, BOARD, SOC
  • create include/config.h -- 產生內容: #include <configs/variabt.h> -- 所以重要的是 configs/variabt.h

所以要 porting uboot 要修改的部份有:
  • include/asm-CPU
  • include/asm-soc
  • include/configs/variant.h

Makefile 的部份: all : depends on u-boot u-boot depends on $(SUBDIRS) $(OBJS) $(LIBS) $(SUBDIRS), $(OBJS) 和 $(LIBS) 的 rule 都是簡單的 make 而已。 $(OBJS) 內都是 cpu/$(CPU)/ 下的 source 檔 $(LIBS) 除一般標準的 driver, disk rtc.. folde 外,還有 board/$(board)/lib$(board).a
所以 porting 時,還要create board/$(board) 目錄。 create 自己需要的 library
Makefile 的 include file:
  • include/config.mk --- 定義 ARCH, CPU, BOAD, VENDOR, SOC -- 這是標準的,不用改
  • config.mk -- 這也是標準的 rule,不用改 --
    • $(CPU)_config.mk -- 標準,不用改
    • cpu/$(CPU)/config.mk
    • cpu/$(CPU)/$(SOC)/config.mk
    • board/$(BOARD)/config.mk

所以porting時,要作自己的 cpu/$(CPU)/$(SOC)/config.mk 和 board/$(BOARD)/config.mk

2010年8月18日 星期三

uboot - config

build uboot 分為兩部份: config - build 一般的 software configure 都是 run ./configure 然後再 make 但是因為 uboot 是 build for target board,不是 host 所以 configure 是要把 uboot configure 成你的 target board. make tt2b_config 意思就是把uboot configure 成我的板子:tt2b 在 Makefile 中可以找到 tt2b_config 這個 target。 可以順便看一下其他的 XXX_config 大部分的 XXX_config 都是 call MKCONFIG... 多了: # include/asm # include/asm-arm/arch # include/asm-arm/proc # include/config.h # include/config.mk tt2b 這個 板子是去執行一個 shell script ...
  • 產生 include/config.h
  • 和其他人一樣,執行 MKCONFIG

所以來看一個 MKCONFIG.. tt2b 呼叫的 argument 是: $MKCONFIG -a tt2b arm arm1136 sssoc NULL sssoc 大概看一下.. mkconfig 這個 shell script 後面的 argument 分別是:
"-a" 一開始被 shift 掉.. 所以 tt2b 算 $1
echo "ARCH = $2" > config.mk echo "CPU = $3" >> config.mk echo "BOARD = $4" >> config.mk echo "VENDOR = $5" >> config.mk echo "SOC = $6" >> config.mk 第一個 argument "tt2b" 會被用在 新產生的 include/config.h 里: cd ./include echo "/* Automatically generated - do not edit */" >>config.h echo "#include <configs/$1.h>" >>config.h $2, $3 還被用來建 inlude/asm,, proc 的 folder link
所以 uboot 的 config 是用 mkconfig 這個 shell 來完成的。 他要產生
  • include/config.h
  • include/config.mk
  • include/asm

2010年8月17日 星期二

worklog - uboot of MCU_P

參考 bsp 下的 makefile, uboot 的 make rule. 可以看到 make $(BDNAME)_config然後去找 BDNAME (是 tt2cb) 在uboot/Makefile找到 tt2cb_config 的 rule : 是 board/vendor/ 下的 一個 shell script,他會去修改 include/config.h 接上 usb... boot uboot 時原來 USB0 Cable is not plugged-in 的 message 消失了。 在 linux host 上 dmesg : [1756640.022407] usb 4-3: USB disconnect, address 9 [1756645.672024] usb 4-3: new high speed USB device using ehci_hcd and address 10 [1756645.808028] hub 4-0:1.0: unable to enumerate USB device on port 3 [1756646.252023] usb 2-1: new full speed USB device using ohci_hcd and address 2 [1756647.500029] hub 2-0:1.0: unable to enumerate USB device on port 1 [1756653.972024] usb 4-3: new high speed USB device using ehci_hcd and address 11 [1756654.105202] usb 4-3: configuration #2 chosen from 1 choice [1756654.110595] usb 4-3: New USB device found, idVendor=105b, idProduct=9030 [1756654.110602] usb 4-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [1756654.110605] usb 4-3: Product: bd2x0bd [1756654.110608] usb 4-3: Manufacturer: Sxxx [1756654.110610] usb 4-3: SerialNumber: 0 [1756654.363827] cdc_acm: This device cannot do calls on its own. It is no modem. [1756654.364055] cdc_acm 4-3:2.0: ttyACM0: USB ACM device [1756654.366357] usbcore: registered new interface driver cdc_acm[1756654.366365] cdc_acm: v0.26:USB Abstract Control Model driver for USB modems and ISDN adapters list installed module 來看..多了 cdc_acm 這個 driver/module. 查一下 include/configs/tt2b.h有定義 #define CONFIG_USB_TTY 0 /* Controller USB0 */ #define CONFIG_USB_ETHER 1 /* Controller USB1 */ 所以知道 Rx6 的 usb port 是 usb0 -- 從 uboot 消失的 message 可以知道。所以是 USB_TTY。 所以 driver 是 cdc_acm. 變更一下,把 USB0 改作 ETHER.. 開機dmesg: [1757943.195445] usb 4-3: New USB device found, idVendor=105b, idProduct=9030 [1757943.195451] usb 4-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [1757943.195454] usb 4-3: Product: bd2x0bd [1757943.195457] usb 4-3: Manufacturer: SiRF [1757943.195459] usb 4-3: SerialNumber: 0 [1757944.330011] usb 4-3: USB disconnect, address 13 [1758205.148026] usb 4-3: new high speed USB device using ehci_hcd and address 14 [1758205.281250] usb 4-3: configuration #1 chosen from 1 choice [1758205.286289] usb 4-3: New USB device found, idVendor=105b, idProduct=9030 [1758205.286296] usb 4-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [1758205.286299] usb 4-3: Product: bd2x0bd [1758205.286302] usb 4-3: Manufacturer: SiRF [1758205.486224] usb0: register 'cdc_ether' at usb-0000:00:0f.3-3, CDC Ethernet Device, 1e:6e:37:bc:8a:47 [1758205.486251] usbcore: registered new interface driver cdc_ether lsmod 果然就有 cdc_ether,ifconfig 則增加了: usb0 Link encap:Ethernet HWaddr 1e:6e:37:bc:8a:47 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:1 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:90 (90.0 B)

標籤

網誌存檔