BCM_SDK命令


啟動bcm的sdk,會進入一個類似shell的交互界面,在其中如入命令,可以配置交換機芯片。
本文主要記錄一下命令:
   1.端口限速命令
   2.鏈路聚合命令
   3.i2c控制命令
啟動方法:
/tmp/bcm # ./bcm.user.proxy
“?”顯示幫助信息。直接輸入會顯示出sdk對所有型號芯片支持的命令,以及當前所支持的命令。
BCM.0> ?
help: "??" or "help" for summary
Commands common to all modes:
?              ??             ASSert         BackGround     BCM            
BCMX           Board          break          CASE           CD             
CONFig         CONSole        CoPy           DATE           DeBug          
DeBugMod       DELAY          DEVice         DIR            DISPatch       
Echo           EXIT           EXPR           FLASHINIT      FLASHSYNC      
FOR            Help           HISTory        IF             JOBS           
KILL           LOCal          LOG            LOOP           LS             
MKDIR          MODE           MORe           MoVe           NOEcho         
Pause          PRINTENV       PWD            QUIT           RCCache        
RCLoad         REBOOT         REName         RESET          RM             
RMDIR          SalProfile     SAVE           SET            SETENV         
SHell          SLeep          TIME           Version        
Commands for current mode:
AGE            Attach         Auth           BIST           BPDU           
BTiMeout       CABLEdiag      CACHE          CellHDR        CHecK          
CLEAR          COLOR          COMBO          COS            CounTeR        
CustomSTAT     DELete         DETach         DMA            DmaRomTest     
DMIRror        DSCP           DTAG           Dump           EditReg        
EGRess         EthernetAV     FieldProcessor Getreg         GPORT          
H2HIGIG        H2HIGIG2       HASH           HeaderMode     INIT           
Insert         INTR           IPFIX          IPG            KNETctrl       
L2             L2MODE         LED            LINKscan       LISTmem        
Listreg        LOOKup         MCAST          MemSCAN        MemWatch       
MIRror         MODify         ModMap         Modreg         MTiMeout       
MultiCast      OAM            PacketWatcher  PBMP           PHY            
POP            PORT           PortRate       PortSampRate   PortStat       
PROBE          PUSH           PUTREG         PVlan          RATE           
RateBw         RegCMp         REMove         RXCfg          RXInit         
RXMon          SCHan          SEArch         Setreg         SHOW           
SOC            STACKMode      StackPortGet   StackPortSet   STG            
STiMeout       STKMode        SwitchControl  SystemSnake    TestClear      
TestList       TestMode       TestParameters TestRun        TestSelect     
TRUNK          TX             TXCount        TXSTArt        TXSTOp         
VLAN           WARMBOOT       Write          XAUI   

### 1.portrate設置端口限速
BCM.0> portrate ?
Usage (PortRate): Set/Display port rate metering characteristics.
Parameters: <pbm> [ingress|egress|pause [arg1 arg2]]
            For Ingress or Egress: arg1 is rate, arg2 is max_burst
            For Pause: arg1 is pause_thresh, arg2 is resume_thresh
            rate is in kilobits (1000 bits) per second
            max_burst and xxx_thresh are in kilobits (1000 bits)
# 設置端口1的入口速率最大為1000,burst是有關qos相關的參數。
BCM.0> portrate ge0 ingress 1000  
PortRate: Error: missing port burst size
BCM.0> portrate ge0 ingress 1000 1000
# 顯示所設置的端口參數,可以看出與設置的有些不同,因該是進行了轉化
BCM.0> portrate
 ge0:   Ingress meter:     1024 kbps     1031 kbits max burst.

### 2.trunk 設置鏈路聚合
BCM.0> trunk
Usage (TRUNK): Usages:
          trunk init
                - Initialize trunking function
          trunk deinit
                - Deinitialize trunking function
          trunk add <Id=val> <Rtag=val> <Pbmp=val>
                - Add ports to a trunk
          trunk remove <Id=val> <Pbmp=val>
                - Remove ports from a trunk
          trunk show [<Id=val>]
                - Display trunk information
          trunk egress [<Id=val>] <Pbmp=val>
                - Set egress ports for trunk
          trunk mcast <Id=val> <Mac=val> <Vlan=val>
                - Join multicast to a trunk
          trunk hash set <Pbmp=val> <HashValue=val>
                - Set ingress port hash value to select egress port of a trunk
          trunk hash get <Pbmp=val>
                - Get ingress port programmable hash value
          trunk psc <Id=val> <Rtag=val>
                - Change Rtag (for testing ONLY)
# rtag指定鏈路聚合的負載分擔方式。當設置2台交換機都配置為srcmac,destmac的時候,
# 再通過測試卡進行發包測試,發送和接收都不會丟包,
# 但是2兩台交換機中有一台配置為srcdestmac的時候就會丟一半的包,正在查原因。
BCM.0> trunk add id=1 rtag=1 pbmp=ge0,ge1
BCM.0> trunk add id=2 rtag=2 pbmp=ge2,ge3
BCM.0> trunk add id=3 rtag=3 pbmp=ge4,ge5
# 查看鏈路聚合的設置
BCM.0> trunk show
Device supports 8 trunk groups:
  8 front panel trunks (0..7), 8 ports/trunk
trunk 1: (front panel, 2 ports)=ge0,ge1 dlf=any mc=any ipmc=any psc=srcmac (0x1)
trunk 2: (front panel, 2 ports)=ge2,ge3 dlf=any mc=any ipmc=any psc=destmac (0x2)
trunk 3: (front panel, 2 ports)=ge4,ge5 dlf=any mc=any ipmc=any psc=srcdestmac (0x3)
### 3.i2c命令
BCM.0> i2c ?
Usage (I2C): Usages:
        i2c probe [pio|intr] [speed] [quiet]
            - probe devices on I2C bus and build device tree.
              If "intr" or "pio" is specified, change to that bus mode.
              If a valid speed is specified, change the bus to that speed.
              If "quiet" is specified, suppresses probe output.
        i2c scan [pio|intr] [saddr] [quiet]
            - Scan devices on I2C bus and display the device list.
        i2c log
            - show I2C bus transaction log.
        i2c backlog
            - show I2C bus transaction log (in reverse order).
        i2c clearlog
            - reset I2C bus transaction log.
        i2c reset
            - reset I2C bus controller core.
        i2c speeds
            - show supported I2C bus controller clock rates.
        i2c show
            - show devices found and their attributes.
        i2c read saddr comm len
            - generic interface to read devices, do probe first
        i2c readb saddr len
            - generic interface to read devices without register based access, do probe first
        i2c write saddr comm [data]
            - generic interface to write a byte to devices, do probe first
            - comm is data when writing directly otherwise command register
# 操作i2c之前,都需要先輸入i2c probe
BCM.0> i2c probe
Yet to Implement soc_i2c_write_word_data
Yet to Implement soc_i2c_write_word_data
I2C: detected 2 devices
# 掃描i2c設備
BCM.0> i2c scan
I2C device found at slave address 0X20 (lpt0: PCF8574 MUX control)
I2C device found at slave address 0X32 (Unknown)
I2C device found at slave address 0X48 (temp0: LM75 Temperature Sensor)
I2C device found at slave address 0X77 (PCA9548 MUX)
# 0x32的設備地址是SD2405時鍾芯片。讀取時鍾芯片秒寄存器的值
BCM.0> i2c read 0x32 0x00 1
00: 18
# 讀取秒寄存器和分寄存器的值
BCM.0> i2c read 0x32 0x00 2
00: 31 35

查看sdk/src/appl/diag/目錄中的文件就可以了解對應的命令的實現。
例如i2c_cmds.c文件。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM