Updating Firmware on the K20

I’m playing with the K20 and custom firmware based on the toradex_tk1_l4t_r21.5 branch.

There is some strange logic for deciding if the file in /lib/firmware/apalis-tk1-k20.bin should be flashed into the K20 or not.

Looking at apalis-tk1-k20.c « mfd « drivers - linux-toradex.git - Linux kernel for Apalis and Colibri modules it seems that the bin file in /lib/firmware/apalis-tk1-k20.bin is only flashed in IF the version of the firmware on the K20 doesn’t match the version baked into the mfd driver APALIS_TK1_K20_FW_VER ( which is defined in apalis-tk1-k20.h « mfd « linux « include - linux-toradex.git - Linux kernel for Apalis and Colibri modules )

This makes replacing the firmware require an extra step to erase the K20 ( dd if=/dev/zero of=/lib/firmware/apalis-tk1-k20.bin bs=1 count=1 ) then restart TK1 and then copy the new custom firmware file to /lib/firmware/apalis-tk1-k20.bin and then restart.

Would it make more snse to compare the version of the firmware on the K20 to the version of firmware of the binary file in the /lib/firmware/apalis-tk1-k20.bin instead? That would make firmware upgrades simpler.

Since we’re only providing updated firmware within updated BSP that’s just an extra step that a right kernel/module combination is used with right rootfs/firmware. When the k20 support is finalized and out of beta, we will probably re-evaluate this mechanism, but I think we’ll probably leave this check and include force fw upload option via sysfs. But for custom firmwares you can easily modify it to work however you like. Also if you’re using our latest -next branch for kernel, you can replace the file with dd, reload k20 modules, replace the fw with the new one then reload k20 without restarting. There is also a way of uploading the fw from userspace after unloading the modules:
http://developer.toradex.com/knowledge-base/using-k20-companion-mcu-on-apalis-tk1#Using_TK1_SPI_with_K20_EzPort

OK. Fair enough. I am using that dd mechanism. What’s the best way to reload the k20 modules? I was unable to do a rmmod. It gave me a ERROR: Module is builtin.

It can only be done when k20 support is compiled as modules (as we do in our BSP). You’ve compiled them in kernel, in that case rebooting is the only solution.