顯示具有 ARM 標籤的文章。 顯示所有文章
顯示具有 ARM 標籤的文章。 顯示所有文章

2015年4月9日 星期四

Change the Audio Output on Raspberry Pi

1. Install related package

# sudo apt-get install alsa-utils

 

2. Modify the audio path on Raspberry Pi

# sudo amixer cset numid=3 X

 

Where X is as following:

0 = Auto

1 = 3.5 mm Audio Jack

2 = HDMI


 

numid=1,iface=MIXER,name='Master Playback Volume'

numid=2,iface=MIXER,name='Master Playback ZC Switch'

numid=3,iface=MIXER,name='Capture Volume'

numid=4,iface=MIXER,name='Capture Switch'numid=5,iface=MIXER,name='Mic Boost (+20dB)'numid=6,iface=MIXER,name='Mic Boost2 (+20dB)'numid=7,iface=MIXER,name='Mic Switch'

numid=8,iface=MIXER,name='Sidetone Playback Volume'numid=9,iface=MIXER,name='ADC High Pass Filter Switch'

numid=10,iface=MIXER,name='Store DC Offset Switch'numid=11,iface=MIXER,name='Capture Source'numid=12,iface=MIXER,name='Playback De-emphasis'numid=13,iface=MIXER,name='Input Mux'numid=16,iface=MIXER,name='Output Mixer HiFi Playback Switch'numid=14,iface=MIXER,name='Output Mixer Line Bypass Switch'numid=15,iface=MIXER,name='Output Mixer Mic Sidetone Switch'

How to setup a VNC Server in Raspberry Pi ?

1. Install x11vnc package

# sudo apt-get install x11vnc

 

2. Setup your password

# x11vnc –savepasswd

 

3. Establish a VNC connection with 1920x1080 resolution and background execution

# x11vnc –geometry 1920x1080 –bg

 

4. Disconnect all of the VNC connections

# x11vnc –R stop

 

5. Change the the default resolution of Raspberry Pi

# vim /boot/config.txt

uncomment the ‘#’ tag in front of the following string

 

hdmi_force_hotplug=1

hdmi_group=2

hdmi_mode=68

hdmi_mode=1    640x350    85 Hz
hdmi_mode=2    640x400    85 Hz
hdmi_mode=3    720x400    85 Hz
hdmi_mode=4    640x480    60 Hz
hdmi_mode=5    640x480    72 Hz
hdmi_mode=6    640x480    75 Hz
hdmi_mode=7    640x480    85 Hz
hdmi_mode=8    800x600    56 Hz
hdmi_mode=9    800x600    60 Hz
hdmi_mode=10   800x600    72 Hz
hdmi_mode=11   800x600    75 Hz
hdmi_mode=12   800x600    85 Hz
hdmi_mode=13   800x600   120 Hz
hdmi_mode=14   848x480    60 Hz
hdmi_mode=15   1024x768   43 Hz  DO NOT USE
hdmi_mode=16   1024x768   60 Hz
hdmi_mode=17   1024x768   70 Hz
hdmi_mode=18   1024x768   75 Hz
hdmi_mode=19   1024x768   85 Hz
hdmi_mode=20   1024x768  120 Hz
hdmi_mode=21   1152x864   75 Hz
hdmi_mode=22   1280x768          Reduced blanking
hdmi_mode=23   1280x768   60 Hz
hdmi_mode=24   1280x768   75 Hz
hdmi_mode=25   1280x768   85 Hz
hdmi_mode=26   1280x768  120 Hz  Reduced blanking
hdmi_mode=27   1280x800          Reduced blanking
hdmi_mode=28   1280x800   60 Hz  
hdmi_mode=29   1280x800   75 Hz  
hdmi_mode=30   1280x800   85 Hz  
hdmi_mode=31   1280x800  120 Hz  Reduced blanking
hdmi_mode=32   1280x960   60 Hz  
hdmi_mode=33   1280x960   85 Hz  
hdmi_mode=34   1280x960  120 Hz  Reduced blanking
hdmi_mode=35   1280x1024  60 Hz  
hdmi_mode=36   1280x1024  75 Hz  
hdmi_mode=37   1280x1024  85 Hz  
hdmi_mode=38   1280x1024 120 Hz  Reduced blanking
hdmi_mode=39   1360x768   60 Hz  
hdmi_mode=40   1360x768  120 Hz  Reduced blanking
hdmi_mode=41   1400x1050         Reduced blanking
hdmi_mode=42   1400x1050  60 Hz  
hdmi_mode=43   1400x1050  75 Hz  
hdmi_mode=44   1400x1050  85 Hz  
hdmi_mode=45   1400x1050 120 Hz  Reduced blanking
hdmi_mode=46   1440x900          Reduced blanking
hdmi_mode=47   1440x900   60 Hz  
hdmi_mode=48   1440x900   75 Hz  
hdmi_mode=49   1440x900   85 Hz  
hdmi_mode=50   1440x900  120 Hz  Reduced blanking
hdmi_mode=51   1600x1200  60 Hz  
hdmi_mode=52   1600x1200  65 Hz  
hdmi_mode=53   1600x1200  70 Hz  
hdmi_mode=54   1600x1200  75 Hz  
hdmi_mode=55   1600x1200  85 Hz  
hdmi_mode=56   1600x1200 120 Hz  Reduced blanking
hdmi_mode=57   1680x1050         Reduced blanking
hdmi_mode=58   1680x1050  60 Hz  
hdmi_mode=59   1680x1050  75 Hz  
hdmi_mode=60   1680x1050  85 Hz  
hdmi_mode=61   1680x1050 120 Hz  Reduced blanking
hdmi_mode=62   1792x1344  60 Hz  
hdmi_mode=63   1792x1344  75 Hz  
hdmi_mode=64   1792x1344 120 Hz  Reduced blanking
hdmi_mode=65   1856x1392  60 Hz  
hdmi_mode=66   1856x1392  75 Hz  
hdmi_mode=67   1856x1392 120 Hz  Reduced blanking
hdmi_mode=68   1920x1200         Reduced blanking
hdmi_mode=69   1920x1200  60 Hz  
hdmi_mode=70   1920x1200  75 Hz  
hdmi_mode=71   1920x1200  85 Hz  
hdmi_mode=72   1920x1200 120 Hz  Reduced blanking
hdmi_mode=73   1920x1440  60 Hz  
hdmi_mode=74   1920x1440  75 Hz  
hdmi_mode=75   1920x1440 120 Hz  Reduced blanking
hdmi_mode=76   2560x1600         Reduced blanking
hdmi_mode=77   2560x1600  60 Hz  
hdmi_mode=78   2560x1600  75 Hz  
hdmi_mode=79   2560x1600  85 Hz  
hdmi_mode=80   2560x1600 120 Hz  Reduced blanking
hdmi_mode=81   1366x768   60 Hz  
hdmi_mode=82   1080p      60 Hz  
hdmi_mode=83   1600x900          Reduced blanking
hdmi_mode=84   2048x1152         Reduced blanking
hdmi_mode=85   720p       60 Hz  
hdmi_mode=86   1366x768          Reduced blanking

6. Install VNC client and connect to Raspberry Pi

YourSVNServerIP:5900

raspberry pi

Thank you.

2012年10月29日 星期一

How To Build EDK & EDK II Environment In Easy Way

如何編譯EDK

請參考 How To Compile UDK2014如果你是要編譯 UDK2014。
請參考 How To Compile UDK2015如果你是要編譯 UDK2015。

image
(D:\為例)
安裝Windows Driver KitC:\WINDDK\3790.1830
Edk 1.06解壓縮到D:\
EfiShell 1.06解壓縮到D:\Edk\Other\Maintained\Application\UefiShell資料夾下
image

修改D:\Edk\Sample\LocalTools.env 確認NASMDDK路徑

image
image


編輯D:\Edk\Sample\Platform\Nt32\Build\Config.env
image


用系統管理完開啟命令提示字元
image

切換目錄到D:\Edk\Sample\Platform\Nt32
輸入SET EDK_SOURCE=D:\Edk
build編譯
image

編譯成功畫面
image

切換到D:\Edk\Sample\Platform\Nt32\uefi\IA32
輸入secmain.exe
image
image
image
image

如何編譯EFI_Toolkit

解壓縮EFI_Toolkit_2.0.0.1 D:\Edk\Sample\Platform
修改D:\Edk\Sample\Platform\EFI_Toolkit_2.0\build.cmdSDK_INSTALL_DIR路徑

image

輸入build
輸入nmake編譯 
image

編譯完成畫面
image

輸出EFI檔在D:\Edk\Sample\Platform\EFI_Toolkit_2.0\build\em64t\bin
如果要編譯成其他檔案可以更改build.cmd裡的SDK_BUILD_ENV
image

