The purpose of this project is to create a LCD display that takes a can message in and then shows the decocded data in a human readable format. This is accomplished by using RT-Thread RTOS with LVGL as the graphics library on an i.MX RT1060-EVK.
NOTE Thank you to RT-Thread, LVGL, NXP for sponsoring this event. It was great fun working on this project and I hope it is usefull.
I was glad to be able to contribute to the project under PR RT-Thread/rt-thread#6238 (comment) which fixed an issue with inititialization of the touch controller out of power up.
This readme should function as a tutorial to provide a user with the following skills.
- Setup and creating a project in RT-Thread Studio
- Creating an Image in LVGL and loading it into RT-Thread
- How to implement NXP FLex CAN sdk drivers in RT-Thread
There are a few vidoes showing different aspects of this project. They are located below where they fit appropriately. They are also linked here for reference.
There is a video of the complete project on YouTube. You can see the final product taking CAN messages and updating LVGL gauges with that data. https://www.youtube.com/embed/a3wtcvLzRa0
- MIMXRT1060-EVKB
- Rocktech LCD
- USB<->CAN Adapter
- 0.1" Pitch Header, two pieces of wire, and a DB-9 Connector for CAN
This is a view of the LVGL project running under RT-Thread.
- RT-Thread Studio
- NXP GUI Guider
The RT-Thread_LVGL_Tutorial.odt document contains a tutorial of how to setup the RT-Thread Studio Environment for developing LVGL applications on RT-Thread.
The code located in the ContestTest folder contains an exmaple project build with this tutorial.
Download and Installation RT-Thread Studio per the installation instructions. RT-Thread Studio
Install GUI Guider per installation instructions.
NXP GUI Guider
We will now setup the development environment and the hardware to be able to debug our application.
-
Follow the instructions provided by NXP at to update the onboard debugger so that we can use J-Link servers. Modifying Debug Firmware on i.MX RT10xx Boards Featuring An LPC4322-based Debug Probe
-
The original debugger firmware enabled the power supply from the USB to provide power to the rest of the board. The update does not turn the power on. If you wish to use the USB Debugger to power the board you will also need to make this hardware modification. Jump R97 with a 10k if you want to power the board from the Debugger using VUSB.
-
CAN Bus connections require the population of J42 with a header or by soldering wires directly.
-
Download the latest RT-Thread code base from Github. The path to the rthread folder will be refered to as <RT-THREAD> for the rest of this document.
-
Create a starter project by following the RT-Thread RTOS — LVGL documentation a. Follow this section: “Import a BSP project into RT-Thread Studio”. b. The path to the BSP is _<RT-THREAD>\bsp\imxrt\imxrt1060-nxp-evk_
-
To import a project open the File->import->BSP project. This will open a window that shows something like this.
-
Now hit the Finish button to create the project.
-
If the project was successful you should now try to build the code. If the build is successful you should see text in the console that looks something like this.
-
Let's try to debug the project to make sure that our system works. a. In the toolbar select the debug configuration:
-
If this fails to launch confirm that you have the correct settings for the debugger and make sure you are using the latest Segger J-Link debugger.
-
Plug a USB cable into the board using the Debug Port, marked J1 on my board.
-
Hit the debug button.
-
You may be asked to acknowledge the use of JLINK software. There is a checkbox at the bottom left that won’t ask again today. This box will timeout and report a failure on the debug console. If you have multiple monitors check the other ones to see if the pop-up window opened there.
-
The current version of RT-Thread Studio is bundled with an older version of J-Link tools. Specifically version 6.80d. This version does not have the MCU I am using in it. To overcome this issue do the following. a. Segger J-Link Debug Tools
b. Download and install the version for your appropriate system. c. Mine was J-Link Version V7.66e. d. Take note of the install location as it is needed later for updating the configuration. e. Once the install is complete update the J-Link executable settings in on the debug settings page. f. Now update the path to the J-Link debugger.
-
Once the connection of the debugger to the process is successful you should see a break point and the code is running. You will see a green highlight and an arrow on the left in of the window pane indication which instruction is the next to execute.
-
You can look up the debug controls as they are common, or hover the mouse over and a description will be displayed in a tooltip.
-
We are going to allow the processor to continue execution so that we can observe continuous execution.
-
This will open the RT-Thread Soft Package Center page.
-
Select the “Hardware” tab on the next page. a. Enable the items shown below.
b. Confirm the display specifics are the same as in your GUI Guider project.
d. Select the “Enable LVGL GUI Guider demo for RT-Thread”
e. At this point build the application and then debug. To confirm that the code builds and we can use the display.
https://www.youtube.com/embed/27I1w731RW4
j. Now we need to create some gui code.
-
Download and Install the latest GUI guider from here
-
Select “Create a new project”
-
This will open a selection for which version of LVGL you would like to use in the project. We will use LVGL V8 for this tutorial.
-
Select “Next”
-
This will open the “Select a Board Template” screen. Select “i.MX RT” tab at the top.
-
Select your board.
- The evaluation board I am using is a MIMXRT1060-EVKB with the details below.
a. Processor is a MIMXRT1062DVL6B
b. Note this is a B type and we will need to account for that later when we want to debug the processor. We will need to update the JLINK configuration to tell the JLINKGDBServer which processor we want to debug.
- Screen is a RockTech Displays, RK043FN66HS-CTG
- So I will select the one highlighted below.
**NOTE: This is not the exact processor that we will use. The one in the selection list is a MIMXRT1062xxxxA and the board I am using is a MIMXRT1062xxxxB. For this example though, this isn’t an issue. You will need to verify that everything works for YOUR particular application.
- I want a single page to add a couple of gauges so I will select the template below.
- This will bring up a summary screen with a few key final selections.
- Final Selections
- “Project Name” and “Project Location”
- Give your project a meaningful name, we will treating this as a separate project for now and only using the output files from GUI Guider. So put this project in a place where you can find it later.
- “Panel Type”
- Select the panel to match the one you have. I had to open the list and select mine from there. You could also specify a custom panel if you wanted.
- “Project Name” and “Project Location”
- This completes the initial creation of the project. Now we can start adapting it to our needs.
- The evaluation board I am using is a MIMXRT1060-EVKB with the details below.
a. Processor is a MIMXRT1062DVL6B
- In GUI Guider, Select the “Generate Files” button.
- This will generate the C Code files necessary to create this image.
- The output files are placed in the “generated” folder in the project path.
- We need these files from that path.
- We will copy the contents of the “generated” folder to the RT-Thread project path.
- These files from the GUI Guider → Generated folder will be placed inside the applications folder and we will create a new “generated” folder like this
- If a file in the generated folder fails to find “lvgl/lvgl.h” replace the path with “lvgl.h
- Some files may need to have their paths resolved. There can be conflicts between the files. This may include the following.
a. To add a folder to the build sometimes means we must un-exclude it from the build.
b. You also need to remove the package files from the include path.
- To enable the FSL CAN Drivers remove it from the exclusion list.
- At this point we are able to create a LVGL project, include that code into an RT-Thread project, and use NXP based FSL driver code.
In the end you should have something that works like this!
https://www.youtube.com/embed/NIXyxk9k4Lg
Future work:
- Enable PXP for hardware graphics acceleration.