Another way to VxWorks application loading

Source: Internet
Author: User

Now in our work, the application is usually linked with the BSP, and then the vxworks_rom.bin is burned to the team. After the BSP is started, the application's function is called.

However, there is a problem, that is, the application and BSP are too tightly combined. The BSP developer will have to give the BSP code to the application developer, or the application developer will have to send the. A file compiled by the application to the BSP developer to complete the program upgrade.

So the following approach is what I've done these two days, a way to isolate the application and BSP development. Just start by agreeing on the interface to be good. Not very mature yet, I have not formally used it in the project, but I believe it is a good choice.

First, to create a filesystem, the Tffs file system is available. Disk size as long as you can put the next application compiled file is good. This step will not repeat.

Then, add the code to download the application module and start the interface program in the Usrapp of the BSP project. The following is the main explanation of this step, the code is as follows:

#include "loadLib.h"
#include "stdio.h"
#include "taskLib.h"
#include "ioLib.h"
 
extern symtab_id SYSSYMTBL;
void Usrappinit (void)
    {
#ifdef user_appl_init
 user_appl_init;  /* For backwards compatibility */
#endif
 funcptr taskentry=null;
 Sym_type *ptype;
 Intfd=open ("/tffs0/appproj.out", o_rdonly,0);
 if (fd==null)
 {
 printf ("/nopen project fail. /n ");
 return;
 }
 if (LoadModule (fd,load_all_symbols) ==error)
 {
 printf ("/nload module fail.../n");
 return;
 }
 if (Symfindbyname (SYSSYMTBL, "Appentry", (char* *) &taskentry,ptype) ==error)
 {
 printf ("/nfind symbol fail.../n ");
 return;
 }
      Taskspawn ("entry", 100,0,1024,taskentry,0,0,0,0,0,0,0,0,0,0);
 
   /* Add Application specific code here * *
 }
 


The main code. As long as the application compiles the upgraded project into an. out file, upload it to disk/tffs0. Of course, the application's entry function Appentry cannot be changed.

Finally, if this code runs, you may encounter some problems:

1.loadMoudle failure, error relocation value doesnot fit in bits. This is because the function's position in memory exceeds the maximum distance of the jump (the general jump instruction is 24bit,32m). To solve this problem, proceed as follows:

In the Application project, select "Builds", "Default", "C/c++complier", add-mlongcall (GUN) or-xcode-absolute-far (Diab), click OK.

Upload this compiled. Out file to the file system.

2.symFindByName failed. This may be because the application project is a CPP file, which is a C + + file. C + + compiled files, symbol table entry and C are different, so can not find. For example, the same entry (Void,int) function, C compiled out is entry, and C + + may be entry_fvi, this is different because of different compilers. There are two ways to solve this problem:

(1). The file where the entry function is located, do not use CPP files, all use C files instead.

(2) The entry function in the. cpp file is contained in external "C" {}.

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.