tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
15.25k stars 900 forks source link

bootloader jump to APP, #4473

Open shanzhuknn opened 2 weeks ago

shanzhuknn commented 2 weeks ago

Hi, folks:

I'm working with an STM32F103 development board and using TinyGo to implement both a bootloader and an app. I want to flash these two programs onto the board: one is the bootloader and the other is the app.

The bootloader's flash start address is 0x08000000. The app's flash start address is 0x08002800. //----------------------------------------------------- Bootloader stm32.ld settings are as follows:

MEMORY
{
FLASH_TEXT (rw) : ORIGIN = 0x08000000, LENGTH = 24K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
}

_stack_size = 2K;

INCLUDE "targets/arm.ld" //------------------------------------------------------ App stm32.ld settings are as follows:

MEMORY
{
FLASH_TEXT (rw) : ORIGIN = 0x08002800, LENGTH = 24K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
}

_stack_size = 2K;

INCLUDE "targets/arm.ld" I want the bootloader to jump to the app, where the app will output information via println() and simultaneously turn on an LED. Currently, the jump to the app is successful. boot

However, if I don't set the SCB.VTOR (Vector Table Offset Register) address, I encounter the following error: fatal error: illegal use of the EPSR with sp=0x200007d4 pc=0x0800094b

When I try to set the SCB.VTOR address in the run method of the runtime/schedule.go file, the program gets stuck in the initAll() function and doesn't respond. The code for setting the SCB.VTOR address is as follows: jumapp

[Code not provided directly in the original message]

vtor

Help: Has anyone successfully implemented a bootloader jumping to an app using the TinyGo framework and had it work correctly? I would greatly appreciate any advice or guidance.

Thanks!