Hackpads are smart collaborative documents. .
692 days ago
Unfiled. Edited by Jim Huang 692 days ago
Jim H STM32 Firmware
Projects/STM32F429I-Discovery/Applications/USB_Host/FWupgrade_Standalone/Src/usbh_conf.c
  •   /*EMBEDDED Physical interface*/
  •   __GPIOB_CLK_ENABLE();
  •   __GPIOC_CLK_ENABLE();
  •   
  •   GPIO_InitStruct.Pin = (GPIO_PIN_14 | GPIO_PIN_15);
  •   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  •   GPIO_InitStruct.Pull = GPIO_NOPULL;
  •   GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  •   GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS;
  •   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 
  •   
  •   /* Configure  VBUS Pin */
  •   GPIO_InitStruct.Pin = GPIO_PIN_13;
  •   GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  •   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  •   GPIO_InitStruct.Pull = GPIO_NOPULL ;
  •   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);    
  •   
  •   /* Enable USB HS Clocks */ 
  •   __USB_OTG_HS_CLK_ENABLE();
  •   
  •   /* Configure Power Switch Vbus Pin */
  •   GPIO_InitStruct.Pin = HOST_POWERSW_VBUS;
  •   GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
  •   GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  •   GPIO_InitStruct.Pull = GPIO_NOPULL ;
  •   HAL_GPIO_Init(HOST_POWERSW_PORT,&GPIO_InitStruct);
  •  
  •   /* By Default, DISABLE is needed on output of the Power Switch */
  •   HAL_GPIO_WritePin(HOST_POWERSW_PORT, HOST_POWERSW_VBUS, GPIO_PIN_SET);
  •   
  •   USBH_Delay(200);   /* Delay is need for stabilising the Vbus Low */
  •   
  •   /* Set USBHS Interrupt to the lowest priority */
  •   HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0);
  •   
  •   /* Enable USBFS Interrupt */
  •   HAL_NVIC_EnableIRQ(OTG_HS_IRQn);
  •  
 
Tip
只更新 kernel image
  • openocd \
  •         -f interface/stlink-v2.cfg \
  •         -f target/stm32f4x_stlink.cfg \
  •         -c "init" \
  •         -c "reset init" \
  •         -c "flash probe 0" \
  •         -c "flash info 0" \
  •         -c "flash write_image erase out/kernel/arch/arm/boot/xipuImage.bin 0x08020000" \
  •         -c "reset run" -c shutdown
 
709 days ago
Unfiled. Edited by 曾柏翔 709 days ago
曾柏翔 fb_moving_tux.c code 紀錄
 
fb_moving_tux.c code
moving_tux_init kernel module 初始化function
  • static int __init moving_tux_init(void)
  • {
  •         int error = 0, i;
  •  
  •         moving_tux_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL,
  •                                      "moving_tux");
//創造一個device給moving_tux_device,moving_tux_device就會自動在/dev下創建my_device文件。
 creates a device and registers it with sysfs
  •         if (IS_ERR(moving_tux_device)) {
  •                 printk(KERN_WARNING "Unable to create device "
  •                        "for moving_tux; errno = %ld\n",
  •                        PTR_ERR(moving_tux_device));
  •                 moving_tux_device = NULL;
  •         }
//確認是否創造device成功。
  •         for (i = 0; i < ARRAY_SIZE(device_attrs); i++) {
  •                 error = device_create_file(moving_tux_device, &device_attrs[i]);
  •  
  •                 if (error)
  •                         break;
  •         }
在/sys/class/下創建一个屬性文件,通過這個文件可進行對此device的相對應操作如:read write
  •         fb_show_logo_fn = fb_get_do_show_logo_fn();
  •         fb_set_logo_truepalette_fn = fb_get_set_logo_truepalette_fn();
  •  
  •         moving_tux_thread = kthread_create(tux_thread, NULL, "moving_tux");
  •  
  •         if (IS_ERR(moving_tux_thread)) {
  •                 error = PTR_ERR(moving_tux_thread);
  •                 printk(KERN_ERR PFX "cannot create a thread failed (%d)\n",
  •                                 error);
  •         }
  •  
  •         move_tux = 0;
  •  
  •         /* Start the thread. */
  •         wake_up_process(moving_tux_thread);
  •  
  •         return error;
  • }
 
710 days ago
Unfiled. Edited by 許元杰 710 days ago
許元杰 設備驅動程式
每當kernel檢測到一個設備時,都會建立一個核心物件kobject。該物件借助於sysfs檔案系統導出到user space,此外,kernel還向user space 發送一個隨插即用的訊息。
如果在系統啟動或運行期間發現有新設備連接上,kernel產生的隨插即用訊息包含了驅動程式為設備分配的major numberminor number。udevd背景程序所需完成的所有工作,就是監聽這些訊息。在註冊新設備時,會在/dev中建立相對應的項目,接下來就可以從使用者區存取該設備了。
 
723 days ago
Unfiled. Edited by 許元杰 723 days ago
許元杰 uClinux燒錄
 
  • 環境建置
