歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux編程 >> Linux編程

Broadcom移植到OpenWrt總結

評估及移植BCM5862x及BCM5301x到OpenWrt平台下:

一、首先得分清楚幾個基本概念:

1、文件系統

文件系統是操作系統用於明確存儲設備(常見的是磁盤,也有基於NAND Flash的固態硬盤)或分區上的文件的方法和數據結構;即在存儲設備上組織文件的方法。操作系統中負責管理和存儲文件信息的軟件機構稱為文件管理系統,簡稱文件系統。文件系統由三部分組成:文件系統的接口,對對象操縱和管理的軟件集合,對象及屬性。從系統角度來看,文件系統是對文件存儲設備的空間進行組織和分配,負責文件存儲並對存入的文件進行保護和檢索的系統。具體地說,它負責為用戶建立文件,存入、讀出、修改、轉儲文件,控制文件的存取,當用戶不再使用時撤銷文件等。

嵌入式系統中常用的文件系統包括:jffs2、squashfs、ubifs、initramfs、nfs、、、、jffs2是最常用的日志文件系統,ubifs是屬於下一代jffs2,initramfs用於驗證kernel是否正常運行,squashfs是一種壓縮型文件系統,所占空間要比jffs2小一半,它通過解壓縮文件系統後,創建新分區rootfs_data,通過overlay(需要內核patch支持)文件系統掛載新分區到jffs2上,從而實現可寫。使用相應的文件系統需要相應的內核配置支持。

 各文件系統的制作:

    jffs2::

    ubifs::

    suqashfs::

    initramfs:

  其中offset是分區開始的偏移地址,MTDPART_OFS_APPEND,表示緊接著上一個分區,

    MTD Core會自動計算和處理分區地址;size是分區的大小,在最後一個分區我們設為

   MTDPART_SIZ_FULL,表示這個NAND剩下的所有部分。這樣配置NAND的分區並不是唯

   一的,需要視具體的系統而定,我們可以在kernel中這樣顯式的指定,也可以使用bootloader

   傳給內核的參數進行配置。

    2、內核

    kernel的幾種格式:

    vlinux:

    vlinuxz:

    image:

    uImage.img:

    3.uboot

    幾個重要的uboot啟動參數:

    bootargs:

    bootcmd:

二、BCM特有的bootloader--CFE基本操作:

Decompressing...done
Found a ST compatible serial flash with 256 64KB blocks; total size 16MB

CFE version 6.30.163.2002 (r382208) based on BBP 1.0.37 for BCM947XX (32bit,SP,)
Build Date: Thu Feb 28 22:09:40 EST 2013 ([email protected])
Copyright (C) 2000-2008 Broadcom Corporation.

Init Arena
Init Devs.
Boot partition size = 262144(0x40000)
DDR Clock: 400 MHz
Warning: using legacy sdram_ncdl parameter to set DDR frequency. Equivalent setting in clkfreq=800,*0* will be ignored.
et0: Broadcom BCM47XX 10/100/1000 Mbps Ethernet Controller 6.30.163.2002 (r382208)
CPU type 0x0: 800MHz
Tot mem: 262144 KBytes

CFE mem: 0x00F00000 - 0x00FDA500 (894208)
Data: 0x00F4EB5C - 0x00F4F014 (1208)
BSS: 0x00F4F020 - 0x00F74500 (152800)
Heap: 0x00F74500 - 0x00FD8500 (409600)
Stack: 0x00FD8500 - 0x00FDA500 (8192)
Text: 0x00F00000 - 0x00F44874 (280692)
Boot: 0x00FDB000 - 0x0101B000
Reloc: I:00000000 - D:00000000

Device eth0: hwaddr 00-90-4C-0F-F0-01, ipaddr 192.168.1.1, mask 255.255.255.0
 gateway not set, nameserver not set
Loader:raw Filesys:tftp Dev:eth0 File:: Options:(null)
Loading: Failed.

CFE> printenv
Variable Name Value
-------------------- --------------------------------------------------
BOOT_CONSOLE uart0
CFE_VERSION 1.0.37
CFE_BOARDNAME BCM947XX
CFE_MEMORYSIZE 262144
NET_DEVICE eth0
NET_IPADDR 192.168.1.1
NET_NETMASK 255.255.255.0
NET_GATEWAY 0.0.0.0
NET_NAMESERVER 0.0.0.0
STARTUP go;
*** command status = 0

CFE> help
Available commands:

