This post was last edited by symic on 2022-4-6 23:57
In the last post, I briefly introduced how to edit and edit programs, but I left a small tail, which was not downloaded to the board. I will make up for it this time.
Before downloading, let me talk about a few small problems I encountered.
1. During compilation, it always prompts that BUILD.gn has illegal signs. After reading it several times, I found that it was because of the use of Tab placeholders in front of output. So I deleted the Tabs in front of all the sections below output. Then the compilation passed.
Previous BUILD.gn. (View using VSCode)
After the modification, there is no indentation.
2. The first compilation process is very long, it is estimated to take several minutes. This is just a small hello world, but I think the next compilation will be much faster.
3. After the compilation is successful, you need to cp the three files to the specified folder. Note that when cpoy, you need to be in the /proj/bearpi-hm_micro_small directory. If you cp in other directories, an error will occur that the file cannot be found.
cp out/bearpi_hm_micro/bearpi_hm_micro/{OHOS_Image.stm32,rootfs_vfat.img,userfs_vfat.img} applications/BearPi/BearPi-HM_Micro/tools/download_img/kernel/
After that, you can smoothly enter the download stage. At this time, the compiled executable file is still in the virtual machine and needs to be copied to the Windows host. Here, RaiDrive is used to map Ubuntu to a drive disk of Windows.
As usual, first turn the three toggle switches on the back to 000, and then use STM32CubeProgrammer to download. The file to be downloaded is transferred to the specified location via cp
Z:\home\bearpi\proj\bearpi-hm_micro_small\applications\BearPi\BearPi-HM_Micro\tools\download_img\kernel
Click + in STM32CubeProgrammer to call the tsv file, which is a fixed burning configuration file. You can see the three compiled files. Then click download to complete the download.
After the download is complete, click disconnect in STM32CubeProgrammer, then turn the toggle switch on the board to 010 (boot from eMMc) and press Reset. Enter the command ./bin/helloworld through XShell to see the result.
To summarize, the complete development and operation process is as follows
1) Create the business source code helloworld.c and the business source code compilation script BUILD.gn
2) Add new components in applications.json and modify the board configuration file in config.json
3) Compile and generate executable files
4)Move the system image file OHOS_Image.stm32, the root file system rootfs_vfat.img, and the user file system userfs_vfat.img to the specified folder
5) Execute ./bin/executable file name