. Net micro framework porting BASICS (package compilation passed)

Source: Internet
Author: User
Tags jlink

On the occasion of Sparta, we were broadcasting live on QQ Group 1600838 today.MfPreparations for the migration environment. You can ask questions about migration at any time!
If you have any questions about the items before MF transplantation, please refer to the top posts on the forum.. Net micro framework navigation stickers (for beginners)

Hardware:*DevelopmentBoard, learning board, core board ......

Software Environment:
System: Win7 x86 OthersI'm not sure I can do it. Both of them are win7x86, so do WINXP. The impact on the operating system should not be big!
http://msdn.itellyou.cn/
development: Visual Studio 2010 C # /C ++ must be installed with VC ++, many people may only have C #, which is not acceptable. Vs2008 is said to be acceptable, while vs2012 never tried.
http://msdn.itellyou.cn/
ed2k: // | file | found | 2685982720 | 4ae6228933dde49d9bfa4c0000c831c2 |/
assembly: Keil MDK 4.54 is used for compiling the firmware of a single chip microcomputer. I used to use 4.12, and then upgraded to 4.54. I'm not sure if 4.12/4.50 is OK. It is said that the probability of 4.54 success is higher than 4.12
Http://pan.baidu.com/share/link? Consumer id = 109154 & UK = 2432978109
Http://www.kuaipan.cn/file/id_2378544298640124.htm
Harmony packageHttp://www.kuaipan.cn/file/id_2378544298617835.htm

. Net micro framework porting kit 4.2 (RTM qfe2)
(We call itMfpk422)
Http://netmf.codeplex.com/releases/view/91594
Http://pan.baidu.com/share/link? Consumer id = 109166 & UK = 2432978109

In addition, you need an advanced text editor.Notepad ++!
We strongly recommend that you install mfpk toSSDOn !!! (For this reason, I bought Samsung 64 GB and 419 RMB)

I. Installation
Install the Keil MDK in c: \ Keil.We need to use c: \ Keil \ arm. If it is not in this position, I will use win7 to establish a soft link or modify the compilation script later. I am not responsible for this!
YourselfOtherwise, you will be responsible for compilation errors.. (Today, someone makes a mistake. If you change the mfpk or MDK, more than two hundred errors are reported)
Install mfpk to c: \ PK or E: \ MF \ PK.

Ii. Compile scripts
MeThe compilation was made into a double-click available batch processing script, which is a little different from other people's, and everyone should follow my work.
We recommend that you create your own SVN, host the entire PK directory, and record each modification history.!
1. There is a setenv_mdk.cmd under the PK root directory. If not, createIf the installation directory of Keil is incorrect, modify it here., The entire file is in these two lines!

@ Echo off

Setenv_base.cmd MDK port % * c: \ Keil \ arm


2. Modify setenv_base.cmd in the root directory.
In 14 rows, add a compiler MDK, because it is too tired to write mdk4.12 and so on, it is not convenient to upgrade MDK

: Error
@ Echo.
@ Echo error: invalid arguments!
@ Echo.
@ Echo usage: setenv_base compiler_tool_version
@ Echo
Where compiler_tool_version is adi5.0, gcc4.2, ads1.2, rvds3.0,
Rvds3.1, rvds4.0, rvds4.1, mdk3.1, mdk3.80a, mdk4.12, mdk4.13, MDK,Shc9.2, vs9, vs10
@ Echo.

About 89 lines. Add the MDK compiler.

If/I "% compiler_tool_version %" = "adi5.0" Call: set_blackfin_vars
If/I "% compiler_tool_version %" = "gcc4.2" call: set_gcc_vars
If/I "% compiler_tool_version %" = "mdk3.1" Call: set_mdk_vars
If/I "% compiler_tool_version %" = "mdk3.80a" call: set_mdk_vars
If/I "% compiler_tool_version %" = "mdk4.12" Call: set_mdk_vars
If/I "% compiler_tool_version %" = "mdk4.13" call: set_mdk_vars
If/I "% compiler_tool_version %" = "MDK" call: set_mdk_vars

3. In the solutions directory, compilation solutions for different boards . To facilitate compilation, we put a compile the batch processing script, which is common, you can copy data to different directories.
here, > stamp as an example, path: e: \ MF \ PK \ solutions \ Stm32stamp \ Release_flash.bat

: @ Echo off
: Set some parameters
Set x_flavor = release
Set x_memory = flash
Set x_root = ..\..\

: First try to get the current directory name as the solution name

For % I in ("% Cd %") do set x_name = % ~ Ni

Title: Compile MF solution [% x_name %] [% x_flavor %] [% x_memory %]

Pushd % x_root %
Call setenv_mdk.cmd
Popd

Call msbuild dotnetmf. proj/T: build/P: flavor = % x_flavor %; Memory = % x_memory %
:> Build. Log

Echo compiled

: Copybin
: Copy the generated file.
Set x_buildout = % x_root % buildoutput \ thumb2 \ % compiler_tool_version % \ Le \ % x_memory % \ % x_flavor % \ % x_name % \ bin
If
Not Exist % x_buildout % set
X_buildout = % x_root % buildoutput \ thumb2fp \ % compiler_tool_version % \ Le \ % x_memory % \ % x_flavor % \ % x_name % \ bin
Set x_bindir = % x_root % .. \ mfbin \ % x_name %

If not exist % x_bindir % MD % x_bindir %
: Copy tinybooter. Bin
Copy % x_buildout % \ *. Bin % x_bindir % \/y
Copy % x_buildout % \ *. axf % x_bindir % \/y

Del % x_buildout % \ *. bin/f/Q
Del % x_buildout % \ *. axf/f/Q

