In the State of Texas, possession of even a microscopic amount of a controlled substance (which includes cocaine, heroin, methamphetamine, ecstasy, etc.) is a state jail felony. If your boyfriend is found guilty of this charge, he can be sentenced from 6 months to 2 years in a state jail or up to 5 years of felony probation (possibly including a fine of up to $10,000). (Even if he is guilty, he may be offered a deferred adjudication probation whereby the judge doesn't actually find him guilty, and as a result, he isn't actually convicted. This kind of probation/record can be sealed if he is eligible).
However, it sounds as if there may be a legitimate defense in your boyfriend's case. The State has to show that there was a legitimate reason and justification for pulling your boyfriend over and for searching his truck. Furthermore, they have to show that he knowingly possessed this controlled substance. It may be very hard for the State to prove to a judge or jury that someone could knowingly possess that controlled substance if it was between the door and the door frame. (However, the police may be saying something completely different than your BF's version, so you both need to be prepared for that possibility.)
(The officer likely did a field test to confirm the presence of a controlled substance and the State will have to do an actual lab test to proceed with this case. You obviously want your own opportunity to test the baggie and a lawyer can file the appropriate motions to preserve that evidence and protect your boyfriend's rights.)
A criminal defense attorney can give your boyfriend more specific advice and evaluate his case a lot better than any of us doing this over the internet. He needs to speak with a local criminal defense attorney who has experience handling drug cases. He should do so as soon as possible. Good luck.
Disclaimer: This answer is provided as a public service and as a general response to a general question, it is not meant, and should not be relied upon as specific legal advice, nor does it create an attorney-client relationship.
Yes, residue can be circumstantial evidence that he possessed cocaine. And there is a defense called unwitting possession under which he can establish that he did not know the baggie was in his possession or belonged to someone else. But under a recent U.S. Supreme Court decision called Arizona v. Gant, I question if the search was legal. Consult a local lawyer as soon as possible.
The Fourth Amendment protects citizens against unreasonable search and siezure. There are some questions a lawyer representing your boyfriend would want to ask. I agree with Mr. Lustig and you should consult with a local attorney to determine his rights and the best remedy for your boyfriend's situation.
You might find my Legal Guide helpful "How to Choose A Lawyer For You"
You might find my Legal Guide helpful " What Do I Tell My Lawyer"
NOTE: This answer is made available by the lawyer for educational purposes only. By using or participating in this site you understand that there is no attorney client privilege between you and the attorney responding. This site should not be used as a substitute for competent legal advice from a licensed professional attorney that practices in the subject practice discipline and with whom you have an atttorney client relationship along with all the privileges that relationship provides. The law changes frequently and varies from jurisdiction to jurisdiction. The information and materials provided are general in nature, and may not apply to a specific factual or legal circumstance described in the question.
Your boyfriend is presumed to be in possession of anything found in his car. This is federal law and does not vary from state to state. If the baggie has residue that is direct, not circumstantial, evidence of possession. The real question is whether or not the search was legal. This is the point that I am sure your boyfriend's lawyer will start with.