apply W806 How to add a large amount of user data to the firmware end and write it through the download tool flash

Published on 2022-05-09 14: 42: 19

In some usage scenarios, Users have a large amount of data to write in advance flash in, By operating in the application code flash Read and write interfaces to read this data using, This article will demonstrate how to add this data to the sdk Generated W806. fls Firmware end, Then use the download tool to write together flash in. 需要注意的是, user data的长度需要大于 1024 字节, 不够的可以use任意数据补齐, 否则会烧录失败.
Assuming the user data file is user. bin, take user. bin put to SDK catalogue bin/W806 Under the directory. user. bin I casually wrote data in.
image. png

open tools/W806/utilities/aft_build_project. sh file, according to W806 Firmware generation rules for, In every. bin Add a file in front of it header, Generate a. img file, Multiple. img Connecting the files together is the final generation. fls file. So two definitions have been added in the following positions, user_img_header It is user data header Storage address, 这个 header 只stay烧录的时候临时apply, 所以此处use的是内存Address of, 内存的起始地址是 0x20000000, 大小是 288KB, choice任意in间的位置都可以. user_img_pos Is the starting address for storing user data, 这个地址可以自己定义, Please be careful not to overlap with the address where the firmware is running, The starting address for running firmware is run_img_header=0x08010000, Generated after compilation W806. img The file size is the size of the firmware running, The minimum starting address for user data is the sum of the two, Less than this address will overlap, Causing errors.
image. png

Add the following two lines of code to the following code, wm_tool. exe It is a tool used to operate and generate firmware, For details, please refer to wm_tool. c file, Here are only a few parameters used. -b Represents the action to be taken. bin File Path, This is placed in the bin/W806/user. bin, So here also corresponds to this directory, If placed in SDK Under other paths of, Corresponding modifications need to be made here as well. -o Representative generated. img Path and name of the file, Simply place it in the same directory, So still bin/W806/user. -it identification img Type of file, equal to 0 Representing secboot. img, equal to 1 Represents running firmware img, Here we choose the same type as running firmware. -fc Whether to compress or not, choice 0 Uncompressed. -ra Represents the starting address for firmware storage, Select the one defined in the previous step user_img_pos. -ih formulation header Address of, Select the one defined in the previous step user_img_header. Other parameters are temporarily unavailable, Without explanation.
The next line of code will be generated. img Splicing files to generate. fls file. You can see that the original code only changed the secboot. img and W806. img Join together, Generated W806. fls. So in the W806. img Add after user. img parameter. Save after modification is completed.
image. png

To test for success, stay main. c Add the test code as follows, call flash Read interface HAL_FLASH_Read Read the user data start address just defined 0x08080400 Location data, See if it matches user. bin The content is consistent.
image. png

Compile the project again, Generate firmware, You can see that in the/bin/W806 Under the directory, Generated user. img file.
image. png

Download firmware, Using Upgrade Tools V1. 4. 19 version, You can see that during the download process, I downloaded a total of three. img file, The printed data is also consistent with user. bin The data in is one样的.
image. png

如果stay修改应use代码过程in担心固件and数据地址有重叠而不知道, 可以stay sdk 的 ld/W806/gcc_csky. ld filein修改运行区固件的大小, 这样如果固件超范围到了数据区地址, 会编译报错, 可以重新划分数据起始地址向后移动.
image. png

1 条评论

release
problem