Hi @PaulHu
If you run this code with no changes on S32K388, it won't work because the flash layout is different.
You can find in the code:

On S32K344, first sector in block 1 is going to be programmed because S32K344_SecureBootBlinky is forced to this block:


But there are 2MB blocks on S32K388, so it's different here:

It's still block 0, so you need to unlock different block and sector.
And one more thing - be aware that read-while-write (RWW) is supported only between blocks. When block 0 is being programmed, the code must run from another flash block or from RAM.
Regards,
Lukas