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.
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, user_img_pos Is the starting address for storing user data, These two addresses can be defined by oneself, 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, These two addresses are different 0x400, It refers to the definition of two external firmware. Pay attention to the address when needed 4k Integer multiples of. 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