Hello Alex,
For the 'SH8 device, you will need to run part of the erase code (and also programming code) from RAM. This is because, when the erase process commences, an internal charge pump applies high voltage to the flash array. Whilst this occurs, flash memory is unreadable.
Using the search engine below, you should find numerous code examples for S08 devices within this forum. Some of the methods use a fixed block for the RAM based code, whereas the other possibility is to load the function code to the stack, and run it from there.
Regards,
Mac