想要決定編譯哪幾個檔案可以修改D:\Edk\Sample\Platform\EFI_Toolkit_2.0\apps\apps.mak

想要修改WINDDK路徑的話
D:\Edk\Sample\Platform\EFI_Toolkit_2.0\build\em64t\sdk.env


如何編譯EDKII

先安裝Tortoise SVN取得EDKII Source Code
安裝完成後在你要的目錄,點右鍵SVN Checkout
image
image
image


系統管理員開啟命令提示字元
輸入edksetup.bat
image

因為我是用Visual Studio 2010
必須修改Conf\target.txt 裡的TOOL_CHAIN_TAG = 2010
image

再輸入Build就會編譯了
image
image


編譯完成畫面
image

直接輸入build run
或是執行D:\EDKII\edk2\Build\NT32\DEBUG_VS2010\IA32\secmain.exe
image

模擬器開啟畫面
image
image
這裡有說明EDK II各個Package的內容
如果要切換不同Package
可以修改Conf\target.txt裡的
ACTIVE_PLATFORM       = Nt32Pkg/Nt32Pkg.dsc
ACTIVE_PLATFORM       = MdePkg/MdePkg.dsc

2011年8月3日 星期三

Linux內核啟動過程

 

Linux的啟動過程可分為兩部分:架構/開發版相關的引導過程、後續的通用啟動過程。

引導階段通常使用組合語言撰寫,首先檢查內核是否支持當前架構的處理器,然後檢查是否支持當前的開發版。通過檢查後就跳到下一階段的start_kernel函數做準備了。

主要分成下列兩個步驟

1. 連接內核時使用的虛擬位址,所以需要設置分頁表、關閉所有Cache、MMU。

2. 執行start_kernel裡的工作,包括複製Data Section、清除BSS區段、執行start_kernel函數。

第二階段的關鍵代碼主要使用C語言撰寫。進行了內核初始化的全部工作,像是輸出Linux版本訊息、設置與結構相關的環境、初始化控制台,最後執行rest_init函數啟動init過程,創建系統第一個行程:init行程。

Bootloader的結構

嵌入式Linux系統從軟體的角度通常可分成以下四個層次

1. 引導加載程式,包括固化在Firmware中的Boot代碼與Bootloader兩大部份。有些CPU在運行Bootloader之前先運行一段固化程式,比如X86結構的CPU就是先運行BIOS中的firmware,然後才運行硬碟的第一個分區(MBR)中的Bootloader。在大多數的嵌入式系統中並沒有Firmware,Bootloader是開啟後執行的第一個程式。

2. Linux內核,特定於嵌入式板子的訂製內核予內核的啟動參數。內核的啟動參數可以是內核默認的,或是由Bootloader傳遞給它的。

3. 文件系統,包括跟文件系統與建立於Flash內存設備上的文件系統。裏面包含了Linux系統能夠運行所需的應用程式、程式庫,比如可以給用戶提供操作Linux的控制介面的Shell、動態連接與運行時需要的glibc、uClibc ...等。

4. 用戶應用程式,他储存在文件系統中。有時在用戶應用程式與內核之間可能還會包括圖形介面像是Qtopia、MiniGUI...等。

2011年1月26日 星期三

Ubuntu 上編譯 RT-Thread 與 Qemu-mini2440模擬執行

平台:Ubuntu 10.04 LTS

RT-Thread : 0.4.0

 

1.到這裡下載Compiler

http://www.codesourcery.com/sgpp/lite/arm/download.html

 

2.安裝SCons

$ sudo apt-get install scons

 

3.安裝 git-core

$ sudo apt-get install git-core

 

4.下載qemu-mini2440

$ git clone git://repo.or.cz/qemu/mini2440.git mini2440-qemu

5.修補qemu-mini2440

$ patch -d mini2440-qemu/ -p1 <mini2440.patch

patching file gdbstub.c
patching file hw/mini2440.c
patching file hw/s3c2410.c
patching file hw/s3c24xx_lcd.c
patching file hw/sd.c

mini2440.patch 如下

-----------------(以下開始)--------------------

diff -Nur mini2440/gdbstub.c mini2440_0308/gdbstub.c
--- mini2440/gdbstub.c    2009-05-20 18:28:02 +0800
+++ mini2440_0308/gdbstub.c    2010-02-07 18:58:36 +0800
@@ -2345,7 +2345,7 @@
         if (strstart(device, "tcp:", NULL)) {
             /* enforce required TCP attributes */
             snprintf(gdbstub_device_name, sizeof(gdbstub_device_name),
-                     "%s,nowait,nodelay,server", device);
+                     "%s,nowait,nodelay,server,ipv4", device);
             device = gdbstub_device_name;
         }
#ifndef _WIN32
diff -Nur mini2440/hw/mini2440.c mini2440_0308/hw/mini2440.c
--- mini2440/hw/mini2440.c    2009-05-20 18:28:02 +0800
+++ mini2440_0308/hw/mini2440.c    2010-01-29 00:56:24 +0800
@@ -258,6 +258,9 @@
     struct mini2440_board_s *s = (struct mini2440_board_s *) opaque;
     uint32_t image_size;

+#if 1
+    s->cpu->env->regs[15] = S3C_RAM_BASE;
+#else
     /*
      * Normally we would load 4 KB of nand to SRAM and jump there, but
      * it is not working perfectly as expected, so we cheat and load
@@ -298,6 +301,7 @@
                mini2440_printf("loaded %s (size %x)\n", s->kernel, image_size);
         }
     }
+#endif   
}

/* Typical touchscreen calibration values */
@@ -328,7 +332,7 @@
         mini2440_printf("This platform requires an ARM920T core\n");
         exit(2);
     }
-    s->cpu = s3c24xx_init(S3C_CPU_2440, 12000000 /* 12 mhz */, s->ram, S3C_SRAM_BASE_NANDBOOT, s->mmc);
+    s->cpu = s3c24xx_init(S3C_CPU_2440, 12000000 /* 12 mhz */, s->ram, S3C_SRAM_BASE_NORBOOT, s->mmc);

     /* Setup peripherals */
     mini2440_gpio_setup(s);
@@ -353,6 +357,11 @@
     return s;
}

+static struct arm_boot_info mini2440_binfo = {
+    .loader_start = S3C_RAM_BASE,
+    .ram_size = 0x04000000,
+    .board_id = 0x050,
+};

static void mini2440_init(ram_addr_t ram_size,
         const char *boot_device,
@@ -371,9 +380,16 @@
     mini = mini2440_init_common(ram_size,
                     kernel_filename, cpu_model, sd);

-    mini->nand = nand_init(NAND_MFR_SAMSUNG, 0x76);
+    mini->nand = nand_init(NAND_MFR_SAMSUNG, 0x76);
     mini->cpu->nand->reg(mini->cpu->nand, mini->nand);

+    /* Load the kernel.  */
+    if (kernel_filename) {
+        mini2440_binfo.kernel_filename = kernel_filename;
+        mini2440_binfo.kernel_cmdline = kernel_cmdline;
+        mini2440_binfo.initrd_filename = initrd_filename;
+        arm_load_kernel(mini->cpu->env, &mini2440_binfo);
+    }   
     mini2440_reset(mini);
}

diff -Nur mini2440/hw/s3c2410.c mini2440_0308/hw/s3c2410.c
--- mini2440/hw/s3c2410.c    2009-05-20 18:28:02 +0800
+++ mini2440_0308/hw/s3c2410.c    2010-01-29 23:33:11 +0800
@@ -1603,7 +1603,7 @@
static void s3c_adc_done(void *opaque)
{
     struct s3c_adc_state_s *s = (struct s3c_adc_state_s *) opaque;
-    s->xdata = s->input[s->in_idx] & 0x3ff;
+    //s->xdata = s->input[s->in_idx] & 0x3ff;
     s->control |= 1 << 15;
     qemu_irq_raise(s->irq);
}
@@ -1630,6 +1630,15 @@
         qemu_mod_timer(s->tst, qemu_get_clock(vm_clock) +
                         (ticks_per_sec >> 5));
     }
+    /* add by yi.qiu@2010.01.28 */
+    else
+    {
+        if (((s->ts & 3) == 3) && (s->ts & (1<<8)) && (s->enable))
+            qemu_irq_raise(s->tcirq);
+
+     qemu_mod_timer(s->tst, qemu_get_clock(vm_clock) +
+                        (ticks_per_sec >> 5));   
+    }
}

static void s3c_adc_event(void *opaque,
@@ -1637,8 +1646,9 @@
{
     struct s3c_adc_state_s *s = (struct s3c_adc_state_s *) opaque;
     s->down = !!buttons_state;
-    s->x = x;
-    s->y = y;
+    s->x = 32767 - y;
+    s->y = 32767 - x;
+   
     s3c_adc_tick(s);
}

@@ -1689,7 +1699,7 @@
         break;

     case S3C_ADCTSC:
-        s->ts = value & 0xff;
+        s->ts = value & 0x1ff;
         break;

     case S3C_ADCDLY:
diff -Nur mini2440/hw/s3c24xx_lcd.c mini2440_0308/hw/s3c24xx_lcd.c
--- mini2440/hw/s3c24xx_lcd.c    2009-05-20 18:28:02 +0800
+++ mini2440_0308/hw/s3c24xx_lcd.c    2010-01-28 18:44:50 +0800
@@ -432,7 +432,7 @@
             dirty[1] = cpu_physical_memory_get_dirty(x, VGA_DIRTY_FLAG);
             dirty[0] |= dirty[1];
         }
-        if (dirty[0] || s->invalidate) {
+        // if (dirty[0] || s->invalidate) {
             s->fn(s->palette, dest, src, s->width, s->dest_width);
             maxy = y;
             end = new_addr;
@@ -440,7 +440,7 @@
                 miny = y;
                 start = addr;
             }
-        }
+        // }
         addr = new_addr;
         dirty[0] = dirty[1];
         src += src_width;
@@ -452,7 +452,9 @@
         cpu_physical_memory_reset_dirty(start, end, VGA_DIRTY_FLAG);
     s->srcpnd |= (1 << 1);            /* INT_FrSyn */
     s3c_lcd_update(s);
-    dpy_update(s->ds, 0, miny, s->width, maxy);
+    /* fix qemu/2410 lcd bug */
+    dpy_update(s->ds, 0, 0, 240, 320);
+    // dpy_update(s->ds, 0, miny, s->width, maxy);
}

static void s3c_invalidate_display(void *opaque)
diff -Nur mini2440/hw/sd.c mini2440_0308/hw/sd.c
--- mini2440/hw/sd.c    2009-05-20 18:28:02 +0800
+++ mini2440_0308/hw/sd.c    2010-02-07 13:26:34 +0800
@@ -195,7 +195,7 @@
static void sd_set_ocr(SDState *sd)
{
     /* All voltages OK, card power-up OK, Standard Capacity SD Memory Card */
-    sd->ocr = 0x80ffff00;
+    sd->ocr = 0x80ff8000;
}

static void sd_set_scr(SDState *sd)

-----------------(到此結束)--------------------

 

5.安裝Libary

$ sudo apt-get install zlib1g-dev libsdl-gfx1.2-dev libsdl1.2-dev

 

6.編譯qemu

$ cd mini2440-qemu

$ ./configure --target-list=arm-softmmu

$ make

 

7.安裝subversion

$ sudo apt-get install subversion

 

8.下載RT-Thread source code

$ svn checkout http://rt-thread.googlecode.com/svn/trunk/ RT-Thread

 

9.修改 RT-Thread/bsp/mini2440/rtconfig.py

 

5 # toolchains options

6 ARCH = 'arm'

7 CPU = 's3c24x0'

8 TextBase = '0x30000000'

9

10 CROSS_TOOL = 'gcc'

11

12 if CROSS_TOOL == 'gcc':

13 PLATFORM = 'gcc'

14 EXEC_PATH = 'yourpath/compiler/bin'

15 elif CROSS_TOOL == 'keil':

16 PLATFORM = 'armcc'

17 EXEC_PATH = 'E:/Keil'

 

10.編譯RT-Thread

$ cd RT-Thread/bsp/min2440

$ scons

 

11.解壓縮SDCARD.zip

$ unzip RT-Thread/tools/SDCARD.zip

 

12. 複製qemu-system-arm 至 RT-Thread/tools

$ cp mini2440-qemu/arm-softmmu/qemu-system-arm RT-Thread/tools/

 

13.模擬執行

$ cd RT-Thread/tools/

$ ./qemu-system-arm -M mini2440 -kernel ../bsp/mini2440/rtthread-mini2440.axf -show-cursor -sd SDCARD -serial telnet:127.0.0.1:1200,server -serial file:virtualkbd

 

跟run-mini2440-sdcard.bat 比較 (for windows)

start qemu-system-arm.exe -M mini2440 -kernel ..\bsp\mini2440\rtthread-mini2440.axf -show-cursor -sd SDCARD -serial telnet:127.0.0.1:1200,server -serial file:virtualkbd

telnet 127.0.0.1 1200

 

14.開啟終端機

$ telnet 127.0.0.1 1200

 

rt-thread

 

Reference :

http://www.rt-thread.org/phpbbforum/viewtopic.php?f=2&t=807