6164 views|6 replies

3414

Posts

0

Resources
The OP
 

【GD32F350 LogicKids】Flash jump [Copy link]

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
  1. void VectorTabs_setup(void) { __disable_irq() ; __disable_fault_irq(); usart_deinit(USART0); usart_deinit(USART1); i2c_deinit(I2C0); i2c_deinit(I2C1); spi_i2s_deinit(SPI1); spi_i2s_deinit(SPI0); rcu_deinit(); nvic_vector_table_set(NVIC_VECTTAB_FLASH,0x5000); __enable_irq(); __enable_fault_irq(); SystemInit(); }
复制代码
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

1.jpg (33.96 KB, downloads: 0)

1.jpg

2.jpg (69.98 KB, downloads: 0)

2.jpg

3.jpg (70.06 KB, downloads: 0)

3.jpg
This post is from GD32 MCU

Latest reply

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
Personal signature

So TM what......?

 


5303

Posts

454

Resources
2
 
Please note that the RAM is only 16k. I recently encountered strange problems when making GUI.
This post is from GD32 MCU

Comments

It’s a little bit small, but I don’t usually use it for drawing, so it’s basically enough for my sofa…  Details Published on 2018-9-12 22:27
 
 
 

3414

Posts

0

Resources
3
 
Blue Rain Night posted on 2018-9-12 22:19 Please note that the RAM is only 16k. I encountered strange problems when I was doing GUI recently.
It is a bit small, but I don’t usually refresh the picture, so it is basically enough for my sofa...
This post is from GD32 MCU
 
Personal signature

So TM what......?

 

 

5303

Posts

454

Resources
4
 
How do you do it on the host computer?
This post is from GD32 MCU

Comments

Java + as for mobile phones, c + koutai for PCs  Details Published on 2018-9-13 10:12
 
 
 

3414

Posts

0

Resources
5
 
Blue Rain Night posted on 2018-9-13 08:23 How do you make the host computer?
Java + as is used on the mobile terminal, and c + koutai is used on the PC terminal.
This post is from GD32 MCU

Comments

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
 
 
 

5303

Posts

454

Resources
6
 
ljj3166 posted on 2018-9-13 10:12 Java + as is used on the mobile phone, c艹 + koutai is used on the PC
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.
This post is from GD32 MCU

Comments

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
 
 
 

3414

Posts

0

Resources
7
 
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.
This post is from GD32 MCU
 
Personal signature

So TM what......?

 

 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list