stm32mp1 nand flash problem swupdate

332 views
Skip to first unread message

Ayoub Zaki

unread,
May 13, 2022, 5:08:26 AM5/13/22
to swupdate
hello,

I'm using a custom stm32mp157c board with 1GB Micron MT29F8G08ADADAH4 Nand flash.

I'm using swupdate with flash handler to update my fsbl (trusted arm firmware) and ssbl (u-boot) as follow:

images:
(
{
name = "tf-a";
filename = "tf-a.stm32";
mtdname = "fsbl1";
type = "flash";
sha256 = "$swupdate_get_sha256(tf-a.stm32)";
},
{
name = "u-boot";
filename = "u-boot.stm32";
mtdname = "ssbl1";
type = "flash";
sha256 = "$swupdate_get_sha256(u-boot.stm32)";
},
{
name = "kernel";
filename = "fitImage";
volume ="kernel_r";
type = "ubivol";
sha256 = "$swupdate_get_sha256(fitImage)";
},
{
name = "rootfs";
filename = "@@IMAGEBASE@@.ubifs";
volume ="rootfs_r";
type = "ubivol";
sha256 = "$swupdate_get_sha256(@@IMAGEBASE@@.ubifs)";
}
);


here is my flash layout:

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00040000 "fsbl1"
mtd1: 00200000 00040000 "fsbl2"
mtd2: 00200000 00040000 "ssbl1"                                                                                               mtd3: 00200000 00040000 "ssbl2"                                                                                               mtd4: 00200000 00040000 "ubootenv"                                                                                       mtd5: 3f600000 00040000 "linux" 

After a swupdate successful update the fsbl hangs with following message:

NOTICE:  BL2: v2.2-r2.1(release):v2.2-stm32mp-r2.1-13-g251aafbea
NOTICE:  BL2: Built : 11:14:14, Feb  4 2022
ERROR:   BL2: Failed to load image (-89)


I booted from SD Card and did a nanddump of the mtd2 partition with the content written by swupdate flash handler:

# nanddump  /dev/mtd2 -f u-boot.stm32.dump -l 864740
ECC failed: 0
ECC corrected: 0
Number of bad blocks: 0
Number of bbt blocks: 0
Block size 262144, page size 4096, OOB size 224
Dumping data starting at 0x00000000 and ending at 0x000d31e4...


# diff -sq u-boot.stm32.dump u-boot.stm32
Files u-boot.stm32.dump and u-boot.stm32 are identical 


If I write a mdt2 partition using mtd-utils nandwrite: 

# nandwrite -p /dev/mtd2 u-boot.stm32
 

My system boot-up correctly:

NOTICE:  BL2: v2.2-r2.1(release):v2.2-stm32mp-r2.1-13-g251aafbea                                       NOTICE:  BL2: Built : 11:14:14, Feb  4 2022                                                                                NOTICE:  ROTPK is not deployed on platform. Skipping ROTPK verification.                            NOTICE:  BL2: Booting BL32                                                                                                      NOTICE:  SP_MIN: v2.2-r2.1(release):v2.2-stm32mp-r2.1-13-g251aafbea                      
NOTICE:  SP_MIN: Built : 11:14:14, Feb  4 2022                              
U-Boot 2020.01-stm32mp-r2.1 (May 12 2022 - 10:33:54 +0000)                                                                              

So there is a difference between swupdate flash handler and nandwrite !

to note that fsbl2 and ssbl2 are empty and that tf-a bootup correctly after writing from swupdate, I cannot figure out now why u-boot is different ?

has someone run into a similar issue ?


thanks,

Best regards,


Måns Andersson

unread,
Apr 11, 2023, 8:08:28 AM4/11/23
to swupdate
Hi,

We think we are experiencing something similar using the STM32MP135F MCU. Did you find a solution to this issue?

Best regards,
Måns

ayoub...@googlemail.com

unread,
Apr 11, 2023, 10:12:19 AM4/11/23
to swupdate
Hi,

I didn't have time to get back to it, just disabled bootloader update for the moment, what is strange is it didn't work with an external lua handler using mtd-utils.

best regards

ayoub...@googlemail.com

unread,
Jun 30, 2023, 10:49:08 AM6/30/23
to swupdate
Hi,

I used the following lua external handler "flash_ext" calling nand-utils :

require ("swupdate")

function flash_ext_lua(image)

local part_erase_cmd, part_write_cmd, err
part_erase_cmd = string.format("flash_erase %s 0 0", image.device)
part_write_cmd = string.format("nandwrite -p %s /tmp/%s", image.device, image.filename)

swupdate.info("handler: '%s' image: '%s' device: '%s'", image.type, image.filename, image.device)
swupdate.info("cmd erase: '%s'", part_erase_cmd)
swupdate.info("cmd write: '%s'", part_write_cmd)

err = os.execute(part_erase_cmd)
if not err then
swupdate.error(string.format("Error: %s return %s!", part_erase_cmd, tostring(err)))
return 1
end

err = os.execute(part_write_cmd)
if not err then
swupdate.error(string.format("Error: %s return %s!", part_write_cmd, tostring(err)))
return 1
end

os.execute("sync")
return 0
end

swupdate.register_handler("flash_ext", flash_ext_lua, swupdate.HANDLER_MASK.IMAGE_HANDLER)



It is working properly.

I analyzed the flash handler in swupdate comparing it with nand-utils but I didn't found where the problem is coming from.

For the moment I will stick with this workaround !

There is something strange with the stm32 I didn't have this problem before with other devices...


BR
Reply all
Reply to author
Forward
0 new messages