該怎麼起動這個 bootloader 呢? stm32 提供了 boot mode 這個機制。
Table 3. Boot Modes
Boot modes Boot mode selection pins | Boot mode | Aliasing | |
BOOT1 | BOOT0 | ||
X | 0 | Main Flash memory | Main Flash memory is selected as the boot space |
0 | 1 | System memory | System memory is selected as the boot space |
1 | 1 | Embedded SRAM | Embedded SRAM is selected as the boot space |
boot0 set to 1 |
boot1 (PB2) sets to 0 |
其中有一種是從 system memory 開機, 這是一塊內部的 boot ROM, 位於 0x1fff0000 ~ 0x1ff77ff, 這裡就是 boot loader 的位址。
寄件者 stm32f4-discovery |
boot0, boot1 可參考這份 pdf:
http://www.kamami.pl/dl/stm32f4discovery_user_manual.pdf
ref: RM0090 Reference manual p57
Boot configuration
Due to its fixed memory map, the code area starts from address 0x0000 0000 (accessed through the ICode/DCode buses) while the data area (SRAM) starts from address 0x2000 0000 (accessed through the system bus). The CortexTM-M4F CPU always fetches the reset vector on the ICode bus, which implies to have the boot space available only in the code area (typically, Flash memory). STM32F4xx microcontrollers implement a special mechanism to be able to boot from other memories (like the internal SRAM).
In the STM32F4xx, three different boot modes can be selected through the BOOT[1:0] pins as shown in Table 3.
Table 3. Boot Modes
Boot modes Boot mode selection pins | Boot mode | Aliasing | |
BOOT1 | BOOT0 | ||
X | 0 | Main Flash memory | Main Flash memory is selected as the boot space |
0 | 1 | System memory | System memory is selected as the boot space |
1 | 1 | Embedded SRAM | Embedded SRAM is selected as the boot space |
The values on the BOOT pins are latched on the 4th rising edge of SYSCLK after a reset. It is up to the user to set the BOOT1 and BOOT0 pins after reset to select the required boot mode.
BOOT0 is a dedicated pin while BOOT1 is shared with a GPIO pin. Once BOOT1 has been sampled, the corresponding GPIO pin is free and can be used for other purposes.
The BOOT pins are also resampled when the device exits the Standby mode. Consequently, they must be kept in the required Boot mode configuration when the device is in the Standby mode. After this startup delay is over, the CPU fetches the top-of-stack value from address 0x0000 0000, then starts code execution from the boot memory starting from 0x0000 0004.
Note:
When the device boots from SRAM, in the application initialization code, you have to relocate the vector table in SRAM using the NVIC exception table and the offset register.
Embedded bootloader
The embedded bootloader mode is used to reprogram the Flash memory using one of the following serial interfaces:
- USART1(PA9/PA10)
- USART3(PB10/11 and PC10/11)
- CAN2(PB5/13)
- USB OTG FS(PA11/12) in Device mode (DFU: device firmware upgrade).
The embedded bootloader code is located in system memory. It is programmed by ST during production. For additional information, refer to application note AN2606.
中間這段英文在介紹這個, 不過若是要看英文的, 我就不用寫這篇文章了, 身為使用中文的你我, 中文資料更有親合力。
BOOT0, BOOT1 的設定知道後還有 uart 的硬體 pin 要知道, 我選用 fig 2 紅色部份這組, PB10/PB11, usart1 PA9, PA10 已經給了 usb 用, 所以不能用, 軟體的設定除了 baud rate, 還要注意是 even parity。
PB10 (TX) 接到 白色 (RX) |
PB11 (RX) 接到 綠色 (TX) |
| ||
寄件者 stm32f4-discovery |
再來是和其 bootloader 通訊的軟體, 以下連結分別是 stm32 (windows)和 linux 的 flash loader。
我用的是 stm32 提供的版本。如果硬體 pin 或是接錯線或是軟體設定有問題, 直接到 fig 4, 連線失敗。
設定畫面 |
fig 4 連線失敗 |
運氣好的話就可以看到以下的畫面:
以下為影片教學:
ref:
Program STM32F4 with UART
請問有備份的影片嗎?
回覆刪除https://www.youtube.com/watch?v=boXSdDnHaAE
刪除參考這影片試試。
都不知道原來的影片被移除了, 感謝告知。