If you're being charged with an illegal firearm in Pennsylvania, what you should do is make certain your rights and interests are protected in all respects. Having an experienced Pennsylvania criminal defense attorney in your corner from as early as possible in the process will best allow you to do so. Whether you've been charged or you're being investigated for a firearm offense, you should not speak to the police or anyone in law enforcement without being represented by an attorney or without having the input of an attorney.
For any court proceedings, you want to make sure that you have an experienced attorney involved so that they can do everything to make certain that the court proceedings go as smoothly and as favorably as possible. Your attorney should prepare a strong defense, which would include an analysis of the discovery at the given time to find any weaknesses in the prosecution's case. They can do a motion to suppress, for example, motion to suppress evidence, evidence being the firearm. If the firearm has evidence to suppress, the prosecution could not use against you at trial.
There's various steps that an attorney could take. They should be involved from as early as possible in the criminal process to both protect your rights and interests and help you best defend against firearm charges.