用keil建全新的project寫了空白的main函數后編譯報錯(sct(7): error: L6236E:和axf: Error: L6218E:)


編譯報錯

.\Objects\LED-GPIO.sct(7): error: L6236E: No section matches selector - no section to be FIRST/LAST.
Not enough information to list image symbols.
Not enough information to list load addresses in the image map.

 

由於沒有加啟動文件,雙擊左邊工程框的文件夾,添加Startup開頭的.s文件即可。若keil生成的里沒有,可以用一個能編譯通過的例程序(根據你的MDK確定的),拷貝工程中的“***.s”文件加到自己的工程目錄中。

 

編譯再次報錯

.\Objects\LED-GPIO.axf: Error: L6218E: Undefined symbol SystemInit (referred from startup_stm32f103xb.o).
Not enough information to list image symbols.
Not enough information to list load addresses in the image map.
Finished: 2 information, 0 warning and 1 error messages.

是這段代碼中調用了SystemInit 但未聲明

; Reset handler
Reset_Handler    PROC
                 EXPORT  Reset_Handler             [WEAK]
     IMPORT  __main
     IMPORT  SystemInit
                 LDR     R0, =SystemInit
                 BLX     R0
                 LDR     R0, =__main
                 BX      R0
                 ENDP

第一種:在工程當中任意一個C文件中加入SystemInit函數的定義,定義為空函數就可以正常編譯。

void SystemInit()
{
    //do nothing 
}

第二種:注釋掉(匯編程序,注釋用 “;”)

Reset_Handler   PROC
                EXPORT  Reset_Handler             [WEAK]
                IMPORT  __main
;               IMPORT  SystemInit
;               LDR     R0, =SystemInit
;               BLX     R0               
                LDR     R0, =__main
                BX      R0
                ENDP

 

*啟動文件添加路徑

 

 

 

 

 

 

 

 

 

 

 


 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM