1 / 62

Transitioning Device Software from Kernel Space to Multiple Real Time Processes

Transitioning Device Software from Kernel Space to Multiple Real Time Processes. Migrate VxWorks 5.x projects into VxWorks 6.x and gain access for the latest Wind River DSO technologies. The demo Use Case. Producer . Consumer . tProducer. send. receive. tConsumer. msgData. allocate.

jaimie
Download Presentation

Transitioning Device Software from Kernel Space to Multiple Real Time Processes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Transitioning Device Software from Kernel Space to Multiple Real Time Processes Migrate VxWorks 5.x projects into VxWorks 6.x and gain access for the latest Wind River DSO technologies

  2. The demo Use Case Producer Consumer tProducer send receive tConsumer msgData allocate fill print free Message Queue struct SinVal struct SinVal This training is based on the simple producer-consumer example - running 2 tasks: Producer - a task that constantly creates data, including a sine value. The data gets allocated on the heap and sent via message queue. Consumer - a task that fetches the data from the producer and “consumes” it. It will print feedback to the shell and it will free the memory allocated for this data package. NOTE:The demo code comes with errors - that it includes a memory leakage and a non-performant code piece. There is also a bug that prevents the consumer from displaying correct data. You will use tools in Wind River Workbench to show where these problems are.

  3. Import code into Downloadable Kernel ModuleDownloadable Kernel Module Note: DKM stands for Download Kernel Module. • This is the well known OUT-File from VxWorks 5.5 • Select File > New > VxWorksDownloadable Kernel Module Project from the menu bar of Wind River Workbench • The New Downloadable Kernel Module Project wizard appears: • Specify the name of the new project: ProdConsDemo • Click Next

  4. Import code into Downloadable Kernel ModuleDownloadable Kernel Module • In the Project Structure dialog make sure no boxes are checked in the Referenced subprojects pane. • Click Next

  5. Import code into Downloadable Kernel ModuleDownloadable Kernel Module • On the Build Setup and Defaults dialog, make sure Standard is selected. • Click Next

  6. Import code into Downloadable Kernel ModuleDownloadable Kernel Module • Leave the Build Support dialog as it is. • Click Next

  7. Import code into Downloadable Kernel ModuleDownloadable Kernel Module • On the Build Specs dialogselect PPC32gnu as Active build spec. You might want to deselect all build rules first and then select just the PPC32gnu • Click Finish

  8. Import code into Downloadable Kernel ModuleDownloadable Kernel Module • Finally you see the new DKM project in the Project Navigator view:

  9. Import code into Downloadable Kernel ModuleDownloadable Kernel Module • This is finally the stage where we migrate (import) our source code into VxWorks 6.3 • As the DKM project is an empty framework, we now go and import the source code. • Select Import from the context menu of the new DKM project in the Project Navigator view • The Import wizard appears. • On the Select dialog: Select File System • Click Next

  10. In the File system dialog, click Browse The Import from directory dialog appears:NavigatetoC:\vx5-to-vx6\chapter3\wrwb_demo\prodconsdemo\kernel_module Click OK Import code into Downloadable Kernel ModuleDownloadable Kernel Module

  11. Import code into Downloadable Kernel ModuleDownloadable Kernel Module • Back in the File system dialog, click the box on the left pane to select the folder “kernel_module” • Click Finish

  12. Import code into Downloadable Kernel ModuleDownloadable Kernel Module • Finally open the ProdConsDemo project folder in the Project Navigator view to see the project contents:

  13. Import code into Downloadable Kernel ModuleDownloadable Kernel Module • Select Build Project from the context menu of the ProdConsDemo project in the Project Navigator view • The Build dialog shown here appears. We ignore this for now. • Click Continue. • Once the build is complete the dialog disappears anyhow. The output can be seen on the Build Console view of Wind River Workbench

  14. Import code into Downloadable Kernel ModuleDownloadable Kernel Module • Open the Terminal view within Workbench and connect to COM1 (9600baud) • PowerCycle your board board on and let it boot. • Wait till the VxWorks banner is out and WDB is ready:

  15. Create Target Server and connect to the boardDownloadable Kernel Module • Select Target > New Connection from the menu bar of Wind River Workbench • In the Connection Type dialog select WindRiver VxWorks 6.x Target Server Connection • Click Next

  16. Create Target Server and connect to the boardDownloadable Kernel Module • In the Target Server Options dialog enter the IP address of your target: • Click Next

  17. Create Target Server and connect to the boardDownloadable Kernel Module • Leave the Object Path Mappings dialog unchanged. • Click Next

  18. Create Target Server and connect to the boardDownloadable Kernel Module • Leave the Target State Refresh dialog unchanged. • Click Next

  19. Create Target Server and connect to the boardDownloadable Kernel Module • In the Connection Summary dialog change the connection name to: powerquicc2. • Click Finish

  20. Create Target Server and connect to the boardDownloadable Kernel Module • Notice the new entry called powerquicc2 in the Target Manager view of Wind River Workbench. • Notice further that the connection gets established automatically upon creation, • Open the tree named Kernel Tasks in order to see the tasks running already on the target

  21. Download and Run Kernel Module • Select Run Kernel Task from the context menu of the ProdConsDemo project in the Project Navigator view • The Create, manage, and run configurations dialog appears: • Enter vStart into the field labeled Entry Point

  22. Download and Run Kernel Module (cont’) • On the Downloads pane you can see which downloadable kernel modules are loaded by this Run Configuration • By default - it is ProdConsDemo.out our new DKM module. • Other modules could be added, if needed.

  23. Download and Run Kernel Module (cont’) • On the Projects to Build pane you can see which projects are rebuilt by this Run Configuration • Again, by default it is our new DKM. • Other projects could be added, if needed. • Click Run to start this Run Configuration

  24. Download and Run Kernel Module (cont’) • In the Terminal your should now see the output of the running code. • You can also open up the Kernel Tasks tree on the powerquicc2 connection in the Target Manager view. There are now two new tasks called tProducer and tConsumer. • You could also debug those tasks now by their context menu (Attach).

  25. Download and Run Kernel Module (cont’) • As long as you just talk about pure application code porting, the transition from VxWorks 5.x to VxWorks 6.3 took place ! • It can be that easy for many of your customers. • Of course there are other situations out there where it takes more than that. For example when you touch • The new file system framework • Custom BSPs without MMU definitions • Tornado or Sniff based customer build scenarios • Learn about your customers requirements and his application, to be able to provide him with a smooth migration work flow process.

  26. Migrate DKM to “One” Real Time Process

  27. Preparations - setup environment Make sure your board runs a VxWorks 6.3 bootloader. If not, use a WindRiverPROBE to program the bootloader into flash. (A prebuild image can be found in C:\Vx5-to-Vx6\chapter1\VxWorks_6.3_prebuild) Configure the bootloader. As for the vxWorks image use this path: C:\vx5-to-vx6\boot\vxWorks As for the host name use host Launch Workbench 2.5 from C:\vx5-to-vx6\workbench-2.5\wrwb\platform\eclipse\x86-win32\bin\wrwb.exe For the workspace, point to (or switch to) C:\vx5-to-vx6\workspace3

  28. Preparations, setup environment By default, the project Navigator comes up with a pre- configured VxWorks 6.3 image project. Learn about the cp2boot build rule and the cp2boot.makefile (This will copy your output file to a dedicated boot folder) Launch FTP server from C:\ vx5-to-vx6 \vxworks-6.3\host\x86-win32\bin\wftpd32.exe (make sure you have the same account name & password specified, like in the bootloader) Build the VxWorks image. You are now done with the preparations.

  29. Migrate DKM to “one” Real Time Process • Step 1: Create Real Time Process Project • Step 2: Import Source Code from C:\vx5-to-vx6\chapter3\prodconsdemo\kernel_module • Step 3: Build the project • Step 4: Add RTP functionality to VxWorks project • Step 5: Rebuild VxWorks and reboot target • Step 6: Modify Target Server Connection • Step 7: Run the RTP We now continue to transfer the same demo source code (The ProdConsDemo coming from the Kernel_Module folder) into a single RTP

  30. Create Real Time Process Project • Note: RTP stands for Real Time Process. • Select File > New > VxWorks Real Time Process Project from the menu bar of Wind River Workbench • The New VxWorks Real Time Process Project wizard appears: • Specify the name of the new project: ProdConsDemo_One_RTP • Click Next

  31. Create Real Time Process Project • On the Project Structure dialog make sure no boxes are checked in the Referenced subprojects pane. • Click Next

  32. Create Real Time Process Project • On the Build Setup and Defaults dialog, make sure Standard is selected. • Click Next

  33. Create Real Time Process Project • Leave the Build Support dialog as it is. • Click Next

  34. Create Real Time Process Project • On the Build Specs dialogselect PPC32gnu_RTP as Active build spec • Click Finish

  35. Import Source Code • Select Import from the context menu of the new project in the Project Navigator view • The Import wizard appears with the Select dialog: • Select File System • Click Next

  36. In the File system dialog, click Browse The Import from directory navigateto C:\vx5-to-vx6\chapter3\wrwb_demo\prodconsdemo\kernel_module Click OK Import Source Code

  37. Import Source Code • Back in the File system dialog, click the box on the left pane to select the folder • Click Finish

  38. Build the project • Select Build Project from the context menu of the ProdConsDemo_One_RTP project in the Project Navigator view • The dialog on the right appears. • Click Continue. • As the build fails, error messages (in red) appear in the Build Console view of Wind River Workbench. Double click on the first error message line

  39. Add RTP functionality to VxWorks project • The source file library.c opens up in the editor view of Wind River Workbench • Note the tooltip of the error icon left to the erroneous line shows the compiler error message

  40. Add RTP functionality to VxWorks project • library.c makes use of wdLib • wdLib is a kernel only API which is not available for Real Time Processes! • Why: Because it requires use of interrupt context ! • Resolution: • wdLib is used here to measure runtime of a loop. • modify program logic to use task and taskDelay instead • Note: modification can be filtered to have common source for kernel and RTP: • Use predefined _WRS_KERNEL macro defined in build for kernel only: #ifdef _WRS_KERNEL <old code for use inside kernel only> #else <code for use inside of RTP> #endif

  41. Add RTP functionality to VxWorks project #include "wdLib.h" void calibrateInt(int *wdRunning) { *wdRunning = 0; } void calibrateLoop() { WDOG_ID wd = wdCreate(); static int wdRunning = 1; MAX_CNT = 0; wdStart(wd, sysClkRateGet(), (FUNCPTR)calibrateInt, (int)&wdRunning); for(MAX_CNT=0;wdRunning;MAX_CNT++) ; MAX_CNT /= 1000; /* printf ("calib: %d\n", MAX_CNT); */ wdDelete (wd); } Old scenario – for KERNEL MODE ONLY

  42. Add RTP functionality to VxWorks project #include "semLib.h" void calibrationTask(SEM_ID startSem, int *wdRunning) { semTake(startSem, WAIT_FOREVER); taskDelay(sysClkRateGet()); *wdRunning = 0; semDelete(startSem); } void calibrateLoop() { volatile static int wdRunning = 1; int myPrio = -1; SEM_ID startSem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY); MAX_CNT = 0; taskPriorityGet(taskIdSelf(),&myPrio); taskSpawn("tCalibration",myPrio-1,0,0x1000, (FUNCPTR)calibrationTask, (int)startSem,(int)&wdRunning,3,4,5,6,7,8,9,0); semGive(startSem); for(MAX_CNT=0;wdRunning;MAX_CNT++) ; MAX_CNT /= 1000; } New scenario – good for RTP MODE

  43. Add RTP functionality to VxWorks project • Edit the source file library.c to replace wdLib usage

  44. Add RTP functionality to VxWorks project Note: There is a wrwb_demo_solution directory that already has all the proper changes! Use those files as copy&paste resource or as generic solution backup. The folder to look for is: C:\KernelToRtp\wrwb_demo_solution

  45. Add RTP functionality to VxWorks project • Select Build Project from the context menu of the ProdConsDemo_One_RTP project in the Project Navigator view to continue with the build. • As you can see, compilation works fine now. • However the build still fails during the linker run: Why does it still not build ? Because an RTP always needs a function main() !

  46. Add RTP functionality to VxWorks project • From VxWorks, 6.3 Application Programmer's Guide, 2.4.1: VxWorks applications have a simple structural requirement that is common to C programs on other operating systems—they must include a main( ) routine. The main( ) routine can be used with the conventional argc and argv arguments, as well as two additional optional arguments, envp and auxp: int main         (         int argc,      /* number of arguments */         char * argv[], /* null-terminated array of argument strings */         char * envp[], /* null-terminated array of environment  variable strings */         void * auxp    /* implementation specific auxiliary vector */         ); The argv[0] argument is typically the relative path to the executable.

  47. Add RTP functionality to VxWorks project • From VxWorks, 6.3 Application Programmer's Guide, 2.3.1: VxWorks processes can be started in a variety of ways: • interactively from the kernel shell • interactively from the host shell and debugger • automatically at boot time, using a startup facility • programmatically from applications or the kernel Processes are terminated under the following circumstances: • When the last task in the process exits. • If any task in the process calls exit( ), regardless of whether or not other tasks are running in the process. • If the process' main( ) routine returns. • If the kill( ) routine is used to terminate the process. • If rtpDelete( ) is called on the process—from a program, a kernel module, the C interpreter of the shell, or from the host IDE. Or if the rtp delete command is used from the shell's command interpreter. • If a process takes an exception during its execution. This default behavior can be changed for debugging purposes. When the error detection and reporting facilities are included in the system, and they are set to debug mode, processes are not terminated when an exception occurs.

  48. Add RTP functionality to VxWorks project rtpSpawn( ) NAME rtpSpawn( ) - spawns a new Real Time Process (RTP) in the system SYNOPSIS RTP_ID rtpSpawn ( const char * rtpFileName, /* Null terminated path to executable */ const char * argv[], /* Pointer to NULL terminated argv array */ const char * envp[], /* Pointer to NULL terminated envp array */ int priority, /* Priority of initial task */ int uStackSize, /* User space stack size for initial task */ int options, /* The options passed to the RTP */ int taskOptions /* Task options for the RTP's initial task */ )

  49. Add RTP functionality to VxWorks project #include "taskLib.h" extern int vStart(); int main (int argc, char **argv) { vStart(); /* don't return - return means end of RTP */ taskSuspend(0); return 0; } Add following code to the end of ProdConsDemo.c This text should be o.k. to use it as a copy&paste resource

More Related