OpenWrt SoM. Developers guide. Part 1.
Once you decided to use OpenWrt driven NetSoM development board as starting point of development your own custom hardware first of all you should choose one of the available image configuration that feets your needs closely. Full list of available configurations can be found here. Here is simple selection algorithm:
- All configurations has both ethernet interfaces available out of box. Linux image but not u-boot. Just one ethernet interface supported by bootloader.
- Each configuration uses same COM-port as user console and each configuration uses same onboard SPI flash IC as booting interface so you shouldn’t worry to switch from one config to another looking for exact one suitable for you.
- Each configuration supports firmware update from linux user space and u-boot console as well.
- If you would like to implement video streaming solution – plug OV5640 5MP video module in development board and use video_stream_ethernet.config or video_stream_wifi.config image;
- If you would like to implement audio streaming solution – plug WM8960 audio module in development board and use audio_stream_ethernet.config or audio_stream_wifi.config image;
- If you would like to implement voice assistant solution – you may try to run Amazon_voice_service.config or amazon_voice_service_wifi.config with HW set for audio solution (WM8960 audio module + development board)
- If you interested in developing LoRaWAN based solution – SX1301 based 8-channel industrial grade extension shield plugged in development board will give you fully functional LoRaWAN gateway capable to work in temperatures from -40°C to 70°C. Use Lorawan_gateway_ethernet.config or lorawan_gateway_wifi.config;
- CAN bus based solution might be implemented basing on flexcan_ethernet.config or flexcan_wifi.config images.
As you noted there are pairs of configs (endings with _ethernet and _wifi) supporting double ethernet and double ethernet + wifi interfaces respectively.
Image compilation
So after choosing one of the config it is time to compile image:
$ cd imx6ull-openwrt.git
and start build process by calling compile.sh script with configuration name you choose as argument. For example:
to get full list of available configurations run:
Available board names:
amazon_voice_service amazon_voice_service_wifi audio_stream_ethernet audio_stream_wifi flexcan_ethernet
flexcan_wifi lorawan_gateway_ethernet lorawan_gateway_wifi video_stream_ethernet video_stream_wifi
In complie.sh script you may find typical steps to build OpenWrt image described here.
After build process completed in bin/targets/imx6ull/cortexa7/ directory you may find built images:
- openwrt-imx6ull-cortexa7-flexcan_wifi-squashfs.sdcard.bin – image to run from SD card;
- openwrt-imx6ull-cortexa7-flexcan_wifi-squashfs.mtd-sysupgrade.bin – image to update firmware using sysupgrade utility;
- openwrt-imx6ull-cortexa7-wirelessroad_gw-imx6ull-squashfs.mtd-factory.bin – image to update SPI flash.
- openwrt-imx6ull-cortexa7-flexcan_wifi-squashfs.u-boot.bin – u-boot image;
Firmware update
Next time to update firmware. Easiest way to do it – using sysupgrade utility. For doing this copy built on previous step image to device:
and start firmware update process:
it takes about 3-5 minutes to complete FW update process and boot from new one.
If you will face error message looking like this:
Supported devices: wirelessroad_stream-imx6ull flexcan_wifi
Image check failed.
don’t worry. It notes you that currently flashed firmware is different rather the one you are trying to flash.
You may get around this just by replacing current configuration name in /tmp/sysinfo/board_name file:
lorawan_gateway_wifi
replace it with configuration name from the error message (flexcan_wifi, not wirelessroad_stream-imx6ull which is deprecated):
press i to enter inser mode and replace config name. Then press ESC and :wq to exit vi.
Now you should be able to update firmware. Try running
again.
Note! You may do it without worrying in a case of using configurations from master branch as all of them uses same booting device (onboard SPI flash IC) and same console. But if you changed something in source code – everything might happens.
But not worry. another possible way to update firmware – using u-boot.
Fimrware update from u-boot
To make upgrade through uboot you’ll need serial connection to board, tftp-server installed on laptop/PC and direct ethernet connection between them.
Herel we use tftp-server IPv4 address 192.168.0.100, board IPv4 address 192.168.0.99 and firmware upgrade file (sysupgrade, not factory) fw.bin
- Hit any key while uboot running.
- Setup addresses for uboot:
# setenv ipaddr 192.168.0.99
# setenv ethaddr 00:11:22:33:44:55
# saveenv
- Execute load to memory to loadaddr (default 0x82000000)
- Probe SPI flash
- Erase block before writing (it can take a while)
- Write firmware to flash
- At this point firmware is loaded and you can restart board by executing:
command or simply powering it off and on.
Caveat
After executing command tftpboot fw.bin on success you will get line like this:
You can use HEX number in sf erase and sf write command as last argument (instead of 0xf00000) to make things faster. For erase we need to round up this number in higher order. So in this example we can use this commands:
# sf write 0x82000000 0x100000 0x78011e
Keep following as here at our telegram channel.