Fibocom's NL668 is an CAT4 module with OpenLinux inside. This means that you can develop your own application to run on Linux platform without need an external MCU/CPU.
In this guide I will explain how to prepare your SDK environment, compile kernel and send your application to use on the module.
This tutorial is focused on the NL668-LA, but can be used for any other Fibocom's module with OpenLinux.
2. Requirements- NL668-LA Module (or any other Fibocom Module)
- Linux Operating System (can be a virtual machine)
- VSCode
- ADB (Android Debug Bridge)
- Fastboot
- GCC
- SDK Files (provided by Fibocom)
To get access to the last firmware and OpenLinux SDK, please contact your sales support or request it at Fibocom's Website.
3. Setting environmentOpen VScode, click on OpenFolder and select the extracted SDK files folder.
Now you workspace should be like below:
Depending the version of your SDK you can have more or less folder, but there is basically 6 important folders that will be described simply here:
- fibo_bootloader: files for the system bootloader
- fibo_crosstools: tools to make an crosscompilation
- fibo_kernel: kernel setting files and drivers
- fibo_rootfs: filesystem structure and files
- fibo_sdk: example source codes to create your application
- target: target path for compiled firmware
For mostly common cases you should use just the fibo_sdk folder, because the applications examples are there. But if you need to do some customization at kernel level (like add an driver or change an port function) you should use the fibo_kernel too. Anyway, I will describe on step 4.1 about how to do that.
3.2 GCC external lib workaround (optional)If you are using the GCC version 10 or newer, you should have issues to compile it. This happens because a library called yylloc that have changed on GCC.
You can made a quickly workaround just going into the file fibo_kernel/build/scripts/dtc/dtc-lexer.lex.c on line 640 and add extern on the library definition like below:
Don't forget to save the file!
3.3 Sourcing crosstoolsNow you just have to add the crosstools as a source to enable the compilation to an other platform (you should using an x86 64 bits and we want to compile to run the firmware on an 32 bits ARM, right?).
Open the VSCode terminal in SDK root folder and run the following command:
source fibo_crosstools/fibo-crosstool-env-init
ADB (Android Debug Interface) and Fastboot are useful tools commonly used in Android devices (you probably know if you already rooted or customized the rom of your smartphone).
In a simply way, the ADB can send commands to device, upload files and provides access to the Linux shell. Meanwhile the fastboot is the tool to connect to the bootloader and flash firmware files.
3.4.1For Windows:
If you are using Windows, download the platform-tools (adb+fastboot) on this link.
Then extract/create folder in C:/platform-tools:
Now, open Windows Search (windows keyboard button), type path and select Edit the system environment variables:
In System Properties > Advanced, select Environment Variables...
Select the Path line and click Edit...
Click New and add the path where you extracted the platform tools (C:\platform-tools)
Follow clicking Ok on current and previously windows to close. Open a Command Prompt and type the commands below to check if the tools are working.
adb --version
fastboot --version
3.4.2For Linux:
If you are using an Debian based distro, just run this command:
sudo apt-get install adb fastboot
Then check both tools:
adb --version
fastboot --version
3.4.3 ADB and Fastboot - Driver and Permission
On first usage of ADB and Fastboot you should required to update the driver (Windows) or give user permission (Linux).
For Windows users, you just need to update the drivers using Windows Device Manager and selecting the provided driver from Fibocom.
For Linux Users you need to create an file in /etc/udev/rules.d/51-android.rules and add the information from lsusb (idVendor and idProduct), or just run the commands below, then reconnect your USB Cable:
sudo sh -c "echo '# Fibocom NL668' >> /etc/udev/rules.d/51-android.rules"
sudo sh -c "echo 'SUBSYSTEM==\"usb\", ATTR{idVendor}==\"1508\", ATTR{idProduct}==\"1001\", MODE=\"0666\", GROUP=\"plugdev\"' >> /etc/udev/rules.d/51-android.rules"
sudo sh -c "echo '# Google Inc. (fastboot)' >> /etc/udev/rules.d/51-android.rules"
sudo sh -c "echo 'SUBSYSTEM==\"usb\", ATTR{idVendor}==\"18d1\", ATTR{idProduct}==\"d00d\", MODE=\"0666\", GROUP=\"plugdev\"' >> /etc/udev/rules.d/51-android.rules"
sudo service udev restart
echo "Done! Reconnect your usb cable now."
More info about the permission can be found at this link.
4. Make Kernel and SystemYou probably already noticed the Makefile in the SDK, which means that you could just execute make to make all the files and get your firmware. But as I said before, sometimes you want to customize something on kernel or driver. So, you can follow the step 4.1 or just skip to step 4.2 and use the default settings.
4.1 Make Menuconfig (optional)The menuconfig is a CLI tool to help us to customize some kernel settings. It's very similar to the menuconfig from ESP, Raspberry or others platforms which allow us to modify settings before create the firmware.
To access the menuconfig tool, you need to enter in fibo_kernel and execute make menuconfig as below:
cd fibo_kernel
make menuconfig
Now you should see this screen:
The menuconfig provide us a lot of settings like add/remove drivers, library routines, manage the power and set file systems.
The file to define the settings is stored in /fibo_kernel/arch/arm/configs/mdm9607-perf_defconfig , so if you made any changes, don't forget to guarantee that you are saving and replacing this file.
4.2 Make!Now, come back to the SDK root folder and lets compile something. You have 2 options to compile:
Option 1: (To compile all) Run make to compile everything:
make
Option 2: (To compile separately) Run make + what do you want to compile:
make rootfs
make aboot
make kernel
make sdk
So, lets just use the first option at this time:
If everything was right, you should see 3 new files in the target folder:
- appsboot.mbn: target from aboot
- mdm9607-boot.img: target from kernel
- mdm9607-sysfs.ubi: target from rootfs
Now that you already have the new firmware files, let's update our module.
5. Updating FirmwareBasically you have 2 options to update the Firmware:
Option 1. Fibocom Tools (Windows)
If you are using Windows, you just need to overwrite this 3 new files into the older firmware folder and execute the Fibocom's tools to update the new firmware.
Example using Fibocom_MDM_MultiUpdater:
Option 2. ADB + Fastboot (Windows or Linux)
Connect your device to USB port and execute the following command to confirm the adb connection:
adb devices
Then send the command to reboot the module and enter in fastboot mode:
adb shell sys_reboot bootloader
Now you should see the device in fastboot mode using fastboot:
fastboot devices
Enter in the target folder, and flash the module using fastboot:
cd target/
fastboot flash aboot appsboot.mbn
fastboot flash boot mdm9607-boot.img
fastboot flash system mdm9607-sysfs.ubi
fastboot reboot
Done! Now you can access the OpenLinux via ADB.
5. Using OpenLinuxThe OpenLinux is already enabled, now you can access it using the command:
adb shell
Looks familiar? You can use it as any Linux distro now.
Lets come back to our VSCode. Open fibo_sdk/examples and check what is inside. There is a lot of examples about how to use module features:
But instead just use a ready example, lets create our own.
So, create a folder inside called hello_world and a new file hello_world.c:
Put this example code inside the hello_world.c and save it:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
Copy any Makefile from other example (lets take from at_test in this case) and put inside the hello_world folder:
Now, edit the new Makefile (inside hello_world) on line 12. Change the target name from at_test to hello_world and save the file:
Open your terminal, come back to SDK root folder and clean just the fibo_sdk binaries:
make sdk/clean
And finally, lets compile our fibo_sdk files:
make sdk
Wait to finish the compilation and check your binary in fibo_sdk/bin. That's it, here is our first application!
But wait... The application is in my PC. So, how can I send it to the module? That's really easy.
Just open your terminal, then use adb push + your file + destination.
cd fibo_sdk/bin
adb push hello_world /data/
6.2 Write PermissionIf you get errors to send, probably is because your file system doesn't have permission to write new files. So, you can use the command below in the adb shell to alow write new files and then try again the step 6.1:
mount -o rw,remount /
mount -o rw,remount /data/
Obs1.:This is not recommended for production.
Obs2.:You can remount any other mount point with permission to read and write just changing the "/" to an other name for mount point.
7. Testing ApplicationFinally you have already full access to openLinux and your application is waiting to execute. Let's try it?
Go to the destination folder inside openLinux and run with ./hello_world
cd /data
./hello_world
Congratulations! You have made your first application using openLinux in a Fibocom module!
This document was a simple tutorial, but you probably understand now how to keep going with your project.
Have fun!
Comments
Please log in or sign up to comment.