contributed by < hugo0406
>
參考 STM32F429 的 Reference Manual
Boot mode selection pins: BOOT0,BOOT1
CPU reset 後會從這兩根 pin 的狀態來決定哪一塊 memory 當 boot space,STM32F429 選用的 default boot space 是 Main Flash memory
BOOT1 | BOOT0 | Boot Mode | Aliasing |
---|---|---|---|
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 |
Flash memory 的 start address 是 0x08000000
等開機時,會自動將 0x08000000-0x080FFFFF
映射到 0x00000000-0x000FFFFF
,所以將 bin檔燒在 0x08000000
,STM32F429 就可以從 0x00000000
開始執行
Start by plugging the STLINK device into the usb port, then run lsusb
.
There have several files in /lib/udev/rules.d
directory. The 49-stlinkv2.rules
file contains the following:
and the idVendor
of 0483
and idProduct
of 3748
matches the vendor id from the lsusb output.
Verify it by checking the installed version :
stlink
is an open source toolset to program and debug STM32 devices and boards manufactured by STMicroelectronics.To verify the successful installation
st-info
: a programmer and chip information tool
STM32F42I-DISCO 內建 ST-LINK/V2,已經包含 ST-Link 了,所以 USB-mini 插上去後就可以直接燒錄,不需要額外的燒錄器。
參考 嵌入式系統建構:開發運作於STM32的韌體程式 確保能成功將檔案燒錄到開發版上
blink.c
Makefile
blink.ld
執行 make
:
編譯完後會產生 blink.out
及 blink.bin
,將 blink.bin
燒進 flash
燒錄後按 RESET 即可看到 LD3(綠)
、LD4(紅)
開始交替閃爍
詳細內容請參閱核心程式碼目錄下的文件 ./Documentation/kbuild/kconfig-language.rst
make tinyconfig
產生最小的核心,產生的 .config 非常小,不能展示訊息
不能使用 tinyconfig
Menu Config
When I try to menuconfig, but got some error message
libncurses5-dev need
to be installed before compiling the kernel
編譯核心:
編譯完後,可以在核心程式碼目錄下 ./arch/arm/boot/ 看到 xipImage
xip 代表 execute in place :
程式直接在 flash 上執行,而不必搬到 RAM 上,只有 data 搬到 RAM 。可以減少 memory 的使用,但執行速度較慢。
查看 xipImage 大小
xipImage 竟然有 1.8MB,幾乎佔了 Flash 大部分的空間,沒有足夠的空間來存放檔案系統,只能保留最基本的功能,盡量減小核心大小
When the processor is powered on, the memory doesn't hold an operating system, so special software is needed to bring the OS into memory from the media on which it resides. This software is normally a small piece of code called the boot loader.
On a desktop PC, the boot loader resides on the master boot record (MBR) of the hard drive and is executed after the PC's basic input output system (BIOS) performs system initialization tasks.
U-Boot is capable of booting images in two formats:
FIT 是 flattened image tree 的縮寫,類似於 FDT (flattened device tree)。它利用了Device Tree Source files(DTS)的語法,生成的 image 文件也和 dtb 文件類似(稱作 itb)
With U-Boot, "normal" build targets like "zImage" or "bzImage" are not used.
U-Boot supports the following STMP32 MCU SoCs:
The boot chain without SPL(Secondary Program Loader)
defconfig_file:
FSBL | OS |
---|---|
U-boot | Linux |
(Debian based) Depending on the build targets further packages maybe needed :
下載 U-boot 原始碼:
編譯 U-boot:
Filename | Description |
---|---|
u-boot.map | The symbol map |
u-boot | U-Boot executable in ELF binary format |
u-boot.bin | U-Boot raw binary image, which can be written to the boot storage device |
查看 u-boot.bin
大小
燒進 FLASH
STM32 PIN | VCP |
---|---|
PA9 | USART1_TX |
PA10 | USART1_RX |
USB to TTL 接線:
安裝 PUTTY:
查看 PUTTY版本
可以從 官方文件中 得知 Baud Rate 預設為 115200
,UART number 預設為 1
開啟 putty
, 選擇 serial , /dev/ttyUSB0 , Baud rate 選擇 115200
按開發版上的 RESET, 可看見 U-Boot 命令提示如下:
version
-> 顯示目前 U-Boot 版本
bdinfo
-> 顯示目前板子資訊
製作 uImage
git@github.com:fdu/STM32F429I-disco_Buildroot.git