This post was last edited by ljj3166 on 2018-9-12 22:24 In the planning of logickids, the FLASH area of F350 needs to be divided. The more important ones are divided into boot area and app area. The boot area is used to upgrade the firmware of F350. The app area is used to parse the script data, which is the jump of FLASH. Today I tried to make a simple partition of F350. Basically, the operation of STM32F1 series can be copied and used directly. Let's take a look at the workspace project [attach] 375479 [/attach] Flash partition of Boot code project [attach] 375480 [/attach] The starting address is 0x8000000. 5000H space and 20kB Flash partition of APP code project [attach] 375481 [/attach] The starting address is 0x8005000 0x08005000 //Application entry address uint32_t JumpAddress = 0; pFunction Jump_To_Application = 0; //Application address pointer volatile bool jump_flag = false, flash_flag = false; void SYSRESET(void) {__disable_fault_irq(); NVIC_SystemReset();} void go_app(void) { uint32_t ApplicationAddress=0; ApplicationAddress = AppAddress; if (((*(volatile uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)//Judge whether the Flash data is legal or not { debug("go app code...\r\n"); OLED_ShowString(5,1,"Go Application...",16); delay_1ms(1000); //Various deinit and disable IRQ, prepare to jump usart_deinit(USART0); usart_deinit(USART1); i2c_deinit(I2C0); spi_i2s_deinit(SPI1); rcu_deinit(); __disable_irq() ; __disable_fault_irq(); nvic_vector_table_set(NVIC_VECTTAB_FLASH, 0x5000); //Address mapping JumpAddress = *(volatile uint32_t*)(ApplicationAddress + 4); Jump_To_Application = (pFunction)JumpAddress; __set_MSP(*(volatile uint32_t*)ApplicationAddress); //Initialize stack pointer Jump_To_Application(); } else { debug("no app in board,please download....\r\n"); OLED_ShowString(15,1,"NO Firmware...",16); while(1); } }[/code] The key is AppAddress, which is the starting address of the app program. Then define a program pointer typedef void (*pFunction)(void); pFunction Jump_To_Application = 0; When Jump_To_Application points to this address, the Flash jump occurs. There is a more important action-the software restart instruction void SYSRESET(void) {__disable_fault_irq(); NVIC_SystemReset();} Finally, the most important address mapping is provided in the GD library. The nvic_vector_table_set function is very convenient to handle. At least there is no need to copy the interrupt vectors one by one. After it is executed, the F350 will be restarted. The basic jump process is commented in the code. Let's take a look at the processing in the app
Disable IRQ Deinit all peripherals initialized in boot, including the clock, and then enable IRQ Then call SystemInit In fact, SystemInit has been called before the main function of the boot code. It is called here because Logickids has two restart methods. One is a single board restart, which is equivalent to powering on again and entering the app from boot. The other is an app restart, which only restarts the code in the APP area. The current method is to set the relevant variables used by the app to zero and then directly call main to complete the restart of the app. So SystemInit is called again here. The previous animated picture
Power on and enter boot, display the logickids logo Display booting, display entering app In the boot code, mcu_led flashes quickly Next enter the app, hardware detection, display hardware check Then read the script data of the external Flash, if not, display NO APP DATA In the app code, mcu_led is blinking slowly As top
I feel that this project is very challenging to do alone! I thought that mBlock was like embedding Arduino into MIT's scratch, but I don't know how this one is embedded. It would be great if Energia could also be embedded into scratch.
Details
Published on 2018-9-13 10:39
I think it is very challenging to complete this project by myself! I thought mBlock is like embedding Arduino into MIT's scratch, but I don't know how to embed it. It would be great if Energia can also be embedded into scratch.
Details
Published on 2018-9-13 10:39
I feel that this project is very challenging to do alone! I thought that mBlock was like embedding Arduino into MIT's scratch, but I don't know how this one is embedded. It would be great if Energia could also be embedded into scratch.
It is a bit big. In fact, it is completely separated from the programming of the single-chip chicken. Instead, it uses the single-chip chicken to parse some commands and data that you have formulated.
Details
Published on 2018-9-14 09:38
Blue Rain Night posted on 2018-9-13 10:39 I feel that this project is very challenging to do alone! I thought that mBlock was like embedding Arduino into MIT's scratch, but I don't know if this...
is a bit big. In fact, it is completely separated from the programming of the single-chip chicken. Instead, it uses the single-chip chicken to parse some commands and data that you have formulated yourself.