Yes, this is possible. You will need to modify the U-boot flashing scripts (or write your own) to accommodate this behavior, but there is not much more to it than preserving an area on flash for the update files. However, there is an element of risk to this approach.
Another approach is to use an A-B partition scheme wherein there are two mirrored partitions which house the rootfs. In this approach, the whole update can be done from Linux since you can update the rootfs which is not mounted from the mounted rootfs and then switch to the newly updated rootfs upon reboot. If the system fails to boot, the system will revert back to the working rootfs. This is the tactic used by mender.io who provides a complete OTA update solution for Linux which is compatible with Toradex modules. View our joint webinar.
Regarding this question I am doing some experiments. This is how my eMMC looks like:
Partition Map for MMC device 0 – Partition Type: DOS
Part Start Sector Num Sectors UUID Type
1 8192 32768 976a3b41-01 0c
2 40960 3502080 976a3b41-02 83
3 3543040 1280000 976a3b41-03 83
4 4823040 2304000 976a3b41-04 83
And I am using the variable setsdupdate as a basis. I have the results of update.sh on the 4th partition and I am trying to create the following environmental variable:
When you set an environment variable that contains ‘;’ you must escape the value with ‘’ or it will set the variable with whatever is before the ‘;’ and then execute whatever comes after that.
Thanks again. This allowed me to set the variable. Now it doesn’t detect the flash_blk but I assume it’s an issue caused by me.
Can you please just confirm that ${drive}:4 scans the 4th partition?
Best regards
EDIT: Ok, I confirmed the ‘:4’ reads the 4th partition. because with the :4 I can read the flash_blk in the parent directory, but it fails when trying to read something from the /apalis_imx6. Is there a reason for it? I simply copied the results of ./update.sh -o /srv/tftp -m 1 to the /firmware_update folder on apalis which is the mountpoint of the 4th partition. Why do I always get ** Unable to read file apalis_imx6/flash_blk.img **?
Apalis iMX6 # load mmc 0:4 0 apalis_imx6/flash_blk.img
4261 bytes read in 81 ms (50.8 KiB/s)
I had to include a ‘0’ there or else it wouldn’t even try, I guess for a syntax error of load.
It can read ‘by hand’ since the byte count is the same as ls command.
Can it be an error caused by the first flash_blk.img in the parent directory? It can read that one and the setup fails while executing that script.
EDIT: Found it. On that script fatload ${interface} ${drive}:1 ${loadaddr} ${board_name}/flash_blk.img && source ${loadaddr} is there a way for me to patch this? meta-toradex-nxp?
EDIT2: Found it on the meta-toradex-demos, just like update.sh. I think i will create a new file script in paralell to this one but i think it’s worked out. Thank you one more time Max
As a follow up, i tried to flash apalis by switching the scripts. The places that load the files in mmc interface + drive : 1 i switched to : 4. Here’s the output. Why do I get bad partition? Is it because I create the partitions 3 & 4 after flashing?
Where can I define the partition table when flashing? That could make some of my initial scripts / reboots useless and that would be a good thing.
Apalis iMX6 # setenv setemmcupdate 'setenv interface mmc; setenv drive 0; mmc rescan; load ${interface} ${drive}:4 ${loadaddr} flash_blk.img && source ${loadaddr}'
Apalis iMX6 # run setemmcupdate
707 bytes read in 25 ms (27.3 KiB/s)
## Executing script at 12000000
4261 bytes read in 81 ms (50.8 KiB/s)
## Executing script at 12000000
enter "run update" to update the entire module
Apalis iMX6 # run update
switch to partitions #1, OK
mmc0(part 1) is current device
MMC read: dev # 0, block # 138, count 1 ... 1 blocks read: OK
371640 bytes read in 70 ms (5.1 MiB/s)
switch to partitions #1, OK
mmc0(part 1) is current device
MMC write: dev # 0, block # 138, count 726 ... 726 blocks written: OK
Fuse 0, 5: 5072
Fast boot mode already fused, no need to fuse
512 bytes read in 69 ms (6.8 KiB/s)
switch to partitions #0, OK
mmc0(part 0) is current device
MMC write: dev # 0, block # 0, count 1 ... 1 blocks written: OK
** Invalid partition 4 **
** Invalid partition 4 **
** Invalid partition 4 **
** Invalid partition 4 **
switch to partitions #0, OK
mmc0(part 0) is current device
MMC write: dev # 0, block # 40960, count 0 ... 0 blocks written: OK
resetting ...
UPDATE: I was right, I was deleting the partitions I needed. I created the 2 partitions I used to create on my init-scripts within update.sh and everything works as intended.
I can now flash a new imagem with the internal eMMC.