安裝 toolchain, st-link, openocd 等工具(參考 : https://stm32f429.hackpad.com/NOTE-WbiooOfkaoR )
 
  • 燒錄 uClinux
照著 stm32f429-linux-builder 的 README.md步驟,將bootloader、kernel、filesystem燒錄進去
 
  • Simply execute make, and it will fetch and build u-boot, linux kernel, and busybox from scratch:
  •     make
  • Once STM32F429 Discovery board is properly connected via USB wire to Linux host, you can execute make install to flash the device. Note: you have to ensure the installation of the latest OpenOCD in advance.
  •     make install
Be patient when OpenOCD is flashing. Typically, it takes about 55 seconds. Use make help to get detailed build targets.
 
 
  • USART Connection
The STM32F429 Discovery is equipped with various USARTs. USART stands for Universal Synchronous Asynchronous Receiver Transmitter. The USARTs on the STM32F429 support a wide range of serial protocols, the usual asynchronous ones, plus things like IrDA, SPI etc. Since the STM32 works on 3.3V levels, a level shifting component is needed to connect the USART of the STM32F429 to a PC serial port.
Most PCs today come without an native RS232 port, thus an USB to serial converter is also needed.
For example, we can simply connect the RX of the STM32 USART3 to the TX of the converter, and the TX of the USART3 to the RX of the converter:
  • pin PC10 -> TXD
  • pin PC11 -> RXD
 
USB Serial接法
  •  PL2303
  •  Black: Ground - Green: Receive - White: Transmit
  • Red : 5V
  • Black: GND
  • Green: RXD
  • White: TXD
 
 
  • 結果
  • U-Boot 2010.03-00003-g934021a ( Feb 09 2014 - 17:42:47)
  •  
  • CPU  : STM32F4 (Cortex-M4)
  • Freqs: SYSCLK=180MHz,HCLK=180MHz,PCLK1=45MHz,PCLK2=90MHz
  • Board: STM32F429I-DISCOVERY board,Rev 1.0
  • DRAM:   8 MB
  • Using default environment
  •  
  • Hit any key to stop autoboot:  0 
  • ## Booting kernel from Legacy Image at 08020000 ...
  • ...
  •  
  • Starting kernel ...
  •  
  • Linux version 2.6.33-arm1 (jserv@venux) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-189) ) #2 Sun Feb 9 17:54:20 CST 2014
  • CPU: ARMv7-M Processor [410fc241] revision 1 (ARMv7M)
  • CPU: NO data cache, NO instruction cache
  • Machine: STMicro STM32
  • ...
  • VFS: Mounted root (romfs filesystem) readonly on device 31:0.
  • Freeing init memory: 16K
  • starting pid 25, tty '/dev/ttyS2': '/bin/login -f root'
  • Welcome to
  •           ____ _  _
  •          /  __| ||_|                 
  •     _   _| |  | | _ ____  _   _  _  _ 
  •    | | | | |  | || |  _ \| | | |\ \/ /
  •    | |_| | |__| || | | | | |_| |/    \
  •    |  ___\____|_||_|_| |_|\____|\_/\_/
  •    | |
  •    |_|
  •  
  • For further information check:
 
758 days ago
Unfiled. Edited by 宋奕德 758 days ago
  • #define V7M_SCS                             0xe000e000
  • #define NVIC_INTR_CTRL                      (V7M_SCS + 0x004)
  • #define NVIC_SYSTICK_CTRL                   (V7M_SCS + 0x010)
  • #define NVIC_SYSTICK_RELOAD                 (V7M_SCS + 0x014)
  • #define NVIC_SYSTICK_CURRENT                (V7M_SCS + 0x018)
  • #define NVIC_SYSTICK_CALIBRATION            (V7M_SCS + 0x01c)
  • #define NVIC_SET_ENABLE                     (V7M_SCS + 0x100)
  • #define NVIC_CLEAR_ENABLE                   (V7M_SCS + 0x180)
  • #define NVIC_SET_PENDING                    (V7M_SCS + 0x200)
  • #define NVIC_CLEAR_PENDING                  (V7M_SCS + 0x280)
  • #define NVIC_ACTIVE_BIT                     (V7M_SCS + 0x300)
  • #define NVIC_PRIORITY                       (V7M_SCS + 0x400)
  • #define NVIC_INTR_CTRL_STATE                (V7M_SCS + 0xd04)
  • #define NVIC_SOFTWARE_INTR                  (V7M_SCS + 0xf00)
 
906 days ago
Unfiled. Edited by Cheng Feng Sheng 906 days ago
  • review:  preemptive
 
 
 
 
  • 何謂 interrupt呢? 這是一個讓軟體(kernel)在接到來自硬體的通告,作出反應的機制。以網路卡為例,硬體在接收到外部的封包之後,便會以interrupt通知OS,展開對應此狀況的中斷處理程序(interrupt handler),運行架構如下圖所示。
 
 
  • 觀察上面的簡要流程,會發現我們需要兩樣未提及東西:masking的控制,以及該條IRQ line的狀態。
 
  • 其中將訊號遮蔽的masking可以透過寫入interrupt controller的register來達成。STM32使用的是cortex M處理器,其Nest Vector Interrupt Controller(NVIC)  masking所對應的位址如下表。
 
  • 能在handler function層級中控制一個irq line的masking與否,意味著OS必須有能力處理不同硬體間的差異,如此一來才具備可攜性。這在linux底下主要透過三個資料結構,分別為irq_chip irqaction以及 irq_desc來達成,其主要成員如下。
  •  
  • struct irq_chip {
 
907 days ago
Members (16)
許元杰 宋奕德 cheng hun lin 黃呂源 Jim Huang 曾柏翔 蔡森至 楊孟勳 楊永平 Cooper Ke 柳冠宇 Cheng Feng Sheng 李明益 lime Michael Shang xu3fu6xup6@gmail.com

Create a New Collection

Cancel

Move XXX to XXX


XXX will be invited to the XXX on XXX.

Cancel

Contact Support



Please check out our How-to Guide and FAQ first to see if your question is already answered! :)

If you have a feature request, please add it to this pad. Thanks!


Log in