網樂通是PDK7105的架構
在 Linux環境裡面套件管理分兩大陣營
分別是Debian的dpkg/apt-get與RedHat的rpm/yum
而很多無線AP裡面跟JB過的iPhone是Debian的dpkg/apt-get
網樂通裡面跑的STLinux屬於RedHat的rpm/yum
Kernel:
2.6.23.17_stm23_A18B
or
2.6.23.17_stm23_A18B-PDK7105-32BITS-A18B
Modules:
rt3070sta
進入root的方法:
拔掉插頭,插上usb碟,按住reset插上電源燈閃3下開機之後更新韌體失敗就會進入root
但是要先確定ip位置才能用telnet連接
/dev/sda1 這個是 recovery 的分割區(按住 reset 插上電源燈閃3下開機就會進來這區)
/dev/sda2 這個是系統正常開機在用的分割區(開機會去執行etc/init.d/rc 和 rcS rcSBB)
/dev/sda3 用來放系統更新檔及備份的分割區
掛在/mnt/usb上記得在根目錄(/dev/sda3)放TARGET.ENC和GB620.SVF可升級韌體
/dev/sda4 似乎是拿來放 p2p 暫存檔用的
/dev/sdb1 USB隨身碟的位置 可用 mount /dev/sdb1 /tmp/usb 掛載
用dd if=/dev/sda1 of=/tmp/usb/sda1_backup.img備份
正常開機會掛 rootfs on / type rootfs(rw)和 /dev/root on ./ type ext3 (rw,data=jounal)
其實就是把/dev/sda2掛在 / 上
掛好之後開機會去執行/etc/init.d/rc
rc會去找 /etc/rc.d/rc3.d/S* 開頭所有檔案
所以建立一個S90neo並更名S90fdtv成@S90fdtv即可
注意給755權限才會執行
echo "/sbin/udhcpc&" >> S90neo
echo "/bin/busybox telnetd -l /bin/sh" >> S90neo
若不要自動登入root就用(要記得先用passwd設好root密碼)
echo "/bin/busybox telnetd -l /bin/login" >> S90neo
就能開啟telnetd
PS:
若要自訂IP則 /sbin/udhcpc& 換成
/bin/busybox ifconfig eth0 192.168.1.100 netmask 255.255.255.0
/bin/busybox route add default gw 192.168.1.1
網路安裝STLinux 2.3 on debian
sudo apt-get install bash (通常已有)
sudo dpkg-reconfigure dash (進入選'否'/bin/sh就會換成bash,debian預設是dash)
sudo apt-get install rpm
wget http://www.stlinux.com/sites/default/files/stlinux23-host-STLinux_deps-0.1-5.i386.rpm
sudo rpm -ivh --force-debian stlinux23-host-STLinux_deps-0.1-5.i386.rpm
wget ftp://ftp.stlinux.com/pub/stlinux/2.3/install將install檔案屬性設定成777
sudo ./install --debian all-sh4-glibc
會下載 664個套件802 MB大小的檔案
跑完後切到 /opt/STM/STLinux-2.3/host/bin目錄
sudo ./stmyum update
將現有的套件再做更新
設定PATH路徑
~/.bashrc 檔案的PATH變數中加/opt/STM/STLinux-2.3/devkit/sh4/bin
試試sh4-linux-gcc有沒有反應
有的話就成功了
離線安裝STLinux 2.3 on ubuntu
下載ftp://ftp.stlinux.com/pub/stlinux/2.3/iso/STLinux-2.3-sh4-03-11-07.iso
sudo dpkg-reconfigure dash 選no
sudo apt-get install rpm yum
sudo apt-get install python-urlgrabber python-rpm python-sqlitecachec
wget http://www.stlinux.com/sites/default/files/stlinux23-host-STLinux_deps-0.1-5.i386.rpm
sudo rpm -ivh stlinux23-host-STLinux_deps-0.1-5.i386.rpm
sudo ./install all-sh4-glibc
跑完後切到 /opt/STM/STLinux-2.3/host/bin目錄
sudo ./stmyum update 將現有的套件再做更新
設定PATH路徑~/.bashrc 檔案的PATH變數中加/opt/STM/STLinux-2.3/devkit/sh4/bin
PATH="$PATH":/opt/STM/STLinux-2.3/devkit/sh4/bin
export PATH
試試sh4-linux-gcc有沒有反應
------------------------------------------------------
Tool | Native Name | STLinux |
------------------------------------------------------
GNU C Compiler | gcc | sh4-linux-gcc |
------------------------------------------------------
GNU C++ Compiler | g++ | sh4-linux-g++ |
------------------------------------------------------
GNU C++ Pre-processor | cpp | sh4-linux-cpp |
------------------------------------------------------
GNU Linker | ld | sh4-linux-ld |
------------------------------------------------------
GNU Assembler | as | sh4-linux-as |
------------------------------------------------------
GNU Librarian | ar | sh4-linux-ar |
------------------------------------------------------
以編譯pureftpd為例 下載source code wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.36.tar.gz tar -zxvf pure-ftpd-1.0.36.tar.gz
對於一個有 configure 文件的軟件來說, 生成Makefile很簡單,只需要指定 --host CC="" CXX="" 即可。具體為:
./configure --host=neo-stlinux23-sh4 CC="sh4-linux-gcc" CXX="sh4-linux-g++"
下來 make 就可以了。
./configure --prefix=/usr/local/pureftpd CC=sh4-linux-gcc --host=neo-linux-gcc --with-everything --with-rfc2640
注意make會用到ar檔
所以增加link
ln -s /opt/STM/STLinux-2.3/devkit/sh4-linux-ar /usr/local/bin/ar
make
make install
--prefix指的是編譯完目的目錄,etc/pureftpd.passwd和etc/pureftpd.pdb都會在底下
CC為交叉編譯的編譯器
--host給一個ID
--with-everything指所有都要安裝
--with-rfc2640支援中文
完成後會有bin,sbin,share都copy到機子上
其中bin/pure-pw可增加帳號
bin/pure-pw useradd -u ftp -d /var/ftp
注意目錄/usr/local/pureftpd/etc/要存在因為pureftpd.passwd會建立
/usr/local/pureftpd/etc/pureftpd.passwd
完成後bin/pure-pw mkdb會建立pureftpd.pdb
/usr/local/pureftpd/etc/pureftpd.pdb
啟動程序
pure-ftpd -E -B -l puredb:/usr/local/pureftpd/etc/pureftpd.pdb
其中-E是禁止匿名登入-B是背景執行-l puredb:讀pdb帳號
/root/pureftpd/sbin/pure-ftpd -E -B -l puredb:/usr/local/pureftpd/etc/pureftpd.pdb
以編譯HelloWorld為例
(sudo mount //位置/目錄 /mnt/samba -o username=使用者,password=密碼,uid=使用者,gid=群組,rw
)
(用samba方式較快)
HelloWorld.c
#include<stdio.h>
#include<stdlib.h>
int main(void){
puts("Hello world");
return EXIT_SUCCESS;
}
用以下指令編譯
sh4-linux-gcc -Wall -fmessage-length=0 -O0 -g3 -MMD -MP -MF"hello.d" -MT"hello.d" hello.c -o hello
到網樂通內執行hello
其中include部分:
/opt/STM/STLinux-2.3/devkit/sh4/lib/gcc/sh4-linux/4.2.4/include
/opt/STM/STLinux-2.3/devkit/sh4/sh4-linux/include
/opt/STM/STLinux-2.3/devkit/sh4/target/usr/include
Makefile部分
//-----------------------------------------------------------
BIN_NAME :=hello C_SRCS :=./hello.c OBJS :=hello.o C_DEPS :=hello.d OUTPUT :=./bin TMP :=./tmp USER_OBJS :=$(TMP)/$(OBJS) LIBS := RM = rm -rf MKDIR = mkdir -p all: $(BIN_NAME) $(TMP): $(MKDIR) $(TMP) $(OUTPUT): $(MKDIR) $(OUTPUT) $(TMP)/$(OBJS): $(TMP) $(C_SRCS) sh4-linux-gcc -Wall -c -fmessage-length=0 -O0 -g3 -MMD -MP -MF"$(TMP)/$(C_DEPS)" -MT"$(TMP)/$(C_DEPS)" $(C_SRCS) -o $(TMP)/$(OBJS) $(BIN_NAME): $(OUTPUT) $(TMP)/$(OBJS) $(USER_OBJS) sh4-linux-gcc -o $(OUTPUT)/$(BIN_NAME) $(USER_OBJS) $(LIBS) clean: -$(RM) $(TMP)/$(OBJS) $(TMP)/$(C_DEPS) $(OUTPUT)/$(BIN_NAME)
//-----------------------------------------------------------
較常見的做法:
//-----------------------------------------------------------
CROSSPATH=/opt/STM/STLinux-2.3/devkit/sh4
SHPREFIX=sh4-linux-
CC = ${SHPREFIX}gcc
CXX = ${SHPREFIX}g++
CFLAGS = -Wall -c -pipe -D_FILE_OFFSET_BITS=64 -D_DEBUG -DDEBUG -fmessage-length=0 -O0 -g3 -MMD -MP -MF"temp.d" -MT"temp.d"
LIBPATH=/opt/STM/STLinux-2.3/devkit/sh4/target/usr/lib
LDFLAGS = -ldl ${LIBPATH}/libpthread.a ${LIBPATH}/libc.a
MODULE_INC = -I$(CROSSPATH)/target/usr/include
MODULE_LIB = -L${CROSSPATH}/target/usr/lib
CFLAGS += $(MODULE_INC)
LDFLAGS += $(MODULE_LIB)
LIBOBJS = hello.o
TARGET = hello
all: $(TARGET)
$(TARGET): $(LIBOBJS)
$(CC) -o $@ $^ $(LDFLAGS)
rm -fr *.o
rm -fr temp.d
clean:
rm -f *.o
rm -f $(TARGET)
rebuild:
make clean
make all
# make rule
%.o : %.c
$(CC) $(CFLAGS) -c $^ -o $@
%.o : %.cpp
$(CXX) $(CFLAGS) -c $^ -o $@
//-----------------------------------------------------------
編譯QT 4.6.0 範例
1:先安裝qt-everywhere-opensource-src-4.6.0.tar.gz
簡單範例qt.cpp
#include <QtGui/QPushButton>
#include <QtGui/QWidget>
#include <QtGui/QLabel>
#include <QtCore/QTextCodec>
int main(int argc, char *argv[])
{
//QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Big5-ETen"));
QApplication app(argc, argv);
QWidget window;
window.setGeometry(300,100,700,500);
QLabel label(&window);
label.setFont(QFont("Times", 60, QFont::Bold));
label.setText("<center><h1>這是標籤</h1></center>");
label.setGeometry(0,0,500, 150);
label.show();
QPushButton quit("這是按鈕", &window);
quit.setFont(QFont("Times", 40, QFont::Bold));
quit.setGeometry(100, 200, 200, 100);
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
window.show();
return app.exec();
}
編譯
sh4-linux-g++ qt.cpp -o qt_sample -I../qt46/usr/include -lQtGui -lQtCore -lQtNetwork -L.
記得目錄下要有libQtCore.so, libQtGui.so, libQtNetwork.so
之後在開發板執行
qt_sample -qws
//------------------------------------------------------------------------------
編譯DirectFB範例1
/opt/STM/STLinux-2.3/devkit/sh4/bin/sh4-linux-gcc db.c -I../directfb10/include -ldirectfb -L.
記得放libdirectfb.so在目錄
#include <directfb.h>
static IDirectFB *dfb = NULL;
//primary為dfb主要Surface
static IDirectFBSurface *primary = NULL;
int main(int argc, char **argv)
{
//定義表面描述dsc
DFBSurfaceDescription dsc;
//定義圖片資訊提供容器provider
IDirectFBImageProvider *provider;
//初始化
DirectFBInit( &argc, &argv );
DirectFBCreate( &dfb );
dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN );
dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY;
//建立primary
dfb->CreateSurface( dfb, &dsc, &primary );
//建立一個provider收集1.jpg圖片資訊
dfb->CreateImageProvider( dfb, "./1.jpg", &provider );
//把provider渲染給到primary
provider->RenderTo(provider, primary, NULL);
provider->Release( provider );
sleep (5);
primary->Release( primary );
dfb->Release( dfb );
return 0; } 編譯DirectFB範例2
#include <directfb.h>
#include <stdio.h>
static IDirectFB *dfb = NULL;
//primary畫滿screen
static IDirectFBSurface *primary = NULL;
//把logo畫在priary上
static IDirectFBSurface *logo = NULL;
static int screen_width = 0;
static int screen_height = 0;
int main(int argc, char **argv)
{
DFBSurfaceDescription dsc;
//IDirectFBImageProvider收集圖片資訊,並將圖片提供給IDirectFBSurface
IDirectFBImageProvider *provider;
//初始化DirectFB
DirectFBInit(&argc, &argv);
DirectFBCreate(&dfb);
dfb->SetCooperativeLevel(dfb, DFSCL_FULLSCREEN);
//定義表面描述
dsc.flags = DSDESC_CAPS;
dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
//利用表面描述(dsc)來創建一個表面(primary)
dfb->CreateSurface(dfb, &dsc, &primary);
//取得screen大小
primary->GetSize(primary, &screen_width, &screen_height);
//建立一個IDirectFBImageProviderg收集1.jpg圖片資訊
dfb->CreateImageProvider(dfb, "./1.jpg", &provider);
provider->GetSurfaceDescription(provider, &dsc);
//利用表面描述(dsc)來創建一個表面(logo)
dfb->CreateSurface(dfb, &dsc, &logo);
//把IDirectFBImageProvider(provider)渲染給IDirectFBSurface(logo)
provider->RenderTo(provider, logo, NULL);
//釋放不需要的provider
provider->Release(provider);
primary->FillRectangle(primary, 0, 0, screen_width - 1, screen_height - 1);
//把logo秀在primary上
primary->Blit(primary, logo, NULL, 0, 0);
primary->Flip(primary, NULL, DSFLIP_WAITFORSYNC);
//while(1){}
logo->Release(logo);
primary->Release(primary);
dfb->Release(dfb);
return 0;
}
#-------------------------------------------------------------------------
LIRC commands
begin remote
name fdremote1
bits 16
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 8957 4477
one 550 1695
zero 550 565
ptrail 551
repeat 8958 2231
pre_data_bits 16
pre_data 0xCE94
gap 107359
toggle_bit_mask 0x0
begin codes
mute 0x40BF
power 0xB847
home 0x7887
red 0x1AE5
blue 0x02FD
volUp 0x906F
volDown 0x807F
chUp 0x10EF
chDown 0x50AF
up 0x8679
down 0x46B9
left 0xC639
right 0x26D9
play 0xD02F
green 0x00FF
yellow 0xC03F
D1 0x708F
D2 0xF00F
D3 0x30CF
D4 0x48B7
D5 0xC837
D6 0x08F7
D7 0x6897
D8 0xE817
D9 0x28D7
D0 0xD827
asterisk 0x12ED
number 0x8877
info 0x22DD
search 0x06F9
favor 0x9867
backspace 0xA857
lang 0xB04F
input 0x0AF5
trigger 0x32CD
end codes
end remote
//------------------------------------------------------------------------------
編譯kernel(記得要先打好補丁且uboot要先編譯出mkimage)
export PATH=$PATH:/opt/STM/STLinux-2.3/devkit/sh4/bin
make distclean
rm vmlinux.bin.gz
rm vmlinux.ub
make ARCH=sh CROSS_COMPILE=sh4-linux- pdk7105se_defconfig
make ARCH=sh CROSS_COMPILE=sh4-linux- menuconfig
make -j4 ARCH=sh CROSS_COMPILE=sh4-linux- vmlinux
sh4-linux-objcopy -O binary vmlinux vmlinux.bin
gzip --best --force vmlinux.bin
./mkimage -A sh -O linux -T kernel -C gzip -a 0x80800000 -e 0x80801000 -n "Linux 2.6" -d vmlinux.bin.gz vmlinux.ub
(-a ==> set load address to addr, -e ==> set entry point to 'ep')
架好TFTP
setenv ipaddr 192.168.1.116
setenv serverip 192.168.1.100
seveenv
tftp 80000000 vmlinux.ub
bootm
您好,我在安裝好 STLinux 2.3 on debian 之後
回覆刪除修改完 ~/.bashrc 結果........
root 權限登入後~幾乎都沒有指令可以用了...........