The algorithm is written! TKM32F499 can finally be downloaded directly using JLINK, with the algorithm file attached

Content

Reply: 35

打印 上一主题 下一主题

出0入143tangyuan

This post was last edited by tiky on 2020-11-18 14:52 TKM32F499 was not intended to rely on any downloader during design, but after it was made, it was found that everyone has an infinite fascination with JLINK, ST-LINK, ARM-OB, DAP download simulation, and we cannot escape the ST ecosystem. Engineers originally wanted to take a shortcut, but found it more troublesome. Unable to bear it, today the download algorithm has been sorted out and is now released for everyone to choose. Currently, TK499 supports two download methods: 1. USB direct download; 2. Download using various simulation downloaders such as JLINK, ST-LINK, ARM-OB, DAP, etc.

Two methods have their own advantages: USB is a dedicated download method for TK499, with very fast speed, not relying on a downloader. When you send something to a customer, if you need to change something, you don't need to look for a serial port everywhere, or open any upper computer. Just use a USB directly; If you use JLINK for downloading, it is more convenient for development, download simulation, one-step process, no need to repeatedly press the reset and power-on buttons. JLINK has a reset command, directly one-step process, more convenient for development.

Due to the way KEIL downloads, it sends packages to the microcontroller one by one, so TK499 does not know the program length to be downloaded. It can only use a simple method, such as calculating the program length by accumulation. Additionally, KEIL resets the MCU once for erasing, programming, and verification, so global variables cannot be used. Originally, there could have been a simple method, but in the end, it had to rely on using QSPI FLASH as temporary memory, making the download algorithm somewhat complex. Does anyone know of a simple method to obtain the program length during KEIL download or where to set a flag indicating the last package?

Download the algorithm file, unzip it, place it in the KEIL directory \ARM\Flash, then after opening all projects, you can see the chip download algorithm of TKM32F499GT8 in the download settings.

TKM32F499GT8.rar (67.56 KB)

Then select the download method and choose to download using the emulator

In the download settings, select as shown in the following figure

注意:1、不要选择全片擦除,因为QSPI FLASH上还有其它数据 及 Bootloader,如果都擦除了又得重新下载一次;2、有的工程PA14及PA15仿真下载口已经被占用作普通GPIO了,要记得不要占用下载仿真口;如果你不小心下载了一个下载口已经被占用的程序,那你再也不能用仿真器下载了,解锁方法很简单:1:按住PA1或者PA13,令芯片一上电就进入下载模式,相当于解锁了;2、按住复位不放,在KEIL上点下载,待下载开始后,迅速松开复位,也能解锁(这个方法放也可以用于ST及其它一些国产ARM的cortex-M核的芯片解锁,全是ARM的东西,全系列兼容 );3、或者干脆用USB随便下载一个PA14及PA15仿真口没被占用的程序也能解锁。招数比ST系列的多,爱用哪样用哪样;

Finally, provide a well-configured project that can be simulated and downloaded using JLINK for everyone's reference. In fact, the setup is very simple, usually just set it up by yourself.

1、TK499_GPIO.rar (282.9 KB)

Do you know what a god is? In fact, gods were originally humans, but they did things that humans couldn't do, so they became gods. (Initial D, Shawn Yue)

Out0In143Tangyuan

 楼主| 发表于 2020-11-18 18:16:45 | 只看该作者

again Posted on 2020-11-18 14:58
Just directly add firmware information after the interrupt vector table.

      Looks like a good method, is there any reference documentation? I'll ask the engineer to give it a try.

Now I find that there is relatively little information available on compilers. Currently, the download algorithm provided by KEIL is based on a sector size of 4KB. Such a small sector is no longer suitable for the large-capacity TK499. It needs to be changed to a sector size of 64KB. However, I encountered a problem. I am not sure if it is due to insufficient JLINK buffer or if there is an issue with a file in the compiler. I have not been successful yet. If successful, the download speed should increase.

出0入0Tangyuan

发表于 2020-11-22 10:22:20 | 只看该作者

When downloading with KEIL, the program is sent to the microcontroller package by package, so TK499 does not know the program length to be downloaded. It can only use a cumbersome method, calculating the program length by accumulation. Additionally, KEIL resets the MCU once for erasing, programming, and verification, so global variables cannot be used. Originally, there was a simple method available, but in the end, it had to rely on using QSPI FLASH as temporary memory, making the download algorithm somewhat complex.

Your chip is an external SPI FLASH, theoretically there should be no difference between H750 or some external FLASH XIP CM4/7, those chips have open-source download algorithm files, theoretically should be modified to work, no need to consider length, sector size, reset and other things. For example, the popular H750 now also uses the same SPI FLASH.

出0入143tangyuan

 楼主| 发表于 2020-11-22 16:58:30 | 只看该作者

      I looked at H750, and couldn't find a breakthrough. When it comes to function parameters, it's all about: address, the size of a packet, and the buffer of that packet (unsigned long adr, unsigned long sz, unsigned char uf), KEIL must know the length of the program to download, but you have to ask KEIL to tell you. When you download, it's KEIL that sends the data to JLINK. The big KEIL boss who sends the packet doesn't know if this length is distributed. It is unknown if there are any other APIs. The direction provided by the user again on the 4th floor is also a direction, directly explaining the first packet sent by KEIL, which should contain length information.

Out0In143Tangyuan

 楼主| 发表于 2020-12-8 11:01:54 | 只看该作者

First, don't mess with downloading anything, see if you can read the kernel; To ensure that the emulation port is not set as a regular GPIO, you can download a simple program from the evaluation board's data set post and burn it in with USB first. If you run a program that disables the emulation port on your chip, you won't be able to connect.

Summary
The article discusses the development of a download algorithm for the TKM32F499 microcontroller, which initially did not rely on downloaders but later incorporated support for JLINK, ST-LINK, ARM-OB, DAP download and simulation tools. The TK499 now supports USB direct download and various simulation downloaders. The article explains the advantages of each method and provides a download algorithm file for KEIL software. It also gives instructions on setting up the download algorithm and warns against erasing QSPI FLASH data unnecessarily. Additionally, it provides tips for unlocking the device if a download port is accidentally occupied. The article concludes with a sample project for JLINK simulation download and discusses the challenges faced in modifying the sector size for larger capacity TK499 devices. The author seeks advice on improving download speed and mentions the scarcity of resources in the field of compilers.