組み込み型開発ボードのファームウェアとアプリケーションのリモートアップグレード

6106 ワード

組み込みLinuxファームウェアアップグレード2018年03月26日10:41:11青竹雨仙読書数:718組み込みLinuxファームウェアアップグレード
開発ニーズ•TCP/IPに基づくドライバモジュールとアプリケーションの更新、アップグレード
このドキュメントのドライバとアプリケーションを総称して「ファームウェア」と呼ぶことを特別に宣言します.
•ホスト:VMWare–Fedora 9
•開発ボード:yc 2440–64 MB Nandflash;Kernel:2.6.24.4
•コンパイラ:arm-linux-gcc-4.0.0
設計原理図
説明:
•開発ボードはFileServerアプリケーションを起動し、TCP/IPのServer側としてアップグレードファイルを受信するサービスを提供する.
•ファームウェアのアップグレードが必要な場合、PCはFileClientアプリケーションを起動し、TCP/IPのClient側としてアップグレードファイルを送信するサービスを提供する.
•ShellスクリプトファイルStartShellは、ファームウェアをアップグレードする必要があるかどうかを判断し、既存のファームウェアが更新された場合は、更新されたファームウェアを起動し、そうでない場合は、既存のファームウェアを起動します.
ファイル名
所在ディレクトリ
機能
FileClient
Linux PC下任意ディレクトリ
PC機TCP/IPクライアント、
アップグレードされたファームウェアを開発ボードに送信します.
FileServer
Linux開発ボード
/tmp/update/
開発ボードTCP/IPサービス
クライアントから送信されたアップグレードファームウェアを受信します.
StartShell
Linux開発ボード
/etc/init.d/
対応するファームウェアを置き換え、
対応するファームウェアを起動します.
実装手順
  •   ( :192.168.1.168)
    

  • 開発ボードでは、起動スクリプト/etc/initを編集します.d/rcS
    #cp ~/StartShell/etc/init.d/
    #vi/etc/init.d/rcS
    このファイルの一番後ろに、次の情報を入力します.
    ./StartShell
    開発ボードを再起動します.
  •   (Linux PC:192.168.1.200)
    

  • #./fileclient ./AppMain 192.168.1.168
    #./fileclient ./helloworld.ko 192.168.1.168
    上記の更新ファイルは、開発ボードの/tmp/update/(FileServerが存在するディレクトリ)ディレクトリに送信されます.
    開発ボードを再起動し、ファイルのアップグレードが完了しました.
    注意:ドライバモジュールを動的にロードする場合は、まず開発ボードに/lib/modules/2.6.24.4ディレクトリを作成する必要があります.
    添付ファイル:•TCP/IPソースファイル
    http://download.csdn.net/source/2996852
    注意:TCP/IPサービスはできるだけ大きなスローガンを使って、例えば:50000、さもなくばサーバー側はBindが失敗する情況が現れます.
    サーバ側にファイアウォールがある場合は、ポート番号を開く必要があります.そうしないと、クライアントがconnectに失敗することがあります.
    •Start Shellスクリプト
    #!/bin/sh
    #新しいドライバファイルがあるかどうかを判断し、置換がある場合は
    if [ -f/tmp/update/helloworld.ko ]
    then
        echo "it is a new ko file"
    
    
    
        rm /lib/modules/helloworld.ko -f
    
        cp /tmp/update/helloworld.ko /lib/modules/
    
        rm /tmp/update/helloworld.ko -f
    

    else
        echo "it is not a new ko file"
    

    fi
    insmod helloworld
    #新しいアプリケーションファイルがあるかどうかを判断し、置換がある場合
    if [ -f/tmp/update/AppMain ]
    then
        echo "it is a new app file"
    
    
    
        rm /root/application/AppMain -f
    
        cp /tmp/update/AppMain /root/application/
    
        chmod 777 /tmp/update/AppMain
    
        rm /tmp/update/AppMain -f
    

    else
        echo "it is not a new app file"
    

    fi
    #アプリケーションの起動
    cd/root/application/
    ./AppMain &
    #TCP/IPサービスプログラムの起動
    cd/tmp/update/
    ./FileServer &
    Embedded Linux firmware upgrade Development requirement • Based on TCP/IP to complete the driver modules and application updates, upgrades Special Statement Drivers program and application program in this document are collectively called the “firmware”.
    • Main machine: VMWare-Fedora 9 • Development Board: yc2440-64MB Nandflash; Kernel: 2.6.24.4 • Compiler: arm-linux-gcc-4.0.0
    Design schematic
    Description: • Start FileServer application on development board, as the TCP/IP server, providing service to receive the upgrade file. • When you need a firmware upgrade, PC starts FileClient application, as the TCP/IP client, providing service to send the upgrade file. • Shell script file StartShell determine whether there is the firmware need to upgrade, if it is existed, launch the updated firmware, if not, start the existing firmware.
    File
    directory
    function
    FileClient
    any directory in linux PC
    PC TCP/IP client, Send upgrade firmware to development board.
    FileServer
    /tmp/update/in
    linux development board
    Development board TCP/IP server,
    receive the upgrade firmware from client.
    StartShell
    /etc/init.d/in
    linux development board
    Replace firmware,
    Start frimware.
    Implementation steps
  • Configuration startup files (development board: 192.168.1.168) In the development board, edit the boot script file/etc/init.d/rcS, input the following information:

  • cp ~ /StartShell /etc/init.d/


    vi /etc/init.d/rcS


    Finally, in the end of the document, input the following information:
    ./StartShell
    Restart the development board.
  • Send the update file file (Linux PC: 192.168.1.200) #./Fileclient ./AppMain 192.168.1.168 #./Fileclient ./Helloworld.ko 192.168.1.168

  • The update file is sent to the development board of the/tmp/update/(FileServer directory) directory.
    Restart the development board, file upgrade is OK.
    Note: If you want to dynamically load the driver module, first the directory/lib/modules/2.6.24.4 must be created in development board.
    Attachment: • TCP/IP source code file http://download.csdn.net/source/2996852
    Note: TCP/IP service port to make use of large numbers, such as: 50000, otherwise there will be bind server failure situation. If the server has a firewall, you need to open up the port number, otherwise the client will connect failure situation.
    • StartShell script
    #!/bin/sh

    Determine whether there is a new driver file, if there is to be replaced


    if [ -f/tmp/update/helloworld.ko ] then echo “it is a new ko file”
        rm /lib/modules/helloworld.ko -f 
        cp /tmp/update/helloworld.ko /lib/modules/ 
        rm /tmp/update/helloworld.ko -f 
    

    else echo “it is not a new ko file” fi
    insmod helloworld

    Determine whether there is a new application file, if there is to be replaced


    if [ -f/tmp/update/AppMain ] then echo “it is a new app file”
        rm /root/application/AppMain -f 
        cp /tmp/update/AppMain /root/application/ 
        chmod 777 /tmp/update/AppMain 
        rm /tmp/update/AppMain -f 
    

    else echo “it is not a new app file” fi

    Start the application program


    cd/root/application/./AppMain &

    Start TCP/IP service program


    cd/tmp/update/./FileServer &