nvram NVRAM utility.
reboot Reboot.
set console Change the active console device
loop Loop a command
flash Update a flash memory device
memtest Test memory.
f Fill contents of memory.
e Modify contents of memory.
d Dump memory.
u Disassemble instructions.
batch Load a batch file into memory and execute it
go Verify and boot OS image.
boot Load an executable file into memory and execute it
load Load an executable file into memory without executing it
save Save a region of memory to a remote file via TFTP
ping Ping a remote IP host.
arp Display or modify the ARP Table
ifconfig Configure the Ethernet interface
show clocks Show current values of the clocks.
show heap Display information about CFE's heap
show memory Display the system physical memory map.
show devices Display information about the installed devices.
unsetenv Delete an environment variable.
printenv Display the environment variables
setenv Set an environment variable.
help Obtain help for CFE commands

For more information about a command, enter 'help command-name'
*** command status = 0
CFE>
CFE> help flash

SUMMARY

Update a flash memory device

USAGE

flash [options] filename [flashdevice]

 Copies data from a source file name or device to a flash memory device.
 The source device can be a disk file (FAT filesystem), a remote file
 (TFTP) or a flash device. The destination device may be a flash or eeprom.
 If the destination device is your boot flash (usually flash0), the flash
 command will restart the firmware after the flash update is complete

OPTIONS

-noerase Don't erase flash before writing
 -offset=* Begin programming at this offset in the flash device
 -size=* Size of source device when programming from flash to flash
 -noheader Override header verification, flash binary without checking
 -mem Use memory as source instead of a device

*** command status = 0
CFE>
CFE>
CFE> help load

SUMMARY

Load an executable file into memory without executing it

USAGE

load [-options] host:filename|dev:filename

 This command loads an executable file into memory, but does not
 execute it. It can be used for loading data files, overlays or
 other programs needed before the 'boot' command is used. By
 default, 'load' will load a raw binary at virtual address 0x20000000.

OPTIONS

-elf Load the file as an ELF executable
 -srec Load the file as ASCII S-records
 -raw Load the file as a raw binary
 -z Load compessed file
 -loader=* Specify CFE loader name
 -tftp Load the file using the TFTP protocol
 -fatfs Load the file from a FAT file system
 -rawfs Load the file from an unformatted file system
 -fs=* Specify CFE file system name
 -max=* Specify the maximum number of bytes to load (raw only)
 -addr=* Specify the load address (hex) (raw only)

*** command status = 0
CFE>
CFE> load tftp 192.168.1.10:Image
*** command status = -6
CFE>
CFE> load -tftp -addr=81008000 192.168.1.10:Image
Loader:raw Filesys:tftp Dev:eth0 File:192.168.1.10:Image Options:(null)
Loading: .. 6566180 bytes read
Entry at 0x81008000
*** command status = 0
CFE>
CFE>
CFE> help go

SUMMARY

Verify and boot OS image.

USAGE

go

 Boots OS image if valid. Waits for a new OS image if image is invalid
 or boot_wait is unset or not on.

*** command status = 0
CFE>

CFE> load -addr=82000000 -tftp 192.168.1.10:u-boot.bin
Loader:raw Filesys:tftp Dev:eth0 File:192.168.1.10:u-boot.bin Options:(null)
Loading: .. 537212 bytes read
Entry at 0x82000000
*** command status = 0
CFE>

CFE> show devices
Device Name Description
------------------- ---------------------------------------------------------
uart0 NS16550 UART at 0x18000300
uart1 NS16550 UART at 0x18000400
flash0 ST Compatible Serial flash size 16384KB
flash0.boot ST Compatible Serial flash offset 00000000 size 256KB
flash0.trx ST Compatible Serial flash offset 00040000 size 1KB
flash0.os ST Compatible Serial flash offset 0004001C size 16064KB
flash0.nvram ST Compatible Serial flash offset 00FF0000 size 64KB
flash1.boot ST Compatible Serial flash offset 00000000 size 256KB
flash1.trx ST Compatible Serial flash offset 00040000 size 16064KB
flash1.nvram ST Compatible Serial flash offset 00FF0000 size 64KB
eth0 Broadcom BCM47XX 10/100/1000 Mbps Ethernet Controller
*** command status = 0
CFE>

CFE> flash -noheader 192.168.1.10:u-boot.bin -offset=0 flash0
Reading 192.168.1.10:u-boot.bin: Done. 537212 bytes read
Programming...done. 537212 bytes written
*** command status = 0
CFE>

三、BCM網絡配置

四、移植SDK到openwrt基本步驟及注意事項

Copyright © Linux教程網 All Rights Reserved