# Flash Burning
You can program the flash of the module through a variety of methods, and burn the firmware with specific functions.
The application scenarios and restrictions of various burning methods are as follows:
Method | Interface | Pin | Status | Preparation |
Simulation Debugger | SWD | PA27,PB3 |
- | Development environment and JTAG debugger |
Serial port download mode | UART0/UART1 | PA7,PA8 | PA7: 0 Low Level | Image Tool burning software |
BAT Burning System | SWD | PA27,PB3 | - | BAT Accounts and tools |
Note: PA7 power on default high level
The application scenarios of each burning method are as follows:
- Simulation debugger: burning in the development and debugging phase of the module.
- Serial port download mode: batch burning modules on the production line.
- BAT burning system: burn the module twice on the production line of the module or product, and it can be used to burn the unique ID of the equipment.
To sum up, it is recommended that PA7, PA8, PA27 and PB3 be introduced on the user's motherboard as the burning test points to facilitate development and production.
#Burning with Simulation Debugger
When using the MXOS system to develop module firmware, you can directly burn the generated firmware to the module through the compilation command in the development environment. Please refer to relevant documents for the construction of MXOS development environment. The hardware emulator usually selects JLink, and the connection method is shown in the figure:
Add the download parameter to the compile command to download the currently compiled firmware. Because the development environment needs to be installed, it is not suitable for batch factory burning of modules.
For example, compile the Helloworld application and execute the command:
mdev build -c app emc3280
Command running result:
Making config file for first time processing components: helloworld emc3280 MXOS …… Downloading applcation, size: 443512 bytes... #################################################################################################################################################################################################################### 100% 433 KiB 8.0 KiB/s 18 s Build complete Making .gdbinit Making .openocd_cfg
If the preburn bootloader of module is broken,it is needed to add 'total' in compile parameter to reburn bootloader.
mxos make helloworld@emc3380 total download
#Burn in serial port download mode
- Connect the hardware as shown below. After grounding PA7, power on or reset the module. Then release PA7 to enter the serial port download mode.
Schematic Diagram of Serial Port Download Mode Connection
If you use the MXKIT series evaluation board provided by MXCHIP, the BOOT0 signal on the Arduino interface on the MXKIT-BASE board is grounded. After reset, cancel grounding.
<img width="361" alt="" src="/img/1585743834662-6f7454d4-62e4-4142-bd9d-a67019c169a2.png"></img>
- Open burning software: image tool,Chip select AmebaD(8721D).📎Image_Tool.7z
- In the Flash Download block, select the binary file to download to the corresponding address.
- If the compilation tool provided by MXCHIP is used, the file xxxx@emc328x.all.bin will be generated and the corresponding download address is 0x08000000.
- If other compilation tools are used, you need query the relevant settings of the compilation system. Usually the file "km0_ boot_ all.bin" will be generated and the download address is 0x08000000.
And the file "km4_ boot_ all. bin" should be downloaded to 0x08004000; the file "km0_ km4_ Image2.bin" should be downloaded to 0x08,006,000.
- Click "Download" button and finish download.
Note: If the download fails, try setting Baudrate to 500,000 or less.
Image Tool Picture
#BAT Burning System
BAT is a production tool for factory batch burning launched by MXCHIP. It can not only burn firmware, but also burn unique ID for each module, such as cloud service verification code, security key, certificate, token, etc.
BAT system adopts server client architecture. Firmware and ID can be imported in batches on the server to create production tasks and uniformly manage the production system. The client synchronizes production tasks from the server, and one client can burn four modules at the same time. The client can also interface with the automatic systems such as the feeding machine and the mechanical arm to achieve fully automatic production.
For the usage of the BAT system, please refer to the relevant usage documents of the BAT system. EMC328x module interacts with BAT system through SWD interface. The following is the application block diagram of BAT system:
BAT Burning System
——————————————————————————————————————————————
End.