To generate code for Raspberry Pi using MATLAB Support Package for Raspberry Pi Hardware, you should set the environment variables non-interactively. For instructions, please refer to the below MATLAB Answer link:
In order to resolve the connection issues with Raspberry Pi hardware, please refer to the below MATLAB Answer link: