Hi @avionics,
After some tests and by reading the source code of the kernel module for the k20, I was able to flash the 1.5 binary and fix the GPIO issue on BSP 2.8 downstream kernel toradex_tk1_l4t_r21.7.
Here is the step-by-step guide:
root@apalis-tk1:~# dmesg | grep k20
[ 12.388235] apalis-tk1-k20 spi1.1: Apalis TK1 K20 MFD driver. Firmware version 1.4.
[ 12.416345] apalis-tk1-k20-can apalis-tk1-k20-can.0: probed 0
[ 12.429787] input: apalis-tk1-k20-ts as /devices/platform/spi-tegra114.1/spi_master/spi1/spi1.1/apalis-tk1-k20-ts/input/input1
[ 12.442199] apalis-tk1-k20-can apalis-tk1-k20-can.1: probed 1
- Copy the 1.5 binary to your module and place it inside
/lib/firmware/
(I copied from a USB stick).
root@apalis-tk1:~# cp /media/sda1/apalis-tk1-k20.bin /lib/firmware/
- Remove the kernel modules responsible for the K20. We’ll need to reload them.
root@apalis-tk1:~# rmmod apalis_tk1_k20_adc apalis_tk1_k20_can apalis_tk1_k20_ts gpio_apalis_tk1_k20
root@apalis-tk1:~# rmmod apalis_tk1_k20
- Now here is the important part, by checking the source code, I was able to find these two parameters:
static unsigned int fw_ignore = 0;
module_param(fw_ignore , uint, 0);
MODULE_PARM_DESC(fw_ignore, "Assume that K20 is running valid fw version. "
"Don't verify, don't erase, don't update");
static unsigned int force_fw_reload = 0;
module_param(force_fw_reload , uint, 0);
MODULE_PARM_DESC(force_fw_reload, "Update K20 fw even when the same version"
" is already flashed.");
So we can make the driver ignore the firmware we’re loading and also force the firmware update. From my tests, you can’t pass both arguments at the same time. Instead, now run the following command:
root@apalis-tk1:~# modprobe apalis_tk1_k20 force_fw_reload=1
[ 94.566330] apalis-tk1-k20 spi1.1: Unsupported firmware version 1.5.
[ 94.576066] apalis-tk1-k20: probe of spi1.1 failed with error -524
This will force the reload of the new firmware.
- Now remove the driver module again and pass the ignore parameter to launch the new firmware. This will force the driver to ignore we’re loading a different version:
root@apalis-tk1:~# rmmod apalis_tk1_k20_adc apalis_tk1_k20_can apalis_tk1_k20_ts gpio_apalis_tk1_k20
root@apalis-tk1:~# rmmod apalis_tk1_k20
root@apalis-tk1:~# modprobe apalis_tk1_k20 fw_ignore=1
[ 127.660098] apalis-tk1-k20 spi1.1: fw_ignore == 1. Detected firmware 1.5. Driver expected 1.4
[ 127.672542] gpio wake34 for gpio=82
[ 127.684604] apalis-tk1-k20 spi1.1: Apalis TK1 K20 MFD driver. Firmware version 1.4.
[ 127.753484] input: apalis-tk1-k20-ts as /devices/platform/spi-tegra114.1/spi_master/spi1/spi1.1/apalis-tk1-k20-ts/input/input2
[ 127.776547] apalis-tk1-k20-can apalis-tk1-k20-can.0: probed 0
[ 127.797811] gpiochip_add: registered GPIOs 856 to 1015 on device: generic
[ 127.811795] apalis-tk1-k20-can apalis-tk1-k20-can.1: probed 1
You can see from this line
[ 127.660098] apalis-tk1-k20 spi1.1: fw_ignore == 1. Detected firmware 1.5. Driver expected 1.4
that we’re able to launch the new firmware.
Now you should be able to export the GPIO and it should work.
A couple of very important things to mention:
- If you reboot, it won’t work because you still need to pass the ignore flag. Otherwise it will detect this is a different firmware version and it won’t launch. So in order to add the flag automatically on boot, please create the following file with the option inside:
root@apalis-tk1:~# cat /etc/modprobe.d/apalis-tk1-k20.conf
options apalis-tk1-k20 fw_ignore=1
Now if you reboot the module, it will load the kernel module with the correct flag.
- Second and the most important part is that I only tested the GPIO. Please note that we are doing something that is not expected, so please, test everything carefully and make sure everything works. Who made this driver in the past added a bunch of verifications (as we can see) to check the firmware version, so it must be something important. By bypassing them, there is no guarantee that everything will work.
Finally, about your request to fix the BSP 2.8 which is on our feed, I will ask the development team internally. Be aware that this can be rejected by them, because this is an very old image (it uses kernel 3.10, now we are using 6.2) which is an EOL module and is not supported anymore. So I don’t expect any fixes right now, unfortunately. Anyways, I will let you know of any changes.
Hope this helps for now. Let me know if you have any questions and if that works on your side as well, I’ll be happy to help.
Best Regards,
Hiago.