Search Google

Sunday, June 25, 2006

讓 Cygwin 顯示中文

讓 Cygwin 顯示中文

vi ~/.inputrc

取消註解以下幾行:

set meta-flag on
set convert-meta off
set input-meta on
set output-meta on

vi ~/.bashrc

加入以下資料:

alias ls='ls -hF --show-control-chars --color=tty'

Friday, June 09, 2006

尋找支援Linux的AD資料擷取卡

產品簡介:
http://www.adlinktech.com/PD/web/PD_detail.php?cKind=FN&pid=390&seq=3&id=3&sid=19

data sheet之一:
http://www.adlinktech.com/PD/marketing/Datasheet/D2K-DASK+X/D2K-DASK+X_Datasheet_1.pdf
single-point digital input,single-point digital output,各有幾個channel?

Thursday, June 08, 2006

原來samba可以設定remote user...

今天在設定vmware上linux的samba時就是一直無法把資料夾mount起來~
搞了很久,確定sampasswd過,甚至連security都設成share了還是失敗
最後在無意間看到smbpasswd可以加上"-U"參數創造remote user,想說
姑且一試~沒想到就這麼將資料夾成功的mount起來了!!!

bye bye vmware!

想要用vmware player卻不知到怎麼樣create image的人可以參考一下下面這個link
的第21篇回文 http://www.hackaday.com/entry/1234000153064739/
重點節錄:
You can use QEMU-img.exe to create VMDK(VMare virtual disk files meaning you
don't need to download the browser image. Also I think this will create files
that can be used as ide drives.
結論:
有了QEMU + vmware player就可以不花錢使用user friendly的virtual machine。
補充:
QEMU也有gui介面了。。。 http://www.davereyn.co.uk/download.htm

為了預防網站掛掉,自己手動copy一份:
21. Posted Oct 25, 2005, 2:04 AM ET by Rhys
Hey, Incase you don't read slashdot? You can use QEMU-img.exe to create
VMDK(VMare virtual disk files meaning you don't need to download the browser
image. Also I think this will create files that can be used as ide drives.
Quick and easy:
1 Download the the vmplayer
2. create a vmdk disk file like this:
qemu-img.exe create -f vmdk
3.Create a vmx config file. Here are the basic options you need:
config.version = "8"
virtualHW.version = "3"
memsize = "128"
ide0:0.present = "TRUE"
ide0:0.fileName = "DiskFile.vmdk"

-------TO BOOT AN ISO----------
ide1:0.present = "TRUE"
ide1:0.fileName = "c:\debian.iso"
ide1:0.deviceType = "cdrom-image"
-----------------------------------
OR
-------TO BOOT CDROM-----------
ide1:0.present = "TRUE"
ide1:0.fileName = "auto detect"
ide1:0.deviceType = "cdrom-raw"
---------------------------------
floppy0.fileName = "A:"
ethernet0.present = "TRUE"
ethernet0.connectionType = "nat"
usb.present = "TRUE"
sound.present = "TRUE"
sound.virtualDev = "es1371"
displayName = "Debian 1"
guestOS = "other24xlinux"
nvram = "debian1.nvram"
scsi0:0.redo = ""
ethernet0.addressType = "generated"
uuid.location = "56 4d f3 a5 03 8c cb b9-ed bb 8f 10 a3 de b0 10"
uuid.bios = "56 4d f3 a5 03 8c cb b9-ed bb 8f 10 a3 de b0 10"
ide1:0.autodetect = "TRUE"
ethernet0.generatedAddress = "00:0c:29:de:b0:10"
ethernet0.generatedAddressOffset = "0"
checkpoint.vmState = ""
tools.remindInstall = "TRUE"
ide0:0.redo = ""
Now just run up the vmx file in the player. Boot the cdrom/iso and install
the os as usual.

qemu-img convert
eg. qemu-img convert -f vmdk /path/filename.vmdk -O raw /path/filename.raw

MS的registry...

我一直以為registry的值改了就算數,今天試了之後發現改了居然沒有效果。
想說登出再登入應該就可以了?但是還是無效!
最後還是要靠重新開機~~~
但是也因此學到從command window下重開機。。。
"shutdown -r -t 1",一秒鐘之後重開機。如果要關機就把"-r"換成"-s"
為什麼需要從command window reboot呢?因為我不在實驗室裡 ^^
所以我從連人的機器透過ssh連到被連的機器來確定開機完畢。
話說我一直想要用不同的port來連遠端桌面,結果還是沒辦法work ><
首先我先把port從3389改成3390(被連的跟連人的都要改),然後將兩台機器都
重新開機。再來修改71.71上的iptables,把3390這個port從71.71轉到自己的ip。
當兩台機器都開完機的時候發現遠端桌面居然失敗了。。。
想試試看改port的人可以先用兩台實體ip的電腦玩玩看~希望可以成功,不然71.71
唯一的3389 port就這麼被我佔住,我會很不好意思。。。

使用不同的port連進MS遠端桌面

1. 將被連機器上的registry:
"hklm\system\currentcontrolset\control\terminal server winstatoins\rdp-tcp"中的PortNumber改成自己想要的port
eg. 3390
2. 重開機
3. 使用實體ip的人可以跳過這一步。
到71.71上修改/etc/iptables & /etc/iptables.sh
前者是正規的設定檔,後者是hanhan or frog 為了方便寫出來的script
修改完之後執行/etc/iptables.sh (需要su access)
4. 使用client機器在連線遠端桌面時在ip後面加上:即可
eg. 140.114.71.71:3390
5. 上一篇說server & client都要改port數是錯誤的。。。
改server的port就ok

Implementation of Real Time Power Saving Scheme for Embedded Device(s)

這本log book實際上是從2005年十月開始寫的,當時想為嵌入是即時系統實做一個省電的scheduler,中間也拉哩拉雜的做了其他事情,所以拖了一陣子。 適逢嵌入是軟體聯盟舉辦了一場軟體競賽,於是在老闆的”督促”下參加了這個比賽,希望可以藉由參加比賽加快作品完成的速度。當初填寫只為了防止自己忘記一 些想法,因此記錄的非常隨性堪稱凌亂,現在會放到網頁上也只是看中了google的storage center”應該”是個頗可靠的資料存放地點,因此也不太想再多加修改。。。

Implementation of Real Time Power Saving Scheme for Embedded Device(s)

Survey the following items:

Real-Time Kernel

Refer to http://www-128.ibm.com/developerworks/cn/linux/embed/l-realtime/, RTAI is the candidate most likely to be used to implement our research topic on DVS+I/O+RT-Kernel.

I/C switch component & inverter selection

Circuit's layout provided by Microtimes

The available GPIO pins are:

J16 aka. CMOS SENSOR/SPI – next to the ethernet socket. The available pins are pin17~22 (don't program these pins to SPI). The memory mapped

J14 aka. con20 – next to the LCD/TOUCH SCREEN socket. Pin1~7 are available if they aren't programmed to function Analog to Digital conversion.

The map between these pins and memory addresses is provided as follows:

SPIMISO0 --> GPE11

SPIMISO1 --> GPG5

SPIMOSI0 --> GPE12

SPIMOSI1 --> GPG6

SPICLK0 --> GPE13

SPICLK1 --> GPG7

AIN1 -->

AIN2 -->

AIN3 -->

AIN4 -->

AIN5 -->

AIN6 -->

AIN7 -->

========== 6th Oct 2005 ==========

In s3c2410.h:

GPECON is defined as a macro, rGPECON.

GPE13 [27:26] --> 01 (configure SPICLK0 to Output)

GPE12 [25:24] --> 01 (configure SPIMOSI0 to Output)

GPE11 [23:22] --> 01 (configure SPIMISO0 to Output)

GPEDAT is defined as a macro, rGPEDAT

GPGCON is defined as a macro, rGPGCON

GPG7 [15:14] --> 01 (configure SPICLK1 to Output)

GPG6 [13:12] --> 01 (configure SPIMOSI1 to Output)

GPG5 [11:10] --> 01 (configure SPIMISO1 to Output)

GPGDAT is defined as a macro, rGPGDAT

Install Domingo, but prefer to try out the experiment with Trace32. Ask Hogan about Trace32 tomorrow.

========== 17th Oct 2005 ==========

l Cannot get Trace32 to work with Creator-s3c410, thus move on to plan B – install Domingo on the PC dedicated for experiments. [done]

l The kernel and file-system images provided by Microtime works all right, but I encounter a problem that kernel debugging with ram-boot doesn't work as described in the tutorial. [done]

l Need to find another NIC for my NB so creator can load kernel module dynamically via a crossed LAN cable. [done]

l The macros (rGPECON, rGPEDAT, rGPEUP, rGPGCON, rGPGDAT, rGPGUP) defined in s3c2410.h cannot be accessed directly in Linux kernel, kernel hangs if we access them by force. Need to try whether mmap() works as well as keep trying out the address listed in s3c2410 datasheet. [under investigation]

l Two major tasks to do:

1. Gain control of the GPIO we need. [todo]

1.1. Try to use the macros defined in linux/include/asm/io.h

2. Look into the example LCD device driver and see if I can shot it down, reinitialize it, and make it to work properly as it was. [todo]

l “make modules_install” incurs building errors... got some files short, reported this problem back to Microtime. [done]

========== 24th Oct 2005 ==========

l Start tracing Linux code (from start_kernel).

1. Macros defined in s3c2410.h is first used in s3c2410_gettimeoffset() <-- setup_timer() <-- time_init() <-- start_kernel(), can we use macros straight forward like this after memory is initialized ? [should be OK, lots of direct GPIO ops are found in module code]

2. Traced routines are kept in ~/research/ext3/logs/ConfigStopGPIO().mm

l Problem 1: Recalculate symbol failure:

Solutions –

1. Use hard copied files, and hard copies only, symbolic links simply won't work!

2. Put everything to the exact path (/usr/src/creator/)! E.g. /usr/src/creator/nfs/... ; /usr/src/creator/s3c2410/...

3. Use the src come with the CD I got today from Microtime and follow the step 1 to 6 marked in Chap3 in the book 05714-007.

l Problem 2: make modules_install failure

Error msg:

Can't open /lib/modules/2.4.18-rmk7-swl8/modules.dep for writing

make: *** [_modinst_post] Error 25

Solutions –

1. No harm is done by this error, just ignore it.

l Problem 3: Lack of creator-s3c2410-cmos.o

Solutions –

1. This obj file is included in the CD came along with the book 05714-007, we have to manually copy the file to .../nfs/ or whichever folder we prefer.

l We can create a new filesystem to replace ext2_2418_Creator2410 and hold all the modules or even build the modules into kernel so we don't need to setup a network connection between Linux host and Linux target.

l Use cross-over LAN cable to reduce the change for bad things to happen throughout the debugging process.

l The basic setup should be like:

Linux host <– LAN –> Windows host <– JTAG –> Linux target

========== 31st Oct 2005 ==========

l Problem 1: Loading symbol table, vmlinux, seems to disturb the system.

Observation –

The console responses from different loading combinations:

1. Load kernel (zImage) and filesystem (ext2_2418_Creator2410) individually with debug->load module –> Console commands work smoothly.

2. Flash filesystem into NAND flash memory and load kernel with debug->load module. All OS features are disabled/unchecked –> Booting is quickly done. Console seems to work all right, but the keyboard inputs are experiencing serious lag. For instance, I have to tap on backspace key for 14 times to get 'ls' parsed and console to print out content of current folder (it's the root folder in my case).

3. Flash filesystem into NAND flash memory and load kernel with debug->load module. One of the OS features, auto attach tasks, is enabled/checked –> Booting process slows down after message, “INIT: version 2.78 booting”, appears on console. printk() doesn't function as smoothly in 2nd observation (don't even mention the 1st observation).

4. Flash filesystem into NAND flash memory and load kernel with debug->load module. Both OS features, auto attach tasks and dynamic loaded module, are enabled/checked –> Booting process halts after message, “INIT: version 2.78 booting”, appears on console and looking for the following object files:

1. cs8900a

The console behaves similar to 3rd observation after the system finishes booting, sometimes Domingo doesn't seem to know where to locate 'ls'...

5. Flash filesystem into NAND flash memory and load kernel with debug->load module. All OS features are disabled/unchecked. Didn't load line number nor symbol –> We have the performance that we observed in the 1st observation.

Explanation –

For the system to support kernel debugging, certain functions introduced to the system might fire excessive interrupts, which causes the disturbance. Let's see how things go after trying out loading APM module dynamically.

Response from microtime

Give it more time to finish booting. (This actually works...)

l Problem 2: Cannot load creator-s3c2410-lcd.o

Solution

IRQ_TIMER1 is occupied by Linux, so we have to change LCD to use IRQ_TIMER2.

[TODO] – Case 1:

1. Initial GPIO pins in either sched_init() or time_init().

2. Modify timer_bh() to trigger certain GPIO pins and use oscilloscope to see whether the pins behave as expected.

Experiments' logs –

1. GPECON and GPGCON are initially set to 0xaaaaaaaa & 0xff95ffba by default. These two registers are changed to 0xa54aaaaa & 0xff9554ba accordingly after setting GPE[13..11] and GPG[7..5] to “Output” respectively. [Just an illusion!!!] Only the variable get changed. Also, instead of editing sched_init() or time_init(), the change should be made in function Port_Init() in linux/include/asm-arm/arch-creator-s3c2410/uncompress.h

2. Set GPE[13..11] and GPG[7..5]'s default to “logic-low” --> “0”. Turns out only JP11[17, 19, 21] (GPEDAT[11..13]) behave accordingly (the observed peak-to-peak voltage is approximately 3.3V). JP11[18, 20] (GPGDAT[5, 6]) & JP11[22] (GPGDAT[7]) stay at high and low forever respectively. It doesn't matter whether rGPxDAT is assigned a value in do_timer() or timer_bh().

Results –

We have only three GPIO (GPE[13..11]) to control the circuit externally by force. Need to find certain IC switch that can be trigger by such low voltage and is capable of holding large power when it keeps the circuit open. [Task is created on 7th Nov 2005][put to on hold list on 16th Nov 2005]

The reason GPGCON[7..5] didn't seem to be changeable is its initial setting is overwritten by a later invoked initial function, HW_kbd_init(). Thus, by modifying HW_kbd_init() both GPECON[13..11] and GPGCON[7..5] are now set to Output. [Problem solved on 10th Nov 2005]

Follow up –

Goto electronic shop and ask for “IC-245”...

Need to buy some relays/switches and voltage amplifiers.

[TODO] – Case 2:

1. Boot the system without any debugging support and load APM module dynamically with 'insmod'.

2. Go through APM module once again and participate the outcome of having such module loaded.

Experiments' logs –

1. 'insmod' and 'rmmod' work all right regardless the system run with or without debugging support. All three modules, lcd, cmos, and codec now can be successfully loaded into and unloaded from the system.

2. Still looking for the module for APM... [Issue brought up on 7th Nov 2005] But there is no such option of power management in 'make menuconfig'. Therefore, look for the registers used to control peripherals becomes an essential task to do. [Task created on 8th Nov 2005]

========== 7th Nov 2005 ==========


Two major issues to think about:

1. How much time would the computation take? How do we overcome the inaccuracy introduced by this computation delay?

2. What's the power-up and shut-down latencies for each I/O device we are going to use?

Discussion –

We can consider and convert these two overheads into a task's execution time, the system would work as long as the utilization is less than 1.

[TODO] – Case 1: [done]

1. Write down all the registers that have anything to do with peripherals controlling and find out where are they set in source.

Logs –

CPU related (registers should be configured in the following order):

  • MPLLCON[19..12], MDIV
  • MPLLCON[9..4], PDIV
  • MPLLCON[1..0], SDIV
  • ----------------------------------------
  • CLKDIVN[1], HDIVN
  • CLKDIVN[0], PDIVN
  • ----------------------------------------
  • CLKCON[3], POWER-OFF
  • ----------------------------------------
  • CLKSLOW[5], MPLL_OFF
  • CLKSLOW[4], SLOW_BIT
  • CLKSLOW[2..0], SLOW_VAL
  • ----------------------------------------
  • LOCKTIME[11..0], M_LTIME

LCD related:

  • CLKCON[5], LCDC
  • ----------------------------------------
  • LCDCON1[0], ENVID
  • ----------------------------------------
  • LCDCON5[3], PWREN

USB related:

  • LOCKTIME[23..12], U_LTIME
  • ----------------------------------------
  • UPLLCON[19..12], MDIV
  • UPLLCON[9..4], PDIV
  • UPLLCON[1..0], SDIV
  • ----------------------------------------
  • CLKCON[7], USB device
  • CLKCON[6], USB host
  • CLKSLOW[7], UCLK_ON
  • ----------------------------------------
  • PWR_REG[0], SUSPEND_EN

[TODO] – Case 2: [in progress]

1. Manage power dissipation by controlling the registers listed in case 1.

Logs –

MPLLCON and CLKDIVN can be updated with ChangeMPllValue() and ChangeClockDivider() respectively, need to find in which file these functions are exported. As a result, both of these functions are not exported at all. Thus I create an additional header file namely custom-fcn.h in linux/include/linux to export these functions and any others might become handy in later development. For rest of the registers listed case1, they are not modified or even referenced in Linux source code. I presume can either use them freely.

Creating [TODO] – Case 3.

[TODO] – Case 3: [done]

1. Try to open LCD device in init_module_drv_lcdtxt().

Logs –

The LCD controller on Creator board is HD66750; its data sheet can be found at http://gaw.ru/pdf/lcd/Chips/Hitachi/hd66750.pdf

I am using this monochrome on-board LCD to exercise manipulating Linux drivers for now, I will eventually switch to the 2.8” colored LCD.

LCD has been initialized in init_module_drv_lcdtxt(), I only need to write some characters with LCD_putchar(). Now I can test whether we need to reinitialize LCD hardware under the following circumstances:

  1. Stop feeding clock to LCD, and resume clock feeding later some time.
  2. Cut of LCD power, and continue supplying power to LCD after a period of time.

I am going to take advantage of the Fixed-Mapped linear address to prevent using additional global variables to monitor whether the LCD is powered on for the first time.

Creating [TODO] – Case 5.

[TODO] – Case 4: [on hold]

1. Purchase 74LS125 chip and test it with the 4V signal generate from GPIO along with DC power supply.

Logs –

On hold...

========== 14th Nov 2005 ==========


[TODO] – Case 5:

1. Initialize LCD hardware in init_module_drv_lcdtxt() for the first execution of insmod, and stop clock feeding and cut off power supply in cleanup_module_drv_lcdtxt(). Observe the change of hardware status closely.

Logs –

To distinguish the first execution of “insmod”, kernel must keeps a counter in global space in keeping track of the behaves of insmod. Hence, there are two things need to be done before I can keep working on this TODO case:

  1. Setup NFS so I can grant s3c2410 development board the access to lcd module without flashing Flash memory whenever I modify the module.
  • Solution

1. Do “dpkg-reconfigure portmap” and enable RPC from other computers or make sure /etc/default/portmap is empty.

2. Put the path of sharing folder into /etc/exports, and append the client's IP and access right.

3. Make sure the client has NFS suport compiled into kernel.

4. Enter the following command into client's console:

1. portmap&

2. mount 192.168.1.10:/usr/src/creator/nfs /mnt

  1. Figure out how to share variables and even functions between kernel and drivers.
  • Findings

1. Use EXPORT_SYMBOL(), but this approach will lead to a unstructured and mess coding style once we are controlling large amount of peripheral. (The major reason for not using this approach is that it doesn't seem to work.)

2. Use system call to get and set variables even data structures kept by kernel. Because the syscalls must be compiled into the core kernel image inall configurations, I will put it in kernel/ksyms.c.

3. You can also export a variable by using:

EXPORT_SYMBOL(variable_name); or

EXPORT_SYMBOL_NOVERS(variable_name);

in the file where it is defined (or anywhere this variable is accessible). Besides, you need to use -DEXPORT_SYMTAB flag for the file where you use EXPORT_SYMBOL macro. All this is inside kernel.

Then you can just declare the variable in your module code and use it.

It should be visible there.

Simply doing “insmod” and “rmmod” doesn't make any change in power dissipation. I then tried to stop feeding clock oscillator to monochrome LCD and see how it goes, it turns out ?! I lowered the operating clock frequency to 32-divided clock and let the LCD to have small amount of fixed current in the operational amplifier, and all these save about 0.2mA of total power consumption as a result.

Now I need to create a new module to control cpu operational voltage and see how much current save each combination can achieve.

Creating [TODO] – Case 6.


[TODO] – Case 6:

  1. Create a new module to change ARM's working voltage.

Logs –

Modify linux/driver/char/Config.in to insert a new entry for our cpu voltage modifying module (creator-s3c2410-cpu.o). I have successfully changed ARM's working frequency and confirmed the frequency is changed according to the value I set in the module by observing the signal on oscilliscope, but the system also turned into chaos (reboot the system is inevitable); need to work on this. Modifying either MPLLCON or CLKSLOW lead to an unstable system (hangs). [insert on 22th Nov 2005] The system is still fully functional after change in frequency takes place (observing the scope), the only problem is that UART's baud rate is changed due to changing MPLLCON also changes all the peripherals' working frequency. This leads to a conclusion that we must reset all peripherals' working frequency upon each change in MPLLCON. I add and insert the following files to the Linux source tree:

  1. /driver/char/creator-s3c2410-cpu.c
  2. 274:/driver/char/Makefile
  3. 355:/driver/char/.depend

========== 21h Nov 2005 ==========

[TODO] – Case 7:

  1. Having RTAI lecture.

Logs –

I am in a very serious trouble now... that's RTAI's patch only supports arm—pxa255, s3c2410 is not in the support list. I can control ARM's working frequency in runtime via inserting and removing kernel modules on both pxa255 and s3c2410, the only compensation is the trade off between ease of taking power/current measurement and integrating a real time scheduler into Linux. RTAI is a ready solution on pxa255, however, I must come up with a power/current measurement scheme for pxa255. On the other hand, on Microtimes's s3c2410 I can take measurements from the reserved jumpers. In addition, I have no chance to discuss the multicore issues if pxa255 becomes my implementation platform.

[TODO] – Case 8:

  1. Try out gprof for profiling the amount of time spent on each code segment.

Logs –

I can wrap up the I/O accesses with a function, so gprof can profile the amount of time spent on both CPU and IO bound operations. Take a look at the example in ~/research/ext3/timing_profil.

========== 28h Nov 2005 ==========


[TODO] – Case 9:

  1. Try out the power management and control on Xscale.

Logs –

Xscale supports the following peripherals:

  • LCD – enable/disable, mono/colored
  • SSP (Synchronized serial port) – enable/disable
  • I2C – bus, must always be on... ?!
  • UART – same as SSP ?
  • IR (Fast Infrared) – enable/disable, full/half-duplex
  • USB – support self-powered devices only
  • AC97 codec – low power mode or power off
  • I2S – direct access to memory
  • MMC (Multimedia card controller) – start/stop clock
  • NSSP (Network SSP) – enable/disable, start/stop clock

[Thought – 1]:

Implement COLORS will hopefully prove that the system is able to save same amount or even more energy without going through the cumbersome power profiling process, such a process is most likely target dependent (you have to know how much energy each instruction/function consumes) while COLORS itself is a universal solution to the problem.

[Thought – 2]:

The implementation I am doing will not compromise quality for reducing a system's power consumption. This makes my work different from any of the existing ones.

[TODO] – Case 10:

  1. Get RTAI running on PCM7230

Logs –

Contact Mike , Microtime, and Advantech for the Linux patch for ARM (PXA255 and ARM920T). Yet haven't received response from Mike and Microtime; Advantech supports PCM7230 only with Linux-2.4.19 without RTAI at the moment.

[Nov 30, 2005]

Mike sent both patch files to me today, and I use the cross-compiler available at <http://www.gtlib.gatech.edu/pub/handhelds.org/projects/toolchain/> to build kernel-2.6.7 with RTAI patch for pxa255 and encountered the 'static declaration of blah follows non-static declaration' error. Here is the solution found in RTAI mailing-list:

From h.mayer@inode.at Wed Jul 13 17:51:14 2005

From: h.mayer@inode.at (Hannes Mayer)

Date: Wed, 13 Jul 2005 18:51:14 +0200

Subject: Fedora Core 4 compile problems (maybe a gcc 4.0.0 thing)

Message-ID: <42d54682.6030003@inode.at>

Ignacio García Pérez wrote:

> Hi,

>

> Today I switched from FC3 to FC4 and found a nasty compile problem in

> RTAI-3.2. Got the bleeding edge magma source from cvs and tried, to no

> avail.

>

> /home/iggarpe/newroot/temp/magma/base/ipc/netrpc/netrpc.c:981: error:

> static declaration of ‘errno’ follows non-static declaration

> include/linux/unistd.h:4: error: previous declaration of ‘errno’ was here

>

I tried compiling 3.2 with GCC4.0 a while ago. Basically there are just a few

minor problems - I've written down some notes (no guarantee for completeness):

kernel:

******

base/config/kconfig/mconf.c:91

static struct menu *current_menu; -> struct menu *current_menu;

base/ipc/netrpc/netrpc.c:981

static int errno; -> int errno;

base/sched/sched.c:53

static int errno; -> int errno;

RTAI:

*****

# grep -R TASK_ZOMBIE *

base/sched/sched.c: lnxtsk->state = TASK_ZOMBIE;

change TASK_ZOMBIE to EXIT_ZOMBIE

Please let us know if that's everything and if it worked.

Best regards,

Hannes.

In short, simply remove the keyword, static.

Another error is “cc1: error: invalid option 'short-load-bytes'”

From: Wouter van Heyst

· To: crossgcc at sources dot redhat dot com

· Date: Mon, 17 May 2004 10:51:13 +0200

· Subject: Re: How to enable "short-load-bytes" feature of the arm-linux-gcc 3.4

· References: <003001c43bab$836cf9a0$27050a0a@jadechip.net> <40A80B58.4080500@kegel.com> <00eb01c43bb3$aef62c10$27050a0a@jadechip.net>

[3] [4] On Mon, May 17, 2004 at 10:07:11AM +0800, Pwu wrote:

> Oh, The original arm-linux-gcc's version is 2.95.3 which I get from the arm-linux.org.

>

> Thank you for your information. So should I change the kernel compile option from "-mshort-load-bytes" to "-malignment-traps"?

Yes.

Wouter van Heyst

Vidicode Datacommunicatie BV

Then the following problem:

========== My console output ==========

cyu021@debian:/usr/src/linux-2.6.7-bk6-karo-rtai$ make ARCH=arm CROSS_COMPILE=arm-linux- bzImage

make[1]: `arch/arm/kernel/asm-offsets.s' is up to date.

make[1]: `include/asm-arm/mach-types.h' is up to date.

CHK include/linux/compile.h

CC kernel/adeos.o

kernel/adeos.c:565: error: invalid lvalue in unary `&'

kernel/adeos.c:565: error: initializer element is not constant

kernel/adeos.c:565: error: (near initialization for `__ksymtab_1.value')

kernel/adeos.c:565: error: __ksymtab_1 causes a section type conflict

make[1]: *** [kernel/adeos.o] Error 1

make: *** [kernel] Error 2

========== My console output ==========

Line 565 in kernel/adeos.c looks like this:
EXPORT_SYMBOL(adp_pipelined);

and in include/asm-arm/adeos.h we have
#ifdef CONFIG_ADEOS_MODULE
extern int adp_pipelined;
#else /* !CONFIG_ADEOS_MODULE */
#define adp_pipelined 1 /* Testing this should be optimized out. */
#endif /* CONFIG_ADEOS_MODULE */

Looks like you have configured Adeos directly into the kernel (instead
as a module) but it seem that this is not supported by the pxa port (it
was not done by myself, so I don't know a lot about it).
So either change kernel/adeos.c to look like

#ifdef CONFIG_ADEOS_MODULE
EXPORT_SYMBOL(adp_pipelined);
#endif

(no guarantee that this will not break other stuff, you have to try) or
re-configure your kernel so that CONFIG_ADEOS_MODULE is set
(recommended).


Another problem:

I download the fresh zImage to PCM7230's memory and run _bootmem_, the booting sequence stuck at _Umcompressing linux kernel....._.

May take some time to fine tune the menuconfig and see if the combination works.

========== 5h Dec 2005 ==========

[TODO] – Case 10: (Continued)

Logs –

[7th Dec 2005]

Traced into function _ulg decompress_kernel()_ and found _puts("Uncompressing Linux......");_, the system seems to hang right after the code returns from gunzip() and before _puts(" done, booting the kernel.\n");_. I still haven't figured out the cause of this disaster...

The memory map between karo and pcm7230 might be different, check this out with Advantech's engineer. Try to look into any code difference with Kdiff3 before hear anything from Advantech.

[8th Dec 2005]

The defined labels specifically for Karo board in kernel-2.6.7-bk6-karo-rtai and other interesting defines are:

CONFIG_ARCH_KARO

CONFIG_KARO_AUTOCNF

CONFIG_KARO_PWR_CHG

CONFIG_KARO_DS2430

CONFIG_KARO_DS2430_EXT

CONFIG_KARO_LCD

CONFIG_KARO_LCD_640_480

CONFIG_KARO_SMC32

CONFIG_CPU_ABRT_EV5T

CONFIG_CPU_TLB_V4WBI

CONFIG_CPU_MINICACHE

CONFIG_CMDLINE="init=/linuxrc root=1f01 rootfstype=jffs2 ro console=/dev/ttyS0,115200"

CONFIG_MTD_KAR

CONFIG_BLK_DEV_RAM_SIZE=8192

CONFIG_ADEOS

CONFIG_ADEOS_CORE

CONFIG_ADEOS_THREADS


Some interesting defined labels found in Advantech 2.4.19's .config file:

CONFIG_ARCH_PXA_CERF

CONFIG_PXA_CERF

CONFIG_PXA_CERF_BOARD

CONFIG_PXA_CERF_RAM_64MB

CONFIG_PXA_CERF_FLASH_32MB

CONFIG_PXA_USB

CONFIG_PXA_USB_NETLINK

CONFIG_CMDLINE="root=/dev/ram0"

CONFIG_MTD_PXA_CERF

CONFIG_BLK_DEV_RAM_SIZE=16384

該試試看用研華的2.4.19+kilauea patch (patch-2.4.19-rmk-pxa-arm-rtha15) ?

Not working either, the patch doesn't match to Advantech's src.

對照.config & arch/arm/boot/compressed/head.S看看開機哪裡出了錯!

... on hold!

========== 12h Dec 2005 ==========

[TODO] – Case 11:

  1. Measure PreSOC board's power consumption at CPU full speed + all I/O on, CPU half speed + LCD at low state, CPU half speed + LCD & USB at low state.

Logs –

Can't measure any meaningful current readings.

FULL SPEED:

Period: 10ms (time period between two consecutive do_timer())

Change to SLOW MODE:

[SLOW_VAL: 000] Period: 113ms ~ 169ms

[SLOW_VAL: 001] Period: 226ms ~ 339ms

[SLOW_VAL: 010] Period: 452ms ~ 678ms

[SLOW_VAL: 011] Period: 1015ms ~ 1030ms

[SLOW_VAL: 100] Period: 1260ms ~ 1350ms

[SLOW_VAL: 101] Period: 1690ms ~ 1700ms

[SLOW_VAL: 110] Period: 2030ms ~ 2260ms

[SLOW_VAL: 111] Period: ~ 2370ms

[TODO] – Case 12:

  1. Find a way to measure the total power consumption.
  2. Make sure ARM920T can do DVS.
  3. Take current measurement on each DVS level.
  4. Find all DPM-able I/O devices.


Logs –

  1. Yet cannot be done.
  1. All operating mode and frequency give same current consumption
  2. same as (2)
  3. LCDs and USB have power management register, ARM920T disables other devices by stop feeding them clock signal.

========== 19h Dec 2005 ==========

[TODO] – Case 13:

打電話問中山大學在用Creator的同學(陳良弼,林麒弘,黃文凱)問問題 (07-525-4337)

  1. CPU的電流消耗量為什麼不會因改變速度/執行模式而改變?
  2. CPU只消耗1.4 mA左右的電流正常嗎?
  3. 確認Creator板子上能開關(或是已經成功開關)I/O device

Logs –

中山大學的人並沒有調整過ARM的工作頻率。

PreSOC上的量測點(TP1 & TP2)是給ARM7用的,新華已經幫我們在S3C2410上面新增了量測ARM9內部電流的量測點。用新的板子所量到的數據為:

Normal mode全速:140mA

Normal mode半速:77mA

Slow mode 全速:12mA

[TODO] – Case 14:

量測PreSOC上能量到的電流。

Logs –

file system燒入flash後無法開機,產生下列錯誤訊息:

RAMDISK: Couldn't find valid RAM disk image starting at 0.

目前是將vmlinux & file system在執行前先downloadmemory中,這樣可以正常讓Linux運作,問題交由新華處理中。

進行以下測量:

  1. ARM的核心頻率由56MHz調升至202MHz,測量總電流
  2. ARM的核心頻率由56MHz調升至202MHz,測量CPU電流

[TODO] – Case 15:

測量/估計device wakeup/shutdown latency

Logs –

尋找測量/估計的方法。

TFT-LCD:

TFT-LCD(TD035STEB1)data sheet中得知該LCDVCC5導通之後需要約40ms~120msdelay螢幕才能顯示畫面。(詢問統寶, toppoly ,)

UART:

MAX3232data sheet中得知我們所使用的UARTpower up到可以傳輸資料的時間大約為210us~220us

USB:

不做USB

Camera:

詢問宜霖, ElecVision,中。

Ethernet (CS8900A-CQ3):

尋找從standby/suspend modes切回normal mode的時間。

CS8900Asuspend/standby mode回復到mornal mode的時候會自行resetconfigure,與calibrate。通常需要10ms完成reset calibration

[TODO] – Case 16:

Trace新華提供的CCD & TFT-LCD demo code並且找出如何initialize CCD & TFT-LCD以及如何擷取/寫入資料。

並看看Linux driver是如何初始網路卡的。

看看將UART & USB斷電後事否需要重新初始。

Logs –

CCD initialization:

重點在GoCCM,直接呼叫CaptureImage_CCM()即可抓到當下鏡頭照到的畫面。再利用ColorInterpolate轉換資料格式並copypbyBmpBuffer中讓之後的程式可以將畫面outputLCD上。(關鍵部份被包在library, s3c2410_gnu_2953.a,)

TFT-LCD data feeding:

Lcd開頭的function都是給TFT-LCD使用的function,例如Lcd_Port_InitLcd_Init(),等等。主要是透過Lcd_Palette8Bit_Init()PutPixel()來初始LCD色盤及填色。(關鍵部份被包在library, s3c2410_gnu_2953.a,)

linux kernel驅動CS8900A-CQ3:

UART:

待測

Codec:

參考新華提供的linux demo,看他們如何使用codec driver in user application.

[TODO] – Case 17:

application

Logs –

大頭拍貼:需要用到CCD取景,TFT-LCD顯示,使用網路傳送照片,或是將照片儲存到USB flash drive --> 很多人排隊用1x/2x連拍。這樣整個過程將形成periodic job,在連拍的同時可以將TFT-LCDUSB,及網路卡關掉,或是切換到較不耗電模式。拍完之後在編輯相片(此時相片存在記憶體中)時只需要開啟TFT-LCD,而在傳送影像的時候只需要將USB或網路卡開啟。

櫃台人員:在人潮擁擠的時候收銀機/兌換代幣工作也會變成periodic job,掃描bar code,顯示金額,將資料回傳讓主機進行後續統計工作。

公路警察測速照相

警局犯人照相機

========== 26h Dec 2005 ==========

[TODO] – Case 18:

試著將新華提供的library, s3c2410_gnu_2953.a, include進自己寫的kernel module

Logs –

Trace Linux Makefile and see how linux uses lib.a in make modules.

Root Makefile (linux/Makefile) includes

- .config

- .depend

- arch/$(ARCH)/Makefile

- s3c2410_gnu_2953.a加入LIBS

- # Include CCM/CCD, TFT-LCD, and CODEC's function lib

- ifeq ($(CONFIG_CREATOR_S3C2410_CPU),y)

- LIBS := /usr/src/creator/examples/arm/lib/s3c2410_gnu_2953.a

- endif

- Rules.make

變更 include/linux/timex.h

- extern unsigned long volatile jiffies;

變更drivers/char/creator-s3c2410-cpu.c

- include

- include

變更 include/asm-arm/arch-creator-s3c2410/s3c2410.h

- #define IO_REG0

- #define CPLD_CTRL

注意 arch/arm/mach-creator-s3c2410/mm.c裡頭的map_desc

- 已經將VA_CREATOR_IO_BASE mapPA_CREATOR_IO_BASE了。

========== 2nd Jan 2006 ==========

[TODO] – Case 19:

Study COLORS並規劃如何將COLORS套到實際的應用上!

Logs –

Interrupt latency

Interrupt何時會發生

page fault 何時會發生 --> 無解

[TODO] – Case 20:

想辦法hack Linux,讓Linux可以達到我們需要的real-time需求。

我們需要:

  1. 使用Linux提供的drivers
  2. 一開機就執行我們設計的tasks,可以是userkernel process
  3. scheduler只會從我們所建立的task list中挑task來做,建立單純的periodic task environment
  4. 確保interrupt依照task的需要而被處理,並不是全部都處理
  5. 在執行task的時候不會產生page fault,以排除task exec time的不確定性

[QUESTION] – Case 1:

為什麼RED-Linux/kernel/timer.c#ifdef CONFIG_UTIME_TIMER_VECTORS#ifdef CONFIG_DSTREAM_KURT_PROFILE包住?

UTIME應該是獨立的個體,為什麼跟KURT有相依性?


2006 Feb-07

尋找設定interrupt controllercode

init_IRQ --> init_arch_irq (arch/arm/kernel/setup.cinit_arch_irq指向mdesc->init_irq)mdescmachine descriptor

mdesc則是在setup_architecture裏面指向__arch_info_beginmdesc structure裏面裝的質則是透過defineinclude/asm-arm/mach/arch.h中的MACHINE_START(_type,_name)寫入記憶體,MACHINE_STARTarch/arm/mach-s3c2410/arch.c中被執行到。

因此存在於mdesc中的3function pointer分別指向:

fixup --> fixup_s3c2410

map_io --> s3c2410_map_io

init_irq --> s3c2410_init_irq

所有的IRQs3c2410_init_irq中被disableds3c2410_init_irq也同時將mask/unmask function卦到irq_desc上。

s3c2410asm檔為armv版本,armo是給以前26-bit用的。

start_kernel開始一直到time_init的時候,所有的interrupt除了timer4以外都是disabled

console_init裡面只有con_init & uart_console_init會執行到。

在執行rest_init --> cpu_idle --> schedule之前,除了timer4以外的interrupt都為masked但是一旦執行完schedule,進入console之後又多了幾個interruptenabled,所以要深入schedule除了schedule tasks之外還額外做了什麼事情。

因為在rest_init呼叫cpu_idle(最後呼叫schedule結束start_kernel)之前process “init”已經先被create出來,所以一旦進入cpu_idle並呼叫schedule之後start_kernel會在執行完init(位於init/main.c --> static int init(void * unused),用cscope找的話是第57entry)之後結束(對使用者來說是進入console畫面)

init最後會呼叫execve --> sys_execve --> do_execve多次後才進入console

s3c2410_timer_interrupt中插入printkjiffies值列印在console上確認timer正常運作。

現在要搞清楚CLONE_xxx flags的意思,此外可能需要更改cpu_idle & schedule這兩個functions,才能讓電腦在兩個我們做出來的kernel threads之間切換。

在執行execve("/sbin/init",argv_init,envp_init);前插入下列的code來關閉除了timer4以外的interrupts

rINTMSK = 0xffffbfff;

rINTSUBMSK = 0x7ff;

rSRCPND = 0xffffffff;

rINTPND = 0xffffffff;

rSUBSRCPND = 0x7ff;

rEINTPND = 0x00fffff0;

printk("\nOnly timer4 interrupt is enabled, INTMSK = %x\n", rINTMSK);

2006 Feb-14

create兩個kernel threadsperiodic_01 and periodic_02,這兩個kernel threads都是在init呼叫execv之前所創造的,而且都正常執行,兩個threads目前只是單純的列印出訊息到console上。

接著在periodic_01 & periodic_02中加入多個printk並在其中穿插yield & schedule,執行的結果看起來也是正確的,兩個threadsprintk相互出現。

於是我將在schedule中試著選擇除了periodic_01 & periodic_02以外的threads執行,在create threads的時候我將"eos”寫入這兩個threadscomm field,所以判斷標準就是comm field不等於"eos”thread就被選為下一個執行的thread但是在實際執行過程中從”c = -1000”"switch_to”之間next thread被改過了,造成threads的執行順序與我逾期的不一樣。

release_kernel_lock的時候會呼叫__sti,所以timer interrupt又再度被打開,造成在schedule中又會呼叫schedule,這個部份先不理。

主要影響下一個該哪個thread執行的因素是goodness所回傳的值,所以我開始研究要如何修改goodness。現在應該把重心放在init/main.c & kernel/sched.c身上,main.c要改的地方就是create kernel thread與標示出使用eos custom schedule機制的時機,sched.c則是時做schedule機制的地方。

createkernel threads 之後將新增的全域變數,custom_sched,設成"1”以供goodness區別。在goodness中,新create出的kernel threads會被壓到最後執行。壓到最後的意思是指系統中指剩下以下11threads

init/swapperksoftirqd_CPU0,我們創造出來的兩個kernel threads,以及其他kernel threads(目前還沒有確定他們的function name)

當系統剩下這四的threads的時候表示系統一經完成開機程序,這時候再開始執行我們創造出來的threads,同時也只執行我們創造出來的threads

至於是否要重新算每個threadcount/time slice則留到稍後再考慮。

對於創造threads的部份,或許在schedule裡面呼叫kernel_thread會比較合適,

因為我們可以利用jiffies搭配上kernel_thread營造出兩個periodic jobs,實際是則上jobs執行完之後隨及結束,等到時機到的時候schedule再自行創造新的job instance給系統執行。

目前觀察到的情況是,執行過的thread似乎並不會被task_struct list中拔除,所以task_struct list越長越長,並且影響到scheduler選擇job的時間。需要檢查task_struct list的內容。即可能需要在task_struct中新增新field,並且在function的最後將這個field設起來,讓scheduler能夠根據這個field將相對應的task_structlist中拔除,這時候在想辦法將這個記憶體區塊free掉。

目前觀察到的情況是,task有被create出來,執行完的task也會從task_struct list中被移除掉,只是現在是由ksoftirqd_CPU0在執行我所create出的kernel_task。要看看到底ksoftirqd_CPU0在搞什麼鬼。

2006 Feb-22

或許將create threadschedule移到s3c2410_timer_interruptdo_timer裡面去做可以解決問題?--> Can't do, 不能在interrupt contextschedule

ksoftirqd_CPU0也是透過kernel_thread做出來的。。。,flag用的跟create init時的flag一模一樣。

光是呼叫do_exit並沒有辦法達到移除threadtask_struct

還要搭配lock_kernel, unlock_kernal, complete_and_exit(包在thread執行code), kill_proc, wait_for_completion, release_task(包在thread removal function)

因此整個架構上必須要有所調整,效法device driver(usb driver為參考對象drivers/usb.c)提供兩個daemons(D1, D2)do_timer/s3c2410_timer_interrupt中執行,D1負責注意何時需要createthreadD2負責移除執行過的thread。因為在interrupt context中無法schedule,所以我還必須要研究do_timer是在什麼時間點跳出interrupt context,在那個當下呼叫schedule


成功的將kernel thread移除,建立thread的步驟請參考usb hub driver (drivers/usb/hub.c),移除的話除了參考usb hub driver之外還要記得呼叫release_task()eg.

|| 870 eosid[0] = kernel_thread(eos_1, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGNAL);

1390 void eos_1 (void)

- 1391 {

| 1392 lock_kernel();

| 1393 printk("\nThis is eos_1: %s[%d].\n", current->comm, current->pid);

| 1394 for_each_task(tsk)

|- 1395 {

|| 1396 printk("%s[%d] ", tsk->comm, tsk->pid);

|| 1397 }

| 1398 eosrm[0] = 1;

| 1399 unlock_kernel();

| 1400 complete_and_exit(&eos1_exited, 0);

| 1401 }

1404 void del_task (void)

- 1405 {

| 1406 kill_proc(eosid[0], SIGTERM, 1);

| 1407 wait_for_completion(&eos1_exited);

| 1408 eosp = find_task_by_pid(eosid[0]);

| 1409 printk("\nRemoving: %s[%d]\n", eosp->comm, eosp->pid);

| 1410 release_task(eosp);

| 1411 }

要先把release_taskstatic宣告拿掉,然後在使用release_task的檔案中將宣告貼在檔案開頭。

2006-Mar-01

能夠建立periodic job之後把job依照priority放在active list裡面讓schedulerpriority最高的task挑出來做。目前需要看的部份有:把job插入active list的部份,scheduler_tick() function

Linux-2.4.18沒有active list。。。

struct completion是改進版的spin lock,拿來防止processmultiprocessors的系統中被異常中止(Understanding the Linux Kernel, 2nd edition, pg179)kernel thread中呼叫complete_and_exit()enablespin lock中的done變數,以便系統在移除kernel thread時呼叫wait_for_completion()時分辨該kernel thread是否已經執行過/或執行結束以便將該kernel thread移除。

為了讓我們建立的task成為real-time task,我們必須設定該process descriptorrt_priority欄位(值的範圍1~99,值越大real-time taskpriority越高)。同時可以把taskpolicy設成SCHED_FIFO,之後再加入計算SCHED_FIFO task優先權的code

重新出發~

periodic jobs最後面加上yield(),然後等時間到的時候再呼叫wake_up()job喚醒,但是應該需要修改wake_up()裡面的程式,才能讓scheduler根據我們的需求挑選job

似乎還有另外一個更快的方法。。。呼叫sleep_on_timeout()!!!

DECLARE_WAITQUEUE(wait, current);

sleep_on_timeout(&wait, ticks);

2006-Mar-08

似乎kernel_thread()運做的時候需要一些緩衝時間,如果連續呼叫兩次kernel_thread()的話(或是間隔太近),後createthread會有問題,比如說task struct裡面的資訊是錯誤的垃圾。

因此我藉由printk將資訊顯示在console上來拉長kernel_thread()之間的間隔。

例如:

|| 856 printk("\neos_thread:%d\n", eos_thread(eos_1, "eos_1", 1000));

|| 857 printk("\neos_thread:%d\n", eos_thread(eos_2, "eos_2", 2000));

eos_thread()的程式則如下:

876 int eos_thread(int (*fn)(void *), char *comm, int ms)

- 877 {

| 878 struct task_struct *tsk;

| 879 int tpid;

| 880

| 881 tpid = kernel_thread(fn, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGNAL);

| 882 tsk = find_task_by_pid(tpid);

| 883 strcpy(tsk->comm, comm);

| 884 tsk->period = ms_to_jiffies(ms);

| 885 tsk->deadline = jiffies + tsk->period;

| 886 printk("\nNew job created: %s[%d], period:%d, deadline:%d\n",

| 887 tsk->comm, tsk->pid, tsk->period, tsk->deadline);

| 888 return (tpid);

| 889 }

scheduler改成priority driven,檢查目前要switch過去的task是否為priority最高的task,如果不是的話就將next指定為priority最高的task

kernel中似乎不能用太高級的語法。

以下的會掛掉:

||| 642 //eos_finished = (tsk->period > 0) ? (eos_finished + tsk->finished):(eos_finished);

以下的OK

||| 643 if (tsk->period > nr_eos)

23- 644 {

234 645 eos_finished = eos_finished + tsk->finished;

234 646 }

完成處理RT/EOS jobsRM scheduler

S3C2410 from Microtimelittle-endian,或許要更換cross compiler

問題出在自己沒有把kernel_thread trace清楚,kernel_thread呼叫sys_clone再間接呼叫到do_fork,而do_fork是有機會呼叫到schedule的,因此我們必須在thread的開頭再初始period & deadline,初始完之後進入while(1)迴圈即可正確運作。

因為不明原因,進入while(1)之前要先將interrupt在開啟一次,這樣在呼叫mdelay()的時候jiffies才會正常更新。

2006-Apr-26

device structure加入owner_head[]*owner,用來monitor device被哪些jobs使用,目前先設定每個device最多只能有16owner

task_struct中加入in_mode,從這個field可以得知該task當時是在使用CPU還是IO

Static slack time計算方法à從最耗電的device中開始找local wait <>task,將該tasklocal wait調到與wakeup time一樣長,增加local wait的同時也將wcet & bcet做等量增加,之後再用新的wcet下去算cpu utilization,如果util超過bound,則不做變更。

如果在能夠延長local wait而且在該時間點之後還有IO access則將增加出來的部分也加到之後IO access listlocal wait當中。Update完該taskdevice request list之後如果cpu util繼續小於cpu util bound,則從最耗電的device中找下一個owner繼續相同的動作,以此類推直到cpu util超過cpu util bound或是每個device的每個owner都看過一遍。

job開始,進入與離開IO mode的時候要去查某個table(正在研究要用什麼形式儲存cpu降速資訊)以調變cpu的工作頻率。

新增check_cpu_speed() & static_dvs(),記得把code寫好,static_dvs()優先。

static_dvs(),分配slack time的時候從最耗電的device使用者中找出priority最高的job開始分配,藉此增加耗電裝置關閉的時間。等到run-time時再改成尋找下一個要使用到該裝置的job來進行dvs。因為這時候jobs根本都還沒有初始好,因此我們可以當作現在的時間是0,並且用給定的時間(每個device list中的required_by)下去運算。

2006-May-03

在調變ARM core speed的時候除了調整MPLL register之外還需要更改PWM timercounter值才能夠繼續讓timer interrupt10ms觸發一次。

2006-May-04

Linux開機時會呼叫pwm_timer_update()設定pwm counter4 buffer,讓do_timer10ms執行一次,設定counter buffer的公式為:

RESCHED_PERIOD * PCLK / ((SYS_TIMER234_PRESCALAR + 1) * SYS_TIMER4_DIVIDER * 1000)

RESCHED_PERIOD = 10

HCLK = FCLK / 2

FCLK = 202800000

SYS_TIMER_234_PRESCALAR = 202

SYS_TIMER4_DIVIDER = 4

程式碼為:

void pwm_timer_update(void)

{

rTCFG0 = (rTCFG0& ~(0xff<<8))|(sys_timer234_prescaler<<8);

rTCFG1 = (rTCFG1& ~(0xf<<16))|(sys_timer4_mux>

NowTCNTB4 = (RESCHED_PERIOD*PCLK)/

((SYS_TIMER234_PRESCALER +1)*(SYS_TIMER4_DIVIDER)*1000);

rTCNTB4 = NowTCNTB4;

rTCON = (rTCON& ~(7<<20))|(6<<20);

/* interval mode(auto reload), update TCNTB4, stop */

rTCON = (rTCON& ~(7<<20))|(5<<20);

/* interval mode, no operation, start for Timer 4 */

}

由上述公式與程式碼可知若想改變cpu speed並且保持timer interrupt10ms觸發一次,除了改變MPLLCON設定之外,還需要更新TCNTB4

因此需要建立change_cpu_speed() function同時設定MPLLCON & TCNTB4

在init/main.c中新增全域變數 rFCLK, rHCLK, rPCLK。

在task_struct中也需要新增field紀錄何時該切換cpu speed。

2006-May-05

在eos_arg中多加一個變數init_cpu_spd,用這個變數紀錄static_dvs()算出來的cpu speed,當task的第一個cpu interval用這個speed執行時,能夠使該task所需的devices在task開始的instant才啟動。因為dynamic_dvs() 並不會事先將速度算出來,因此不需要在task structure中預留位置存放這些資訊。

在job_sim()中執行eos_delay()之前(cpu interval的部分) ,如果nth_cpu_job為0,又init_cpu_spd不為0,則將cpu speed調整至init_cpu_spd。

進入使用device的狀態時呼叫change_cpu_speed()將速度調到最高速,減少device的耗電時間,而離開io mode的時候馬上呼叫dynamic_dvs()視情況決定是否要調降cpu speed以增加關閉device的機會。

change_cpu_speed(spd)
{
lookup MPLLCON's value;
calculate new PWM timer4's counter value;
set MPLLCON with new value;
set TCNTB4 with new value;
}


dynamic_dvs()

{

???

}