: Copy er_flash and er_config
Set x_buildout = % x_buildout % \ tinyclr. Bin
Copy % x_buildout % \ *. * % x_bindir % \/y
Copy % x_bindir % \ er_flash % x_bindir % \ tinyclr. bin/y

Del % x_bindir % \ er_flash/f/Q

Echo output copied to % x_bindir % \

Pause

After compilation, the output is assigned to the E: \ MF \ mfbin directory. The mfbin directory is side by side with the PK!

4. Since we have added an MDK compiler, We have to modify it.
Mfpk uses the msbuild compiling system, so we need to modify E: \ MF \ PK \ tools \ targets \ microsoft.spot.system.mdk.tar gets, About 40 rows added

 <CC condition = "'$ (compiler_tool_version)' = 'mdk'"> "$ (mdk_tool_path) \ bin40 \ armcc.exe" </CC> 
<CPP condition = "'$ (compiler_tool_version)' = 'mdk'"> "$ (mdk_tool_path) \ bin40 \ armcc.exe" </CPP>
<As condition = "'$ (compiler_tool_version)' = 'mdk'"> "$ (mdk_tool_path) \ bin40 \ armasm.exe" </As>
<Link condition = "'$ (compiler_tool_version)' = 'mdk'"> "$ (mdk_tool_path) \ bin40 \ armlink.exe" </link>
<Ar condition = "'$ (compiler_tool_version)' = 'mdk'"> "$ (mdk_tool_path) \ bin40 \ armar.exe" </Ar>
<Fromelf condition = "'$ (compiler_tool_version)' = 'mdk'"> "$ (mdk_tool_path) \ bin40 \ fromelf.exe" </fromelf>

If the script is not correct, download the ready-made script! Released two months ago, may not apply to mf4.2 (RTM qfe2) And later versions!
. Net micro framework port the compilation script

Iii. Compilation
That's right. You can compile it here!Double-click Stm32stamp Release_flash.bat in, compilation starts. !
The output directory is E: \ MF \ PK \ buildoutput.
The first compilation,It takes a very long time. Traditional SATA takes more than half an hour and SSD takes more than 20 minutes.
Compile laterIt takes 5 to 10 minutes for SATA and two to three minutes for SSD.
Then,During the first compilation, there will basically be errors. You don't need to worry about it. Then, you can compile it several times until there are no errors or the number of errors remains constant.!
In this step, various problems may occur. As long as we locate the problem, we can use the corresponding tactics to deal with it!
For details about the compilation script, see:
. Net micro framework port the compilation script

In order to keep it as much as possible, I use SVNCodeUpdate to 20May 1!
Also deleted the output directory buildoutput!
I'm lucky,Compilation successful once This indicates that the first step of MF transplantation has been completed. !

In the E: \ MF \ mfbin \ mongostamp directory, we have seen a 241KB tinyclr. bin. This is the MF firmware we need!
Click it to test it!With jlinkIf you use jlink, use the serial port. General development board brush tutorial
Connect to the serial port and power on, Boot, the start information of MF is displayed in the serial port software:

The startup information indicates that step 2 of MF porting has been completed.! The rest is refined!

Iv. compilation principles
Understanding the compilation principles is more conducive to our porting work.
1. The entire mfpk compilation system adopts msbuild, so Visual StudioAnd. Net 4.0 are essential! (The msbuild command is called in the script above)
2. Microsoft . sp OT. System .mdk.tar gets is in msbuild format. If you are interested, take a look at it;
3. Each MF solution is a project proj, which introduces other projects;
4. Compile a in this solution, other projects are compiled based on the sequence and reference relationship. This is similar to compiling with C # project references. it takes a long time to compile all the projects for the first compilation. Later, you only need to compile the modified project, so it will be much faster;
5, targets specify How to compile each project to generate an OBJ file, here, we naturally call MDK to compile ;< br> 6. Most of the MF source code is compiled by C ++. In the project file, the header file is more important than Source Code , there are a lot of directory references, which will definitely make you dizzy. References between C ++ projects are implemented by referencing header files, different from C # projects only need to reference the project or Program set , therefore, the directory structure is very important.
7. msbuild creates a process for the source code of each project. A waste of time ( frequent process creation), but it is very safe and does not interfere with each other;

5. Error Correction
errors are inevitable, however, msbuild is compiled one by one for each project. Even if a project fails to be compiled, it will continue to be compiled. The screen is rolled too fast. WE there is no chance to view the detailed error! Then it finally reports the number of errors, probably where the error is, and it is almost difficult to know the details of the error , This is the biggest difficulty for MF transplantation !
in the preceding compilation script, the msbuild line is followed by a comment, the result of msbuild is output to a log file build. log. After compilation, we can use the Text Editor open and search for the keyword "error" , generally, there is a detailed error message!
of course, specific code errors can only be attributed to the skill of each person! We welcome to exchange various common non-code errors !

Common Errors:
1, noHarmonious MDK.A newbie directly reports hundreds of errors, most of which are those;
2. VC ++ 2010, MDK 4.54, and mfpk 4. 2 (RTM qfe2) These versions are incorrect;
3. The fragment file is missing. For example, manyNo tinyclr for the project\ Scatterfile_tinyclr_mdk.xml file;

 

I have been busy for one day and modified 30 or 40 times before and after the end of this article!

If you like the. NET micro framework and are interested in C # single chip microcomputer and IOT and industrial and agricultural automation, MF will be a good choice!

Mf is an open-source Microsoft Project.Independent porting capabilitiesIn concert with the market40 ~ 300rmbYou can go further!


End.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.